[PATCH v3 2/2] PCI/ATS: Disable ATS when ACS TB is set upstream

From: Danny Gonzalez

Date: Thu Nov 19 2026 - 19:23:30 EST


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. Ignore bridges whose config read fails or returns an error
response (PCI_POSSIBLE_ERROR()) so inaccessible bridges are not treated
as having PCI_ACS_TB set.

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@xxxxxxxxxx>
---

v3:
- Move the upstream ACS TB check back into pci_ats_supported(),
dropping pci_ats_check_acs() and changes to pci-driver.c and pci.h
- Read PCI_ACS_CTRL directly and check the return value and
PCI_POSSIBLE_ERROR() so inaccessible bridges are not treated as
having PCI_ACS_TB set
- Remove the pci_warn_once() logging and separate helper function

v2 (based on sashiko review):
- Move the upstream ACS TB check from pci_ats_supported() into
pci_ats_check_acs() called after pci_enable_acs()
- Use pci_acs_enabled() instead of reading PCI_ACS_CTRL directly

drivers/pci/ats.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c
index 9cb23780093d..e3c78a575800 100644
--- a/drivers/pci/ats.c
+++ b/drivers/pci/ats.c
@@ -40,12 +40,31 @@ 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 */
+ for (bridge = pci_upstream_bridge(dev); bridge;
+ bridge = pci_upstream_bridge(bridge)) {
+ u16 ctrl;
+ int ret;
+
+ if (!bridge->acs_cap)
+ continue;
+ ret = pci_read_config_word(bridge,
+ bridge->acs_cap + PCI_ACS_CTRL,
+ &ctrl);
+ if (ret || PCI_POSSIBLE_ERROR(ctrl))
+ continue;
+ if (ctrl & PCI_ACS_TB)
+ return false;
+ }
+
return true;
}
EXPORT_SYMBOL_GPL(pci_ats_supported);
--
2.56.1.708.g77570a6a1d-goog