Skip to content

Commit 18f5a6b

Browse files
hegdevasantjoergroedel
authored andcommitted
iommu/amd: Improve amd_iommu_release_device()
Previous patch added ops->release_domain support. Core will attach devices to release_domain->attach_dev() before calling this function. Devices are already detached their current domain and attached to blocked domain. This is mostly dummy function now. Just throw warning if device is still attached to domain. Suggested-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Vasant Hegde <vasant.hegde@amd.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/20241030063556.6104-13-vasant.hegde@amd.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent a0e086b commit 18f5a6b

File tree

1 file changed

+6
-27
lines changed

1 file changed

+6
-27
lines changed

drivers/iommu/amd/iommu.c

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ DEFINE_IDA(pdom_ids);
7777

7878
struct kmem_cache *amd_iommu_irq_cache;
7979

80-
static void detach_device(struct device *dev);
81-
8280
static int amd_iommu_attach_device(struct iommu_domain *dom,
8381
struct device *dev);
8482

@@ -563,22 +561,6 @@ static void iommu_ignore_device(struct amd_iommu *iommu, struct device *dev)
563561
setup_aliases(iommu, dev);
564562
}
565563

566-
static void amd_iommu_uninit_device(struct device *dev)
567-
{
568-
struct iommu_dev_data *dev_data;
569-
570-
dev_data = dev_iommu_priv_get(dev);
571-
if (!dev_data)
572-
return;
573-
574-
if (dev_data->domain)
575-
detach_device(dev);
576-
577-
/*
578-
* We keep dev_data around for unplugged devices and reuse it when the
579-
* device is re-plugged - not doing so would introduce a ton of races.
580-
*/
581-
}
582564

583565
/****************************************************************************
584566
*
@@ -2249,17 +2231,14 @@ static struct iommu_device *amd_iommu_probe_device(struct device *dev)
22492231

22502232
static void amd_iommu_release_device(struct device *dev)
22512233
{
2252-
struct amd_iommu *iommu;
2253-
2254-
if (!check_device(dev))
2255-
return;
2234+
struct iommu_dev_data *dev_data = dev_iommu_priv_get(dev);
22562235

2257-
iommu = rlookup_amd_iommu(dev);
2258-
if (!iommu)
2259-
return;
2236+
WARN_ON(dev_data->domain);
22602237

2261-
amd_iommu_uninit_device(dev);
2262-
iommu_completion_wait(iommu);
2238+
/*
2239+
* We keep dev_data around for unplugged devices and reuse it when the
2240+
* device is re-plugged - not doing so would introduce a ton of races.
2241+
*/
22632242
}
22642243

22652244
static struct iommu_group *amd_iommu_device_group(struct device *dev)

0 commit comments

Comments
 (0)