[PATCH] iommu: Remove functions that support private domain
Prakhya, Sai Praneeth
sai.praneeth.prakhya at intel.com
Thu May 28 19:31:40 UTC 2020
> -----Original Message-----
> From: Joerg Roedel <joro at 8bytes.org>
> Sent: Monday, May 25, 2020 6:57 AM
> To: Prakhya, Sai Praneeth <sai.praneeth.prakhya at intel.com>
> Cc: Lu Baolu <baolu.lu at linux.intel.com>; iommu at lists.linux-foundation.org
> Subject: Re: [PATCH] iommu: Remove functions that support private domain
> On Sun, May 17, 2020 at 08:29:17AM +0000, Prakhya, Sai Praneeth wrote:
> > iommu_bus_notifier()
> > -> iommu_release_device()
> > -> ops->release_device() (Eg: intel_iommu_release_device())
> > -> iommu_group_remove_device()
> > -> mutex_lock()
> > But, I added print statements to iommu_bus_notifier() and
> > iommu_group_remove_device() and noticed that
> > iommu_group_remove_device() wasn't being called upon modprobe -r
> > <driver_name> and iommu_probe_device() isn't called upon modprobe
> > <driver_name> because
> Calling modprobe is the device driver binding path, the release_device event is
> called when a device is going away, e.g. on hotunplug or when a VF of a PCI
> device is released.
> This could also happen at runtime, and the code needs to protect against that.
> My suggestion is still to limit runtime-changing of default domains to groups
> with only one device. The flow would be as follows:
Thanks for explaining how lock release path could be called at run time. It makes sense to me now.
> 1. device_lock(dev);
> // Device can't be bound to a driver or hot-removed from now
> // on.
> 2. if (device_is_bound_to_some_driver(dev))
> goto 6;
> 3. mutex_lock(&group->mutex);
> // group of dev
> 4. Change the default domain
> 5. mutex_unlock(&group->mutex);
> 6. device_unlock(dev);
> This avoids lock inversion and should be safe with regard to hotplug and device
> driver probing.
Thanks for the steps. I have implemented "changing default domain" following the steps you gave above. Could you please review the patch set when you have some time and let me know your comments?
More information about the iommu