All of lore.kernel.org
 help / color / mirror / Atom feed
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>,
	"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>
Subject: Re: [PATCH 07/10] vfio: Refactor vfio_device open and close
Date: Fri, 2 Dec 2022 11:07:25 -0400	[thread overview]
Message-ID: <Y4oUrX23H3ocanuR@nvidia.com> (raw)
In-Reply-To: <23a0105d-b108-056d-7b4a-1235d5bb8049@intel.com>

On Fri, Dec 02, 2022 at 02:37:18PM +0800, Yi Liu wrote:
> On 2022/12/2 14:15, Tian, Kevin wrote:
> > > From: Liu, Yi L <yi.l.liu@intel.com>
> > > Sent: Thursday, December 1, 2022 10:56 PM
> > > 
> > > This refactor makes the vfio_device_open() to accept device, iommufd_ctx
> > > pointer and kvm pointer. These parameters are generic items in today's
> > > group path and furute device cdev path. Caller of vfio_device_open() should
> > > take care the necessary protections. e.g. the current group path need to
> > > hold the group_lock to ensure the iommufd_ctx and kvm pointer are valid.
> > > 
> > > This refactor also wraps the group spefcific codes in the device open and
> > > close paths to be paired helpers like:
> > > 
> > > - vfio_device_group_open/close(): call vfio_device_open/close()
> > > - vfio_device_group_use/unuse_iommu(): call iommufd or container
> > > use/unuse
> > 
> > this pair is container specific. iommufd vs. container is selected
> > in vfio_device_first_open().
> 
> got it.
> 
> > > @@ -765,77 +796,56 @@ static int vfio_device_first_open(struct vfio_device
> > > *device)
> > >   	if (!try_module_get(device->dev->driver->owner))
> > >   		return -ENODEV;
> > > 
> > > -	/*
> > > -	 * Here we pass the KVM pointer with the group under the lock.  If
> > > the
> > > -	 * device driver will use it, it must obtain a reference and release it
> > > -	 * during close_device.
> > > -	 */
> > > -	mutex_lock(&device->group->group_lock);
> > > -	if (!vfio_group_has_iommu(device->group)) {
> > > -		ret = -EINVAL;
> > > +	if (iommufd)
> > > +		ret = vfio_iommufd_bind(device, iommufd);
> > 
> > This probably should be renamed to vfio_device_iommufd_bind().
> 
> I'd like to see if Jason wants to modify it or not as it is
> introduced in vfio compat series.
> 
> https://lore.kernel.org/kvm/6-v4-42cd2eb0e3eb+335a-vfio_iommufd_jgg@nvidia.com/

Ah, it is a bit late, if we want to change it please make a patch

> > 
> > > +	else
> > > +		ret = vfio_device_group_use_iommu(device);
> > 
> > what about vfio_device_container_bind()?
> 
> maybe use_iommu seems suit more. bind is more likely a kind of
> associating something with something. but this helper is more kind
> of using the container. so I chose use_iommu. But I see the value
> of using bind, it would make the two branches aligned.

I prefer use iommu, "bind" is so vauge

Jason

  reply	other threads:[~2022-12-02 15:07 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-01 14:55 [PATCH 00/10] Move group specific code into group.c Yi Liu
2022-12-01 14:55 ` [PATCH 01/10] vfio: Simplify vfio_create_group() Yi Liu
2022-12-01 14:55 ` [PATCH 02/10] vfio: Move the sanity check of the group to vfio_create_group() Yi Liu
2022-12-01 14:55 ` [PATCH 03/10] vfio: Create wrappers for group register/unregister Yi Liu
2022-12-01 14:55 ` [PATCH 04/10] vfio: Set device->group in helper function Yi Liu
2022-12-02  5:34   ` Tian, Kevin
2022-12-01 14:55 ` [PATCH 05/10] vfio: Swap order of vfio_device_container_register() and open_device() Yi Liu
2022-12-01 14:55 ` [PATCH 06/10] vfio: Move device open/close code to be helpfers Yi Liu
2022-12-02  5:44   ` Tian, Kevin
2022-12-02  6:37     ` Yi Liu
2022-12-01 14:55 ` [PATCH 07/10] vfio: Refactor vfio_device open and close Yi Liu
2022-12-02  6:15   ` Tian, Kevin
2022-12-02  6:37     ` Yi Liu
2022-12-02 15:07       ` Jason Gunthorpe [this message]
2022-12-02 21:58   ` Alex Williamson
2022-12-03 13:46     ` Yi Liu
2022-12-01 14:55 ` [PATCH 08/10] vfio: Wrap vfio group module init/clean code into helpers Yi Liu
2022-12-01 14:55 ` [PATCH 09/10] vfio: Refactor dma APIs for emulated devices Yi Liu
2022-12-01 14:55 ` [PATCH 10/10] vfio: Move vfio group specific code into group.c Yi Liu
2022-12-02  6:26   ` Tian, Kevin
2022-12-01 20:39 ` [PATCH 00/10] Move " Jason Gunthorpe
2022-12-02 13:57   ` Yi Liu
2022-12-02 14:44     ` Jason Gunthorpe
2022-12-02 23:12       ` Alex Williamson
2022-12-03 13:53         ` Yi Liu
2022-12-05 13:43           ` Jason Gunthorpe
2022-12-06  7:31           ` Yang, Lixiao
2022-12-07  4:12             ` He, Yu

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=Y4oUrX23H3ocanuR@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.