Re: [PATCH v20 00/16] vfio/pci: Add PCIe TPH support

fengchengwen <[email protected]>
Newsgroups org.kernel.vger.linux-pci,org.kernel.vger.kvm
Message-ID <[email protected]>
Hi Alex,

Hope everything goes well.

I’m sending a gentle follow‑up on my previous mail dated Jul 27,
about splitting this VFIO‑TPH v20 patchset into standalone‑core series
and the subsequent dma‑buf P2P TPH extension to resolve the
invalidate‑mapping lifecycle issue.

One extra question I’d like to consult with you.
This v20 series is built upon Zhiping’s v11 dma‑buf TPH patches,
and his patchset has now advanced to v13.
Should I rebase my work on top of his latest v13 for the next revision,
or keep another way to organise the patch series?

I will arrange v21 accordingly once I get your advice.
Thanks a lot.

Best regards,
Chengwen Feng

On 7/14/2026 6:43 PM, Chengwen Feng wrote:
> This patchset enables full userspace configurable PCIe TPH support for
> VFIO, which brings performance benefits for userspace workloads such as
> DPDK and SPDK.
> 
> Currently VFIO only exposes read-only TPH capability registers to
> userspace, while all write operations are silently discarded. This
> prevents userspace from enabling and configuring TPH, limiting performance
> optimization opportunities.
> 
> Per PCIe spec 7.5.3.15: TPH Completer support is applicable to Root Ports
> and Endpoints, allowing Steering Tags to target host CPUs or peer devices
> for P2P transactions.
> 
> TPH usage model can be divided into three fundamental parts:
> 1. Retrieve Steering Tag:
>    - Tags targeting host CPUs are obtained via platform methods (ACPI _DSM)
>      wrapped in pcie_tph_get_cpu_st(). Userspace requires a generic
>      interface to query these CPU-associated ST values.
>    - Tags targeting peer devices are managed by userspace drivers, and set
>      to kernel by dmabuf ioctl which address by zhiping's patchset.
> 2. Program Steering Tag table:
>    - For devices with standard ST table structures (in capability space or
>      MSI-X table), userspace needs a unified interface to configure ST
>      entries.
>    - Devices without standard ST tables are handled by userspace itself.
> 3. Toggle device TPH Requester enable/disable state.
> 
> The patchset builds a complete, secure, staged TPH feature stack with core
> design objectives:
> 1. Refactor & fix upstream PCI/TPH core implementation to provide clean,
>    safe, extendable helper APIs for VFIO consumption;
> 2. Introduce configurable per-device TPH policy for staged feature
>    enablement, supporting progressive enabling of No-ST/IV/DS/LITERAL
>    modes;
> 3. Fully virtualize PCIe TPH config space: read-only capability header,
>    virtually writable TPH_CTRL, silent discard invalid writes;
> 4. Implement unified VFIO user feature uAPI (TPH / TPH_RESOLVE / TPH_ST)
>    for TPH enablement, tag resolution and batch ST table programming;
> 
> The patchset is split into three logical parts:
> 1. The first three patches is Zhiping's patchset of add TPH support for
>    p2p access (based on v11), because this patchset support query dmabuf's
>    ST/PH
> 2. The second eight patches fix and refactor core PCI/TPH kernel code to
>    export required helper interfaces
> 3. The last five patches implement corresponding VFIO TPH virtualization
>    and uAPI step by step.
> 
> Based on earlier RFC work by Wathsala Vithanage
> 
> ---
> v20:
> - Address almost all comments from Alex about v19, not within Alex's
>   scope:
>   - Drop LITERAL policy support
>   - uAPI changes: cap have been split into fine-grained
>   - TPH config access: still based on perm mechanism, but restrict the
>     readable and writable length
>   - Debugfs add more fields
> v19:
> - Address all comments from Alex
>   - Drop CPU-to-ST translation of PCI/TPH
>   - Re-implement vfio part, please refer:
>     https://lore.kernel.org/linux-pci/[email protected]/
> - Add expose tph_policy via debugfs
> 
> Chengwen Feng (13):
>   PCI/TPH: Fix pcie_tph_get_st_table_loc() field extraction
>   PCI/TPH: Fix tph_enabled concurrent update race by bitfield packing
>   PCI/TPH: Cache negotiated max requester type at probe time
>   PCI/TPH: Refactor pcie_enable_tph and add requester variant
>   PCI/TPH: Refactor pcie_tph_get_cpu_st & add requester variant
>   PCI/TPH: Add macros to check standard and extended TPH support
>   PCI/TPH: Add pcie_tph_set_st_entries() batch ST entry programming
>     helper
>   PCI/TPH: Add pci_tph_dsm_supported() helper to detect device TPH ST
>     _DSM
>   vfio/pci: Add basic NO-ST TPH VFIO device feature support
>   vfio/pci: Add IV-ST TPH policy and VFIO TPH_ST batch programming
>     support
>   vfio/pci: Add DS-ST TPH policy and extend TPH_RESOLVE capabilities
>   vfio/pci: Sync core PCI TPH software state across device lifecycle and
>     resets
>   vfio/pci: Expose per-device TPH state via debugfs
> 
> Zhiping Zhang (3):
>   PCI/TPH: Add requester/completer type helpers
>   dma-buf: add optional get_pci_tph() callback
>   vfio/pci: implement get_pci_tph and DMA_BUF_TPH feature
> 
>  drivers/dma-buf/dma-buf.c          |  32 +++
>  drivers/pci/tph.c                  | 282 ++++++++++++++++++------
>  drivers/vfio/pci/vfio_pci.c        |  23 ++
>  drivers/vfio/pci/vfio_pci_config.c | 164 ++++++++++++--
>  drivers/vfio/pci/vfio_pci_core.c   | 341 ++++++++++++++++++++++++++++-
>  drivers/vfio/pci/vfio_pci_dmabuf.c | 102 ++++++++-
>  drivers/vfio/pci/vfio_pci_priv.h   |  18 ++
>  include/linux/dma-buf.h            |  25 +++
>  include/linux/pci-tph.h            |  53 ++++-
>  include/linux/pci.h                |   6 +-
>  include/linux/vfio_pci_core.h      |   3 +
>  include/uapi/linux/vfio.h          | 144 ++++++++++++
>  12 files changed, 1090 insertions(+), 103 deletions(-)
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.