* [PATCH] PCI/ATS: Disable ATS when ACS TB is set upstream
@ 2026-10-20 18:10 Danny Gonzalez
0 siblings, 0 replies; only message in thread
From: Danny Gonzalez @ 2026-10-20 18:10 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: David Decotigny, Sheena Mohan, linux-pci, linux-kernel, Danny Gonzalez
Enabling ATS allows an endpoint to cache translations and initiate DMA
requests with Translated addresses, which an upstream bridge with ACS
Translation Blocking (PCI_ACS_TB) set will block as ACS Violations.
Because pci_enable_acs() preserves existing PCI_ACS_CTRL bits (e.g., from
firmware, a kexec kernel, or "pci=config_acs=") without relaxing them,
PCI_ACS_TB may remain set on upstream bridges.
Update pci_ats_supported() to walk upstream bridges and return false if
any bridge has PCI_ACS_TB set, leaving the endpoint to use Untranslated
addresses.
Tested by booting a machine with an endpoint advertising the ATS Capability
behind a Root Port with PCI_ACS_TB set; verified ATS is disabled and the
system boots cleanly.
Signed-off-by: Danny Gonzalez <digonzal@google.com>
---
drivers/pci/ats.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c
index 9cb23780093d..094f4f825acf 100644
--- a/drivers/pci/ats.c
+++ b/drivers/pci/ats.c
@@ -31,6 +31,24 @@ void pci_ats_init(struct pci_dev *dev)
dev->ats_cap = pos;
}
+static struct pci_dev *pci_acs_tb_path_blocked(struct pci_dev *dev)
+{
+ struct pci_dev *bridge;
+
+ for (bridge = pci_upstream_bridge(dev); bridge;
+ bridge = pci_upstream_bridge(bridge)) {
+ u16 ctrl;
+
+ if (!bridge->acs_cap)
+ continue;
+ pci_read_config_word(bridge, bridge->acs_cap + PCI_ACS_CTRL,
+ &ctrl);
+ if (ctrl & PCI_ACS_TB)
+ return bridge;
+ }
+ return NULL;
+}
+
/**
* pci_ats_supported - check if the device can use ATS
* @dev: the PCI device
@@ -40,12 +58,22 @@ void pci_ats_init(struct pci_dev *dev)
*/
bool pci_ats_supported(struct pci_dev *dev)
{
+ struct pci_dev *bridge;
+
if (!dev->ats_cap || dev->untrusted)
return false;
if (dev->is_virtfn)
return pci_ats_supported(pci_physfn(dev));
+ /* Do not allow ATS if any upstream bridge blocks translation */
+ bridge = pci_acs_tb_path_blocked(dev);
+ if (bridge) {
+ pci_warn_once(dev, "ATS disabled: upstream bridge %s has ACS Translation Blocking enabled\n",
+ pci_name(bridge));
+ return false;
+ }
+
return true;
}
EXPORT_SYMBOL_GPL(pci_ats_supported);
--
2.56.0.218.g1ec904b173-goog
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-20 18:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-20 18:10 [PATCH] PCI/ATS: Disable ATS when ACS TB is set upstream Danny Gonzalez
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®