Re: [PATCH v3 2/2] PCI: Add the enhanced ACS controls check to pci_acs_flags_enabled()

From: Jason Gunthorpe

Date: Mon Feb 02 2026 - 11:08:10 EST


On Mon, Feb 02, 2026 at 07:33:35PM +0800, Wei Wang wrote:
> +static bool pci_acs_ecap_enabled(struct pci_dev *pdev, u16 ctrl)
> +{
> + struct pci_dev *usp_pdev = pci_upstream_bridge(pdev);
> + u16 mask = PCI_ACS_DMAC_RB | PCI_ACS_DMAC_RR;
> +
> + /*
> + * For ACS DSP/USP Memory Target Access Control, either Request
> + * Redirect or Request Blocking must be enabled to enforce isolation.
> + * According to PCIe spec 7.0, the DSP Memory Target Access is
> + * applicable to both Root Ports and Switch Upstream Ports that have
> + * applicable Memory BAR space to protect. So if the device does not
> + * have a Memory BAR, it skips the check.
> + */
> + if (pci_dev_has_memory_bars(pdev) &&
> + (ctrl & mask) != PCI_ACS_DMAC_RB &&
> + (ctrl & mask) != PCI_ACS_DMAC_RR)
> + return false;
> +
> + mask = PCI_ACS_UMAC_RB | PCI_ACS_UMAC_RR;
> + /*
> + * The USP Memory Target Access is only applicable to downstream ports
> + * that have applicable Memory BAR space in the Switch Upstream Port to
> + * protect. Root Ports, which have usp_pdev set to NULL, will skip the
> + * check.
> + */
> + if (usp_pdev && pci_dev_has_memory_bars(usp_pdev) &&
> + (ctrl & mask) != PCI_ACS_UMAC_RB &&
> + (ctrl & mask) != PCI_ACS_UMAC_RR)
> + return false;

I'm not sure about using this logic to detect a USP, it would be
better to drive it off PCI_EXP_TYPE_DOWNSTREAM

Everything else looks OK though

Jason