From patchwork Mon Feb 19 22:38:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elizabeth Figura X-Patchwork-Id: 203309 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp76964dyc; Mon, 19 Feb 2024 14:47:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUFYT6P+hY1em2fre1hSXRgL9wjteZ8mwIezDDNIxQDkKxEj7oP+RIYIE6umWOGX7C6zc3XjVUfPkqlpuWAf0VsS/tAfQ== X-Google-Smtp-Source: AGHT+IE640IJf4hoQJH/yOj6bGbx34C3lUzMbQ44H//ersCbC6rx64bzsLj1UhYL2CIZ5+U4uW1x X-Received: by 2002:a05:6512:4843:b0:512:9717:ded9 with SMTP id ep3-20020a056512484300b005129717ded9mr6452170lfb.67.1708382820442; Mon, 19 Feb 2024 14:47:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708382820; cv=pass; d=google.com; s=arc-20160816; b=fhS4kBbGpQ+DnGW0RimHBI+48tTcUXj/mJWYc6PMrC0ulWSOPz7820nBsUJGkK3JkG Fm/MP3hXoIvSlKefYv1H8ZztHNtQMdVBcyjfpxipd3DDVX+CRNvwhPij9ji+UX0mCuyc d2zXC0pGB1wjdF0s9mk8+VUGSUBEYxpAQG3K9ghkbVjHM4NJtij7qwGTfCPuhgHVEGEr dYTQiQiMVQJP/tcwWmI7ZOq+CrjU74Z1XMhTfYeeFsENvVrB+eP25SWvnjZfEnBtjiGb nxgY/QnObjUE9NmtLiF/6mkZ7fBtmhVfCDBLZApcNaalH3rL8Fp1OtiF/3k1lskZmSIb 28xA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=W95fpCDCr/MGQuaZIDQ6+RU3d/BuLfSm75zuuDbXCag=; fh=hR3Xqo6s6FufP5gEw1XgbtLHrluZu7hd5XGp+hLIfiM=; b=WdQ2ZcIdknmbTrJl7pL7XtvSAQadJhqgS4FdAgRdINHKWEX8aCC6EqCcaKhT2dBrio 4VxAHuPU9EmWuKOipYoEdBoVcbozUEHO9VkteRJGcV9XnoRwMWws8JWB+ICxfjA6ADNb nLRx4m8ntun9FtWgE4l7Zi1k9um0gy8m9nBn1vYblK/nGb/O7LQzjHC/oYzRgKtPZiLa KGcRof+tkAAv65y54qkSRiE/Y+dAkuqFYrsbmhU7SXOKSmKadz71m0ZgBuGSDMpSc1c3 K9wch7uTx5RpyL6KeVT2UwY43c0qkY1S9jWAW1AhoYR8Ggh2OLIzr8bKWTgXK4o44J/6 UA7Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=DEzB3DbP; arc=pass (i=1 spf=pass spfdomain=codeweavers.com dkim=pass dkdomain=codeweavers.com dmarc=pass fromdomain=codeweavers.com); spf=pass (google.com: domain of linux-kernel+bounces-72092-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72092-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id kl15-20020a170907994f00b00a3d59c61574si2969233ejc.991.2024.02.19.14.47.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 14:47:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72092-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=DEzB3DbP; arc=pass (i=1 spf=pass spfdomain=codeweavers.com dkim=pass dkdomain=codeweavers.com dmarc=pass fromdomain=codeweavers.com); spf=pass (google.com: domain of linux-kernel+bounces-72092-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72092-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9B5AB1F2121F for ; Mon, 19 Feb 2024 22:46:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1E27C664B5; Mon, 19 Feb 2024 22:39:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="DEzB3DbP" Received: from mail.codeweavers.com (mail.codeweavers.com [4.36.192.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA3E555E77; Mon, 19 Feb 2024 22:39:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=4.36.192.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708382381; cv=none; b=sTrcMBxFuZ58RycbsWBfQTwPmVeuBG518jCuISfUkCNdhH48latBY+jygBYCEeEKJn/PpkpC/lKyr6nQRlbbdkdX+NJyw0xUnACQu4fHxriOfo/yKuCDOBnNPngtRiJo+XBgFSnl9I0rdT0mUwfntSMc2tg0mP2sqV4pN45Te+8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708382381; c=relaxed/simple; bh=BTVyPW+nCOff9QU9KQbiXnral4ioCopMjHWlcapiQ6o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J+adVgqUeP6Bq0sNBXhxFX4F1JsQFIquXdyWbBPpNGQx731j//LAcIBl8vF2bjDNt84pPxat2X21Rb6UAdaEjrzVqB7uOOlx7c2M+aQdJDnloXdtm3ot3TtSI8uAEE6Jmby7q4fz8/2FhSvUfuoCEIsm8y+PvF4AwgAuMMoi5Zk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codeweavers.com; spf=pass smtp.mailfrom=codeweavers.com; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b=DEzB3DbP; arc=none smtp.client-ip=4.36.192.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codeweavers.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=codeweavers.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codeweavers.com; s=s1; h=Message-ID:Date:Subject:Cc:To:From:Sender; bh=W95fpCDCr/MGQuaZIDQ6+RU3d/BuLfSm75zuuDbXCag=; b=DEzB3DbPSKtbx4NsW3qPVJyPun 1fqyLIMzy+t/btEyjK1ZtTkjIZBP9i+kDDt4e7LtuDJCPFOdUbSyh8IUhJU+o8xD/zJ++rbvelP5m pPF8RgN0XR1NUntgora+0pzKjIKN5UTQMiiEnnxALgmIWbxOiRkAS7BglNfmOjjr3ZLcj0DVw5A0S 4NNp6JjNAsiYcdvycqiQiiquUZiytZlHKM7q/vONF7WUDOubw1tklMMv3i9R3TPz2xii9MzWxLOWH E0TLado047f381RljdiCOT5FjYJsJ/g7kJ4pr1d6pTeZVG8Irh84D7bqq1uIZV69kJEeFwKyun+C9 QVfsdbYw==; Received: from cw137ip160.mn.codeweavers.com ([10.69.137.160] helo=camazotz.mn.codeweavers.com) by mail.codeweavers.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rcCIM-0037Oz-1c; Mon, 19 Feb 2024 16:39:30 -0600 From: Elizabeth Figura To: Arnd Bergmann , Greg Kroah-Hartman , Jonathan Corbet , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, wine-devel@winehq.org, =?utf-8?q?Andr=C3=A9_Almeida?= , Wolfram Sang , Arkadiusz Hiler , Peter Zijlstra , Andy Lutomirski , linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Randy Dunlap , Elizabeth Figura Subject: [PATCH v2 10/31] ntsync: Introduce NTSYNC_IOC_EVENT_SET. Date: Mon, 19 Feb 2024 16:38:12 -0600 Message-ID: <20240219223833.95710-11-zfigura@codeweavers.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240219223833.95710-1-zfigura@codeweavers.com> References: <20240219223833.95710-1-zfigura@codeweavers.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791369224628724120 X-GMAIL-MSGID: 1791369224628724120 This corresponds to the NT syscall NtSetEvent(). This sets the event to the signaled state, and returns its previous state. Signed-off-by: Elizabeth Figura --- drivers/misc/ntsync.c | 37 +++++++++++++++++++++++++++++++++++++ include/uapi/linux/ntsync.h | 1 + 2 files changed, 38 insertions(+) diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c index 17dd47d06e0a..edfbf11cafe0 100644 --- a/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c @@ -469,6 +469,41 @@ static int ntsync_mutex_kill(struct ntsync_obj *mutex, void __user *argp) return ret; } +static int ntsync_event_set(struct ntsync_obj *event, void __user *argp) +{ + struct ntsync_device *dev = event->dev; + __u32 prev_state; + + if (event->type != NTSYNC_TYPE_EVENT) + return -EINVAL; + + if (atomic_read(&event->all_hint) > 0) { + spin_lock(&dev->wait_all_lock); + spin_lock_nest_lock(&event->lock, &dev->wait_all_lock); + + prev_state = event->u.event.signaled; + event->u.event.signaled = true; + try_wake_all_obj(dev, event); + try_wake_any_event(event); + + spin_unlock(&event->lock); + spin_unlock(&dev->wait_all_lock); + } else { + spin_lock(&event->lock); + + prev_state = event->u.event.signaled; + event->u.event.signaled = true; + try_wake_any_event(event); + + spin_unlock(&event->lock); + } + + if (put_user(prev_state, (__u32 __user *)argp)) + return -EFAULT; + + return 0; +} + static int ntsync_obj_release(struct inode *inode, struct file *file) { struct ntsync_obj *obj = file->private_data; @@ -492,6 +527,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, return ntsync_mutex_unlock(obj, argp); case NTSYNC_IOC_MUTEX_KILL: return ntsync_mutex_kill(obj, argp); + case NTSYNC_IOC_EVENT_SET: + return ntsync_event_set(obj, argp); default: return -ENOIOCTLCMD; } diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h index 040cbdb39033..af518530bffd 100644 --- a/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h @@ -48,5 +48,6 @@ struct ntsync_wait_args { #define NTSYNC_IOC_SEM_POST _IOWR('N', 0x81, __u32) #define NTSYNC_IOC_MUTEX_UNLOCK _IOWR('N', 0x85, struct ntsync_mutex_args) #define NTSYNC_IOC_MUTEX_KILL _IOW ('N', 0x86, __u32) +#define NTSYNC_IOC_EVENT_SET _IOR ('N', 0x88, __u32) #endif