From patchwork Wed Feb 14 23:52:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elizabeth Figura X-Patchwork-Id: 201185 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp61294dyb; Wed, 14 Feb 2024 15:56:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW0ZPbbYgHV+r6Py1KIV5y+e6Le/G0rT6ipD7WU8rK5445mbK37920IajSvSI7Uzbi0ea+B8KIR3+2OyScxApUjl2nKJg== X-Google-Smtp-Source: AGHT+IFK3fkUEL6X9QFC+6PeW/H+k5ELn+sq0zz4xL4QHvOLWXGC5zc1jnKnz+nixmWY82Pa2QZq X-Received: by 2002:a1f:6283:0:b0:4c0:1c20:f827 with SMTP id w125-20020a1f6283000000b004c01c20f827mr9686vkb.8.1707954970273; Wed, 14 Feb 2024 15:56:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707954970; cv=pass; d=google.com; s=arc-20160816; b=waJ0Cbmi15PZj8iq85cxY2YWkDgN74eCrztesfbk+TgaV1DP5SuDwq7SEQ7V6SqAnW Ey2hYwpP+iOcIOtzFj7gICAVdcQDOSiDtynZAQKuE2AQdDzIjUsKJ5R+gB29VA3Gib1k uNGX855hL/Q4n6UgpbS0OeaGAn/2ByZn8LHSZhLw02zNVtRxMiC2w0gcuNDxwB+gm8de tNlgIGmVKLPGKU/v6MBb+btHUa+PQLt9JW9NaLHR5Xz3u8CR5rqRzzcc3yxkX3YOHI2T Ob/4ET3+6vUiij8pdAV3MQMsD9nyj5T7c9PjO47DIDaig95MXtaDrWJzMDIZZnfMZIEj Ei+g== 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=MxsYi41f9tZrdqx7LdjDj8QNEYN8tm/gWSuMV4y4n5k=; fh=sOAzP1IXJnllEbSCBRlwdfT0MN3UiaRLwzx1Tpw7GJA=; b=jt3+IMNuzNr/gPzPDhakiwZZysAWiwPNZNL2v4w+jQqo+fqrjdUFsPzDliFoMWoMcd KTMlopDTurKp4ZXWNM6loXa7S0k/Pmj96e3b7+r6tz3WBz58hwuAyAWD3oZpW06k0b6O e8nfj0LpkDFVcFMpnn4Jk4zg0m0RmXDIoixGLynjrxU0czvLwWR+6WNb9v80e3cyg6ke ENvyCKyFTd0AYZHXxqPeF6AhHYqRZPgMJjoWuWoPBHQYETFb4PnWJUyAzBDNYAVkRgNy UK/tdeesI1osxxVhi504vgZ+r8LfK9sEtuQeZ2oWnu2VXQ17g9/XEGCFrbtQZLdlPsho mOSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=CFdUGGkj; 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-66143-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66143-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ey2-20020a0562140b6200b0068ccdb86eb6si218095qvb.4.2024.02.14.15.56.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 15:56:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66143-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=CFdUGGkj; 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-66143-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66143-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id DF8C21C2753A for ; Wed, 14 Feb 2024 23:55:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F3CE71474C5; Wed, 14 Feb 2024 23:53:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="CFdUGGkj" 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 DD9AA145339; Wed, 14 Feb 2024 23:53:29 +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=1707954811; cv=none; b=e5GFkaDO2OFHtt8ht048vdgy2OfrXmkgNow3rg7QHaZwGMEB8qAplU2fq1ytyvc2DZDuFP/YaMdBAiQcF+7RT0K7trsC09UlorByvPfgORBtJLp5/bGq9rgq3kDwEozvP0pJO/RHb7EFcuEKbpWv4T92CND02KkpzvDkiHrL2O4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707954811; c=relaxed/simple; bh=ZiDY1OWbO8A0kyxcTCRHN/56efSCVGBgAzSPdarUcgI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gt9zdVd22Jb3P3D/vGZW/aATriHxr9wqxTgDUPiEUTfWnKyTSOMrTHUQ1Pw19Y0iiYUl3p0z6cGUzn7qzdh201ptUrndAxgsqgHglfWaFf3BI/c8t0fJ0Vhew9fdeBdHo4FXLU+nSp51ccOopyOCctFW+A2GBPYZ50v+YM18kuM= 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=CFdUGGkj; 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=MxsYi41f9tZrdqx7LdjDj8QNEYN8tm/gWSuMV4y4n5k=; b=CFdUGGkjQyLXTB63BQqeAVx/nF OgHHDlxUvcWp7eyR0LFIOiW9KbDJpkZOmSWVx2nVdMmYXajdxxw9kWteTYttNqmhcDAKurOsmNoso I8T+8wXHVReHmp1ybHGZ6O2dpAai0UOhwik6mfxccoimLGc+SJy6fKym7I3sD4wnJojK1Zl3O3M1G 7qX49a0WaEbm4Is2jzreGuZjdTcsZ19zxKS87PUiGsTWEtuJL8GEYnrV4zcHSNwP3mGvA4+LNCerr ZBnul6auuecHximlbnC66y/bUYuA14yrKgXnVTh9qFS0YivKHODLM00AmcmAgPs5uvoGJjLSN1MO0 nmMhsyGg==; 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 1raP44-00GcSK-1d; Wed, 14 Feb 2024 17:53:20 -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 10/31] ntsync: Introduce NTSYNC_IOC_EVENT_SET. Date: Wed, 14 Feb 2024 17:52:45 -0600 Message-ID: <20240214235307.10494-1-zfigura@codeweavers.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240214233645.9273-1-zfigura@codeweavers.com> References: <20240214233645.9273-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: 1790920590917890512 X-GMAIL-MSGID: 1790920590917890512 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 2a21e7b0982a..bc24de02fd1c 100644 --- a/drivers/misc/ntsync.c +++ b/drivers/misc/ntsync.c @@ -456,6 +456,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; @@ -479,6 +514,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 b8cf503365ef..782057552483 100644 --- a/include/uapi/linux/ntsync.h +++ b/include/uapi/linux/ntsync.h @@ -48,5 +48,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