iommu: Remove deferred attach check from __iommu_detach_device()
authorJason Gunthorpe <jgg@nvidia.com>
Tue, 10 Jan 2023 02:54:07 +0000 (10:54 +0800)
committerJoerg Roedel <jroedel@suse.de>
Fri, 13 Jan 2023 15:39:17 +0000 (16:39 +0100)
commitdd8a25c557e109f868430bd2e3e8f394cb40eaa7
treef9a2cc3f95174846dcfe5df5c280ef3d5dcdc95a
parentc1fe9119ee707459421d8f7387e803b0ea78c21b
iommu: Remove deferred attach check from __iommu_detach_device()

At the current moment, __iommu_detach_device() is only called via call
chains that are after the device driver is attached - eg via explicit
attach APIs called by the device driver.

Commit bd421264ed30 ("iommu: Fix deferred domain attachment") has removed
deferred domain attachment check from __iommu_attach_device() path, so it
should just unconditionally work in the __iommu_detach_device() path.

It actually looks like a bug that we were blocking detach on these paths
since the attach was unconditional and the caller is going to free the
(probably) UNAMANGED domain once this returns.

The only place we should be testing for deferred attach is during the
initial point the dma device is linked to the group, and then again
during the dma api calls.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/20230110025408.667767-5-baolu.lu@linux.intel.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/iommu.c
include/linux/iommu.h