From: Leon Romanovsky <leon@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v4 11/18] PCI/P2PDMA: Derive peer-to-peer routing from ACS control bits
Date: Sat, 22 Aug 2026 16:31:09 +0300 [thread overview]
Message-ID: <20260822133109.GG66924@unreal> (raw)
In-Reply-To: <20260821195404.5A4901F000E9@smtp.kernel.org>
On Fri, Aug 21, 2026 at 07:54:03PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] ACS Egress Control (EC) is incorrectly bypassed for Completion TLPs, violating the PCIe specification and allowing unworkable P2P DMA paths to be mapped as direct.
> --
>
> --- Patch [11]: [PATCH v4 11/18] PCI/P2PDMA: Derive peer-to-peer routing from ACS control bits ---
> commit e4c8e3c20c328ff7022188129cc2873b1613420b
> Author: Leon Romanovsky <leon@kernel.org>
>
> PCI/P2PDMA: Derive peer-to-peer routing from ACS control bits
>
> This commit modifies the P2PDMA ACS redirection check to separate the logic
> for Request and Completion TLPs. It evaluates Request Redirect for client
> requests and Completion Redirect for provider read completions.
>
> > diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
> > index a364008bbf504..1eda7b2135d70 100644
> > --- a/drivers/pci/p2pdma.c
> > +++ b/drivers/pci/p2pdma.c
>
> [ ... ]
>
> > @@ -536,26 +538,35 @@ static struct pci_dev *find_parent_pci_dev(struct device *dev)
> > return NULL;
> > }
> >
> > -/*
> > - * Check if a PCI bridge has its ACS redirection bits set to redirect P2P
> > - * TLPs upstream via ACS. Returns 1 if the packets will be redirected
> > - * upstream, 0 otherwise.
> > - */
> > -static int pci_bridge_has_acs_redir(struct pci_dev *pdev)
> > +enum pci_acs_p2pdma_state {
> > + PCI_ACS_P2PDMA_DIRECT,
> > + PCI_ACS_P2PDMA_REDIRECT,
> > +};
> > +
> > +enum pci_acs_p2pdma_tlp {
> > + PCI_ACS_P2PDMA_TLP_REQUEST,
> > + PCI_ACS_P2PDMA_TLP_COMPLETION,
> > +};
> > +
> > +static enum pci_acs_p2pdma_state
> > +pci_acs_p2pdma_state(struct pci_dev *pdev, enum pci_acs_p2pdma_tlp tlp)
> > {
> > int pos;
> > u16 ctrl;
> >
> > pos = pdev->acs_cap;
> > if (!pos)
> > - return 0;
> > + return PCI_ACS_P2PDMA_DIRECT;
> >
> > - pci_read_config_word(pdev, pos + PCI_ACS_CTRL, &ctrl);
> > + if (pci_read_config_word(pdev, pos + PCI_ACS_CTRL, &ctrl))
> > + return PCI_ACS_P2PDMA_REDIRECT;
> >
> > - if (ctrl & (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_EC))
> > - return 1;
> > + if (tlp == PCI_ACS_P2PDMA_TLP_COMPLETION)
> > + return ctrl & PCI_ACS_CR ? PCI_ACS_P2PDMA_REDIRECT :
> > + PCI_ACS_P2PDMA_DIRECT;
>
> [Severity: High]
> According to PCIe Base Specification 6.12.4, ACS Egress Control applies to
> all TLPs, including both Requests and Completions.
No, it is wrong.
"PCIe 7.0 explicitly states in §6.12.1.1 and §6.12.1.2: “Completions are never affected
by ACS P2P Egress Control.” Section 6.12.3 says Completion routing is determined exclusively
by Completion Redirect. The EC Control bit description in §7.7.12.3 also refers only
to peer-to-peer Requests."
>
> Does this logic incorrectly bypass Egress Control (PCI_ACS_EC) for Completion
> TLPs by only evaluating Completion Redirect (PCI_ACS_CR)?
>
> If a PCIe switch has ACS Egress Control configured to isolate P2P traffic,
> will the hardware drop P2P Read Completions as ACS violations while the
> kernel incorrectly maps the path as direct? This could lead to Completion
> Timeouts and potential runtime failures when drivers attempt P2P DMA reads.
>
> > - return 0;
> > + return ctrl & (PCI_ACS_RR | PCI_ACS_EC) ?
> > + PCI_ACS_P2PDMA_REDIRECT : PCI_ACS_P2PDMA_DIRECT;
> > }
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260821-fix-p2p-acs-v4-0-v4-0-94426b96de73@nvidia.com?part=11
>
next prev parent reply other threads:[~2026-08-22 13:31 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 19:38 [PATCH v4 00/18] PCI/P2PDMA: Fix ACS egress control handling Leon Romanovsky
2026-08-21 19:38 ` [PATCH v4 01/18] PCI/P2PDMA: Do not tear down the allocate attribute on registration failure Leon Romanovsky
2026-08-21 19:53 ` sashiko-bot
2026-08-21 23:08 ` Logan Gunthorpe
2026-08-24 23:22 ` Jason Gunthorpe
2026-08-21 19:38 ` [PATCH v4 02/18] PCI/P2PDMA: Wait for RCU readers before freeing state Leon Romanovsky
2026-08-21 19:48 ` sashiko-bot
2026-08-21 23:10 ` Logan Gunthorpe
2026-08-24 23:22 ` Jason Gunthorpe
2026-08-21 19:38 ` [PATCH v4 03/18] PCI/P2PDMA: Restrict the p2pmem search to pool backed providers Leon Romanovsky
2026-08-21 19:59 ` sashiko-bot
2026-08-21 23:14 ` Logan Gunthorpe
2026-08-24 23:22 ` Jason Gunthorpe
2026-08-21 19:38 ` [PATCH v4 04/18] PCI/P2PDMA: Safely terminate ACS redirect lists Leon Romanovsky
2026-08-21 19:47 ` sashiko-bot
2026-08-24 23:22 ` Jason Gunthorpe
2026-08-21 19:38 ` [PATCH v4 05/18] PCI/P2PDMA: Document the pdev->p2pdma lifetime and RCU rules Leon Romanovsky
2026-08-21 19:56 ` sashiko-bot
2026-08-24 20:29 ` I Logan Gunthorpe
2026-08-21 19:38 ` [PATCH v4 06/18] PCI/P2PDMA: Gate the host bridge whitelist warning on verbose Leon Romanovsky
2026-08-21 19:47 ` sashiko-bot
2026-08-24 21:08 ` Logan Gunthorpe
2026-08-24 23:22 ` Jason Gunthorpe
2026-08-21 19:38 ` [PATCH v4 07/18] PCI/P2PDMA: Document the Address Type assumption Leon Romanovsky
2026-08-21 19:43 ` sashiko-bot
2026-08-24 23:22 ` Jason Gunthorpe
2026-08-21 19:38 ` [PATCH v4 08/18] PCI: Account for Direct Translated P2P in ACS isolation checks Leon Romanovsky
2026-08-21 19:54 ` sashiko-bot
2026-08-24 23:22 ` Jason Gunthorpe
2026-08-21 19:38 ` [PATCH v4 09/18] PCI: Add ACS egress control vector accessor Leon Romanovsky
2026-08-21 19:50 ` sashiko-bot
2026-08-21 19:38 ` [PATCH v4 10/18] PCI: Account for ACS egress control in isolation checks Leon Romanovsky
2026-08-21 19:51 ` sashiko-bot
2026-08-24 23:22 ` Jason Gunthorpe
2026-08-21 19:38 ` [PATCH v4 11/18] PCI/P2PDMA: Derive peer-to-peer routing from ACS control bits Leon Romanovsky
2026-08-21 19:54 ` sashiko-bot
2026-08-22 13:31 ` Leon Romanovsky [this message]
2026-08-21 19:38 ` [PATCH v4 12/18] PCI/P2PDMA: Honor ACS egress control vectors Leon Romanovsky
2026-08-21 19:56 ` sashiko-bot
2026-08-21 19:38 ` [PATCH v4 13/18] PCI/P2PDMA: Document ACS egress control handling Leon Romanovsky
2026-08-21 19:44 ` sashiko-bot
2026-08-21 19:38 ` [PATCH v4 14/18] PCI/P2PDMA: Extract pure ACS routing decision helpers Leon Romanovsky
2026-08-21 19:49 ` sashiko-bot
2026-08-21 19:38 ` [PATCH v4 15/18] PCI/P2PDMA: Add KUnit tests for ACS routing decisions Leon Romanovsky
2026-08-21 19:50 ` sashiko-bot
2026-08-21 19:38 ` [PATCH v4 16/18] PCI/P2PDMA: Add KUnit coverage for the ACS P2P routing walk Leon Romanovsky
2026-08-21 19:51 ` sashiko-bot
2026-08-21 19:38 ` [PATCH v4 17/18] PCI: Add KUnit coverage for ACS isolation checks Leon Romanovsky
2026-08-21 19:52 ` sashiko-bot
2026-08-21 19:38 ` [PATCH v4 18/18] PCI/P2PDMA: Log detailed ACS routing diagnostics Leon Romanovsky
2026-08-21 20:02 ` sashiko-bot
2026-08-22 13:28 ` Leon Romanovsky
2026-08-24 23:22 ` [PATCH v4 00/18] PCI/P2PDMA: Fix ACS egress control handling Jason Gunthorpe
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=20260822133109.GG66924@unreal \
--to=leon@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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