public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: "Tian, Kevin" <kevin.tian@intel.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>,
	David Airlie <airlied@linux.ie>,
	Tony Krowiak <akrowiak@linux.ibm.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Cornelia Huck <cohuck@redhat.com>,
	Daniel Vetter <daniel@ffwll.ch>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	Eric Farman <farman@linux.ibm.com>,
	Harald Freudenberger <freude@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	"intel-gfx@lists.freedesktop.org"
	<intel-gfx@lists.freedesktop.org>,
	"intel-gvt-dev@lists.freedesktop.org" 
	<intel-gvt-dev@lists.freedesktop.org>,
	Jani Nikula <jani.nikula@linux.intel.com>,
	Jason Herne <jjherne@linux.ibm.com>,
	Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>,
	Matthew Rosato <mjrosato@linux.ibm.com>,
	Peter Oberparleiter <oberpar@linux.ibm.com>,
	Halil Pasic <pasic@linux.ibm.com>,
	"Vivi, Rodrigo" <rodrigo.vivi@intel.com>,
	Sven Schnelle <svens@linux.ibm.com>,
	Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
	Vineeth Vijayan <vneethv@linux.ibm.com>,
	Zhenyu Wang <zhenyuw@linux.intel.com>,
	"Wang, Zhi A" <zhi.a.wang@intel.com>,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v2 2/2] vfio: Replace the iommu notifier with a device list
Date: Wed, 8 Jun 2022 08:26:41 -0300	[thread overview]
Message-ID: <20220608112641.GM1343366@nvidia.com> (raw)
In-Reply-To: <BN9PR11MB527600F9745D1AE27150CF938CA49@BN9PR11MB5276.namprd11.prod.outlook.com>

On Wed, Jun 08, 2022 at 03:47:12AM +0000, Tian, Kevin wrote:
> > From: Jason Gunthorpe
> > Sent: Wednesday, June 8, 2022 7:02 AM
> > 
> > Instead of bouncing the function call to the driver op through a blocking
> > notifier just have the iommu layer call it directly.
> > 
> > Register each device that is being attached to the iommu with the lower
> > driver which then threads them on a linked list and calls the appropriate
> > driver op at the right time.
> > 
> > Currently the only use is if dma_unmap() is defined.
> > 
> > Also, fully lock all the debugging tests on the pinning path that a
> > dma_unmap is registered.
> >
> ... 
> > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> > diff --git a/drivers/vfio/vfio_iommu_type1.c
> > b/drivers/vfio/vfio_iommu_type1.c
> > index c13b9290e35759..4ddb1f1abd238b 100644
> > +++ b/drivers/vfio/vfio_iommu_type1.c
> > @@ -67,7 +67,8 @@ struct vfio_iommu {
> >  	struct list_head	iova_list;
> >  	struct mutex		lock;
> >  	struct rb_root		dma_list;
> > -	struct blocking_notifier_head notifier;
> > +	struct list_head	device_list;
> > +	struct mutex		device_list_lock;
> 
> emulated_device_list or unmap_device_list, to be more accurate?

I don't think it is worth getting too specific here, the fact it only
has dma_unmap devices is a bit of a shortcut to save some work.

> btw a few lines downward there is already a emulated_iommu_groups.
> the two sounds a bit overlapping given mdev's iommu group is faked
> and singleton. Wonder whether it's cleaner to just reuse the existing field...

The locking is more complicated on this since we still have check
every device in the group if it is opened or not while launching the
callback and prevent it from opening/closing while the callback is
running.

Since I plan to delete the dirty tracking which will drop the
emulated_iommu_groups too I would leave it like this.

Jason

  reply	other threads:[~2022-06-08 11:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-07 23:02 [PATCH v2 0/2] Remove the VFIO_IOMMU_NOTIFY_DMA_UNMAP notifier Jason Gunthorpe
2022-06-07 23:02 ` [PATCH v2 1/2] vfio: Replace the DMA unmapping notifier with a callback Jason Gunthorpe
2022-06-08  3:37   ` Tian, Kevin
2022-06-08 15:50   ` Eric Farman
2022-06-09 14:43     ` Jason Gunthorpe
2022-06-09 13:21   ` Tony Krowiak
2022-06-17 22:42   ` Alex Williamson
2022-06-17 22:47     ` Alex Williamson
2022-06-07 23:02 ` [PATCH v2 2/2] vfio: Replace the iommu notifier with a device list Jason Gunthorpe
2022-06-08  3:47   ` Tian, Kevin
2022-06-08 11:26     ` Jason Gunthorpe [this message]
2022-06-08 23:50       ` Tian, Kevin
2022-06-08  5:33   ` Christoph Hellwig
2022-06-17 23:19   ` Alex Williamson

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=20220608112641.GM1343366@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=agordeev@linux.ibm.com \
    --cc=airlied@linux.ie \
    --cc=akrowiak@linux.ibm.com \
    --cc=alex.williamson@redhat.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=farman@linux.ibm.com \
    --cc=freude@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=hch@lst.de \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-gvt-dev@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=jjherne@linux.ibm.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mjrosato@linux.ibm.com \
    --cc=oberpar@linux.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=svens@linux.ibm.com \
    --cc=tvrtko.ursulin@linux.intel.com \
    --cc=vneethv@linux.ibm.com \
    --cc=zhenyuw@linux.intel.com \
    --cc=zhi.a.wang@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