From: Jason Gunthorpe <jgg@nvidia.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: "Liu, Yi L" <yi.l.liu@intel.com>,
"Tian, Kevin" <kevin.tian@intel.com>,
"joro@8bytes.org" <joro@8bytes.org>,
"robin.murphy@arm.com" <robin.murphy@arm.com>,
"cohuck@redhat.com" <cohuck@redhat.com>,
"eric.auger@redhat.com" <eric.auger@redhat.com>,
"nicolinc@nvidia.com" <nicolinc@nvidia.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"mjrosato@linux.ibm.com" <mjrosato@linux.ibm.com>,
"chao.p.peng@linux.intel.com" <chao.p.peng@linux.intel.com>,
"yi.y.sun@linux.intel.com" <yi.y.sun@linux.intel.com>,
"peterx@redhat.com" <peterx@redhat.com>,
"jasowang@redhat.com" <jasowang@redhat.com>,
"shameerali.kolothum.thodi@huawei.com"
<shameerali.kolothum.thodi@huawei.com>,
"lulu@redhat.com" <lulu@redhat.com>,
"suravee.suthikulpanit@amd.com" <suravee.suthikulpanit@amd.com>,
"intel-gvt-dev@lists.freedesktop.org"
<intel-gvt-dev@lists.freedesktop.org>,
"intel-gfx@lists.freedesktop.org"
<intel-gfx@lists.freedesktop.org>,
"linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>,
"Hao, Xudong" <xudong.hao@intel.com>,
"Zhao, Yan Y" <yan.y.zhao@intel.com>,
"Xu, Terrence" <terrence.xu@intel.com>,
"Jiang, Yanting" <yanting.jiang@intel.com>,
"Duan, Zhenzhong" <zhenzhong.duan@intel.com>,
"clegoate@redhat.com" <clegoate@redhat.com>
Subject: Re: [PATCH v7 8/9] vfio/pci: Extend VFIO_DEVICE_GET_PCI_HOT_RESET_INFO for vfio device cdev
Date: Tue, 13 Jun 2023 14:40:10 -0300 [thread overview]
Message-ID: <ZIip+nGKr8+jZb1z@nvidia.com> (raw)
In-Reply-To: <20230613083229.44a3f3ec.alex.williamson@redhat.com>
On Tue, Jun 13, 2023 at 08:32:29AM -0600, Alex Williamson wrote:
> On Tue, 13 Jun 2023 12:50:43 +0000
> "Liu, Yi L" <yi.l.liu@intel.com> wrote:
>
> > > From: Jason Gunthorpe <jgg@nvidia.com>
> > > Sent: Tuesday, June 13, 2023 7:47 PM
> > >
> > > On Fri, Jun 02, 2023 at 05:15:14AM -0700, Yi Liu wrote:
> > > > +/*
> > > > + * Return devid for a device which is affected by hot-reset.
> > > > + * - valid devid > 0 for the device that is bound to the input
> > > > + * iommufd_ctx.
> > > > + * - devid == VFIO_PCI_DEVID_OWNED for the device that has not
> > > > + * been bound to any iommufd_ctx but other device within its
> > > > + * group has been bound to the input iommufd_ctx.
> > > > + * - devid == VFIO_PCI_DEVID_NOT_OWNED for others. e.g. device
> > > > + * is bound to other iommufd_ctx etc.
> > > > + */
> > > > +int vfio_iommufd_device_hot_reset_devid(struct vfio_device *vdev,
> > > > + struct iommufd_ctx *ictx)
> > > > +{
> > > > + struct iommu_group *group;
> > > > + int devid;
> > > > +
> > > > + if (vfio_iommufd_device_ictx(vdev) == ictx)
> > > > + return vfio_iommufd_device_id(vdev);
> > > > +
> > > > + group = iommu_group_get(vdev->dev);
> > > > + if (!group)
> > > > + return VFIO_PCI_DEVID_NOT_OWNED;
> > > > +
> > > > + if (iommufd_ctx_has_group(ictx, group))
> > > > + devid = VFIO_PCI_DEVID_OWNED;
> > > > + else
> > > > + devid = VFIO_PCI_DEVID_NOT_OWNED;
> > > > +
> > > > + iommu_group_put(group);
> > > > +
> > > > + return devid;
> > > > +}
> > > > +EXPORT_SYMBOL_GPL(vfio_iommufd_device_hot_reset_devid);
> > >
> > > This function really should not be in the core iommufd.c file - it is
> > > a purely vfio-pci function - why did you have to place it here?
> >
> > Put it here can avoid calling iommufd_ctx_has_group() in vfio-pci,
> > which requires to import IOMMUFD_NS. If this reason is not so
> > strong I can move it back to vfio-pci code.
>
> The PCI-isms here are the name of the function and the return value,
> otherwise this is simply a "give me the devid for this device in this
> context". The function name is trivial to change and we can define the
> internal errno usage such that the vfio-pci-core code can interpret the
> correct uAPI value. For example, -EXDEV ("Cross-device link") could
> maybe be interpreted as owned and any other errno is not-owned, -ENODEV
> maybe being the default.
Yeah, this approach seems logical
If the function is called
vfio_iommufd_get_dev_id(struct vfio_device *vdev, struct iommufd_ctx *ictx)
Then maybe
ENOENT = device is owned but there is no Id
ENODEV = device is not owned
EXDEV is good too, nice symmetry with ENODEV - it doesn't really
matter since there is only one caller and there is no embedded errno
propogation.
Jason
next prev parent reply other threads:[~2023-06-13 17:40 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-02 12:15 [PATCH v7 0/9] Enhance vfio PCI hot reset for vfio cdev device Yi Liu
2023-06-02 12:15 ` [PATCH v7 1/9] vfio/pci: Update comment around group_fd get in vfio_pci_ioctl_pci_hot_reset() Yi Liu
2023-06-02 12:15 ` [PATCH v7 2/9] vfio/pci: Move the existing hot reset logic to be a helper Yi Liu
2023-06-02 12:15 ` [PATCH v7 3/9] iommufd: Reserve all negative IDs in the iommufd xarray Yi Liu
2023-06-13 11:46 ` Jason Gunthorpe
2023-06-02 12:15 ` [PATCH v7 4/9] iommufd: Add iommufd_ctx_has_group() Yi Liu
2023-06-08 21:40 ` Alex Williamson
2023-06-08 23:44 ` Liu, Yi L
2023-06-13 11:46 ` Jason Gunthorpe
2023-06-02 12:15 ` [PATCH v7 5/9] iommufd: Add helper to retrieve iommufd_ctx and devid Yi Liu
2023-06-13 11:47 ` Jason Gunthorpe
2023-06-02 12:15 ` [PATCH v7 6/9] vfio: Mark cdev usage in vfio_device Yi Liu
2023-06-13 17:56 ` Jason Gunthorpe
2023-06-14 5:56 ` Liu, Yi L
2023-06-14 12:11 ` Jason Gunthorpe
2023-06-02 12:15 ` [PATCH v7 7/9] vfio: Add helper to search vfio_device in a dev_set Yi Liu
2023-06-13 11:47 ` Jason Gunthorpe
2023-06-02 12:15 ` [PATCH v7 8/9] vfio/pci: Extend VFIO_DEVICE_GET_PCI_HOT_RESET_INFO for vfio device cdev Yi Liu
2023-06-08 22:26 ` Alex Williamson
2023-06-09 0:04 ` Liu, Yi L
2023-06-13 11:46 ` Jason Gunthorpe
2023-06-13 12:50 ` Liu, Yi L
2023-06-13 14:32 ` Alex Williamson
2023-06-13 17:40 ` Jason Gunthorpe [this message]
2023-06-13 18:23 ` Jason Gunthorpe
2023-06-14 10:35 ` Liu, Yi L
2023-06-14 12:17 ` Jason Gunthorpe
2023-06-14 13:05 ` Liu, Yi L
2023-06-14 13:37 ` Jason Gunthorpe
2023-06-15 3:31 ` Liu, Yi L
2023-06-02 12:15 ` [PATCH v7 9/9] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET Yi Liu
2023-06-08 22:30 ` Alex Williamson
2023-06-09 0:13 ` Liu, Yi L
2023-06-09 14:38 ` Jason Gunthorpe
2023-06-13 18:09 ` Jason Gunthorpe
2023-06-08 6:59 ` [PATCH v7 0/9] Enhance vfio PCI hot reset for vfio cdev device Jiang, Yanting
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZIip+nGKr8+jZb1z@nvidia.com \
--to=jgg@nvidia.com \
--cc=alex.williamson@redhat.com \
--cc=chao.p.peng@linux.intel.com \
--cc=clegoate@redhat.com \
--cc=cohuck@redhat.com \
--cc=eric.auger@redhat.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-gvt-dev@lists.freedesktop.org \
--cc=jasowang@redhat.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=lulu@redhat.com \
--cc=mjrosato@linux.ibm.com \
--cc=nicolinc@nvidia.com \
--cc=peterx@redhat.com \
--cc=robin.murphy@arm.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=terrence.xu@intel.com \
--cc=xudong.hao@intel.com \
--cc=yan.y.zhao@intel.com \
--cc=yanting.jiang@intel.com \
--cc=yi.l.liu@intel.com \
--cc=yi.y.sun@linux.intel.com \
--cc=zhenzhong.duan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox