From patchwork Wed Jan 31 02:13:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elizabeth Figura X-Patchwork-Id: 194456 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1628920dyb; Tue, 30 Jan 2024 18:28:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEOKx8Fq8IsI90Cb7FhIml2ea3AovEQcT7+zrmb4n9/kjxGYin6Lhb55vijZke70BzerwZA X-Received: by 2002:a17:903:2302:b0:1d8:e771:c40a with SMTP id d2-20020a170903230200b001d8e771c40amr481225plh.14.1706668136801; Tue, 30 Jan 2024 18:28:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706668136; cv=pass; d=google.com; s=arc-20160816; b=CkOMh1mrZhmMIGp9a44L4XpGlGJyE7jePnJd+SYUj4KlwX+6TKL/Z/OqotGM8Fzo0P hf2vT4UJHwOs86gPWlQ6oKamr5jVn0r/NKidgd/1kZ4HWY8GDtR1giFfGIsm//+9r2qA /GneMDfpAfGaZHy2VfZj56ey7N+RUz8VVg5WeoiawJAfZ4tM1IHdXeC9CDqT7sobLtYo mdgehsJkE9C9HF81wyEHGvpyMLZQI/0vTeWZ/YrihFukNCi3MdwxFMNuLMHPuGEaYct4 ZGYI8cHPZhIdkuUDPkFFERyVuXYxgF2X8Fnarqxdk9MCOXQ90q7J9fexSgTxk1EXJvdw P7cQ== 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=WRk28nnebpEDG8oEow/kRhN8Lt9f1MHcVAwX3iEhD18=; fh=KMGYaisZbbuGkU8PiFXHZLiwtSR16nbny0wD3HRg9DA=; b=CHaukQ0DuK1EoMnRn2fMUg6xOZpAW2q9Hj6ejwBz0RKytdjNsDUr1u+6QfkCJg3HZZ m/+p5VcQEsUyGoA3zO6xkhG9AFs8isU1LuTCoGLb42A/WaITxLq1j5dIICPqLh6EEK1F wDWNqho960f1YYhk26Df3TAx/iMDKT32MxxuSZtQlxRz2xk1XS5rZtUVmBHzHViit/iy +3C4t4tVJuh6YXKJ3KEUN6ucLvxv/Yk+/JIS1A8MRn9kfeKffgyJKhPo+dJgvEaAi1Lw Gc4YBZ6GiEF2ZYoY2eA2HZ6nIwtX5o8//usv7TXE1GRcNpAZ41oPNKfblXk1qudfQAnD 6+Vw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=cGd8qBhZ; 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-45659-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45659-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com X-Forwarded-Encrypted: i=1; AJvYcCVTNw3GpLQGjSD/CpwXIjPWi4cgA38/pNuf0j3UcB05VJd+KZBJNKBLn6GUAyvOqWXUMUzm7Xy2JA07NE+2iczhwOA2Sw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id f2-20020a170902ce8200b001d75d88f9a0si8554422plg.466.2024.01.30.18.28.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 18:28:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45659-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=cGd8qBhZ; 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-45659-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45659-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id C52CFB26F62 for ; Wed, 31 Jan 2024 02:23:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D43F3E470; Wed, 31 Jan 2024 02:16:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="cGd8qBhZ" 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 9673B5684; Wed, 31 Jan 2024 02:16:03 +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=1706667370; cv=none; b=dNSWOSW9+NSGAG0lHvJTbBGTyuLbQWCmY48BWRnwQQLw6CnL/JmJRQQ1s8yM12+xsX5JfesgBQP/xkJ37eGBMnRzMgQHUBCwzAWKSsPoy7rQg+Hb/iJQ0rSHtXt0fIExpA+CUN1GMQXDmRxKro+JtatNmjd0l/DnxGLVqfwxOl4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706667370; c=relaxed/simple; bh=hMJdmUKFkzno0ji8YpHS/pTDnN+SSVTCS/COoDL60fA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W0DQoUu4ONfr246CUyFXllTJt55e4jHG+a8Iv8p38D9NlZTEJlVEuRrjacjOyj/J04xW3e47bszp9TO3GbpK6y1/g8Si4Ooj9xzZeBNNhAPVhFqOgtVmCmCTsRyrYmtNZGuCnl7Eivq6ZnbzFKdxBItTCj7Bs4aW9JuydjdPODU= 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=cGd8qBhZ; 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=WRk28nnebpEDG8oEow/kRhN8Lt9f1MHcVAwX3iEhD18=; b=cGd8qBhZDagdmZQ+X2glRs5nfU Q5ih2Dm2wM0UtHrDeoXrMVb7Xwsv941ueKGPsMxFzgLUTFBnQHqALtbJDFZJJZAS8dikbRTQIvNj+ zHgd68xeIF8AF9Fke5W8wjGsVf84dCqgFTmRA5k3pm/pJWqeONOi+yQp1vHZheaKDcPTa5WOwCYrb 7FCOFONgURxnnIVkgmHPiTTZR7Xp5/qON9z19WrFdYp6u7K4kM/3zS+sTBt0/8jujstRe/8K37lci EkjToTagxoqBiq0xkJd5vc3iJj5E3IM47k0x0lJE1wZm1VMlPKs3dRbbtrjcT4eb/gwo1dGhQIxME jdiLKuHw==; 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 1rV08o-0038Kv-0N; Tue, 30 Jan 2024 20:15:54 -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, Elizabeth Figura Subject: [RFC PATCH v2 12/29] ntsync: Introduce NTSYNC_IOC_EVENT_PULSE. Date: Tue, 30 Jan 2024 20:13:39 -0600 Message-ID: <20240131021356.10322-13-zfigura@codeweavers.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131021356.10322-1-zfigura@codeweavers.com> References: <20240131021356.10322-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: 1789571248120283317 X-GMAIL-MSGID: 1789571248120283317 This corresponds to the NT syscall NtPulseEvent(). This wakes up any waiters as if the event had been set, but does not set the event, instead resetting it if it had been signalled. Thus, for a manual-reset event, all waiters are woken, whereas for an auto-reset event, at most one waiter is woken. Signed-off-by: Elizabeth Figura --- drivers/misc/ntsync.c | 10 ++++++++-- include/uapi/linux/ntsync.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c index 009d927739b8..240ae858fa96 100644 --- a/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c @@ -447,7 +447,7 @@ 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) +static int ntsync_event_set(struct ntsync_obj *event, void __user *argp, bool pulse) { struct ntsync_device *dev = event->dev; __u32 prev_state; @@ -463,6 +463,8 @@ static int ntsync_event_set(struct ntsync_obj *event, void __user *argp) event->u.event.signaled = true; try_wake_all_obj(dev, event); try_wake_any_event(event); + if (pulse) + event->u.event.signaled = false; spin_unlock(&event->lock); spin_unlock(&dev->wait_all_lock); @@ -472,6 +474,8 @@ static int ntsync_event_set(struct ntsync_obj *event, void __user *argp) prev_state = event->u.event.signaled; event->u.event.signaled = true; try_wake_any_event(event); + if (pulse) + event->u.event.signaled = false; spin_unlock(&event->lock); } @@ -526,9 +530,11 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, case NTSYNC_IOC_MUTEX_KILL: return ntsync_mutex_kill(obj, argp); case NTSYNC_IOC_EVENT_SET: - return ntsync_event_set(obj, argp); + return ntsync_event_set(obj, argp, false); case NTSYNC_IOC_EVENT_RESET: return ntsync_event_reset(obj, argp); + case NTSYNC_IOC_EVENT_PULSE: + return ntsync_event_set(obj, argp, true); default: return -ENOIOCTLCMD; } diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h index f2d7507d8438..598f894f868d 100644 --- a/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h @@ -50,5 +50,6 @@ struct ntsync_wait_args { #define NTSYNC_IOC_MUTEX_KILL _IOW ('N', 0x86, __u32) #define NTSYNC_IOC_EVENT_SET _IOR ('N', 0x88, __u32) #define NTSYNC_IOC_EVENT_RESET _IOR ('N', 0x89, __u32) +#define NTSYNC_IOC_EVENT_PULSE _IOR ('N', 0x8a, __u32) #endif