From patchwork Wed Feb 14 23:52:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elizabeth Figura X-Patchwork-Id: 201190 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp62176dyb; Wed, 14 Feb 2024 15:58:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWR4z8gzBm1K4oZOgV2XD72S2wGww/W2w2OvbxOldp8Tipyei3dyxOKrbhnEAChfwO9N9rjEiRz7z9avoL+aFiOPOnWqw== X-Google-Smtp-Source: AGHT+IGhdbLahR5vNYAHKVNDFn2IT+Wc2UESbwFXlCiy4/JrKkTwoX13poe8DJPqJy65ZDd+tFFS X-Received: by 2002:a17:902:c1c4:b0:1d9:ec19:2c95 with SMTP id c4-20020a170902c1c400b001d9ec192c95mr128062plc.58.1707955105851; Wed, 14 Feb 2024 15:58:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707955105; cv=pass; d=google.com; s=arc-20160816; b=XZpo//rSFemlEamWmHYu/7jDB+YNduvt8SN2+5INOTbUfTmw47m/mIpJ9JTngr4MzU y5+Oc1ZMuzN7S+uy3nDLRPPpcab5y10ylo3WwQfJfNOh7Nb0J97HnaxGQs1fWF+aLfvL 3o9dHmIfYxH6++PcjMNbhATVUJF4XanPIOsP7aA9CXbS/ufkFVP05QNJMyLpEXS76JEY OgYz+9vDr3avG67uJvdQzbxmCrFJawRZcOlD3LLM29ZUASjeJspCjePIeSKS2TChpNZ6 DCsY/wonLIPjAUSu9vv5liDKVyXPlDq3LXpDSE9o7xNxgCyBEV4xZj+1UYZO0PuwOZ7x nHcw== 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=Uw+YvaVU15ffM3A3JgczPQnnrN3QpOwwpO53Okg4P4E=; fh=sOAzP1IXJnllEbSCBRlwdfT0MN3UiaRLwzx1Tpw7GJA=; b=mL0X+GdZNsUMKoxhH/nqrYmhTPKQ1MwSFD7P3hk5wbDH1rXU/ixkEjh+QJjGMv0Y3u lUJ6Pw/K2hvUThsxC/dfftrzl1l8JWHdMxVXuU7TPA6tCnGA3pzJocKWodwGH/T6vGWB wEnyH5s4xb9GdrcyA804Ub0T/5ARGA4vJy35T0O4tF3JI643wpisGHmvLY3k/wccK7fV Ecx4lfjJX0wk8xhb+OUkL4rHpegL33F/ueu+/E8vQGhIZgS964RhdR56X2FTFhNZHf3E Iw6RsI+pDoJam5bNmhEhfmcvKgeoi8WO70r++g8IQ9eJsSqsFdX1Zfkgyl/aZpn8X0RZ 2cqg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=rZGFSYLg; 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-66144-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66144-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b5-20020a170902650500b001db675b3a9asi28534plk.377.2024.02.14.15.58.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 15:58:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66144-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=rZGFSYLg; 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-66144-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66144-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 34C1D28E960 for ; Wed, 14 Feb 2024 23:56:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 727941474D1; Wed, 14 Feb 2024 23:53:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="rZGFSYLg" 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 EB26C1468FD; Wed, 14 Feb 2024 23:53:31 +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=1707954813; cv=none; b=jZthh6JyxuGC+L6fGwPyhRZOaSD3yQdpOde6wKFcfkUW0pb4dSG6ExbdonzMyiMaig2NKPIeQIpCoNwcsj2BT2HG8AupdcyO1RJul4f+uK99Rlnj+pJPJ9LNGHSuqTB9h5h161g/2MIwlwXEnxaQs5ctgTIPgNxpmEgC1VVz+QU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707954813; c=relaxed/simple; bh=BWsVN5Nd9zC4qkmCZzbH4sC7w+cs5Ze1LqiDpK6tZ0A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IdXvBi048mKZNHK/5xeQo82BJ6XgPJ4fwX9UN9Ykgqdy2K9dxPNTwMzC97CKYvsFZ9br+OX2bnzecHQmtLwyjMGI5KATbNaPlXgbUvRSnJ+bu6zUKeqoEQE08keHlE0iVQsjKOwolJlxif98WikcTPEsLrW9DnX7NVC/OOr8T8w= 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=rZGFSYLg; 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=Uw+YvaVU15ffM3A3JgczPQnnrN3QpOwwpO53Okg4P4E=; b=rZGFSYLg4jw4IbY3qq5tAfHU0M I8lUpi9v35Z1C0x6h1K/qIfE83vQHpzglujzeV/J9BXQfALYoOkN9JuaVu/NH9FYYhvhgd/9E6BMy 8+KAsZP12ETBWY4diDpnKaIY0l8EPyflu6I/ODD3kNq8FEAY4cDBXDMgSBUNyaE5EaH6TLCpay1yq GW5skFY49cUDu2q72spUKxQd6OOC1U1f49R68P6y+HSAHQj8E5rjwd1AS+U0pjR/qisKN6SppgDba gFxXuD5m6w5mUW/Hgx6zy07lx6zGXnRAp7WnBTa7SfDs3+a3iQooq9VA65wG5ARSzv0ptLGJEBeMa Torntyrg==; 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 1raP46-00GcSK-1f; Wed, 14 Feb 2024 17:53:22 -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: [PATCH 12/31] ntsync: Introduce NTSYNC_IOC_EVENT_PULSE. Date: Wed, 14 Feb 2024 17:52:47 -0600 Message-ID: <20240214235307.10494-3-zfigura@codeweavers.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240214235307.10494-1-zfigura@codeweavers.com> References: <20240214233645.9273-1-zfigura@codeweavers.com> <20240214235307.10494-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: 1790920733462970668 X-GMAIL-MSGID: 1790920733462970668 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 57d78b086241..e8e58274e4e8 100644 --- a/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c @@ -456,7 +456,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; @@ -472,6 +472,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); @@ -481,6 +483,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); } @@ -535,9 +539,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