[PATCH v4 2/4] iommu/amd: Remove iommu_ignore_device()
From: Pranjal Shrivastava
Date: Thu Sep 10 2026 - 10:42:58 EST
The iommu_ignore_device() helper was historically called on device
initialization failure to clear the primary Device Table Entry (DTE) via
memset() and nullify the rlookup_table entry.
However, clearing the DTE on probe failure is problematic:
1. During normal boot, DTEs start out unconfigured (blocking DMA), making
clearing redundant.
2. During kdump boot, pre-existing translations should be kept running
until deferred attach rather than abruptly clearing them, which risks
breaking in-flight transfers.
3. Writing to the DTE table via memset without flushing the hardware DTE
cache risks aliasing & torn writes.
4. Clearing the rlookup_table entry breaks interrupt remapping for
devices that fail probe or operate in translation-less modes.
Remove iommu_ignore_device() entirely and simplify the error return
paths in amd_iommu_probe_device().
Suggested-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
Suggested-by: Vasant Hegde <vasant.hegde@xxxxxxx>
Reported-by: sashiko-bot@xxxxxxxxxx
Closes: https://lore.kernel.org/all/20260529153216.2AD1E1F00899@xxxxxxxxxxxxxxx/
Signed-off-by: Pranjal Shrivastava <praan@xxxxxxxxxx>
---
drivers/iommu/amd/iommu.c | 24 ++----------------------
1 file changed, 2 insertions(+), 22 deletions(-)
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 5e144a60c397..7f8b51c28a7e 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -728,22 +728,6 @@ static struct iommu_dev_data *iommu_init_device(struct amd_iommu *iommu,
return dev_data;
}
-static void iommu_ignore_device(struct amd_iommu *iommu, struct device *dev)
-{
- struct amd_iommu_pci_seg *pci_seg = iommu->pci_seg;
- struct dev_table_entry *dev_table = get_dev_table(iommu);
- int devid, sbdf;
-
- sbdf = get_device_sbdf_id(dev);
- if (sbdf < 0)
- return;
-
- devid = PCI_SBDF_TO_DEVID(sbdf);
- pci_seg->rlookup_table[devid] = NULL;
- memset(&dev_table[devid], 0, sizeof(struct dev_table_entry));
-
- setup_aliases(iommu, dev);
-}
/****************************************************************************
@@ -2528,9 +2512,7 @@ static struct iommu_device *amd_iommu_probe_device(struct device *dev)
dev_data = iommu_init_device(iommu, dev, devid);
if (IS_ERR(dev_data)) {
dev_err(dev, "Failed to initialize - trying to proceed anyway\n");
- iommu_dev = ERR_CAST(dev_data);
- iommu_ignore_device(iommu, dev);
- goto out_err;
+ return ERR_CAST(dev_data);
}
iommu_init_device_caps(dev_data, dev, iommu);
@@ -2544,11 +2526,9 @@ static struct iommu_device *amd_iommu_probe_device(struct device *dev)
if (amd_iommu_pgtable == PD_MODE_NONE) {
pr_warn_once("%s: DMA translation not supported by iommu.\n",
__func__);
- iommu_dev = ERR_PTR(-ENODEV);
- goto out_err;
+ return ERR_PTR(-ENODEV);
}
-out_err:
return iommu_dev;
}
--
2.55.0.1003.g10538fe699-goog