Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp305089rdb; Thu, 15 Feb 2024 00:01:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXejEMVGZkvvg+70B/wlh0KirycxrfHbWM5Gqzoli1zgkJoJbuizWECoW1RAfB9SWiXhTzBF3K6Ww9xTLiZo7X9WnOpfzipOzJmiS3fng== X-Google-Smtp-Source: AGHT+IEKzYShfAZQC14aMObkK80cRcHJItCerfQTAEIVEztLXBshrGTjZqwrBS+psSU3hVxbjTqy X-Received: by 2002:a17:90a:8a0d:b0:299:d17:a992 with SMTP id w13-20020a17090a8a0d00b002990d17a992mr525636pjn.25.1707984116766; Thu, 15 Feb 2024 00:01:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707984116; cv=pass; d=google.com; s=arc-20160816; b=iirrOV3XZ/tsDPPGGZzIuTYG+gEaPwc4UDDjEgajTXWVlNoTs7jvPa0nPCaNxqaEFg E9jVyycWfEsRJwn9DWAIzdUnP98zuL1iphtnssBg2NUR5XiTAmQdYMs5u+IRJxACDkPO /FYGyYMTB59KgNPzKeHWxptc9VVeuXgiesymCIVcrtTSUqcQqhLStq1TV9tcFsxZXGQ2 ZY3ylxZGSruQTwIxanrD0trLwmdtMGhx+cqCw2Iv0j2lMyiG4MGC6Ncoi6zLZziko0lE Xo0Su6c8Cyp2AsMTlWEFUOx7OLQ4oT1NLGnnDM9l+EkGCaJiQccg0Kwdil1EEwtS2v53 SSCw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=3TsnWnB41zRDVlL6leWjevdUPUGO84Pt8SU40wDzoIY=; fh=4/3+VLBIJuSftZIj/RgvQttLtZBha28q7yt0qBd3sxc=; b=qm+SStWZGb3tG+tikI8YsyyK40Kjt49x+E3sPgx6T4Mv9K07gvyrRNQ56UD5X2LcpM wiVz+K4mvHpt3OboLSdLro48ZLrUBWo+ARDMXQt4Iri45/QFclsX7RGaNvQhuvxYYBzx oP/9pKtEAY0PjE/O7ih4r7zHlNqo651W7k11lh4WDRgFMMJ/B+9uGYk3m0mJM1OU/Bhk FVt4czrWpcRcnkcp4Zz1DYx8meFTO+hwglXTWWGbKpOabzfjKsvMMnQQSRBCvPzM9QZe HzNXRCFtZS7ATRNuro923hgVwKc/hrR11zs+ouQVImAUsE8zG0sSpexf4Xr7Oj1J1HBF Ilqg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ipny7f7i; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-66361-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66361-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id jb20-20020a17090b409400b00296890c7545si2629544pjb.161.2024.02.15.00.01.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 00:01:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66361-linux.lists.archive=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=@linuxfoundation.org header.s=korg header.b=ipny7f7i; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-66361-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66361-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org 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 8CB19B2B569 for ; Thu, 15 Feb 2024 07:28:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F0B68DF6C; Thu, 15 Feb 2024 07:28:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ipny7f7i" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 09D14DDAE; Thu, 15 Feb 2024 07:28:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707982116; cv=none; b=FJrkfxBgIYVL12tThp6Q/I4lx7q4pPalLPcELKQ9+qgay1eSqoQONzM8rWVzG+X0V1+tePoGC4B4Nw9azJ3+GmdeVy0F9UBVP+FjG2PK0yEyjrob+4qA6c4E2D9N5vNqSSssHbaQPcGxz0+vNpKGUGNlZKWXdCJAgZZSYdoHgAU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707982116; c=relaxed/simple; bh=gbL0L0Sae19SG2KgNLVf95WEEBt6X+RJInvUGB6tvck=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rGYEdg0zpOuy6tLhhI1TSgcaeFQMiTVNHdL9qKfKxLrcAZm4DE+kX/FodIZd4oQm9Efb7GfK9R5c9tHJ/yvxPg8WmGoWOZOs+WaHsujWk6ErBS05vNQVzaOg84sW6TmC6o6rvZpRgQIPYwyMesxPYKtLMbjFjuISIx8ft42xKNA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ipny7f7i; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA68AC433C7; Thu, 15 Feb 2024 07:28:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1707982115; bh=gbL0L0Sae19SG2KgNLVf95WEEBt6X+RJInvUGB6tvck=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ipny7f7iORZ4op8HwPfI6UoXbtYCCdM7oE+JQlTAZt642ZlkH8OlNW9y9HU74VObE BAKZefYpkxSY/jwyDeTOW0MoLY6vu1PiLwnyqsbAZx1MeNpPHxKwNZQ0m6eoBM2LqV xpLEvyMhHA7tTVurz8ZNEu61kuUvz+gv+X6hm5DQ= Date: Thu, 15 Feb 2024 08:28:32 +0100 From: Greg Kroah-Hartman To: Elizabeth Figura Cc: Arnd Bergmann , Jonathan Corbet , Shuah Khan , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, wine-devel@winehq.org, =?iso-8859-1?Q?Andr=E9?= Almeida , Wolfram Sang , Arkadiusz Hiler , Peter Zijlstra , Andy Lutomirski , linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH 02/31] ntsync: Introduce NTSYNC_IOC_CREATE_SEM. Message-ID: <2024021533-thicken-handed-7d2d@gregkh> References: <20240214233645.9273-1-zfigura@codeweavers.com> <20240214233645.9273-3-zfigura@codeweavers.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240214233645.9273-3-zfigura@codeweavers.com> On Wed, Feb 14, 2024 at 05:36:38PM -0600, Elizabeth Figura wrote: > This corresponds to the NT syscall NtCreateSemaphore(). > > Semaphores are one of three types of object to be implemented in this driver, > the others being mutexes and events. > > An NT semaphore contains a 32-bit counter, and is signaled and can be acquired > when the counter is nonzero. The counter has a maximum value which is specified > at creation time. The initial value of the semaphore is also specified at > creation time. There are no restrictions on the maximum and initial value. > > Each object is exposed as an file, to which any number of fds may be opened. > When all fds are closed, the object is deleted. > > Signed-off-by: Elizabeth Figura > --- > .../userspace-api/ioctl/ioctl-number.rst | 2 + > drivers/misc/ntsync.c | 120 ++++++++++++++++++ > include/uapi/linux/ntsync.h | 21 +++ > 3 files changed, 143 insertions(+) > create mode 100644 include/uapi/linux/ntsync.h > > diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst b/Documentation/userspace-api/ioctl/ioctl-number.rst > index 457e16f06e04..2f5c6994f042 100644 > --- a/Documentation/userspace-api/ioctl/ioctl-number.rst > +++ b/Documentation/userspace-api/ioctl/ioctl-number.rst > @@ -173,6 +173,8 @@ Code Seq# Include File Comments > 'M' 00-0F drivers/video/fsl-diu-fb.h conflict! > 'N' 00-1F drivers/usb/scanner.h > 'N' 40-7F drivers/block/nvme.c > +'N' 80-8F uapi/linux/ntsync.h NT synchronization primitives > + > 'O' 00-06 mtd/ubi-user.h UBI > 'P' all linux/soundcard.h conflict! > 'P' 60-6F sound/sscape_ioctl.h conflict! > diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c > index e4969ef90722..3ad86d98b82d 100644 > --- a/drivers/misc/ntsync.c > +++ b/drivers/misc/ntsync.c > @@ -5,26 +5,146 @@ > * Copyright (C) 2024 Elizabeth Figura > */ > > +#include > +#include > #include > #include > #include > +#include > +#include > > #define NTSYNC_NAME "ntsync" > > +enum ntsync_type { > + NTSYNC_TYPE_SEM, > +}; > + > +struct ntsync_obj { > + enum ntsync_type type; > + > + union { > + struct { > + __u32 count; > + __u32 max; > + } sem; > + } u; > + > + struct file *file; > + struct ntsync_device *dev; > +}; > + > +struct ntsync_device { > + struct file *file; > +}; No reference counting is needed for your ntsync_device? Or are you relying on the reference counting of struct file here? You pass around pointers to this structure, and save it off into other structures, how do you know it is "safe" to do so? thanks, greg k-h