| Message ID | 20261001-fix-p2p-acs-v4-0-v9-0-1a8e0f50ddd9@nvidia.com |
|---|---|
| Headers | show |
| Series | PCI/P2PDMA: Route peer-to-peer DMA by TLP class | expand |
> From: Leon Romanovsky <leonro@nvidia.com> > > A Downstream Port with ACS Direct Translated P2P enabled routes a Request > whose Address Type is Translated "to the peer Egress Port without > redirection, regardless of ACS P2P Request Redirect and ACS P2P Egress > Control", per PCIe r7.0 sec 6.12.3. P2PDMA assumes every Request carries an > Untranslated address, so it sends an ATS client through the host bridge > even where the fabric would route it straight to the peer. > > Add PCI_P2PDMA_TLP_TRANSLATED and consult Direct Translated P2P for the > Requests it describes. > > Reviewed-by: Logan Gunthorpe <logang@deltatee.com> > Tested-by: Tushar Dave <tdave@nvidia.com> > Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Sashiko has reviewed this patch and found no issues. It looks great!
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] pci/p2pdma: pcim_p2pdma_set_ats_per_mapping() silently fails for pure clients -- commit 39432dea495f68fb0a21d0daa1f31ba24e130b39 Author: Leon Romanovsky <leon@kernel.org> PCI/P2PDMA: Evaluate the ATS path for clients with ATS enabled P2PDMA assumes every client issues Untranslated Requests. A device with ATS enabled may translate any address it is handed, including a bus address, and Translation Blocking can reject its Translated Requests on a route the Untranslated answer called usable. This commit takes the Address Type from its ATS Enable bit and avoids handing such a client bus addresses unless the client declared per-mapping ATS. > diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c > index 6a63901c65fb6..9c0943fdb3e36 100644 > --- a/drivers/pci/p2pdma.c > +++ b/drivers/pci/p2pdma.c [ ... ] > @@ -1633,6 +1674,9 @@ pci_p2pdma_map_type_tlp(struct p2pdma_provider *provider, struct device *dev, > cache_index = map_types_idx(client); > > rcu_read_lock(); > + /* The declaration belongs to the client, the cache to the provider. */ > + p2pdma = rcu_dereference(client->p2pdma); > + per_mapping = p2pdma && p2pdma->ats_per_mapping; [Severity: High] Does this code handle pure P2PDMA clients correctly? Since pure clients (devices initiating P2P transfers but not providing memory) have no mechanism or reason to call pcim_p2pdma_init(), client->p2pdma will be NULL for them. This means when they call pcim_p2pdma_set_ats_per_mapping(), it silently returns and drops the configuration: drivers/pci/p2pdma.c:pcim_p2pdma_set_ats_per_mapping() { ... p2p = rcu_dereference_protected(pdev->p2pdma, 1); if (!p2p) /* * ats_per_mapping is a performance optimization, ... */ return; p2p->ats_per_mapping = true; } Because client->p2pdma is NULL, per_mapping will always evaluate to false here in pci_p2pdma_map_type_tlp(). This leads to pci_p2pdma_client_map_type() incorrectly overriding the map type, which could return PCI_P2PDMA_MAP_NOT_SUPPORTED and break P2P transfers that should have been permitted. How should pure clients register their ATS per-mapping capability if they do not initialize pdev->p2pdma? > p2pdma = rcu_dereference(pdev->p2pdma); > > if (p2pdma)
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] pci/p2pdma: pure clients cannot set ats_per_mapping because pdev->p2pdma is NULL -- commit f332086fc4a4273d099c81fafb33298021d47d1a Author: Leon Romanovsky <leon@kernel.org> PCI/P2PDMA: Let a client declare that it selects ATS per mapping The PCIe ATS Enable bit covers the whole device, so P2PDMA cannot tell from it whether a client will translate a given address. Most devices translate any address once ATS is enabled, but some choose ATS per DMA mapping and can still use bus addresses for the rest. Add pcim_p2pdma_set_ats_per_mapping() so the driver of such a device can declare that before P2PDMA starts treating clients with ATS enabled as translating everything. > diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c > index cf190bd572d4a..6a63901c65fb6 100644 > --- a/drivers/pci/p2pdma.c > +++ b/drivers/pci/p2pdma.c [ ... ] > @@ -1562,6 +1563,32 @@ void pci_p2pmem_publish(struct pci_dev *pdev, bool publish) > } > EXPORT_SYMBOL_GPL(pci_p2pmem_publish); > > +/** > + * pcim_p2pdma_set_ats_per_mapping - Declare per-mapping ATS for a client > + * @pdev: PCI device that initiates peer-to-peer DMA > + * > + * Declare that @pdev issues Translated Requests only for the DMA mappings its > + * driver sets up to use ATS, rather than for any address once ATS is enabled. > + * P2PDMA then routes this client's Requests with the Address Type each query > + * asks about, rather than the one its ATS Enable bit implies. > + */ > +void pcim_p2pdma_set_ats_per_mapping(struct pci_dev *pdev) > +{ > + struct pci_p2pdma *p2p; > + > + p2p = rcu_dereference_protected(pdev->p2pdma, 1); > + if (!p2p) > + /* > + * ats_per_mapping is a performance optimization, > + * if pcim_p2pdma_init() didn't set pdev->p2pdma pointer > + * for some reason, let's simply use ATS global settings. > + */ > + return; [Severity: Medium] Will this silently fail for pure P2PDMA clients? It looks like pdev->p2pdma is only allocated when a device registers as a P2P memory provider via pcim_p2pdma_init(): drivers/pci/p2pdma.c:pcim_p2pdma_init() { ... p2p = devm_kzalloc(&pdev->dev, sizeof(*p2p), GFP_KERNEL); ... } If a driver for a pure P2PDMA client (e.g., an NVMe initiator without CMB) calls pcim_p2pdma_set_ats_per_mapping() to declare its ATS behavior, won't pdev->p2pdma be NULL since it never called pcim_p2pdma_init()? If so, wouldn't this cause the client to silently fall back to suboptimal global ATS routing, as it can never successfully set the ats_per_mapping flag?
On Thu, Oct 01, 2026 at 12:08:07PM +0000, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: > - [Medium] pci/p2pdma: pure clients cannot set ats_per_mapping because pdev->p2pdma is NULL > -- > > commit f332086fc4a4273d099c81fafb33298021d47d1a > Author: Leon Romanovsky <leon@kernel.org> > > PCI/P2PDMA: Let a client declare that it selects ATS per mapping > > The PCIe ATS Enable bit covers the whole device, so P2PDMA cannot tell > from it whether a client will translate a given address. Most devices > translate any address once ATS is enabled, but some choose ATS per DMA > mapping and can still use bus addresses for the rest. > > Add pcim_p2pdma_set_ats_per_mapping() so the driver of such a device can > declare that before P2PDMA starts treating clients with ATS enabled as > translating everything. > > > diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c > > index cf190bd572d4a..6a63901c65fb6 100644 > > --- a/drivers/pci/p2pdma.c > > +++ b/drivers/pci/p2pdma.c > > [ ... ] > > > @@ -1562,6 +1563,32 @@ void pci_p2pmem_publish(struct pci_dev *pdev, bool publish) > > } > > EXPORT_SYMBOL_GPL(pci_p2pmem_publish); > > > > +/** > > + * pcim_p2pdma_set_ats_per_mapping - Declare per-mapping ATS for a client > > + * @pdev: PCI device that initiates peer-to-peer DMA > > + * > > + * Declare that @pdev issues Translated Requests only for the DMA mappings its > > + * driver sets up to use ATS, rather than for any address once ATS is enabled. > > + * P2PDMA then routes this client's Requests with the Address Type each query > > + * asks about, rather than the one its ATS Enable bit implies. > > + */ > > +void pcim_p2pdma_set_ats_per_mapping(struct pci_dev *pdev) > > +{ > > + struct pci_p2pdma *p2p; > > + > > + p2p = rcu_dereference_protected(pdev->p2pdma, 1); > > + if (!p2p) > > + /* > > + * ats_per_mapping is a performance optimization, > > + * if pcim_p2pdma_init() didn't set pdev->p2pdma pointer > > + * for some reason, let's simply use ATS global settings. > > + */ > > + return; > > [Severity: Medium] > Will this silently fail for pure P2PDMA clients? > > It looks like pdev->p2pdma is only allocated when a device registers as a > P2P memory provider via pcim_p2pdma_init(): Yes, this is exactly for them and no one else. Thanks > > drivers/pci/p2pdma.c:pcim_p2pdma_init() { > ... > p2p = devm_kzalloc(&pdev->dev, sizeof(*p2p), GFP_KERNEL); > ... > } > > If a driver for a pure P2PDMA client (e.g., an NVMe initiator without CMB) > calls pcim_p2pdma_set_ats_per_mapping() to declare its ATS behavior, won't > pdev->p2pdma be NULL since it never called pcim_p2pdma_init()? Only RDMA NICs support that per-mapping thing. Thanks > > If so, wouldn't this cause the client to silently fall back to suboptimal > global ATS routing, as it can never successfully set the ats_per_mapping flag? > > -- > Sashiko AI review · https://sashiko.dev/#/patchset/20261001-fix-p2p-acs-v4-0-v9-0-1a8e0f50ddd9@nvidia.com?part=16
On Thu, Oct 01, 2026 at 12:07:56PM +0000, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: > - [High] pci/p2pdma: pcim_p2pdma_set_ats_per_mapping() silently fails for pure clients > -- > > commit 39432dea495f68fb0a21d0daa1f31ba24e130b39 > Author: Leon Romanovsky <leon@kernel.org> > > PCI/P2PDMA: Evaluate the ATS path for clients with ATS enabled > > P2PDMA assumes every client issues Untranslated Requests. A device with > ATS enabled may translate any address it is handed, including a bus > address, and Translation Blocking can reject its Translated Requests on > a route the Untranslated answer called usable. This commit takes the > Address Type from its ATS Enable bit and avoids handing such a client > bus addresses unless the client declared per-mapping ATS. > > > diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c > > index 6a63901c65fb6..9c0943fdb3e36 100644 > > --- a/drivers/pci/p2pdma.c > > +++ b/drivers/pci/p2pdma.c > [ ... ] > > @@ -1633,6 +1674,9 @@ pci_p2pdma_map_type_tlp(struct p2pdma_provider *provider, struct device *dev, > > cache_index = map_types_idx(client); > > > > rcu_read_lock(); > > + /* The declaration belongs to the client, the cache to the provider. */ > > + p2pdma = rcu_dereference(client->p2pdma); > > + per_mapping = p2pdma && p2pdma->ats_per_mapping; > > [Severity: High] > Does this code handle pure P2PDMA clients correctly? > > Since pure clients (devices initiating P2P transfers but not providing memory) > have no mechanism or reason to call pcim_p2pdma_init(), client->p2pdma will > be NULL for them. > > This means when they call pcim_p2pdma_set_ats_per_mapping(), it silently returns > and drops the configuration: > > drivers/pci/p2pdma.c:pcim_p2pdma_set_ats_per_mapping() { > ... > p2p = rcu_dereference_protected(pdev->p2pdma, 1); > if (!p2p) > /* > * ats_per_mapping is a performance optimization, > ... > */ > return; > > p2p->ats_per_mapping = true; > } > > Because client->p2pdma is NULL, per_mapping will always evaluate to false > here in pci_p2pdma_map_type_tlp(). This leads to pci_p2pdma_client_map_type() > incorrectly overriding the map type, which could return > PCI_P2PDMA_MAP_NOT_SUPPORTED and break P2P transfers that should have been > permitted. > > How should pure clients register their ATS per-mapping capability if they > do not initialize pdev->p2pdma? I don't know there Sashiko gets these ideas, but no "pure client" shouldn't call to pcim_p2pdma_set_ats_per_mapping(). Thanks > > > p2pdma = rcu_dereference(pdev->p2pdma); > > > > if (p2pdma) > > -- > Sashiko AI review · https://sashiko.dev/#/patchset/20261001-fix-p2p-acs-v4-0-v9-0-1a8e0f50ddd9@nvidia.com?part=17
On Thu, Oct 01, 2026 at 02:55:08PM +0300, Leon Romanovsky wrote: > PCI P2PDMA applies Request and Completion Redirect throughout both paths. > This misclassifies asymmetric and nested switches, and reports one answer > for every kind of TLP. > > Three ACS controls act on TLP attributes the client chooses rather than > on the topology: Translation Blocking and Direct Translated P2P act on > a Request's Address Type, and Completion Redirect skips Completions carrying > Relaxed Ordering. > > Evaluate each direction at the path divergence, decide every class from the > one walk, and treat a client with ATS enabled as translating unless its > driver declares per-mapping ATS. > > This completes the P2PDMA side; dma-buf and mlx5 follow separately. > ... > Leon Romanovsky (18): > PCI/P2PDMA: Document the TLP attribute assumptions > PCI/P2PDMA: Derive routing from directional ACS controls > PCI: Reject unreadable ACS controls in isolation checks > PCI/P2PDMA: Evaluate ACS controls at the path divergence > PCI/P2PDMA: Document directional ACS routing > PCI/P2PDMA: Collect the path's ACS controls before deciding > PCI/P2PDMA: Answer routing per TLP class > PCI/P2PDMA: Route Relaxed Ordering Completions directly > PCI/P2PDMA: Reject Translated Requests blocked by Translation Blocking > PCI/P2PDMA: Route Translated Requests under Direct Translated P2P > PCI/P2PDMA: Log detailed ACS routing diagnostics > PCI/P2PDMA: Add KUnit tests for the ACS routing decisions > PCI/P2PDMA: Test the ACS P2P routing walk > PCI: Add KUnit coverage for ACS isolation checks > PCI/P2PDMA: Document TLP-class routing > PCI/P2PDMA: Let a client declare that it selects ATS per mapping > PCI/P2PDMA: Evaluate the ATS path for clients with ATS enabled > PCI/P2PDMA: Test the routing of clients with ATS enabled > > Documentation/admin-guide/kernel-parameters.txt | 15 +- > Documentation/driver-api/pci/p2pdma.rst | 80 +++ > drivers/pci/Kconfig | 15 + > drivers/pci/Makefile | 1 + > drivers/pci/p2pdma.c | 719 ++++++++++++++++++-- > drivers/pci/pci.c | 7 +- > drivers/pci/pci.h | 58 ++ > drivers/pci/pci_acs_test.c | 860 ++++++++++++++++++++++++ > drivers/pci/quirks.c | 6 +- > include/linux/pci-p2pdma.h | 12 +- > 10 files changed, 1687 insertions(+), 86 deletions(-) > --- > base-commit: 08dbfad3f5040f5bdb6c529da20d6d4e81fefd72 > change-id: 20260821-fix-p2p-acs-v4-0-e72455e3a261 > prerequisite-message-id: <20260830-batch-p2p-fixes-v1-0-5044e8dfbe2e@nvidia.com> > prerequisite-patch-id: 6b25c7fcf164cdfc14e9fac5b908d97fcf6509d7 > prerequisite-patch-id: 0d083c281001365aae4b35544cf28891a6ab9a96 > prerequisite-patch-id: bfd9dabf271f3cc9a3a61f46387d20c20311363d > prerequisite-patch-id: fad0275efc722830fc591509506c0a5e4f581073 > prerequisite-patch-id: 0c83bee688fec1f6d1564654df7c630fa6a4a978 This seems like material for the PCI tree, but I'm not sure how to apply it. It doesn't apply cleanly on the current pci/p2pdma (https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/log/?h=p2pdma), which does contain your series from 20260830-batch-p2p-fixes-v1-0-5044e8dfbe2e@nvidia.com. I could probably fix the conflicts but I don't know why there should be conflicts, since the only commits on pci/p2pdma other than yours are a few trivial allow-list updates. Bjorn
On Tue, Oct 06, 2026 at 02:29:55PM -0500, Bjorn Helgaas wrote: > On Thu, Oct 01, 2026 at 02:55:08PM +0300, Leon Romanovsky wrote: > > PCI P2PDMA applies Request and Completion Redirect throughout both paths. > > This misclassifies asymmetric and nested switches, and reports one answer > > for every kind of TLP. > > > > Three ACS controls act on TLP attributes the client chooses rather than > > on the topology: Translation Blocking and Direct Translated P2P act on > > a Request's Address Type, and Completion Redirect skips Completions carrying > > Relaxed Ordering. > > > > Evaluate each direction at the path divergence, decide every class from the > > one walk, and treat a client with ATS enabled as translating unless its > > driver declares per-mapping ATS. > > > > This completes the P2PDMA side; dma-buf and mlx5 follow separately. > > ... > > > Leon Romanovsky (18): > > PCI/P2PDMA: Document the TLP attribute assumptions > > PCI/P2PDMA: Derive routing from directional ACS controls > > PCI: Reject unreadable ACS controls in isolation checks > > PCI/P2PDMA: Evaluate ACS controls at the path divergence > > PCI/P2PDMA: Document directional ACS routing > > PCI/P2PDMA: Collect the path's ACS controls before deciding > > PCI/P2PDMA: Answer routing per TLP class > > PCI/P2PDMA: Route Relaxed Ordering Completions directly > > PCI/P2PDMA: Reject Translated Requests blocked by Translation Blocking > > PCI/P2PDMA: Route Translated Requests under Direct Translated P2P > > PCI/P2PDMA: Log detailed ACS routing diagnostics > > PCI/P2PDMA: Add KUnit tests for the ACS routing decisions > > PCI/P2PDMA: Test the ACS P2P routing walk > > PCI: Add KUnit coverage for ACS isolation checks > > PCI/P2PDMA: Document TLP-class routing > > PCI/P2PDMA: Let a client declare that it selects ATS per mapping > > PCI/P2PDMA: Evaluate the ATS path for clients with ATS enabled > > PCI/P2PDMA: Test the routing of clients with ATS enabled > > > > Documentation/admin-guide/kernel-parameters.txt | 15 +- > > Documentation/driver-api/pci/p2pdma.rst | 80 +++ > > drivers/pci/Kconfig | 15 + > > drivers/pci/Makefile | 1 + > > drivers/pci/p2pdma.c | 719 ++++++++++++++++++-- > > drivers/pci/pci.c | 7 +- > > drivers/pci/pci.h | 58 ++ > > drivers/pci/pci_acs_test.c | 860 ++++++++++++++++++++++++ > > drivers/pci/quirks.c | 6 +- > > include/linux/pci-p2pdma.h | 12 +- > > 10 files changed, 1687 insertions(+), 86 deletions(-) > > --- > > base-commit: 08dbfad3f5040f5bdb6c529da20d6d4e81fefd72 > > change-id: 20260821-fix-p2p-acs-v4-0-e72455e3a261 > > prerequisite-message-id: <20260830-batch-p2p-fixes-v1-0-5044e8dfbe2e@nvidia.com> > > prerequisite-patch-id: 6b25c7fcf164cdfc14e9fac5b908d97fcf6509d7 > > prerequisite-patch-id: 0d083c281001365aae4b35544cf28891a6ab9a96 > > prerequisite-patch-id: bfd9dabf271f3cc9a3a61f46387d20c20311363d > > prerequisite-patch-id: fad0275efc722830fc591509506c0a5e4f581073 > > prerequisite-patch-id: 0c83bee688fec1f6d1564654df7c630fa6a4a978 > > This seems like material for the PCI tree, but I'm not sure how to > apply it. It doesn't apply cleanly on the current pci/p2pdma > (https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/log/?h=p2pdma), > which does contain your series from > 20260830-batch-p2p-fixes-v1-0-5044e8dfbe2e@nvidia.com. > > I could probably fix the conflicts but I don't know why there should > be conflicts, since the only commits on pci/p2pdma other than yours > are a few trivial allow-list updates. So maybe this is related to these trivial updates, my series was based on the clean p2pdma branch: https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git/log/?h=fix-p2p-acs-v9 Thanks > > Bjorn
On Wed, Oct 07, 2026 at 12:22:27AM +0300, Leon Romanovsky wrote: > On Tue, Oct 06, 2026 at 02:29:55PM -0500, Bjorn Helgaas wrote: > > On Thu, Oct 01, 2026 at 02:55:08PM +0300, Leon Romanovsky wrote: > > > PCI P2PDMA applies Request and Completion Redirect throughout both paths. > > > This misclassifies asymmetric and nested switches, and reports one answer > > > for every kind of TLP. > > > > > > Three ACS controls act on TLP attributes the client chooses rather than > > > on the topology: Translation Blocking and Direct Translated P2P act on > > > a Request's Address Type, and Completion Redirect skips Completions carrying > > > Relaxed Ordering. > > > > > > Evaluate each direction at the path divergence, decide every class from the > > > one walk, and treat a client with ATS enabled as translating unless its > > > driver declares per-mapping ATS. > > > > > > This completes the P2PDMA side; dma-buf and mlx5 follow separately. > > > ... > > > > > Leon Romanovsky (18): > > > PCI/P2PDMA: Document the TLP attribute assumptions > > > PCI/P2PDMA: Derive routing from directional ACS controls > > > PCI: Reject unreadable ACS controls in isolation checks > > > PCI/P2PDMA: Evaluate ACS controls at the path divergence > > > PCI/P2PDMA: Document directional ACS routing > > > PCI/P2PDMA: Collect the path's ACS controls before deciding > > > PCI/P2PDMA: Answer routing per TLP class > > > PCI/P2PDMA: Route Relaxed Ordering Completions directly > > > PCI/P2PDMA: Reject Translated Requests blocked by Translation Blocking > > > PCI/P2PDMA: Route Translated Requests under Direct Translated P2P > > > PCI/P2PDMA: Log detailed ACS routing diagnostics > > > PCI/P2PDMA: Add KUnit tests for the ACS routing decisions > > > PCI/P2PDMA: Test the ACS P2P routing walk > > > PCI: Add KUnit coverage for ACS isolation checks > > > PCI/P2PDMA: Document TLP-class routing > > > PCI/P2PDMA: Let a client declare that it selects ATS per mapping > > > PCI/P2PDMA: Evaluate the ATS path for clients with ATS enabled > > > PCI/P2PDMA: Test the routing of clients with ATS enabled > > > > > > Documentation/admin-guide/kernel-parameters.txt | 15 +- > > > Documentation/driver-api/pci/p2pdma.rst | 80 +++ > > > drivers/pci/Kconfig | 15 + > > > drivers/pci/Makefile | 1 + > > > drivers/pci/p2pdma.c | 719 ++++++++++++++++++-- > > > drivers/pci/pci.c | 7 +- > > > drivers/pci/pci.h | 58 ++ > > > drivers/pci/pci_acs_test.c | 860 ++++++++++++++++++++++++ > > > drivers/pci/quirks.c | 6 +- > > > include/linux/pci-p2pdma.h | 12 +- > > > 10 files changed, 1687 insertions(+), 86 deletions(-) > > > --- > > > base-commit: 08dbfad3f5040f5bdb6c529da20d6d4e81fefd72 > > > change-id: 20260821-fix-p2p-acs-v4-0-e72455e3a261 > > > prerequisite-message-id: <20260830-batch-p2p-fixes-v1-0-5044e8dfbe2e@nvidia.com> > > > prerequisite-patch-id: 6b25c7fcf164cdfc14e9fac5b908d97fcf6509d7 > > > prerequisite-patch-id: 0d083c281001365aae4b35544cf28891a6ab9a96 > > > prerequisite-patch-id: bfd9dabf271f3cc9a3a61f46387d20c20311363d > > > prerequisite-patch-id: fad0275efc722830fc591509506c0a5e4f581073 > > > prerequisite-patch-id: 0c83bee688fec1f6d1564654df7c630fa6a4a978 > > > > This seems like material for the PCI tree, but I'm not sure how to > > apply it. It doesn't apply cleanly on the current pci/p2pdma > > (https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/log/?h=p2pdma), > > which does contain your series from > > 20260830-batch-p2p-fixes-v1-0-5044e8dfbe2e@nvidia.com. > > > > I could probably fix the conflicts but I don't know why there should > > be conflicts, since the only commits on pci/p2pdma other than yours > > are a few trivial allow-list updates. > > So maybe this is related to these trivial updates, my series was based > on the clean p2pdma branch: > https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git/log/?h=fix-p2p-acs-v9 Ah, yeah, it must be the allow-list additions that I have but you don't. I wouldn't have thought the offsets would have been a problem.
On Tue, Oct 06, 2026 at 04:36:50PM -0500, Bjorn Helgaas wrote: > On Wed, Oct 07, 2026 at 12:22:27AM +0300, Leon Romanovsky wrote: > > On Tue, Oct 06, 2026 at 02:29:55PM -0500, Bjorn Helgaas wrote: > > > On Thu, Oct 01, 2026 at 02:55:08PM +0300, Leon Romanovsky wrote: > > > > PCI P2PDMA applies Request and Completion Redirect throughout both paths. > > > > This misclassifies asymmetric and nested switches, and reports one answer > > > > for every kind of TLP. > > > > > > > > Three ACS controls act on TLP attributes the client chooses rather than > > > > on the topology: Translation Blocking and Direct Translated P2P act on > > > > a Request's Address Type, and Completion Redirect skips Completions carrying > > > > Relaxed Ordering. > > > > > > > > Evaluate each direction at the path divergence, decide every class from the > > > > one walk, and treat a client with ATS enabled as translating unless its > > > > driver declares per-mapping ATS. > > > > > > > > This completes the P2PDMA side; dma-buf and mlx5 follow separately. > > > > ... > > > > > > > Leon Romanovsky (18): > > > > PCI/P2PDMA: Document the TLP attribute assumptions > > > > PCI/P2PDMA: Derive routing from directional ACS controls > > > > PCI: Reject unreadable ACS controls in isolation checks > > > > PCI/P2PDMA: Evaluate ACS controls at the path divergence > > > > PCI/P2PDMA: Document directional ACS routing > > > > PCI/P2PDMA: Collect the path's ACS controls before deciding > > > > PCI/P2PDMA: Answer routing per TLP class > > > > PCI/P2PDMA: Route Relaxed Ordering Completions directly > > > > PCI/P2PDMA: Reject Translated Requests blocked by Translation Blocking > > > > PCI/P2PDMA: Route Translated Requests under Direct Translated P2P > > > > PCI/P2PDMA: Log detailed ACS routing diagnostics > > > > PCI/P2PDMA: Add KUnit tests for the ACS routing decisions > > > > PCI/P2PDMA: Test the ACS P2P routing walk > > > > PCI: Add KUnit coverage for ACS isolation checks > > > > PCI/P2PDMA: Document TLP-class routing > > > > PCI/P2PDMA: Let a client declare that it selects ATS per mapping > > > > PCI/P2PDMA: Evaluate the ATS path for clients with ATS enabled > > > > PCI/P2PDMA: Test the routing of clients with ATS enabled > > > > > > > > Documentation/admin-guide/kernel-parameters.txt | 15 +- > > > > Documentation/driver-api/pci/p2pdma.rst | 80 +++ > > > > drivers/pci/Kconfig | 15 + > > > > drivers/pci/Makefile | 1 + > > > > drivers/pci/p2pdma.c | 719 ++++++++++++++++++-- > > > > drivers/pci/pci.c | 7 +- > > > > drivers/pci/pci.h | 58 ++ > > > > drivers/pci/pci_acs_test.c | 860 ++++++++++++++++++++++++ > > > > drivers/pci/quirks.c | 6 +- > > > > include/linux/pci-p2pdma.h | 12 +- > > > > 10 files changed, 1687 insertions(+), 86 deletions(-) > > > > --- > > > > base-commit: 08dbfad3f5040f5bdb6c529da20d6d4e81fefd72 > > > > change-id: 20260821-fix-p2p-acs-v4-0-e72455e3a261 > > > > prerequisite-message-id: <20260830-batch-p2p-fixes-v1-0-5044e8dfbe2e@nvidia.com> > > > > prerequisite-patch-id: 6b25c7fcf164cdfc14e9fac5b908d97fcf6509d7 > > > > prerequisite-patch-id: 0d083c281001365aae4b35544cf28891a6ab9a96 > > > > prerequisite-patch-id: bfd9dabf271f3cc9a3a61f46387d20c20311363d > > > > prerequisite-patch-id: fad0275efc722830fc591509506c0a5e4f581073 > > > > prerequisite-patch-id: 0c83bee688fec1f6d1564654df7c630fa6a4a978 > > > > > > This seems like material for the PCI tree, but I'm not sure how to > > > apply it. It doesn't apply cleanly on the current pci/p2pdma > > > (https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/log/?h=p2pdma), > > > which does contain your series from > > > 20260830-batch-p2p-fixes-v1-0-5044e8dfbe2e@nvidia.com. > > > > > > I could probably fix the conflicts but I don't know why there should > > > be conflicts, since the only commits on pci/p2pdma other than yours > > > are a few trivial allow-list updates. > > > > So maybe this is related to these trivial updates, my series was based > > on the clean p2pdma branch: > > https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git/log/?h=fix-p2p-acs-v9 > > Ah, yeah, it must be the allow-list additions that I have but you > don't. I wouldn't have thought the offsets would have been a problem. It applies fine if I move the Haswell and Alibaba allowlist patches t to the end so the base matches fix-p2p-acs-v9, thanks.
On Wed, Oct 07, 2026 at 01:56:44AM -0500, Bjorn Helgaas wrote: > On Tue, Oct 06, 2026 at 04:36:50PM -0500, Bjorn Helgaas wrote: > > On Wed, Oct 07, 2026 at 12:22:27AM +0300, Leon Romanovsky wrote: > > > On Tue, Oct 06, 2026 at 02:29:55PM -0500, Bjorn Helgaas wrote: > > > > On Thu, Oct 01, 2026 at 02:55:08PM +0300, Leon Romanovsky wrote: > > > > > PCI P2PDMA applies Request and Completion Redirect throughout both paths. > > > > > This misclassifies asymmetric and nested switches, and reports one answer > > > > > for every kind of TLP. > > > > > > > > > > Three ACS controls act on TLP attributes the client chooses rather than > > > > > on the topology: Translation Blocking and Direct Translated P2P act on > > > > > a Request's Address Type, and Completion Redirect skips Completions carrying > > > > > Relaxed Ordering. > > > > > > > > > > Evaluate each direction at the path divergence, decide every class from the > > > > > one walk, and treat a client with ATS enabled as translating unless its > > > > > driver declares per-mapping ATS. > > > > > > > > > > This completes the P2PDMA side; dma-buf and mlx5 follow separately. > > > > > ... > > > > > > > > > Leon Romanovsky (18): > > > > > PCI/P2PDMA: Document the TLP attribute assumptions > > > > > PCI/P2PDMA: Derive routing from directional ACS controls > > > > > PCI: Reject unreadable ACS controls in isolation checks > > > > > PCI/P2PDMA: Evaluate ACS controls at the path divergence > > > > > PCI/P2PDMA: Document directional ACS routing > > > > > PCI/P2PDMA: Collect the path's ACS controls before deciding > > > > > PCI/P2PDMA: Answer routing per TLP class > > > > > PCI/P2PDMA: Route Relaxed Ordering Completions directly > > > > > PCI/P2PDMA: Reject Translated Requests blocked by Translation Blocking > > > > > PCI/P2PDMA: Route Translated Requests under Direct Translated P2P > > > > > PCI/P2PDMA: Log detailed ACS routing diagnostics > > > > > PCI/P2PDMA: Add KUnit tests for the ACS routing decisions > > > > > PCI/P2PDMA: Test the ACS P2P routing walk > > > > > PCI: Add KUnit coverage for ACS isolation checks > > > > > PCI/P2PDMA: Document TLP-class routing > > > > > PCI/P2PDMA: Let a client declare that it selects ATS per mapping > > > > > PCI/P2PDMA: Evaluate the ATS path for clients with ATS enabled > > > > > PCI/P2PDMA: Test the routing of clients with ATS enabled > > > > > > > > > > Documentation/admin-guide/kernel-parameters.txt | 15 +- > > > > > Documentation/driver-api/pci/p2pdma.rst | 80 +++ > > > > > drivers/pci/Kconfig | 15 + > > > > > drivers/pci/Makefile | 1 + > > > > > drivers/pci/p2pdma.c | 719 ++++++++++++++++++-- > > > > > drivers/pci/pci.c | 7 +- > > > > > drivers/pci/pci.h | 58 ++ > > > > > drivers/pci/pci_acs_test.c | 860 ++++++++++++++++++++++++ > > > > > drivers/pci/quirks.c | 6 +- > > > > > include/linux/pci-p2pdma.h | 12 +- > > > > > 10 files changed, 1687 insertions(+), 86 deletions(-) > > > > > --- > > > > > base-commit: 08dbfad3f5040f5bdb6c529da20d6d4e81fefd72 > > > > > change-id: 20260821-fix-p2p-acs-v4-0-e72455e3a261 > > > > > prerequisite-message-id: <20260830-batch-p2p-fixes-v1-0-5044e8dfbe2e@nvidia.com> > > > > > prerequisite-patch-id: 6b25c7fcf164cdfc14e9fac5b908d97fcf6509d7 > > > > > prerequisite-patch-id: 0d083c281001365aae4b35544cf28891a6ab9a96 > > > > > prerequisite-patch-id: bfd9dabf271f3cc9a3a61f46387d20c20311363d > > > > > prerequisite-patch-id: fad0275efc722830fc591509506c0a5e4f581073 > > > > > prerequisite-patch-id: 0c83bee688fec1f6d1564654df7c630fa6a4a978 > > > > > > > > This seems like material for the PCI tree, but I'm not sure how to > > > > apply it. It doesn't apply cleanly on the current pci/p2pdma > > > > (https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/log/?h=p2pdma), > > > > which does contain your series from > > > > 20260830-batch-p2p-fixes-v1-0-5044e8dfbe2e@nvidia.com. > > > > > > > > I could probably fix the conflicts but I don't know why there should > > > > be conflicts, since the only commits on pci/p2pdma other than yours > > > > are a few trivial allow-list updates. > > > > > > So maybe this is related to these trivial updates, my series was based > > > on the clean p2pdma branch: > > > https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git/log/?h=fix-p2p-acs-v9 > > > > Ah, yeah, it must be the allow-list additions that I have but you > > don't. I wouldn't have thought the offsets would have been a problem. > > It applies fine if I move the Haswell and Alibaba allowlist patches t > to the end so the base matches fix-p2p-acs-v9, thanks. Bjorn, It is unclear to me if I should to resend. Thanks
On Wed, Oct 07, 2026 at 01:54:09PM +0300, Leon Romanovsky wrote: > On Wed, Oct 07, 2026 at 01:56:44AM -0500, Bjorn Helgaas wrote: > > On Tue, Oct 06, 2026 at 04:36:50PM -0500, Bjorn Helgaas wrote: > > > On Wed, Oct 07, 2026 at 12:22:27AM +0300, Leon Romanovsky wrote: > > > > On Tue, Oct 06, 2026 at 02:29:55PM -0500, Bjorn Helgaas wrote: > > > > > On Thu, Oct 01, 2026 at 02:55:08PM +0300, Leon Romanovsky wrote: > > > > > > PCI P2PDMA applies Request and Completion Redirect throughout both paths. > > > > > > This misclassifies asymmetric and nested switches, and reports one answer > > > > > > for every kind of TLP. > > > > > > > > > > > > Three ACS controls act on TLP attributes the client chooses rather than > > > > > > on the topology: Translation Blocking and Direct Translated P2P act on > > > > > > a Request's Address Type, and Completion Redirect skips Completions carrying > > > > > > Relaxed Ordering. > > > > > > > > > > > > Evaluate each direction at the path divergence, decide every class from the > > > > > > one walk, and treat a client with ATS enabled as translating unless its > > > > > > driver declares per-mapping ATS. > > > > > > > > > > > > This completes the P2PDMA side; dma-buf and mlx5 follow separately. > > > > > > ... > > > > > > > > > > > Leon Romanovsky (18): > > > > > > PCI/P2PDMA: Document the TLP attribute assumptions > > > > > > PCI/P2PDMA: Derive routing from directional ACS controls > > > > > > PCI: Reject unreadable ACS controls in isolation checks > > > > > > PCI/P2PDMA: Evaluate ACS controls at the path divergence > > > > > > PCI/P2PDMA: Document directional ACS routing > > > > > > PCI/P2PDMA: Collect the path's ACS controls before deciding > > > > > > PCI/P2PDMA: Answer routing per TLP class > > > > > > PCI/P2PDMA: Route Relaxed Ordering Completions directly > > > > > > PCI/P2PDMA: Reject Translated Requests blocked by Translation Blocking > > > > > > PCI/P2PDMA: Route Translated Requests under Direct Translated P2P > > > > > > PCI/P2PDMA: Log detailed ACS routing diagnostics > > > > > > PCI/P2PDMA: Add KUnit tests for the ACS routing decisions > > > > > > PCI/P2PDMA: Test the ACS P2P routing walk > > > > > > PCI: Add KUnit coverage for ACS isolation checks > > > > > > PCI/P2PDMA: Document TLP-class routing > > > > > > PCI/P2PDMA: Let a client declare that it selects ATS per mapping > > > > > > PCI/P2PDMA: Evaluate the ATS path for clients with ATS enabled > > > > > > PCI/P2PDMA: Test the routing of clients with ATS enabled > > > > > > > > > > > > Documentation/admin-guide/kernel-parameters.txt | 15 +- > > > > > > Documentation/driver-api/pci/p2pdma.rst | 80 +++ > > > > > > drivers/pci/Kconfig | 15 + > > > > > > drivers/pci/Makefile | 1 + > > > > > > drivers/pci/p2pdma.c | 719 ++++++++++++++++++-- > > > > > > drivers/pci/pci.c | 7 +- > > > > > > drivers/pci/pci.h | 58 ++ > > > > > > drivers/pci/pci_acs_test.c | 860 ++++++++++++++++++++++++ > > > > > > drivers/pci/quirks.c | 6 +- > > > > > > include/linux/pci-p2pdma.h | 12 +- > > > > > > 10 files changed, 1687 insertions(+), 86 deletions(-) > > > > > > --- > > > > > > base-commit: 08dbfad3f5040f5bdb6c529da20d6d4e81fefd72 > > > > > > change-id: 20260821-fix-p2p-acs-v4-0-e72455e3a261 > > > > > > prerequisite-message-id: <20260830-batch-p2p-fixes-v1-0-5044e8dfbe2e@nvidia.com> > > > > > > prerequisite-patch-id: 6b25c7fcf164cdfc14e9fac5b908d97fcf6509d7 > > > > > > prerequisite-patch-id: 0d083c281001365aae4b35544cf28891a6ab9a96 > > > > > > prerequisite-patch-id: bfd9dabf271f3cc9a3a61f46387d20c20311363d > > > > > > prerequisite-patch-id: fad0275efc722830fc591509506c0a5e4f581073 > > > > > > prerequisite-patch-id: 0c83bee688fec1f6d1564654df7c630fa6a4a978 > > > > > > > > > > This seems like material for the PCI tree, but I'm not sure how to > > > > > apply it. It doesn't apply cleanly on the current pci/p2pdma > > > > > (https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/log/?h=p2pdma), > > > > > which does contain your series from > > > > > 20260830-batch-p2p-fixes-v1-0-5044e8dfbe2e@nvidia.com. > > > > > > > > > > I could probably fix the conflicts but I don't know why there should > > > > > be conflicts, since the only commits on pci/p2pdma other than yours > > > > > are a few trivial allow-list updates. > > > > > > > > So maybe this is related to these trivial updates, my series was based > > > > on the clean p2pdma branch: > > > > https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git/log/?h=fix-p2p-acs-v9 > > > > > > Ah, yeah, it must be the allow-list additions that I have but you > > > don't. I wouldn't have thought the offsets would have been a problem. > > > > It applies fine if I move the Haswell and Alibaba allowlist patches t > > to the end so the base matches fix-p2p-acs-v9, thanks. > > Bjorn, > > It is unclear to me if I should to resend. No need.
PCI P2PDMA applies Request and Completion Redirect throughout both paths. This misclassifies asymmetric and nested switches, and reports one answer for every kind of TLP. Three ACS controls act on TLP attributes the client chooses rather than on the topology: Translation Blocking and Direct Translated P2P act on a Request's Address Type, and Completion Redirect skips Completions carrying Relaxed Ordering. Evaluate each direction at the path divergence, decide every class from the one walk, and treat a client with ATS enabled as translating unless its driver declares per-mapping ATS. This completes the P2PDMA side; dma-buf and mlx5 follow separately. Signed-off-by: Leon Romanovsky <leonro@nvidia.com> --- Changes in v9: - Removed dmabuf patches for now. - Removed mlx5 per-mapping ATS declaration for now; it comes back with the dmabuf patches. - Link to v8: https://patch.msgid.link/20260928-fix-p2p-acs-v4-0-v8-0-404453b9c435@nvidia.com Changes in v8: - Added extra Reviewed-by from Logan. - Added patches to take care of ATS per-device vs. per-mapping option - Link to v7: https://patch.msgid.link/20260920-fix-p2p-acs-v4-0-v7-0-ca0828ab697c@nvidia.com Changes in v7: - Removed "Document pdev->p2pdma lifetime rules" patch, it gives nothing after p2pmem fix. - Split dmabuf patch. - Tushar retested the series, so added his Tested-by. - Added Logan's ROB tags and fixed minor documentation issues pointed by him. - Link to v6: https://lore.kernel.org/all/20260914-fix-p2p-acs-v4-0-v6-0-5ef07ec9ef06@nvidia.com/ Changes in v6: - Changed DMABUF to use callbacks and not directly stored pointer. - Link to v5: https://patch.msgid.link/20260910-fix-p2p-acs-v4-0-v5-0-856087f63c0d@nvidia.com Changes in v5: - Rebase on the posted fixes. - Dropped tags from changed patches. - Remove Egress Control Vector interpretation and coverage. - Keep enabled Egress Control conservative as a Request redirect. - Use pci_dbg()/dev_dbg() for diagnostics and drop the "debug" prefix. - Removed code comments from "Document the pdev->p2pdma lifetime and RCU rules" patch and reduced description to actual lifetime explanation. - Added note that Linux assumes that TLPs are in strict-ordering and untranslated. - Added code to calculate p2p paths per-TLP type. - Converted mlx5 to use that new proposed API. - Link to https://patch.msgid.link/20260821-fix-p2p-acs-v4-0-v4-0-94426b96de73@nvidia.com Changes in v4: - Reject ACS Violations and unreadable routing state instead of treating them as host-bridge redirects - Added Tested-by tags from Tushar Dave - Added support to asymmetric ACS routing - Limited redirect checks to the two ports at the path divergence - Added standalone ACS routing diagnostics for hardware retesting - Dropped " PCI: Account for Direct Translated P2P in ACS isolation checks" patch - Link to v3: https://patch.msgid.link/20260811-fix-p2p-acs-v3-0-efc488ee7c03@nvidia.com Changes in v3: - Fixed pci_p2pdma_add_resource() error unwinding - Made pdev->p2pdma teardown wait unconditionally for RCU readers - Restricted pci_p2pmem_find_many() to pool-backed providers - Documented the pdev->p2pdma lifetime and RCU rules - Fixed calc_map_type_and_dist() handling of the verbose argument - Required the ACS port and target to share a bus before indexing the Egress Control Vector - Gave pci_acs_enabled() and pci_acs_path_enabled() a scope, so the ACS Direct Translated P2P rule no longer stops pci_enable_pasid() from enabling PASID - Dropped "Report ACS ports when the paths share no upstream bridge": the mapping type cannot change without a shared upstream bridge, so the pci=disable_acs_redir= hint was not actionable there and the ACS walk only cost config space reads - Folded the Request Redirect rule into pci_acs_rr_ineffective(), so pci_acs_flags_enabled() and the Intel SPT PCH quirk share one copy - Renamed pci_acs_egress_ctrl_set() to pci_acs_egress_ctrl_is_set(), it reads the bit rather than setting it - Reworded the blocked-path warning: ACS may also leave the direct route indeterminate rather than blocked - Added KUnit coverage for the shared-bus guard, a device with no ACS capability and an unreadable ACS Control register - Added the missing Fixes: tags, a second one on the pci_p2pdma_add_resource() unwinding fix (the dangling devres action dates to f58ef9d1d135) and one on the Egress Control isolation change - Link to v2: https://patch.msgid.link/20260806-fix-p2p-acs-v2-0-0cec14812965@nvidia.com Changes in v2: - Added Logan's ROB tags - Added commas in Documentation patch - Link to v1: https://patch.msgid.link/20260802-fix-p2p-acs-v1-0-a7c5eb64fff6@nvidia.com --- Leon Romanovsky (18): PCI/P2PDMA: Document the TLP attribute assumptions PCI/P2PDMA: Derive routing from directional ACS controls PCI: Reject unreadable ACS controls in isolation checks PCI/P2PDMA: Evaluate ACS controls at the path divergence PCI/P2PDMA: Document directional ACS routing PCI/P2PDMA: Collect the path's ACS controls before deciding PCI/P2PDMA: Answer routing per TLP class PCI/P2PDMA: Route Relaxed Ordering Completions directly PCI/P2PDMA: Reject Translated Requests blocked by Translation Blocking PCI/P2PDMA: Route Translated Requests under Direct Translated P2P PCI/P2PDMA: Log detailed ACS routing diagnostics PCI/P2PDMA: Add KUnit tests for the ACS routing decisions PCI/P2PDMA: Test the ACS P2P routing walk PCI: Add KUnit coverage for ACS isolation checks PCI/P2PDMA: Document TLP-class routing PCI/P2PDMA: Let a client declare that it selects ATS per mapping PCI/P2PDMA: Evaluate the ATS path for clients with ATS enabled PCI/P2PDMA: Test the routing of clients with ATS enabled Documentation/admin-guide/kernel-parameters.txt | 15 +- Documentation/driver-api/pci/p2pdma.rst | 80 +++ drivers/pci/Kconfig | 15 + drivers/pci/Makefile | 1 + drivers/pci/p2pdma.c | 719 ++++++++++++++++++-- drivers/pci/pci.c | 7 +- drivers/pci/pci.h | 58 ++ drivers/pci/pci_acs_test.c | 860 ++++++++++++++++++++++++ drivers/pci/quirks.c | 6 +- include/linux/pci-p2pdma.h | 12 +- 10 files changed, 1687 insertions(+), 86 deletions(-) --- base-commit: 08dbfad3f5040f5bdb6c529da20d6d4e81fefd72 change-id: 20260821-fix-p2p-acs-v4-0-e72455e3a261 prerequisite-message-id: <20260830-batch-p2p-fixes-v1-0-5044e8dfbe2e@nvidia.com> prerequisite-patch-id: 6b25c7fcf164cdfc14e9fac5b908d97fcf6509d7 prerequisite-patch-id: 0d083c281001365aae4b35544cf28891a6ab9a96 prerequisite-patch-id: bfd9dabf271f3cc9a3a61f46387d20c20311363d prerequisite-patch-id: fad0275efc722830fc591509506c0a5e4f581073 prerequisite-patch-id: 0c83bee688fec1f6d1564654df7c630fa6a4a978 Best regards, -- Leon Romanovsky <leonro@nvidia.com>