mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

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. Part of the reason is that the spec doesn't define how the context information is exposed to the software and left it to the vendor implementation. So there is no standardized way to get access to the context information and each vendor have defined their own way. This commit adds debugfs support to expose the PTM context to userspace from both PCIe RC and EP controllers. Since the context information is exposed in a vendor specific way, the debugfs interface allows the controller drivers to implement callbacks for each attribute, to be called by the generic PTM driver. The 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@linaro.org> [kwilczynski: fix overflow issue reported by Dan Carpenter from https://lore.kernel.org/linux-pci/b41c1754-c6b7-4805-9f14-7c643d6c5304@suswa.mountain] Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> Link: https://patch.msgid.link/20250505-pcie-ptm-v4-1-02d26d51400b@linaro.org
70 lines
2.2 KiB
Text
70 lines
2.2 KiB
Text
What: /sys/kernel/debug/pcie_ptm_*/local_clock
|
|
Date: May 2025
|
|
Contact: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
|
Description:
|
|
(RO) PTM local clock in nanoseconds. Applicable for both Root
|
|
Complex and Endpoint controllers.
|
|
|
|
What: /sys/kernel/debug/pcie_ptm_*/master_clock
|
|
Date: May 2025
|
|
Contact: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
|
Description:
|
|
(RO) PTM master clock in nanoseconds. Applicable only for
|
|
Endpoint controllers.
|
|
|
|
What: /sys/kernel/debug/pcie_ptm_*/t1
|
|
Date: May 2025
|
|
Contact: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
|
Description:
|
|
(RO) PTM T1 timestamp in nanoseconds. Applicable only for
|
|
Endpoint controllers.
|
|
|
|
What: /sys/kernel/debug/pcie_ptm_*/t2
|
|
Date: May 2025
|
|
Contact: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
|
Description:
|
|
(RO) PTM T2 timestamp in nanoseconds. Applicable only for
|
|
Root Complex controllers.
|
|
|
|
What: /sys/kernel/debug/pcie_ptm_*/t3
|
|
Date: May 2025
|
|
Contact: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
|
Description:
|
|
(RO) PTM T3 timestamp in nanoseconds. Applicable only for
|
|
Root Complex controllers.
|
|
|
|
What: /sys/kernel/debug/pcie_ptm_*/t4
|
|
Date: May 2025
|
|
Contact: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
|
Description:
|
|
(RO) PTM T4 timestamp in nanoseconds. Applicable only for
|
|
Endpoint controllers.
|
|
|
|
What: /sys/kernel/debug/pcie_ptm_*/context_update
|
|
Date: May 2025
|
|
Contact: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
|
Description:
|
|
(RW) Control the PTM context update mode. Applicable only for
|
|
Endpoint controllers.
|
|
|
|
Following values are supported:
|
|
|
|
* auto = PTM context auto update trigger for every 10ms
|
|
|
|
* manual = PTM context manual update. Writing 'manual' to this
|
|
file triggers PTM context update (default)
|
|
|
|
What: /sys/kernel/debug/pcie_ptm_*/context_valid
|
|
Date: May 2025
|
|
Contact: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
|
Description:
|
|
(RW) Control the PTM context validity (local clock timing).
|
|
Applicable only for Root Complex controllers. PTM context is
|
|
invalidated by hardware if the Root Complex enters low power
|
|
mode or changes link frequency.
|
|
|
|
Following values are supported:
|
|
|
|
* 0 = PTM context invalid (default)
|
|
|
|
* 1 = PTM context valid
|