Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp235667pxb; Tue, 28 Sep 2021 20:34:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWrmtsgnHN7O+MO/btfa+Q9t9jPnmZmIR4UVfbTPvSepnGX56GMYwpOtfbVhlY6iDm/eWr X-Received: by 2002:a50:9d49:: with SMTP id j9mr11811125edk.39.1632886447460; Tue, 28 Sep 2021 20:34:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632886447; cv=none; d=google.com; s=arc-20160816; b=WGTYJ3eV08p25ZXr6aZ7QqZuP2ElGSr0BRFsCNbMcitPNtkKTqCWDMDssE6WSovZqO g5D8KKhqsCsw40T7LJyPYM7vehfYBKfnb60hcq0yOCfSSxhf2JYS6NE8YtCyHuErgLj3 xKwEPPbn6Ql+Jfg1LV1lRxbqdcRP9xlWbixjEzOpVf7ss4EQ9Pc+GVWqNGPLiaoowEXJ FIE49lUc16H1EqPbw3wk5Cdd4CukvvE71XtEqhy2gOoWfnDVWZaX10kb1X7VjoBKhG9M XJhJ7UUiKSlabRwH9CkTQhVKe4ZZsgtWJsajXyuzYt8YEDeji4FsotG7JUTockMV1F6b WN+g== 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=qzQIQZ4QRhIcmilmBeomTPiSlLs3WETVdIoKH8ljR5I=; b=Id2N48kauGNDCVrASRnHsJP6UJxvSMnbfJV/hH0sPBEqnNu3R0AIYX2H64HjY/kc2a tseXFxDDiCDMM4BKWMJQeYDE1M1t1xZKQaJDGYOg4ArVHRbJvuTxnkW0grnZYT0BmrMn BJ/PklT+CQ8LHML4g3QfXHkF7/j9WrvH4/EukS2MlHW/vwUe/zBjI0J4hjHuw/LWH/ri Cd4klmFhqhEPxdgKnWIpkfp6Ll/RaibHZ/lU+jiw8KIH50PEnzDU8yk5tYhJISUW5mZQ bpqnYuMzMqMe1pRlY5IEmoFiiydBv2H2sghF+F5qsmj5hP01pr/U/a0JV/86vSFpOfyK 5LdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gibson.dropbear.id.au header.s=201602 header.b=p5e2lRrX; 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 g20si1163048edr.364.2021.09.28.20.33.36; Tue, 28 Sep 2021 20:34:07 -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=p5e2lRrX; 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 S243994AbhI2D3w (ORCPT + 99 others); Tue, 28 Sep 2021 23:29:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243941AbhI2D3n (ORCPT ); Tue, 28 Sep 2021 23:29:43 -0400 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee2:21ea]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5752C061745; Tue, 28 Sep 2021 20:28:02 -0700 (PDT) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4HK1zN6cnQz4xbT; Wed, 29 Sep 2021 13:28:00 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1632886080; bh=qzQIQZ4QRhIcmilmBeomTPiSlLs3WETVdIoKH8ljR5I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=p5e2lRrXkAIwbSxkG3qdFSqNl4eS0ICYpOq4Hcu5VnMPhSadYB0m7dyvRiC++N3Lg 8arvLC3O7qOMZjze+SPIHfiKcZWeSnfEeejTsR98qNOzIYVzQKTVZTraACX8JjPnVJ bBLKwH+HMNsXDmQWOS8SMuMsqAS3TnSMGTxZrasU= Date: Wed, 29 Sep 2021 12:46:14 +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> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="M1+gRInfuzVDe7lG" Content-Disposition: inline In-Reply-To: <20210922010014.GE327412@nvidia.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --M1+gRInfuzVDe7lG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 mixed > > > devname > > > > from all kinds of devices. The prerequisite of this model is that d= evnames > > > > 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 adds the > > > struct device in the first place, and I think most of the code here > > > 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 specifi= ed=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 passed > to qemu. 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. 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 - > =2E./devices/vfioXX based on the sysfs information. >=20 > You can look at this for some general over engineered code to handle > opening from a sysfs handle like above: >=20 > https://github.com/linux-rdma/rdma-core/blob/master/util/open_cdev.c >=20 > Jason >=20 --=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 --M1+gRInfuzVDe7lG Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAmFT03YACgkQbDjKyiDZ s5L5+RAA2E2lYOOD4bTHuC/PsiWELLG1eQQa3Jb4G+sT+fOVdbBmt8zME8lEAiXb iKIx7FlKDY1YCkr3fHedUDTXNRKphIvtkJYkHS43zI2KaRkqn20pxvps6kjA0MvV IMdk+8ZiUyA806bldQ6iEYhk7K888zeHPhSBhdZ6tSiWi5Yg6llD0A+WTGVmI9vx pm6Cu3r80UouuTm2JY37yyYamFsGAGs0iVNiFxA/zhtGjJ5soKUOcqZSx4P8MfHD 2GOsiRGlwRx2peP+yrqAw9CutaR4jphP2ehVoqjyKq4wzMZ7PQCkuoUiFo3fNFjs J8lUiY9PxisD+0rStds1WF1oPHocq2B/ALXzDlHPxFTitdH/OiDKZ0p86jHZcNVN QdqipuJH4bXo4iyqWg0ksf3ECdekPJo0xfN4aMmDLHst4mhjSslQz/0WPZlQJKCe cOiG2I6akTADkQR65q1bKyr2gZR0fZTZp0AwBGQ6Nj1I2iHKHOI05+/pQC9NCVkn pkWc6WL12WGybyo/GyDblf5h1bfZTDJFLxS16uymh/MT+LPjGtik1I4KQezl1IA5 rAy5LpQ11dBOizN6dCO7XhmGLeRGXLXGxhe676t9fix+bibSYU0pvZUnffYHOxZw pOv6wsRFvaM4ZhTBIB8PcbgNZHreiWAoFGdvfjHVRVR1Xl9Kx2A= =JS/Z -----END PGP SIGNATURE----- --M1+gRInfuzVDe7lG--