Thread (1 message) flat view 1 message, 1 author, 2026-05-27

Re: [PATCH v5 2/4] dma-buf: add optional get_tph() callback

From: Alex Williamson <alex@shazbot.org>
Date: 2026-05-27 17:03:47
Also in: dri-devel, kvm, linux-pci, linux-rdma

On Tue, 26 May 2026 07:43:54 -0700
Zhiping Zhang [off-list ref] wrote:
quoted hunk
Add an optional dma-buf get_tph callback so an exporter can return TPH
(TLP Processing Hints) metadata to an importer.

8-bit ST and 16-bit Extended ST are distinct namespaces in the PCIe TPH
ST table and may both be present with different values. The importer
passes its supported steering-tag width and the exporter returns the
matching value, or -EOPNOTSUPP if no metadata is available for that
width.

The first user is VFIO_DEVICE_FEATURE_DMA_BUF_TPH in vfio-pci, with the
mlx5 RDMA driver as the first importer.

Signed-off-by: Zhiping Zhang <redacted>
---
 include/linux/dma-buf.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
index d1203da56fc5..49eb6ad644a2 100644
--- a/include/linux/dma-buf.h
+++ b/include/linux/dma-buf.h
@@ -113,6 +113,27 @@ struct dma_buf_ops {
 	 */
 	void (*unpin)(struct dma_buf_attachment *attach);
 
+	/**
+	 * @get_tph:
+	 * @dmabuf: DMA buffer for which to retrieve TPH metadata
+	 * @steering_tag: Returns the raw TPH steering tag for @st_width
+	 * @ph: Returns the TPH processing hint (2-bit value)
+	 * @st_width: Consumer's supported steering tag width in bits (8 or 16)
+	 *
+	 * Return the TPH (TLP Processing Hints) metadata associated with this
+	 * DMA buffer for the requested steering-tag width. 8-bit ST and 16-bit
+	 * Extended ST are distinct namespaces in the PCIe TPH ST table and may
+	 * both be present with different values, so the exporter must select the
+	 * value that matches @st_width and must not substitute one for the other.
+	 *
+	 * Return 0 on success, -EOPNOTSUPP if no metadata is available for the
+	 * requested width, or -EINVAL if @st_width is not 8 or 16.
+	 *
+	 * This callback is optional.
+	 */
+	int (*get_tph)(struct dma_buf *dmabuf, u16 *steering_tag, u8 *ph,
+		       u8 st_width);
Why not make this `bool extended` rather than `u8 st_width` to avoid
the entire class of errors involving an invalid width?  Thanks,

Alex
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help