diff options
author | Jason Gunthorpe <jgg@nvidia.com> | 2023-05-11 01:42:08 -0300 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2023-05-23 08:15:55 +0200 |
commit | 152431e4fe7f1aac8aa6cc57bfe58d2d2596be4d (patch) | |
tree | 36784fc8cda55c172b732e95405b58efeecb0cf5 /drivers/iommu | |
parent | e7f85dfbbc9cf8660174c45c213571aaa518df85 (diff) | |
download | linux-stable-152431e4fe7f1aac8aa6cc57bfe58d2d2596be4d.tar.gz linux-stable-152431e4fe7f1aac8aa6cc57bfe58d2d2596be4d.tar.bz2 linux-stable-152431e4fe7f1aac8aa6cc57bfe58d2d2596be4d.zip |
iommu: Do iommu_group_create_direct_mappings() before attach
The iommu_probe_device() path calls iommu_create_device_direct_mappings()
after attaching the device.
IOMMU_RESV_DIRECT maps need to be continually in place, so if a hotplugged
device has new ranges the should have been mapped into the default domain
before it is attached.
Move the iommu_create_device_direct_mappings() call up.
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/10-v5-1b99ae392328+44574-iommu_err_unwind_jgg@nvidia.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu')
-rw-r--r-- | drivers/iommu/iommu.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 29ab5d990ef6..6b39f756c020 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -423,6 +423,8 @@ int iommu_probe_device(struct device *dev) mutex_lock(&group->mutex); + iommu_create_device_direct_mappings(group, dev); + if (group->domain) { ret = __iommu_device_set_domain(group, dev, group->domain, 0); } else if (!group->default_domain) { @@ -434,9 +436,11 @@ int iommu_probe_device(struct device *dev) */ iommu_alloc_default_domain(group, dev); group->domain = NULL; - if (group->default_domain) + if (group->default_domain) { + iommu_create_device_direct_mappings(group, dev); ret = __iommu_group_set_domain(group, group->default_domain); + } /* * We assume that the iommu driver starts up the device in @@ -447,8 +451,6 @@ int iommu_probe_device(struct device *dev) if (ret) goto err_unlock; - iommu_create_device_direct_mappings(group, dev); - mutex_unlock(&group->mutex); iommu_group_put(group); |