Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* Re: [PATCH v8 4/4] RDMA/mlx5: get tph for p2p access when registering dma-buf mr
       [not found] ` <20260615065912.2177918-5-zhipingz@meta.com>
@ 2026-06-17  9:25   ` Leon Romanovsky
  2026-06-18  6:09     ` Zhiping Zhang
  0 siblings, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2026-06-17  9:25 UTC (permalink / raw)
  To: Zhiping Zhang
  Cc: Jason Gunthorpe, Michael Guralnik, Sumit Semwal, Christian Konig,
	Alex Williamson, Bjorn Helgaas, kvm, linux-rdma, linux-pci,
	dri-devel

On Sun, Jun 14, 2026 at 11:59:01PM -0700, Zhiping Zhang wrote:
> Query dma-buf PCI TPH metadata when registering a dma-buf MR for
> peer-to-peer access to a PCIe endpoint and use it to program
> requester-side TPH on the outbound mkey. If the exporter has no
> metadata, fall back to the existing no-TPH path.
> 
> Use mlx5_st_alloc_index_by_tag() to translate exporter-provided
> steering tags into local ST entries when table mode is active, and add
> mlx5_st_get_index() for DMAH-backed flows that already carry an ST
> index.
> 
> For TPH-backed FRMRs, keep the extra ST-table reference tied to MR
> lifetime rather than pooled mkey lifetime. Acquire the ref before MR
> creation and release it again when the MR is returned to the pool or
> the backing mkey is destroyed, while leaving the generic FRMR pool core
> unchanged.
> 
> Import the DMA_BUF namespace for the new dma_buf_get_pci_tph() call so
> modular mlx5_ib builds link cleanly.

The commit message explains *what* the patch does, but it lacks context on
*why* the change is needed. The 'what' is mostly clear from reading the code;
the important part missing here is the rationale behind the change.

Thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v8 2/4] dma-buf: add optional get_pci_tph() callback
       [not found] ` <20260615065912.2177918-3-zhipingz@meta.com>
@ 2026-06-17  9:41   ` Leon Romanovsky
  2026-06-18  6:10     ` Zhiping Zhang
  0 siblings, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2026-06-17  9:41 UTC (permalink / raw)
  To: Zhiping Zhang
  Cc: Jason Gunthorpe, Michael Guralnik, Sumit Semwal, Christian Konig,
	Alex Williamson, Bjorn Helgaas, kvm, linux-rdma, linux-pci,
	dri-devel

