From: Jason Gunthorpe <jgg@nvidia.com>
To: "Tian, Kevin" <kevin.tian@intel.com>
Cc: "Liu, Yi L" <yi.l.liu@intel.com>,
"alex.williamson@redhat.com" <alex.williamson@redhat.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>
Subject: Re: [PATCH v1 5/5] vfio: Check the presence for iommufd callbacks in __vfio_register_dev()
Date: Fri, 10 Mar 2023 10:04:07 -0400 [thread overview]
Message-ID: <ZAs419G/RNoEgPxq@nvidia.com> (raw)
In-Reply-To: <BN9PR11MB5276BA4E1FF1345433FB8D338CBA9@BN9PR11MB5276.namprd11.prod.outlook.com>
On Fri, Mar 10, 2023 at 02:15:32AM +0000, Tian, Kevin wrote:
> > From: Liu, Yi L <yi.l.liu@intel.com>
> > Sent: Wednesday, March 8, 2023 9:14 PM
> >
> > After making the no-DMA drivers (samples/vfio-mdev) providing iommufd
> > callbacks, __vfio_register_dev() should check the presence of the iommufd
> > callbacks if CONFIG_IOMMUFD is enabled.
> >
> > Signed-off-by: Yi Liu <yi.l.liu@intel.com>
> > ---
> > drivers/vfio/vfio_main.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c
> > index 43bd6b76e2b6..89497c933490 100644
> > --- a/drivers/vfio/vfio_main.c
> > +++ b/drivers/vfio/vfio_main.c
> > @@ -255,8 +255,9 @@ static int __vfio_register_dev(struct vfio_device
> > *device,
> > {
> > int ret;
> >
> > - if (WARN_ON(device->ops->bind_iommufd &&
> > - (!device->ops->unbind_iommufd ||
> > + if (WARN_ON(IS_ENABLED(CONFIG_IOMMUFD) &&
> > + (!device->ops->bind_iommufd ||
> > + !device->ops->unbind_iommufd ||
> > !device->ops->attach_ioas)))
> > return -EINVAL;
> >
>
> I don't think IS_ENABLED() check is necessary. those ops are
> defined in the driver side w/o a conditional CONFIG_IOMMUFD.
>
> We should warn out lacking of those ops to the driver developer
> as early as possible, instead of postponing it until someone
> starts to build kernel with CONFIG_IOMMUFD.
The ops are NULL if !CONFIG_IOMMUFD. The previous code was OK because
it checked for non-null bind before demanding the others be non-null.
Jason
next prev parent reply other threads:[~2023-03-10 14:04 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-08 13:13 [PATCH v1 0/5] vfio: Make emulated devices prepared for vfio device cdev Yi Liu
2023-03-08 13:13 ` [PATCH v1 1/5] iommufd: Create access in vfio_iommufd_emulated_bind() Yi Liu
2023-03-10 2:08 ` Tian, Kevin
2023-03-14 18:50 ` Nicolin Chen
2023-03-15 6:16 ` Tian, Kevin
2023-03-15 6:21 ` Nicolin Chen
2023-03-15 6:52 ` Tian, Kevin
2023-03-15 8:52 ` Liu, Yi L
2023-03-16 0:17 ` Tian, Kevin
2023-03-16 0:28 ` Nicolin Chen
2023-03-10 17:36 ` Jason Gunthorpe
2023-03-14 8:20 ` Nicolin Chen
2023-03-15 1:01 ` Nicolin Chen
2023-03-15 6:15 ` Tian, Kevin
2023-03-15 6:32 ` Nicolin Chen
2023-03-15 6:50 ` Tian, Kevin
2023-03-15 9:03 ` Nicolin Chen
2023-03-15 12:18 ` Liu, Yi L
2023-03-16 0:32 ` Nicolin Chen
2023-03-16 2:53 ` Tian, Kevin
2023-03-16 3:25 ` Nicolin Chen
2023-03-16 5:33 ` Nicolin Chen
2023-03-16 5:38 ` Tian, Kevin
2023-03-16 5:43 ` Nicolin Chen
2023-03-16 5:49 ` Tian, Kevin
2023-03-16 5:56 ` Nicolin Chen
2023-03-16 6:01 ` Liu, Yi L
2023-03-20 14:49 ` Jason Gunthorpe
2023-03-20 15:11 ` Yi Liu
2023-03-20 15:33 ` Jason Gunthorpe
2023-03-08 13:13 ` [PATCH v1 2/5] vfio-iommufd: No need to record iommufd_ctx in vfio_device Yi Liu
2023-03-10 17:37 ` Jason Gunthorpe
2023-03-08 13:13 ` [PATCH v1 3/5] vfio-iommufd: Make vfio_iommufd_emulated_bind() return iommufd_access ID Yi Liu
2023-03-10 2:08 ` Tian, Kevin
2023-03-10 17:37 ` Jason Gunthorpe
2023-03-08 13:13 ` [PATCH v1 4/5] Samples/mdev: Uses the vfio emulated iommufd ops set in the mdev sample drivers Yi Liu
2023-03-10 2:10 ` Tian, Kevin
2023-03-10 17:39 ` Jason Gunthorpe
2023-03-08 13:13 ` [PATCH v1 5/5] vfio: Check the presence for iommufd callbacks in __vfio_register_dev() Yi Liu
2023-03-10 2:15 ` Tian, Kevin
2023-03-10 14:04 ` Jason Gunthorpe [this message]
2023-03-10 14:12 ` Liu, Yi L
2023-03-10 15:25 ` Jason Gunthorpe
2023-03-13 1:49 ` Tian, Kevin
2023-03-10 17:39 ` Jason Gunthorpe
2023-03-15 12:15 ` Liu, Yi L
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=ZAs419G/RNoEgPxq@nvidia.com \
--to=jgg@nvidia.com \
--cc=alex.williamson@redhat.com \
--cc=chao.p.peng@linux.intel.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=yi.l.liu@intel.com \
--cc=yi.y.sun@linux.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;
as well as URLs for NNTP newsgroup(s).