Re: [PATCH v4 1/4] PCI: Add debugfs support for exposing PTM context
From: Eric Biggers
Date: Fri Jun 06 2025 - 22:55:55 EST
On Mon, May 05, 2025 at 07:54:39PM +0530, Manivannan Sadhasivam wrote:
> Precision Time Management (PTM) mechanism defined in PCIe spec r6.0,
> sec 6.21 allows precise coordination of timing information across multiple
> components in a PCIe hierarchy with independent local time clocks.
>
> PCI core already supports enabling PTM in the root port and endpoint
> devices through PTM Extended Capability registers. But the PTM context
> supported by the PTM capable components such as Root Complex (RC) and
> Endpoint (EP) controllers were not exposed as of now.
>
> Hence, add the debugfs support to expose the PTM context to userspace from
> both PCIe RC and EP controllers. Controller drivers are expected to call
> pcie_ptm_create_debugfs() to create the debugfs attributes for the PTM
> context and call pcie_ptm_destroy_debugfs() to destroy them. The drivers
> should also populate the relevant callbacks in the 'struct pcie_ptm_ops'
> structure based on the controller implementation.
>
> Below PTM context are exposed through debugfs:
>
> PCIe RC
> =======
>
> 1. PTM Local clock
> 2. PTM T2 timestamp
> 3. PTM T3 timestamp
> 4. PTM Context valid
>
> PCIe EP
> =======
>
> 1. PTM Local clock
> 2. PTM T1 timestamp
> 3. PTM T4 timestamp
> 4. PTM Master clock
> 5. PTM Context update
>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx>
> ---
> Documentation/ABI/testing/debugfs-pcie-ptm | 70 +++++++
> MAINTAINERS | 1 +
> drivers/pci/pcie/ptm.c | 300 +++++++++++++++++++++++++++++
> include/linux/pci.h | 45 +++++
> 4 files changed, 416 insertions(+)
There's a build error on mainline from this commit:
drivers/pci/pcie/ptm.c:498:25: error: redefinition of 'pcie_ptm_create_debugfs'
498 | struct pci_ptm_debugfs *pcie_ptm_create_debugfs(struct device *dev, void *pdata,
| ^
./include/linux/pci.h:1915:2: note: previous definition is here
1915 | *pcie_ptm_create_debugfs(struct device *dev, void *pdata,
| ^
drivers/pci/pcie/ptm.c:546:6: error: redefinition of 'pcie_ptm_destroy_debugfs'
546 | void pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs)
| ^
./include/linux/pci.h:1918:1: note: previous definition is here
1918 | pcie_ptm_destroy_debugfs(struct pci_ptm_debugfs *ptm_debugfs) { }
| ^
This is with CONFIG_DEBUG_FS=n && CONFIG_PCIE_PTM=y.
- Eric