Kernel KVM virtualization development
 help / color / mirror / Atom feed
* [PATCH v19 00/18] vfio/pci: Add PCIe TPH support
@ 2026-07-02 12:42 Chengwen Feng
  2026-07-02 12:42 ` [PATCH v19 01/18] PCI/TPH: Fix pcie_tph_get_st_table_loc() field extraction Chengwen Feng
                   ` (17 more replies)
  0 siblings, 18 replies; 45+ messages in thread
From: Chengwen Feng @ 2026-07-02 12:42 UTC (permalink / raw)
  To: alex, jgg, helgaas
  Cc: wathsala.vithanage, wei.huang2, zhipingz, wangzhou1, wangyushan12,
	liuyonglong, kvm, linux-pci

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 and ST-table entries, 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 two logical parts: the first eight patches fix       
and refactor core PCI/TPH kernel code to export required helper interfaces,
the remaining eight patches implement corresponding VFIO TPH virtualization
and uAPI step by step.

Based on earlier RFC work by Wathsala Vithanage
Based on zhiping's patchset of add TPH support for p2p access

---
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/20260626092232.53ed3a7c@shazbot.org/
- Add expose tph_policy via debugfs
v18-resend:                                                                     
- Fix apply failed only                                                         
v18:                                                                            
- Address all comments of [08/12] commit from Alex                              
  - Add document in sysfs-bus-pci                                               
  - Place the new field at the root port                                        
  - Add new filed only when root port support TPH completer and _DSM            
    method                                                                      
  - Support random offset read, return zero if cpu is offline                   
  - Zero-initialize the buffer rather than memset and reserved = 0              
- Fix git am fail for [10/12] commit                                            
- Fix folloing Sashiko review comments of [11/12] commit:                       
  - Add __GFP_ACCOUNT in thp_st_shadow allocation                               
  - Move reset tph_permit in vfio_pci_tph_init/deinit                           
  - Refine feature PROBE for `TPH_ST_CONFIG`, make sure probe OK when           
    enable_unsafe_tph is set                                                    
  - Add commit-log about why TPH ST shadow table is not cleared when the        
    VFIO device is reset 

Chengwen Feng (17):
  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 TPH requester capability at probe time
  PCI/TPH: Refactor pcie_enable_tph & add explicit requester variant
  PCI/TPH: Refactor pcie_tph_get_cpu_st & add explicit variant
  PCI/TPH: Add pcie_tph_supported() helper to check TPH capability
    attributes
  PCI/TPH: Add pci_tph_dsm_supported() helper to detect device TPH ST
    _DSM
  vfio/pci: Hide TPH capability when TPH is unsupported
  vfio/pci: Introduce tph policy parameter for staged TPH feature
    enablement
  vfio/pci: Virtualize PCIe TPH capability registers
  vfio/pci: Add dmabuf TPH metadata storage and fd query helper
  vfio/pci: Introduce VFIO_DEVICE_FEATURE_TPH family uapi for PCI TPH
    control
  vfio/pci: Implement VFIO_DEVICE_FEATURE_TPH and valid TPH config write
    support
  vfio/pci: Implement TPH_RESOLVE feature for DMABUF and CPU source
    resolving
  vfio/pci: Implement TPH_ST feature for batch ST table programming
  vfio/pci: Reset hardware TPH state on device enable/disable
  vfio/pci: Expose tph_policy via debugfs

Zhiping Zhang (1):
  PCI/TPH: Expose the enabled TPH requester type

 drivers/pci/tph.c                  | 246 +++++++++++++++++++++-------
 drivers/vfio/pci/vfio_pci.c        |  25 +++
 drivers/vfio/pci/vfio_pci_config.c | 129 +++++++++++++++
 drivers/vfio/pci/vfio_pci_core.c   | 252 ++++++++++++++++++++++++++++-
 drivers/vfio/pci/vfio_pci_dmabuf.c |  49 +++++-
 drivers/vfio/pci/vfio_pci_priv.h   |  13 ++
 include/linux/pci-tph.h            |  25 +++
 include/linux/pci.h                |   6 +-
 include/linux/vfio_pci_core.h      |   2 +
 include/uapi/linux/vfio.h          |  62 +++++++
 10 files changed, 742 insertions(+), 67 deletions(-)

-- 
2.17.1


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

end of thread, other threads:[~2026-07-03  1:42 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-02 12:42 [PATCH v19 00/18] vfio/pci: Add PCIe TPH support Chengwen Feng
2026-07-02 12:42 ` [PATCH v19 01/18] PCI/TPH: Fix pcie_tph_get_st_table_loc() field extraction Chengwen Feng
2026-07-02 12:51   ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 02/18] PCI/TPH: Fix tph_enabled concurrent update race by bitfield packing Chengwen Feng
2026-07-02 12:51   ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 03/18] PCI/TPH: Cache TPH requester capability at probe time Chengwen Feng
2026-07-02 12:55   ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 04/18] PCI/TPH: Refactor pcie_enable_tph & add explicit requester variant Chengwen Feng
2026-07-02 12:50   ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 05/18] PCI/TPH: Refactor pcie_tph_get_cpu_st & add explicit variant Chengwen Feng
2026-07-02 12:56   ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 06/18] PCI/TPH: Expose the enabled TPH requester type Chengwen Feng
2026-07-02 12:49   ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 07/18] PCI/TPH: Add pcie_tph_supported() helper to check TPH capability attributes Chengwen Feng
2026-07-02 12:53   ` sashiko-bot
2026-07-03  0:39     ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 08/18] PCI/TPH: Add pci_tph_dsm_supported() helper to detect device TPH ST _DSM Chengwen Feng
2026-07-02 12:55   ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 09/18] vfio/pci: Hide TPH capability when TPH is unsupported Chengwen Feng
2026-07-02 13:00   ` sashiko-bot
2026-07-03  0:36     ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 10/18] vfio/pci: Introduce tph policy parameter for staged TPH feature enablement Chengwen Feng
2026-07-02 12:50   ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 11/18] vfio/pci: Virtualize PCIe TPH capability registers Chengwen Feng
2026-07-02 13:04   ` sashiko-bot
2026-07-03  0:51     ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 12/18] vfio/pci: Add dmabuf TPH metadata storage and fd query helper Chengwen Feng
2026-07-02 12:56   ` sashiko-bot
2026-07-03  0:53     ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 13/18] vfio/pci: Introduce VFIO_DEVICE_FEATURE_TPH family uapi for PCI TPH control Chengwen Feng
2026-07-02 13:01   ` sashiko-bot
2026-07-03  0:57     ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 14/18] vfio/pci: Implement VFIO_DEVICE_FEATURE_TPH and valid TPH config write support Chengwen Feng
2026-07-02 13:04   ` sashiko-bot
2026-07-03  1:16     ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 15/18] vfio/pci: Implement TPH_RESOLVE feature for DMABUF and CPU source resolving Chengwen Feng
2026-07-02 13:00   ` sashiko-bot
2026-07-03  1:26     ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 16/18] vfio/pci: Implement TPH_ST feature for batch ST table programming Chengwen Feng
2026-07-02 13:04   ` sashiko-bot
2026-07-03  1:42     ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 17/18] vfio/pci: Reset hardware TPH state on device enable/disable Chengwen Feng
2026-07-02 13:00   ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 18/18] vfio/pci: Expose tph_policy via debugfs Chengwen Feng
2026-07-02 12:59   ` sashiko-bot

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