Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2104752lqo; Sun, 19 May 2024 13:48:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU47d1bkQlIjWkXoIAVfLli4Vhq2CFrY7TMUCBzNRv1PLmfIj1/DG8X39AU/OxZB5lnP2jDx4go/4hlRxwp22PLuyi/ilWJya9Dsm4z9w== X-Google-Smtp-Source: AGHT+IFaDTbXK0bn2LIaNU9QgRWeU8GZPatsyJ3bhxfWDxdFMPfRIvZcLPRNubt5O4+f4JUWqbGK X-Received: by 2002:a05:6a20:9741:b0:1af:f38e:85b with SMTP id adf61e73a8af0-1b1ca3b8eedmr5279404637.10.1716151695282; Sun, 19 May 2024 13:48:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716151695; cv=pass; d=google.com; s=arc-20160816; b=PvboNQEeOd0JQerWubcHFV3NuEwK4twO/rBnUItnxedUvoaxts+yQw4c0+x48tZ1qm C6O/7FMGFIA1XnYyvpSuYYYBBaqkgJX9W+NhC60xT0t+a3BwMjOOZrsir6FRWU/YgdVy MZs3uPF7B+Rr+nHnqdtmlceq3Y/di6xUiEthZN0g/tb7XydJ0GUhtxXpzh2RfQiArlKD 5VzqDScdElIio4vM4wAob6Pc3U/mNJANsPmAFQKOE09Gwbfjl+3tuTKQbWXWsfbJxqtk rT1JyX8Ytjk21ghuC0Z+9QLFeuIhd6gJL5V9bDjUpLUv+l50BiQGSh0CdS2szryECB1R 4n9w== 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=pL6Tm6skS7blT8ASXZCJbM/G11ZABjcrsi4h3uCYUDs=; fh=eVY06L/C5FDTmF2RNqfudsnjwkB3tbhT/y33cGhZc0I=; b=ATsX4wUmErhonVejzjZCBm1CRnV++1hDybVNnwxh7xUUnIJhW5aACSOy1hgS+j7OPm qtSTfyPdK1kYNYRtZ0A9os5UOFr7p6Vi5JTdZuaxPUywd6lEc+T8j0j/L7AhZqUzBE0B 9l6aYRU6AsjlbN121WscqPzlhNGde37ww7d1YrwyiO4BhkPycB7jrpKzRgjikDyBNSCX P24/MxWfKlyHr9OtXq/tcCaW56LBZ1JolUdAW3FyZmIZDUSTIiMNU6za0vNpqmc/+C9w XzRhCxM3ckFM6wH78ssWHF/GqgC5jwQ/agreP3YjLmv/KY5OZi1poNKKD4WqYX1VXf7a PZ3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=TCuZIzEy; 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-183238-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183238-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-63412a4dcaesi21821487a12.736.2024.05.19.13.48.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 May 2024 13:48:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183238-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=TCuZIzEy; 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-183238-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183238-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6D673B20D47 for ; Sun, 19 May 2024 20:27:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F5F57BB1F; Sun, 19 May 2024 20:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="TCuZIzEy" 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 A79A94D9E8; Sun, 19 May 2024 20:25:14 +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=1716150317; cv=none; b=BtKz5ftharH8IWCDqsGwXNIgXQOby048M96zZ7Y9svLMNhvdUEyq+lcktlCdAvCE9n0XcQTxgnBi3zeKhaX7PheV0PCwVhgZUhhv6Fobz3OgLwmNJDYG2Nd+wElTxrVCSzJfd6lBwndO6DxrTqoiAVjeS22Agnyiuf7tOtLgCVs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716150317; c=relaxed/simple; bh=JPwpOPm0N9ZgjW13Ej2at6+3IKaszLDWcChcGhTd/AY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gy4XZjGdq2ue8SUMs4v3pSs8/gf3rGIWlfG0A68Bo+wAFH//RJDWgFT1P7JDtrEIJpQS5Pc2KvI9vZKc0IW9cYgM6dt+Lv44qwGKCaTFKo2pSYRUcMeM++SDDiizQR25BsxoU70DuawmXKjbrdgX/gVH13tYHsvalEYHG7MTuUE= 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=TCuZIzEy; 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=pL6Tm6skS7blT8ASXZCJbM/G11ZABjcrsi4h3uCYUDs=; b=TCuZIzEyY6Inx8fJfGoY0fLzif vH4r3Tn/3RcEvV0fYPReUkW9BRj5/FgdzDuKMUiI24ZxB5W+ZhvB9wX6YFja22SzACI/0jKMgFzDs NO7RlqAB5a6NV66QA/aNPAAu2pNzaOgCY5wfOqHobSM4EmwF4xelJnIlnOAfU+FP5f6GL8gdircZx WmsT70btUZsjLYtsCJplvxG/Xct1Cm4/frFVGAs9oKpAigdX6cbqQtIehQNUtlbFPbbY5X10nqWYz WbZRdgumYu7jkK25jBJUPL/9vF4LcZ5L4IQXtnhPdR7bEhmfVS4tQ4OU8EYxIAWpb5j4KVPe6x8Bf Kv7uuIDg==; 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 1s8n5c-008wIn-0O; Sun, 19 May 2024 15:25:04 -0500 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 , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , Elizabeth Figura Subject: [PATCH v5 07/28] ntsync: Introduce NTSYNC_IOC_EVENT_SET. Date: Sun, 19 May 2024 15:24:33 -0500 Message-ID: <20240519202454.1192826-8-zfigura@codeweavers.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240519202454.1192826-1-zfigura@codeweavers.com> References: <20240519202454.1192826-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 | 27 +++++++++++++++++++++++++++ include/uapi/linux/ntsync.h | 1 + 2 files changed, 28 insertions(+) diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c index 2bce03187c17..97d9b6047fbe 100644 --- a/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c @@ -534,6 +534,31 @@ 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; + bool all; + + if (event->type != NTSYNC_TYPE_EVENT) + return -EINVAL; + + all = ntsync_lock_obj(dev, event); + + prev_state = event->u.event.signaled; + event->u.event.signaled = true; + if (all) + try_wake_all_obj(dev, event); + try_wake_any_event(event); + + ntsync_unlock_obj(dev, event, all); + + 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; @@ -557,6 +582,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 4c0c4271c7de..36d903521bbe 100644 --- a/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h @@ -51,5 +51,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