Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1405540rdb; Mon, 19 Feb 2024 14:51:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCViVbW+YzSRLZND3FA6xy7unxBSPNKhHmar+noXQ+bxSla6PkHquB5wA3PLKypdfIpNVidkQ/3QJ0QtseQ1KQm+I207s4P+/Xmk/RF3mQ== X-Google-Smtp-Source: AGHT+IFYhuZw//sGWEFWAq6UKVvMNBDhhxtbbNRToTXBQEFDsd30zTGnfvBGY6ED1fIrEuu52u2+ X-Received: by 2002:a05:6a20:671f:b0:19e:cd12:f220 with SMTP id q31-20020a056a20671f00b0019ecd12f220mr9943203pzh.30.1708383075981; Mon, 19 Feb 2024 14:51:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708383075; cv=pass; d=google.com; s=arc-20160816; b=rTrIf5yJBj6AtZ9wmW+Z+pRuklc7fVzjx9frXjc3Gp0Uq84gsf5ddnLxKxirFaO8/W dHnDxCJ2GdkIe3LBpT4FEjo4fJ4NjFmeWxiouh87tjWUcnmLmxx0hqci1/mZWuRovikG wkP/ztnLkulaxU7s6wU6cg5okrYbf0oSxVZ6+0PJ09iCF1u9dtqg9IGms+b+7x8OXeG0 1uR2uqtJaQuQ0fwcYfFCnj/S9Bga8X8cPhv9AMqJL4wX4kZV79MQOEvwz+EiY9+aqK2e 0asmYFQzUwWTKeW9zUexppkYMXonAhowrscP8Bt2a3l7/zRNs74anF8F2bCpJRfu3LQK 62Ag== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72092-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e19-20020a63ee13000000b005d8c5595ddbsi4979539pgi.271.2024.02.19.14.51.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 14:51:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72092-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72092-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4C8A12891E9 for ; Mon, 19 Feb 2024 22:44:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D6DC6167E; Mon, 19 Feb 2024 22:39:49 +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=20Almeida?= , 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 Content-Transfer-Encoding: 8bit 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 -- 2.43.0