[PATCH] iommu: Remove functions that support private domain
Joerg Roedel
joro at 8bytes.org
Mon May 25 13:56:45 UTC 2020
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:
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.
Regards,
Joerg
More information about the iommu
mailing list