All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: "Leon Romanovsky" <leon@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Logan Gunthorpe" <logang@deltatee.com>,
	"Jason Gunthorpe" <jgg@ziepe.ca>,
	"Joerg Roedel (AMD)" <joro@8bytes.org>,
	"Will Deacon" <will@kernel.org>,
	"Robin Murphy" <robin.murphy@arm.com>,
	"Christian König" <christian.koenig@amd.com>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-doc@vger.kernel.org, iommu@lists.linux.dev,
	Tushar Dave <tdave@nvidia.com>,
		linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
		linaro-mm-sig@lists.linaro.org, linux-rdma@vger.kernel.org,
	kvm@vger.kernel.org,  Chaitanya Kulkarni	 <kch@nvidia.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jens Axboe	 <axboe@kernel.dk>, Alex Williamson <alex@shazbot.org>,
	Ankit Agrawal <ankita@nvidia.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan	 <skhan@linuxfoundation.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	Sumit Semwal	 <sumit.semwal@linaro.org>
Subject: Re: [PATCH v8 20/23] PCI/P2PDMA: Let a client declare that it selects ATS per mapping
Date: Mon, 28 Sep 2026 14:44:32 +0200	[thread overview]
Message-ID: <417b4032fd106c6730558759fd02e67e2fdc1c82.camel@linux.intel.com> (raw)
In-Reply-To: <20260928-fix-p2p-acs-v4-0-v8-20-404453b9c435@nvidia.com>

On Mon, 2026-09-28 at 14:19 +0300, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> 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. Keep it in the device's P2PDMA state, which
> already ends with the driver binding.
> 
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>

