From: Pranjal Shrivastava <praan@google.com>
To: iommu@lists.linux.dev, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Vasant Hegde <vasant.hegde@amd.com>,
Ankit Soni <ankit.soni@amd.com>,
Jason Gunthorpe <jgg@nvidia.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Samiullah Khawaja <skhawaja@google.com>,
Pranjal Shrivastava <praan@google.com>,
sashiko-bot@kernel.org
Subject: [PATCH v4 2/4] iommu/amd: Remove iommu_ignore_device()
Date: Thu, 10 Sep 2026 14:26:53 +0000 [thread overview]
Message-ID: <20260910142655.3281464-3-praan@google.com> (raw)
In-Reply-To: <20260910142655.3281464-1-praan@google.com>
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@nvidia.com>
Suggested-by: Vasant Hegde <vasant.hegde@amd.com>
Reported-by: sashiko-bot@kernel.org
Closes: https://lore.kernel.org/all/20260529153216.2AD1E1F00899@smtp.kernel.org/
Signed-off-by: Pranjal Shrivastava <praan@google.com>
---
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
next prev parent reply other threads:[~2026-09-10 14:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 14:26 [PATCH v4 0/4] iommu/amd: Refactors for ATS robustness Pranjal Shrivastava
2026-09-10 14:26 ` [PATCH v4 1/4] iommu/amd: Refactor device probe and capability initialization Pranjal Shrivastava
2026-09-10 14:26 ` Pranjal Shrivastava [this message]
2026-09-10 14:40 ` [PATCH v4 2/4] iommu/amd: Remove iommu_ignore_device() Jason Gunthorpe
2026-09-11 4:26 ` Vasant Hegde
2026-09-10 14:26 ` [PATCH v4 3/4] iommu/amd: Fail probe on ATS configuration failure Pranjal Shrivastava
2026-09-10 14:26 ` [PATCH v4 4/4] PCI/ATS: Mandate checking pci_ats_supported() before pci_prepare_ats() Pranjal Shrivastava
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260910142655.3281464-3-praan@google.com \
--to=praan@google.com \
--cc=ankit.soni@amd.com \
--cc=bhelgaas@google.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-bot@kernel.org \
--cc=skhawaja@google.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=vasant.hegde@amd.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®