From patchwork Mon Feb 19 22:38:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elizabeth Figura X-Patchwork-Id: 203327 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp78013dyc; Mon, 19 Feb 2024 14:50:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUoOQXwFsfsUA34Th5IS5Vb0WqB8yafoxSuH/vGz1BlKUHzw5W0kkRWBwYaH7sHBe+G8/GQQWJSE8HosjUUXWp203cHfg== X-Google-Smtp-Source: AGHT+IFkFKax9qy7ExZ/SpxEoLLP8xucxQFuLCvQlLIAg/KMtqSSsjLJ6bMyAkdud1NE+H+2R17W X-Received: by 2002:a17:902:7c8c:b0:1d9:b8bc:fd7 with SMTP id y12-20020a1709027c8c00b001d9b8bc0fd7mr11245059pll.68.1708383020057; Mon, 19 Feb 2024 14:50:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708383020; cv=pass; d=google.com; s=arc-20160816; b=aQA+mpK+6mhebQLfMMQSZvD4ChoswK9RSvALwOg6wxiNlcAdMcMEYWqpBgdT9ARw+r /e53aMnV7ellbCPC2kurkmQ29JWZcmAOfVPCjJprH1io0hr9Lp6qUFpD2uNjM03Pp2M7 Fk2pi3+E/WUbLVJE/YhocIl7ew6yI/nnKqMCVy/DeOvD14XP4oGgkIxHQ33UPO/Ri1U0 EVUmmOcAcPI2tA/8/OrJwrqVn/QW5aJ7H7EM+GZq8/+239iLNvNLvyXH5rFR/MQ4JSmQ kjQk+ytmXmdQ54votLtxmpmJPrhj3XZdHfURxF1aOvH+KC+A0y7H7qrGU+lwdiMkmybg PYRw== 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=BFNtqlFDBUjcBXNMOPIpSEYmwboigNzB4lierY0STj4=; fh=hR3Xqo6s6FufP5gEw1XgbtLHrluZu7hd5XGp+hLIfiM=; b=AyutljFHJ+IE6a1EOqaNlL6QoKGJ8Qk5rPtngO2SbglKrCxPlBLxns31lOwOEOzniD H1PBrJW+fbE+Po6A+3nFYkGondN+WddWcPTcS9/xvEqI/6LWGCA0meyx/p6/AhWZ8r3P Cw5HJPkljPVIRyK9PdDKMjwYpF/n/lAEmbxexe/mbnh4gy5fBF8PRFWyIgVYB/v34roM R8o0jMRnG1Ar5jNyj6jrUmvrZY1yLSjy4JTxJ9TXJuDz3dwanN0MIyi2t8uBdDDCiov+ BqMu/0l61zpGUTLYqpMLRXcCRrG8zpn+uREfec0ldxBzLkBql7eQX4UR6xgosCeHZDem ASWw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=HasNCES3; 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-72085-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72085-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 e8-20020a170902784800b001d8eaf6626esi5000833pln.440.2024.02.19.14.50.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 14:50:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72085-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=HasNCES3; 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-72085-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72085-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 5603028824E for ; Mon, 19 Feb 2024 22:43:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A4C86026B; Mon, 19 Feb 2024 22:39:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="HasNCES3" 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 0301956756; 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=1708382380; cv=none; b=klfyJ8JM59A/moW+WDLkw6qSpIlHsh+JTb1Rq5C2nSWoUPJSILXD4zqxU/xwbTuqhnBziRB5VS/FjZQVlSINDd2gBWti9a09Rd/uCEPJolnWRES7+s43krv/CDeBEvm9CQKrgAEjlttMIdbk9H82GG0aBa8QbxGu/mT9Rzx5jq8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708382380; c=relaxed/simple; bh=JQFvbdQ3WTwEsVrsFXyNcm8fJYqqIYVgs75ah6Rl1uA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k0X+UDORKdy4yvTn/jylME6G2i4H5sp5M2Q4W8brMnS8TkenNeFgvj2VPs6hhf/q+jM3DfkRmiZjkTB/11PVPpobIFSnmaRjsLDvZPsO9EXGF/Q3S4dFBswKxItlejivcKZAA1JnbwK9IcTl51q/fq+8BnLayXL/I7Gn/kl8ijc= 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=HasNCES3; 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=BFNtqlFDBUjcBXNMOPIpSEYmwboigNzB4lierY0STj4=; b=HasNCES3vI0in8Dy94cKwdwJYV TgK9YAwmpfSCLe9K1qjKWkYErCEP5mCD8AgMT6YpPlCs1iTmwHooCVS5Q7OVkITocw8TGKoemBg3/ atT4gaxiM8VldC6BoqWB5D15t3seHbhuL7MqKCpU0YJBxs+4P45AaZ7MIlC+B9nVlXNpbEY/+n5dZ HAq//ArfX1nXEkoOvm2ayo61RxCUbxrIIov1+bwbJ1KLJiH/2l8tUW5FKCWdMhJ9iLV02MjLJmeaZ b1BKWwy2NeGeM3LJyGnjPYd6AKlf+2rDsgqd5x7GCNLPLbGqMJ6h6qF9F+eNGdnTHo6zXcztpTelo Qj4VBMEg==; 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-2h; 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 12/31] ntsync: Introduce NTSYNC_IOC_EVENT_PULSE. Date: Mon, 19 Feb 2024 16:38:14 -0600 Message-ID: <20240219223833.95710-13-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: 1791369433624157992 X-GMAIL-MSGID: 1791369433624157992 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 fa4c3fa1e496..b9b4127a6c9f 100644 --- a/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c @@ -469,7 +469,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; @@ -485,6 +485,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); @@ -494,6 +496,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); } @@ -548,9 +552,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 6963356ee3f7..72047f36c45d 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