> ---
>  drivers/pci/p2pdma.c       | 27 +++++++++++++++++++++++++++
>  include/linux/pci-p2pdma.h |  4 ++++
>  2 files changed, 31 insertions(+)
> 
> diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
> index 1f4bf0125a5c..ae676509f9f3 100644
> --- a/drivers/pci/p2pdma.c
> +++ b/drivers/pci/p2pdma.c
> @@ -26,6 +26,7 @@
>  struct pci_p2pdma {
>  	struct gen_pool *pool;
>  	bool p2pmem_published;
> +	bool ats_per_mapping;
>  	struct xarray map_types;
>  	struct p2pdma_provider mem[PCI_STD_NUM_BARS];
>  };
> @@ -1568,6 +1569,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 takes the Address Type of this client's Requests from
> the TLP
> + * flags its callers pass.
> + */
> +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;
> +
> +	p2p->ats_per_mapping = true;
> +}
> +EXPORT_SYMBOL_GPL(pcim_p2pdma_set_ats_per_mapping);
> +
>  /**
>   * pci_p2pdma_map_type_tlp - Determine the mapping type for P2PDMA
> transfers
>   * @provider: P2PDMA provider structure
> diff --git a/include/linux/pci-p2pdma.h b/include/linux/pci-p2pdma.h
> index 36045b1b730c..543a09426a11 100644
> --- a/include/linux/pci-p2pdma.h
> +++ b/include/linux/pci-p2pdma.h
> @@ -109,6 +109,7 @@ struct scatterlist *pci_p2pmem_alloc_sgl(struct
> pci_dev *pdev,
>  					 unsigned int *nents, u32
> length);
>  void pci_p2pmem_free_sgl(struct pci_dev *pdev, struct scatterlist
> *sgl);
>  void pci_p2pmem_publish(struct pci_dev *pdev, bool publish);
> +void pcim_p2pdma_set_ats_per_mapping(struct pci_dev *pdev);
>  int pci_p2pdma_enable_store(const char *page, struct pci_dev
> **p2p_dev,
>  			    bool *use_p2pdma);
>  ssize_t pci_p2pdma_enable_show(char *page, struct pci_dev *p2p_dev,
> @@ -166,6 +167,9 @@ static inline void pci_p2pmem_free_sgl(struct
> pci_dev *pdev,
>  static inline void pci_p2pmem_publish(struct pci_dev *pdev, bool
> publish)
>  {
>  }
> +static inline void pcim_p2pdma_set_ats_per_mapping(struct pci_dev
> *pdev)
> +{
> +}
>  static inline int pci_p2pdma_enable_store(const char *page,
>  		struct pci_dev **p2p_dev, bool *use_p2pdma)
>  {

  reply	other threads:[~2026-09-28 12:44 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28 11:19 [PATCH v8 00/23] PCI/P2PDMA: Route peer-to-peer DMA by TLP class Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 01/23] PCI/P2PDMA: Document the TLP attribute assumptions Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 02/23] PCI/P2PDMA: Derive routing from directional ACS controls Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 03/23] PCI: Reject unreadable ACS controls in isolation checks Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 04/23] PCI/P2PDMA: Evaluate ACS controls at the path divergence Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 05/23] PCI/P2PDMA: Document directional ACS routing Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 06/23] PCI/P2PDMA: Collect the path's ACS controls before deciding Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 07/23] PCI/P2PDMA: Answer routing per TLP class Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 08/23] PCI/P2PDMA: Route Relaxed Ordering Completions directly Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 09/23] PCI/P2PDMA: Reject Translated Requests blocked by Translation Blocking Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 10/23] PCI/P2PDMA: Route Translated Requests under Direct Translated P2P Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 11/23] PCI/P2PDMA: Log detailed ACS routing diagnostics Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 12/23] PCI/P2PDMA: Add KUnit tests for the ACS routing decisions Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 13/23] PCI/P2PDMA: Test the ACS P2P routing walk Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 14/23] PCI: Add KUnit coverage for ACS isolation checks Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 15/23] PCI/P2PDMA: Document TLP-class routing Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 16/23] dma-buf: Let importers ask how peer-to-peer traffic is routed Leon Romanovsky
2026-09-29  9:34   ` Christian König
2026-09-29 13:23     ` Leon Romanovsky
2026-09-29 13:39       ` Christian König
2026-09-29 17:57         ` Leon Romanovsky
2026-09-30  7:00           ` Christian König
2026-09-30  8:18             ` Leon Romanovsky
2026-09-30  8:34               ` Christian König
2026-09-30 11:43                 ` Leon Romanovsky
2026-09-30 11:52                   ` Christian König
2026-09-30 14:32                     ` Leon Romanovsky
2026-09-30 14:52                       ` Christian König
2026-10-01  6:17                         ` Leon Romanovsky
2026-10-01  7:06                           ` Christian König
2026-09-30 14:57                       ` Thomas Hellström
2026-09-30 15:03                         ` Christian König
2026-09-30 16:52                         ` Jason Gunthorpe
2026-10-02  8:19                           ` Alistair Popple
2026-10-01  6:37                         ` Leon Romanovsky
2026-10-01  7:49                           ` Christian König
2026-10-01  8:27                             ` Leon Romanovsky
2026-10-01  9:07                               ` Christian König
2026-10-01  8:11                           ` Thomas Hellström
2026-09-28 11:19 ` [PATCH v8 17/23] vfio/pci: Hand out the P2PDMA provider behind a dma-buf Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 18/23] RDMA/uverbs: " Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 19/23] RDMA/mlx5: Ask P2PDMA whether ATS takes a direct peer-to-peer route Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 20/23] PCI/P2PDMA: Let a client declare that it selects ATS per mapping Leon Romanovsky
2026-09-28 12:44   ` Thomas Hellström [this message]
2026-09-28 11:19 ` [PATCH v8 21/23] RDMA/mlx5: Declare to P2PDMA that ATS is selected per memory key Leon Romanovsky
2026-09-28 11:19 ` [PATCH v8 22/23] PCI/P2PDMA: Evaluate the ATS path for clients with ATS enabled Leon Romanovsky
2026-09-28 12:43   ` Thomas Hellström
2026-09-28 11:19 ` [PATCH v8 23/23] PCI/P2PDMA: Test the routing of " Leon Romanovsky

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=417b4032fd106c6730558759fd02e67e2fdc1c82.camel@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=alex@shazbot.org \
    --cc=ankita@nvidia.com \
    --cc=axboe@kernel.dk \
    --cc=bhelgaas@google.com \
    --cc=christian.koenig@amd.com \
    --cc=corbet@lwn.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=kch@nvidia.com \
    --cc=kvm@vger.kernel.org \
    --cc=leon@kernel.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=logang@deltatee.com \
    --cc=rdunlap@infradead.org \
    --cc=robin.murphy@arm.com \
    --cc=skhan@linuxfoundation.org \
    --cc=sumit.semwal@linaro.org \
    --cc=tdave@nvidia.com \
    --cc=will@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.