From: Jason Gunthorpe <jgg@nvidia.com>
To: Yi Liu <yi.l.liu@intel.com>
Cc: "Tian, Kevin" <kevin.tian@intel.com>,
"alex.williamson@redhat.com" <alex.williamson@redhat.com>,
"eric.auger@redhat.com" <eric.auger@redhat.com>,
"cohuck@redhat.com" <cohuck@redhat.com>,
"nicolinc@nvidia.com" <nicolinc@nvidia.com>,
"yi.y.sun@linux.intel.com" <yi.y.sun@linux.intel.com>,
"chao.p.peng@linux.intel.com" <chao.p.peng@linux.intel.com>,
"mjrosato@linux.ibm.com" <mjrosato@linux.ibm.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [RFC v2 05/11] vfio: Make vfio_device_open() group agnostic
Date: Thu, 1 Dec 2022 08:48:15 -0400 [thread overview]
Message-ID: <Y4iij7hyD2Qhj/F9@nvidia.com> (raw)
In-Reply-To: <f57fcc1d-a3a4-c423-a863-b1958a8d453f@intel.com>
On Thu, Dec 01, 2022 at 03:08:12PM +0800, Yi Liu wrote:
> On 2022/11/28 17:19, Yi Liu wrote:
> > On 2022/11/28 16:17, Tian, Kevin wrote:
> > > > From: Liu, Yi L <yi.l.liu@intel.com>
> > > > Sent: Thursday, November 24, 2022 8:27 PM
> > > >
> > > > This prepares for moving group specific code to separate file.
> > > >
> > > > Signed-off-by: Yi Liu <yi.l.liu@intel.com>
> > > > ---
> > > > drivers/vfio/vfio_main.c | 7 ++++---
> > > > 1 file changed, 4 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c
> > > > index edcfa8a61096..fcb9f778fc9b 100644
> > > > --- a/drivers/vfio/vfio_main.c
> > > > +++ b/drivers/vfio/vfio_main.c
> > > > @@ -878,9 +878,6 @@ static struct file *vfio_device_open(struct vfio_device
> > > > *device)
> > > > */
> > > > filep->f_mode |= (FMODE_PREAD | FMODE_PWRITE);
> > > >
> > > > - if (device->group->type == VFIO_NO_IOMMU)
> > > > - dev_warn(device->dev, "vfio-noiommu device opened by
> > > > user "
> > > > - "(%s:%d)\n", current->comm, task_pid_nr(current));
> > > > /*
> > > > * On success the ref of device is moved to the file and
> > > > * put in vfio_device_fops_release()
> > > > @@ -927,6 +924,10 @@ static int vfio_group_ioctl_get_device_fd(struct
> > > > vfio_group *group,
> > > > goto err_put_fdno;
> > > > }
> > > >
> > > > + if (group->type == VFIO_NO_IOMMU)
> > > > + dev_warn(device->dev, "vfio-noiommu device opened by
> > > > user "
> > > > + "(%s:%d)\n", current->comm, task_pid_nr(current));
> > > > +
> > > > fd_install(fdno, filep);
> > > > return fdno;
> > > >
> > >
> > > Do we want to support no-iommu mode in future cdev path?
> > >
> > > If yes keeping the check in vfio_device_open() makes more sense. Just
> > > replace direct device->group reference with a helper e.g.:
> > >
> > > vfio_device_group_noiommu()
> >
> > I didn't see a reason cdev cannot support no-iommu mode. so a helper to
> > check noiommu is reasonable.
>
> This check should be done after opening device and the file. Current
> vfio_device_open() opens device first and then open file. Open file is
> group path specific, not needed in future device cdev path. So if want to
> have this check in the common function, the open device and open file
> order should be swapped. However, it is not necessary here. So may just
> drop this patch and consider it in future device cdev series.
the point here was to remove the device->group touches from
vfio_main.c, which this does and seems appropraite.
cdev no-iommu mode is going to be quite different since it will work
without groups
Jason
next prev parent reply other threads:[~2022-12-01 12:48 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-24 12:26 [RFC v2 00/11] Move group specific code into group.c Yi Liu
2022-11-24 12:26 ` [RFC v2 01/11] vfio: Simplify vfio_create_group() Yi Liu
2022-11-28 7:57 ` Tian, Kevin
2022-11-24 12:26 ` [RFC v2 02/11] vfio: Move the sanity check of the group to vfio_create_group() Yi Liu
2022-11-28 8:05 ` Tian, Kevin
2022-11-24 12:26 ` [RFC v2 03/11] vfio: Set device->group in helper function Yi Liu
2022-11-24 13:17 ` Jason Gunthorpe
2022-11-24 13:50 ` Yi Liu
2022-11-28 8:08 ` Tian, Kevin
2022-11-28 9:17 ` Yi Liu
2022-11-29 2:04 ` Tian, Kevin
2022-11-29 13:27 ` Jason Gunthorpe
2022-11-30 7:09 ` Yi Liu
2022-11-24 12:26 ` [RFC v2 04/11] vfio: Wrap group codes to be helpers for __vfio_register_dev() and unregister Yi Liu
2022-11-28 8:11 ` Tian, Kevin
2022-11-28 9:17 ` Yi Liu
2022-11-24 12:26 ` [RFC v2 05/11] vfio: Make vfio_device_open() group agnostic Yi Liu
2022-11-28 8:17 ` Tian, Kevin
2022-11-28 9:19 ` Yi Liu
2022-12-01 7:08 ` Yi Liu
2022-12-01 12:48 ` Jason Gunthorpe [this message]
2022-11-24 12:26 ` [RFC v2 06/11] vfio: Move device open/close code to be helpfers Yi Liu
2022-11-28 8:21 ` Tian, Kevin
2022-11-28 9:27 ` Yi Liu
2022-11-24 12:26 ` [RFC v2 07/11] vfio: Swap order of vfio_device_container_register() and open_device() Yi Liu
2022-11-28 8:27 ` Tian, Kevin
2022-11-28 9:28 ` Yi Liu
2022-11-24 12:26 ` [RFC v2 08/11] vfio: Refactor vfio_device_first_open() and _last_close() Yi Liu
2022-11-24 14:56 ` Jason Gunthorpe
2022-11-25 8:57 ` Yi Liu
2022-11-25 12:37 ` Jason Gunthorpe
2022-11-25 14:06 ` Yi Liu
2022-11-25 14:15 ` Jason Gunthorpe
2022-11-25 14:33 ` Yi Liu
2022-11-28 8:31 ` Tian, Kevin
2022-11-24 12:27 ` [RFC v2 09/11] vfio: Wrap vfio group module init/clean code into helpers Yi Liu
2022-11-28 8:36 ` Tian, Kevin
2022-11-24 12:27 ` [RFC v2 10/11] vfio: Refactor dma APIs for emulated devices Yi Liu
2022-11-24 22:05 ` kernel test robot
2022-11-28 8:42 ` Tian, Kevin
2022-11-24 12:27 ` [RFC v2 11/11] vfio: Move vfio group specific code into group.c Yi Liu
2022-11-24 14:36 ` Jason Gunthorpe
2022-11-25 8:45 ` Yi Liu
2022-11-28 21:21 ` kernel test robot
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=Y4iij7hyD2Qhj/F9@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=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=mjrosato@linux.ibm.com \
--cc=nicolinc@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.