Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp30045pxb; Wed, 29 Sep 2021 20:10:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDeINGIbwSCgl1eo0y9Y/4of21YHUzMd3IedGrs969eJWbANDlIbG+eX5harw/+159A7g6 X-Received: by 2002:a17:907:2cf6:: with SMTP id hz22mr3949437ejc.134.1632971444654; Wed, 29 Sep 2021 20:10:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632971444; cv=none; d=google.com; s=arc-20160816; b=mAwIzGlbjvBCbSOwINiIu+HKr4Ucv+AxYFR76HMgqtfSzrkpIKabu6me4zysv3h4qx KcAl0U/F4sIB3OjZc1JsIT/1FIta3MGihby5/4NKRHrvG5zCWv+DCXtm2NvPAuuk4ONp elhxVoS4dt/bLzwNIdLOg4vI4Ugq9MbtRDpY0/J5nZzoUjUD8E/6p9DWyFgiM8xHH01n wEOo+t4qMUf0MZCnqAMZY01mkm1PFG5uHXaM5Wbn7dfSB4RsX9bTYVBd0+Wfir16Qn+x QreI0rX0cwRnIoyLgvJHkPEyEP6gxl69fTU4RtuSJElmeSqV4/NnCKtdG2s3kMmnZP9P CuCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=bVSYF7uJlZF85jEcbVvfB45l/qUznn+q8FvDHqhizO0=; b=g8nkLCTmJGZlQzahQF2ar7PfswdPWXW0wRLeR5hCxXxs0Fa87IEAcJg3lGH8uMDPd4 OuuVeNZLJQFRKUnpXMgH0rYch1UGT5agBPfs4CF+Jo6Hfek2YEnvlts3Q4vZ7gg3wl8R asfj82cAd6N7LIM7ag0kjHpjF/pb54N2FsDAKuN2BFufi2iLZvC0mjFVfii0Ad8r5bWu LfillnbsN+gqbPsSZCR6F56bWCXC0z3wyoKKHW+j9xZaeF+UzyDYdPKWvg1RB+iEmDD5 6Ly8vwRi9/ykhgC8pQUORDtHF2h/+3aDjWsO9g8ehvZl8PunhK2CmNWzXS6VgS5jaRVG UgvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gibson.dropbear.id.au header.s=201602 header.b=Cnh0oOWx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d21si2009613ejj.20.2021.09.29.20.10.20; Wed, 29 Sep 2021 20:10:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gibson.dropbear.id.au header.s=201602 header.b=Cnh0oOWx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347955AbhI3DEb (ORCPT + 99 others); Wed, 29 Sep 2021 23:04:31 -0400 Received: from gandalf.ozlabs.org ([150.107.74.76]:40727 "EHLO gandalf.ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347930AbhI3DE3 (ORCPT ); Wed, 29 Sep 2021 23:04:29 -0400 Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4HKdMn5D01z4xVP; Thu, 30 Sep 2021 13:02:45 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1632970965; bh=bVSYF7uJlZF85jEcbVvfB45l/qUznn+q8FvDHqhizO0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Cnh0oOWxARQj4pXBGaJspCnYZDi/18iEwECYzATMMFrV0rie8dj0kAKHE/rojFdlt W6n99DYr6n44OH89RrDLmVenjwb8Lc2SIRK+Y/XtQRVahr5LhQpGQvWgvHA7c3eojn o5dCH4z4NayPEdPTkPZ3TFrt6RGrjXspxXuJFtFw= Date: Thu, 30 Sep 2021 12:48:16 +1000 From: "david@gibson.dropbear.id.au" To: Jason Gunthorpe Cc: "Tian, Kevin" , "Liu, Yi L" , "alex.williamson@redhat.com" , "hch@lst.de" , "jasowang@redhat.com" , "joro@8bytes.org" , "jean-philippe@linaro.org" , "parav@mellanox.com" , "lkml@metux.net" , "pbonzini@redhat.com" , "lushenming@huawei.com" , "eric.auger@redhat.com" , "corbet@lwn.net" , "Raj, Ashok" , "yi.l.liu@linux.intel.com" , "Tian, Jun J" , "Wu, Hao" , "Jiang, Dave" , "jacob.jun.pan@linux.intel.com" , "kwankhede@nvidia.com" , "robin.murphy@arm.com" , "kvm@vger.kernel.org" , "iommu@lists.linux-foundation.org" , "dwmw2@infradead.org" , "linux-kernel@vger.kernel.org" , "baolu.lu@linux.intel.com" , "nicolinc@nvidia.com" Subject: Re: [RFC 03/20] vfio: Add vfio_[un]register_device() Message-ID: References: <20210919063848.1476776-1-yi.l.liu@intel.com> <20210919063848.1476776-4-yi.l.liu@intel.com> <20210921160108.GO327412@nvidia.com> <20210922010014.GE327412@nvidia.com> <20210929122230.GO964074@nvidia.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="h1nhRvd2ptQmOAKV" Content-Disposition: inline In-Reply-To: <20210929122230.GO964074@nvidia.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --h1nhRvd2ptQmOAKV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Sep 29, 2021 at 09:22:30AM -0300, Jason Gunthorpe wrote: > On Wed, Sep 29, 2021 at 12:46:14PM +1000, david@gibson.dropbear.id.au wro= te: > > On Tue, Sep 21, 2021 at 10:00:14PM -0300, Jason Gunthorpe wrote: > > > On Wed, Sep 22, 2021 at 12:54:02AM +0000, Tian, Kevin wrote: > > > > > From: Jason Gunthorpe > > > > > Sent: Wednesday, September 22, 2021 12:01 AM > > > > >=20 > > > > > > One open about how to organize the device nodes under > > > > > /dev/vfio/devices/. > > > > > > This RFC adopts a simple policy by keeping a flat layout with m= ixed > > > > > devname > > > > > > from all kinds of devices. The prerequisite of this model is th= at devnames > > > > > > from different bus types are unique formats: > > > > >=20 > > > > > This isn't reliable, the devname should just be vfio0, vfio1, etc > > > > >=20 > > > > > The userspace can learn the correct major/minor by inspecting the > > > > > sysfs. > > > > >=20 > > > > > This whole concept should disappear into the prior patch that add= s the > > > > > struct device in the first place, and I think most of the code he= re > > > > > can be deleted once the struct device is used properly. > > > > >=20 > > > >=20 > > > > Can you help elaborate above flow? This is one area where we need > > > > more guidance. > > > >=20 > > > > When Qemu accepts an option "-device vfio-pci,host=3DDDDD:BB:DD.F", > > > > how does Qemu identify which vifo0/1/... is associated with the spe= cified=20 > > > > DDDD:BB:DD.F?=20 > > >=20 > > > When done properly in the kernel the file: > > >=20 > > > /sys/bus/pci/devices/DDDD:BB:DD.F/vfio/vfioX/dev > > >=20 > > > Will contain the major:minor of the VFIO device. > > >=20 > > > Userspace then opens the /dev/vfio/devices/vfioX and checks with fstat > > > that the major:minor matches. > > >=20 > > > in the above pattern "pci" and "DDDD:BB:DD.FF" are the arguments pass= ed > > > to qemu. > >=20 > > I thought part of the appeal of the device centric model was less > > grovelling around in sysfs for information. Using type/address > > directly in /dev seems simpler than having to dig around matching > > things here. >=20 > I would say more regular grovelling. Starting from a sysfs device > directory and querying the VFIO cdev associated with it is much more > normal than what happens today, which also includes passing sysfs > information into an ioctl :\ Hm.. ok. Clearly I'm unfamiliar with the things that do that. Other than current VFIO, the only model I've really seen is where you just point your program at a device node. > > Note that this doesn't have to be done in kernel: you could have the > > kernel just call them /dev/vfio/devices/vfio0, ... but add udev rules > > that create symlinks from say /dev/vfio/pci/DDDD:BB:SS.F - > > > ../devices/vfioXX based on the sysfs information. >=20 > This is the right approach if people want to do this, but I'm not sure > it is worth it given backwards compat requires the sysfs path as > input. You mean for userspace that needs to be able to go back to the old VFIO interface as well? It seems silly to force this sysfs mucking about on new programs that depend on the new interface. > We may as well stick with sysfs as the command line interface > for userspace tools. > And I certainly don't want to see userspace tools trying to reverse a > sysfs path into a /dev/ symlink name when they can directly and > reliably learn the correct cdev from the sysfspath. Um.. sure.. but they can get the correct cdev from the sysfspath no matter how we name the cdevs. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --h1nhRvd2ptQmOAKV Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAmFVJXAACgkQbDjKyiDZ s5IQsQ//a9V6hdhkrwfjVg6eLiQNWabABagPIW1pwpFfrQKDiYkmXjBOg5EV0sXq nld3ED5fjbeTz1XIGFLihE2soGMjfi1+h9bIWl+Yq1idN6Gxkd1Gq3JDqbfg6C4R SnR1SmqsRvan+Br2Et/2jrdx3qEKEsdvCod33q443cKjNkmDtzrUHJiVE25SRyO/ Z2N2E4N8l+c1nbABzadlLJtKRmO84ptwgnCCnaeg0dg9EBatl00CxNVhM9HuHkOG q277x6vv5rEBhrW+MbjQNVt0wcKG1lCtWfdOrFl0QkBeI0fjSFCSQcxwnE7r8ehN /oyBmSaHuuAj5EVUPmJKh7PBf2zlpmhJUe9jOrrsUC7GXW3ykTvCG477Vpr7Pq21 zPcLDzrfrs1J1SW8o8Yc01lW3lsECwqzUW0dO83pblaz0AQimYFmbm+X7FXiHPOu /cXcoCBpTvBAyXt2I1eThH8HZY4gQoxmL0FWF87ifCKyFWvsZkmSaafEBE2nzkah c1wutGjFbhxdFZlZbu/R702kC/S4QYoPXgXno9bJkmnZE1xhesbiVBEeeMDu9xak eCiYkC4yZ3tR/qxsoHpzaa5SS95jbmU9kjNL3QAnasRdMCbRjWXmOApy7h4Avb67 idR+fs+Yk2p9P4kmQUVPeQwF2JW2hvDzh22naJeS9RtLxhlTwtc= =rIzq -----END PGP SIGNATURE----- --h1nhRvd2ptQmOAKV--