On Sun, Jun 14, 2026 at 11:58:59PM -0700, Zhiping Zhang wrote:
> Add an optional dma_buf_ops.get_pci_tph callback and a
> DMA-buf importer wrapper, dma_buf_get_pci_tph().
> 
> TPH is PCIe TLP Processing Hint. 8-bit ST and 16-bit Extended ST are
> distinct PCIe TPH namespaces, so the importer requests the namespace it
> can emit and the exporter returns the matching ST/PH tuple or
> -EOPNOTSUPP.
> 
> dma_buf_get_pci_tph() is the importer entry point. It requires
> &dmabuf->resv to be held while the callback runs and returns
> -EOPNOTSUPP when the exporter does not provide PCI TPH metadata.
> 
> The first user is VFIO_DEVICE_FEATURE_DMA_BUF_TPH in vfio-pci, with
> mlx5 as the first importer.
> 
> Signed-off-by: Zhiping Zhang <zhipingz@meta.com>
> ---
>  drivers/dma-buf/dma-buf.c | 25 +++++++++++++++++++++++++
>  include/linux/dma-buf.h   | 16 ++++++++++++++++
>  2 files changed, 41 insertions(+)
> 
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index d504c636dc29..7a4c9b0d5dab 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -1144,6 +1144,31 @@ void dma_buf_unpin(struct dma_buf_attachment *attach)
>  }
>  EXPORT_SYMBOL_NS_GPL(dma_buf_unpin, "DMA_BUF");
>  
> +/**
> + * dma_buf_get_pci_tph - Retrieve PCIe TLP Processing Hint (TPH) metadata
> + * @dmabuf: DMA buffer to query
> + * @extended: false for 8-bit ST, true for 16-bit Extended ST
> + * @steering_tag: returns the raw steering tag for the requested namespace
> + * @ph: returns the TPH processing hint
> + *
> + * Wrapper for the optional &dma_buf_ops.get_pci_tph callback.
> + *
> + * Must be called with &dma_buf.resv held. Returns -EOPNOTSUPP if the
> + * exporter does not implement the callback or has no metadata for the
> + * requested namespace.
> + */
> +int dma_buf_get_pci_tph(struct dma_buf *dmabuf, bool extended,
> +			u16 *steering_tag, u8 *ph)
> +{
> +	dma_resv_assert_held(dmabuf->resv);
> +
> +	if (!dmabuf->ops->get_pci_tph)
> +		return -EOPNOTSUPP;
> +
> +	return dmabuf->ops->get_pci_tph(dmabuf, extended, steering_tag, ph);
> +}
> +EXPORT_SYMBOL_NS_GPL(dma_buf_get_pci_tph, "DMA_BUF");
> +
>  /**
>   * dma_buf_map_attachment - Returns the scatterlist table of the attachment;
>   * mapped into _device_ address space. Is a wrapper for map_dma_buf() of the
> diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
> index d1203da56fc5..5e7b69a40f3d 100644
> --- a/include/linux/dma-buf.h
> +++ b/include/linux/dma-buf.h
> @@ -113,6 +113,20 @@ struct dma_buf_ops {
>  	 */
>  	void (*unpin)(struct dma_buf_attachment *attach);
>  
> +	/**
> +	 * @get_pci_tph:

There should be a blank line after the line above, along with a clear and
concise description of what this callback does.

Thanks

> +	 * @dmabuf: DMA buffer for which to retrieve TPH metadata
> +	 * @extended: false for 8-bit ST, true for 16-bit Extended ST
> +	 * @steering_tag: Returns the raw TPH steering tag for the requested
> +	 *                namespace
> +	 * @ph: Returns the TPH processing hint (2-bit value)
> +	 *
> +	 * Optional callback for dma_buf_get_pci_tph(). Called with
> +	 * &dma_buf.resv held.
> +	 */
> +	int (*get_pci_tph)(struct dma_buf *dmabuf, bool extended,
> +			   u16 *steering_tag, u8 *ph);
> +
>  	/**
>  	 * @map_dma_buf:
>  	 *
> @@ -563,6 +577,8 @@ void dma_buf_detach(struct dma_buf *dmabuf,
>  		    struct dma_buf_attachment *attach);
>  int dma_buf_pin(struct dma_buf_attachment *attach);
>  void dma_buf_unpin(struct dma_buf_attachment *attach);
> +int dma_buf_get_pci_tph(struct dma_buf *dmabuf, bool extended,
> +			u16 *steering_tag, u8 *ph);
>  
>  struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info);
>  
> -- 
> 2.53.0-Meta
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v8 4/4] RDMA/mlx5: get tph for p2p access when registering dma-buf mr
  2026-06-17  9:25   ` [PATCH v8 4/4] RDMA/mlx5: get tph for p2p access when registering dma-buf mr Leon Romanovsky
@ 2026-06-18  6:09     ` Zhiping Zhang
  0 siblings, 0 replies; 4+ messages in thread
From: Zhiping Zhang @ 2026-06-18  6:09 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Jason Gunthorpe, Michael Guralnik, Sumit Semwal, Christian Konig,
	Alex Williamson, Bjorn Helgaas, kvm, linux-rdma, linux-pci,
	dri-devel

On Wed, Jun 17, 2026 at 2:25 AM Leon Romanovsky <leon@kernel.org> wrote:
>
> >
> On Sun, Jun 14, 2026 at 11:59:01PM -0700, Zhiping Zhang wrote:
> > Query dma-buf PCI TPH metadata when registering a dma-buf MR for
> > peer-to-peer access to a PCIe endpoint and use it to program
> > requester-side TPH on the outbound mkey. If the exporter has no
> > metadata, fall back to the existing no-TPH path.
> >
> > Use mlx5_st_alloc_index_by_tag() to translate exporter-provided
> > steering tags into local ST entries when table mode is active, and add
> > mlx5_st_get_index() for DMAH-backed flows that already carry an ST
> > index.
> >
> > For TPH-backed FRMRs, keep the extra ST-table reference tied to MR
> > lifetime rather than pooled mkey lifetime. Acquire the ref before MR
> > creation and release it again when the MR is returned to the pool or
> > the backing mkey is destroyed, while leaving the generic FRMR pool core
> > unchanged.
> >
> > Import the DMA_BUF namespace for the new dma_buf_get_pci_tph() call so
> > modular mlx5_ib builds link cleanly.
>
> The commit message explains *what* the patch does, but it lacks context on
> *why* the change is needed. The 'what' is mostly clear from reading the code;
> the important part missing here is the rationale behind the change.
>
> Thanks

Noted, will change the msg in the next version.

Thanks,
Zhiping

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v8 2/4] dma-buf: add optional get_pci_tph() callback
  2026-06-17  9:41   ` [PATCH v8 2/4] dma-buf: add optional get_pci_tph() callback Leon Romanovsky
@ 2026-06-18  6:10     ` Zhiping Zhang
  0 siblings, 0 replies; 4+ messages in thread
From: Zhiping Zhang @ 2026-06-18  6:10 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Jason Gunthorpe, Michael Guralnik, Sumit Semwal, Christian Konig,
	Alex Williamson, Bjorn Helgaas, kvm, linux-rdma, linux-pci,
	dri-devel

On Wed, Jun 17, 2026 at 2:41 AM Leon Romanovsky <leon@kernel.org> wrote:
>
> >
> On Sun, Jun 14, 2026 at 11:58:59PM -0700, Zhiping Zhang wrote:
> > Add an optional dma_buf_ops.get_pci_tph callback and a
> > DMA-buf importer wrapper, dma_buf_get_pci_tph().
> >
> > TPH is PCIe TLP Processing Hint. 8-bit ST and 16-bit Extended ST are
> > distinct PCIe TPH namespaces, so the importer requests the namespace it
> > can emit and the exporter returns the matching ST/PH tuple or
> > -EOPNOTSUPP.
> >
> > dma_buf_get_pci_tph() is the importer entry point. It requires
> > &dmabuf->resv to be held while the callback runs and returns
> > -EOPNOTSUPP when the exporter does not provide PCI TPH metadata.
> >
> > The first user is VFIO_DEVICE_FEATURE_DMA_BUF_TPH in vfio-pci, with
> > mlx5 as the first importer.
> >
> > Signed-off-by: Zhiping Zhang <zhipingz@meta.com>
> > ---
> >  drivers/dma-buf/dma-buf.c | 25 +++++++++++++++++++++++++
> >  include/linux/dma-buf.h   | 16 ++++++++++++++++
> >  2 files changed, 41 insertions(+)
> >
> > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> > index d504c636dc29..7a4c9b0d5dab 100644
> > --- a/drivers/dma-buf/dma-buf.c
> > +++ b/drivers/dma-buf/dma-buf.c
> > @@ -1144,6 +1144,31 @@ void dma_buf_unpin(struct dma_buf_attachment *attach)
> >  }
> >  EXPORT_SYMBOL_NS_GPL(dma_buf_unpin, "DMA_BUF");
> >
> > +/**
> > + * dma_buf_get_pci_tph - Retrieve PCIe TLP Processing Hint (TPH) metadata
> > + * @dmabuf: DMA buffer to query
> > + * @extended: false for 8-bit ST, true for 16-bit Extended ST
> > + * @steering_tag: returns the raw steering tag for the requested namespace
> > + * @ph: returns the TPH processing hint
> > + *
> > + * Wrapper for the optional &dma_buf_ops.get_pci_tph callback.
> > + *
> > + * Must be called with &dma_buf.resv held. Returns -EOPNOTSUPP if the
> > + * exporter does not implement the callback or has no metadata for the
> > + * requested namespace.
> > + */
> > +int dma_buf_get_pci_tph(struct dma_buf *dmabuf, bool extended,
> > +                     u16 *steering_tag, u8 *ph)
> > +{
> > +     dma_resv_assert_held(dmabuf->resv);
> > +
> > +     if (!dmabuf->ops->get_pci_tph)
> > +             return -EOPNOTSUPP;
> > +
> > +     return dmabuf->ops->get_pci_tph(dmabuf, extended, steering_tag, ph);
> > +}
> > +EXPORT_SYMBOL_NS_GPL(dma_buf_get_pci_tph, "DMA_BUF");
> > +
> >  /**
> >   * dma_buf_map_attachment - Returns the scatterlist table of the attachment;
> >   * mapped into _device_ address space. Is a wrapper for map_dma_buf() of the
> > diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
> > index d1203da56fc5..5e7b69a40f3d 100644
> > --- a/include/linux/dma-buf.h
> > +++ b/include/linux/dma-buf.h
> > @@ -113,6 +113,20 @@ struct dma_buf_ops {
> >        */
> >       void (*unpin)(struct dma_buf_attachment *attach);
> >
> > +     /**
> > +      * @get_pci_tph:
>
> There should be a blank line after the line above, along with a clear and
> concise description of what this callback does.
>
> Thanks
>
Sure, will change!

Thanks,
Zhiping

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-06-18  6:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260615065912.2177918-1-zhipingz@meta.com>
     [not found] ` <20260615065912.2177918-5-zhipingz@meta.com>
2026-06-17  9:25   ` [PATCH v8 4/4] RDMA/mlx5: get tph for p2p access when registering dma-buf mr Leon Romanovsky
2026-06-18  6:09     ` Zhiping Zhang
     [not found] ` <20260615065912.2177918-3-zhipingz@meta.com>
2026-06-17  9:41   ` [PATCH v8 2/4] dma-buf: add optional get_pci_tph() callback Leon Romanovsky
2026-06-18  6:10     ` Zhiping Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox