Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1782575lqp; Mon, 15 Apr 2024 18:21:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV+UmBVmXI3i+bAEVG/sxVVeLO1j/Kcx/fLSoODpox1zQcjoAu4tYxCpL4U5afb0uxuqXmkTiKVhusOl+U1+wuTQALMTFFk7Q/BxRrl6w== X-Google-Smtp-Source: AGHT+IGi3Udkh7168xjjZ9U0YfGAyp3jn1ajAhsapw75MpJvzdlEVsYMpUL9mJDSeQviR45SA8n1 X-Received: by 2002:a05:6358:7b97:b0:183:55a6:b240 with SMTP id n23-20020a0563587b9700b0018355a6b240mr14192604rwg.4.1713230514497; Mon, 15 Apr 2024 18:21:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713230514; cv=pass; d=google.com; s=arc-20160816; b=0iZkERTqyczIDXX8t8UF+X13Y+E1czLclDOi0TM2FDIfsdFstJJDNJEdyGAhMF7LZR xn5ey5iEkI/w1Ih7ZumHQ71GGtGDCyLGW9JfsQGfx6gaJkfhYuSy3J21pD6c+9eZmIIp oEiGM/iwzBcGV0OUs44wMLCMD+XRLvZ5y8RzdEd7+ouEgG4Z0ubmNcLavhR7r7d50it8 mgS/gqRjzASBjWYJe8D1pHv8/2KmpqOMmyLO6iXFhIVVjq1UbigEpsPnxFSpl2YMlXpd dyw9gB7tIbGrq30HXo+U+KNHHnaqK6pTfWtbu77TrvuLme2xhcExq7KfWRODn2lbyA5o QctA== 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=JMqQ+0LCTlI6uyQYIwA0XTuobJBuM0j6P3qXqvgCk9c=; fh=eVY06L/C5FDTmF2RNqfudsnjwkB3tbhT/y33cGhZc0I=; b=zTr4KnsK4XuLbVSswvAricZIeOP1k9dt+Tz8z83vKE/f2l0zjfR694PsxmxTfLrn/2 UXt6qqozNQNsUD2DztlHcHyMrOjx1ba8fivlRxXSacWowjqVFGvw0nOYrgku2m9fkWC1 cZNTh6evsv0EUWUJiUnHX45am9Xo1l/rqssHUj6/VY5GhodpA5ekQ/tRga8bfT3GOoNm YsOmEqGXv2xne8ppPW+5dJ7puY/7tzAr1ZzOhL4sPhR1JnqyfiogOFcwUDW7eglPnZ33 4uURlCXnnraqo6LLcIwNdwIb2Wk6Q3FwZf/UujFNyrPZJqhNIzJ2Bfazp6n1z5kZEkkw Db2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b="NnUpG/0f"; 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-146070-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146070-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 u27-20020a63455b000000b005d8d56cd646si8662954pgk.130.2024.04.15.18.21.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 18:21:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146070-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="NnUpG/0f"; 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-146070-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146070-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 4540DB2256C for ; Tue, 16 Apr 2024 01:15:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 222DE15AADE; Tue, 16 Apr 2024 01:10:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="NnUpG/0f" 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 BC0976AC2; Tue, 16 Apr 2024 01:10:28 +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=1713229832; cv=none; b=TfgJxp4glqo+qXzo83CEVdHVyqAglzO6QjWrG84a2HN0FPSrRcJslFUscCXuh1uuerbW9AhHrtR1jcxJv71cMbRplhTF3AQCMGHnQVv3kAu2tx0gjfqMvkpuuhh9+wURFriBIykApHc7kCjBe4LukroXMMRgPQX/7dQIz2rpBTo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713229832; c=relaxed/simple; bh=c+LLrvBoCuPfC4CclqS/TQ4HIIJMP43vsE7lYq1LxX4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bpHaxGh+kGauSoY/f24ZCAtlEzEM4cHN20ggkCSz8O+hjNJkk62aruT+NNmK+NQIDarrAoybYVcEIFODcLHwmrovd9vpBDwRaohr4sSIvkUxDhID220wVOeLEI9t0IFj/zsmr+Rpsb5GCdAfPRUxZOyUi6RzE9+RXYoFgfgiycs= 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=NnUpG/0f; 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=JMqQ+0LCTlI6uyQYIwA0XTuobJBuM0j6P3qXqvgCk9c=; b=NnUpG/0fLKDcjGxOL5VGKlqWps 2Q6i4CkWE8imrbZt95QfIye1NvdHugB/jv5dNhvOiKFLZue1DT3mVtG9lYeuuL0noJiJEggRJC7aY Y5KeICnYWVIbtz4lUL0BjzpKiMK27PYSzKJG6cYiCsEYMrtZW7Rd2dMnjcDT3DKqzktnyM0GyO4O6 Ge7wi0ic90zseCCY+5MvZCW1Wkn+DnHzXfTDq/TeYpaWhxzu4qKNvovLKi0jMCdoqbA+vlRnv3bcS EaF2oFk+DebKD7bCyBtqrwS5IwWqB+25M8H3fCtwTZZ7tPBwLm/0dl1Bv1HQ+ydKBop1lyNx02KgF RCHx0F9Q==; 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 1rwXL0-00FbQv-0G; Mon, 15 Apr 2024 20:10:18 -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 v4 07/27] ntsync: Introduce NTSYNC_IOC_EVENT_SET. Date: Mon, 15 Apr 2024 20:08:17 -0500 Message-ID: <20240416010837.333694-8-zfigura@codeweavers.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240416010837.333694-1-zfigura@codeweavers.com> References: <20240416010837.333694-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 3e125c805c00..69f359241cf6 100644 --- a/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c @@ -473,6 +473,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; @@ -496,6 +531,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 0d133f2eaf0b..65329d15a472 100644 --- a/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h @@ -52,5 +52,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