Message ID | 20250218-pcie-qcom-ptm-v1-0-16d7e480d73e@linaro.org (mailing list archive) |
---|---|
Headers | show |
Series | PCI: dwc: Add PTM sysfs support | expand |
On Tue, Feb 18, 2025 at 08:06:39PM +0530, Manivannan Sadhasivam via B4 Relay wrote: > Hi, > > This series adds sysfs support for PCIe PTM in Synopsys Designware IPs. > > First patch moves the common DWC struct definitions (dwc_pcie_vsec_id) to > include/pci/pcie-dwc.h from dwc-pcie-pmu driver. This allows reusing the same > definitions in pcie-designware-sysfs driver introduced in this series and also > in the debugfs series by Shradha [1]. > > Second patch adds support for searching the Vendor Specific Extended Capability > (VSEC) in the pcie-designware driver. This patch was originally based on > Shradha's patch [2], but modified to accept 'struct dwc_pcie_vsec_id' to avoid > iterating through the vsec_ids in the driver. > > Third patch adds the actual sysfs support for PTM in a new file > pcie-designware-sysfs.c built along with pcie-designware.c. > > Finally, fourth patch masks the PTM_UPDATING interrupt in the pcie-qcom-ep > driver to avoid processing the interrupt for each PTM context update. > > Testing > ======= > > This series is tested on Qcom SA8775p Ride Mx platform where one SA8775p acts as > RC and another as EP with following instructions: > > RC > -- > > $ echo 1 > /sys/devices/platform/1c10000.pcie/dwc/ptm/ptm_context_valid > > EP > -- > > $ echo auto > /sys/devices/platform/1c10000.pcie-ep/dwc/ptm/ptm_context_update > > $ cat /sys/devices/platform/1c10000.pcie-ep/dwc/ptm/ptm_local_clock > 159612570424 > > $ cat /sys/devices/platform/1c10000.pcie-ep/dwc/ptm/ptm_master_clock > 159609466232 > > $ cat /sys/devices/platform/1c10000.pcie-ep/dwc/ptm/ptm_t1 > 159609466112 > > $ cat /sys/devices/platform/1c10000.pcie-ep/dwc/ptm/ptm_t4 > 159609466518 I am not sure what real means by only show these number. It is quite similar to network 1588, ptp. There were already linux-ptp https://www.kernel.org/doc/html/v5.5/driver-api/ptp.html Can we use similar method to sync local timer to master? I think it is real purpuse of PTM. Frank > > NOTE: To make use of the PTM feature, the host PCIe client driver has to call > 'pci_enable_ptm()' API during probe. This series was tested with enabling PTM in > the MHI host driver with a local change (which will be upstreamed later). > Technically, PTM could also be enabled in the pci_endpoint_test driver, but I > didn't add the change as I'm not sure we'd want to add random PCIe features in > the test driver without corresponding code in pci-epf-test driver. > > Merging Strategy > ================ > > I'd like to have an ACK from the perf maintainers to take the whole series > through PCI tree. > > [1] https://lore.kernel.org/linux-pci/20250214105007.97582-1-shradha.t@samsung.com > [2] https://lore.kernel.org/linux-pci/20250214105007.97582-2-shradha.t@samsung.com > > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> > --- > Manivannan Sadhasivam (4): > perf/dwc_pcie: Move common DWC struct definitions to 'pcie-dwc.h' > PCI: dwc: Add helper to find the Vendor Specific Extended Capability (VSEC) > PCI: dwc: Add sysfs support for PTM > PCI: qcom-ep: Mask PTM_UPDATING interrupt > > Documentation/ABI/testing/sysfs-platform-dwc-pcie | 70 ++++++ > MAINTAINERS | 2 + > drivers/pci/controller/dwc/Makefile | 2 +- > drivers/pci/controller/dwc/pcie-designware-ep.c | 3 + > drivers/pci/controller/dwc/pcie-designware-host.c | 4 + > drivers/pci/controller/dwc/pcie-designware-sysfs.c | 278 +++++++++++++++++++++ > drivers/pci/controller/dwc/pcie-designware.c | 46 ++++ > drivers/pci/controller/dwc/pcie-designware.h | 22 ++ > drivers/pci/controller/dwc/pcie-qcom-ep.c | 8 + > drivers/perf/dwc_pcie_pmu.c | 23 +- > include/linux/pcie-dwc.h | 42 ++++ > 11 files changed, 478 insertions(+), 22 deletions(-) > --- > base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b > change-id: 20250218-pcie-qcom-ptm-bf6952f5c4e5 > > Best regards, > -- > Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> > >
On Tue, Feb 18, 2025 at 11:17:03AM -0500, Frank Li wrote: > On Tue, Feb 18, 2025 at 08:06:39PM +0530, Manivannan Sadhasivam via B4 Relay wrote: > > Hi, > > > > This series adds sysfs support for PCIe PTM in Synopsys Designware IPs. > > > > First patch moves the common DWC struct definitions (dwc_pcie_vsec_id) to > > include/pci/pcie-dwc.h from dwc-pcie-pmu driver. This allows reusing the same > > definitions in pcie-designware-sysfs driver introduced in this series and also > > in the debugfs series by Shradha [1]. > > > > Second patch adds support for searching the Vendor Specific Extended Capability > > (VSEC) in the pcie-designware driver. This patch was originally based on > > Shradha's patch [2], but modified to accept 'struct dwc_pcie_vsec_id' to avoid > > iterating through the vsec_ids in the driver. > > > > Third patch adds the actual sysfs support for PTM in a new file > > pcie-designware-sysfs.c built along with pcie-designware.c. > > > > Finally, fourth patch masks the PTM_UPDATING interrupt in the pcie-qcom-ep > > driver to avoid processing the interrupt for each PTM context update. > > > > Testing > > ======= > > > > This series is tested on Qcom SA8775p Ride Mx platform where one SA8775p acts as > > RC and another as EP with following instructions: > > > > RC > > -- > > > > $ echo 1 > /sys/devices/platform/1c10000.pcie/dwc/ptm/ptm_context_valid > > > > EP > > -- > > > > $ echo auto > /sys/devices/platform/1c10000.pcie-ep/dwc/ptm/ptm_context_update > > > > $ cat /sys/devices/platform/1c10000.pcie-ep/dwc/ptm/ptm_local_clock > > 159612570424 > > > > $ cat /sys/devices/platform/1c10000.pcie-ep/dwc/ptm/ptm_master_clock > > 159609466232 > > > > $ cat /sys/devices/platform/1c10000.pcie-ep/dwc/ptm/ptm_t1 > > 159609466112 > > > > $ cat /sys/devices/platform/1c10000.pcie-ep/dwc/ptm/ptm_t4 > > 159609466518 > > > I am not sure what real means by only show these number. These values are supposed to be consumed by the userspace applications to make sure that whether the PTM feature is working as expected or not. For instance, once the PTM dialog is established with PTM root, PTM requester's local clock should be synchronized with PTM master clock. And these can be verified using these sysfs attributes. > It is quite > similar to network 1588, ptp. There were already linux-ptp > https://www.kernel.org/doc/html/v5.5/driver-api/ptp.html > PTP and PTM are different even though both are meant to synchronize times across devices. PTM is limited to PCIe hierarchy and the actual synchronization is performed at the hw level, limited to PCIe clock source (core_clk in DWC terms). > Can we use similar method to sync local timer to master? I think it is real > purpuse of PTM. > Actual synchronization happens in the hardware itself as I explained above. Software is not intended to do anything (if not using any external master clock source) to synchronize the clocks. I think you are referring to synchronizing the global clock source (the one used by the kernel) of the endpoint based on PTM. But I don't think that is what intended by this feature. - Mani
Hi, This series adds sysfs support for PCIe PTM in Synopsys Designware IPs. First patch moves the common DWC struct definitions (dwc_pcie_vsec_id) to include/pci/pcie-dwc.h from dwc-pcie-pmu driver. This allows reusing the same definitions in pcie-designware-sysfs driver introduced in this series and also in the debugfs series by Shradha [1]. Second patch adds support for searching the Vendor Specific Extended Capability (VSEC) in the pcie-designware driver. This patch was originally based on Shradha's patch [2], but modified to accept 'struct dwc_pcie_vsec_id' to avoid iterating through the vsec_ids in the driver. Third patch adds the actual sysfs support for PTM in a new file pcie-designware-sysfs.c built along with pcie-designware.c. Finally, fourth patch masks the PTM_UPDATING interrupt in the pcie-qcom-ep driver to avoid processing the interrupt for each PTM context update. Testing ======= This series is tested on Qcom SA8775p Ride Mx platform where one SA8775p acts as RC and another as EP with following instructions: RC -- $ echo 1 > /sys/devices/platform/1c10000.pcie/dwc/ptm/ptm_context_valid EP -- $ echo auto > /sys/devices/platform/1c10000.pcie-ep/dwc/ptm/ptm_context_update $ cat /sys/devices/platform/1c10000.pcie-ep/dwc/ptm/ptm_local_clock 159612570424 $ cat /sys/devices/platform/1c10000.pcie-ep/dwc/ptm/ptm_master_clock 159609466232 $ cat /sys/devices/platform/1c10000.pcie-ep/dwc/ptm/ptm_t1 159609466112 $ cat /sys/devices/platform/1c10000.pcie-ep/dwc/ptm/ptm_t4 159609466518 NOTE: To make use of the PTM feature, the host PCIe client driver has to call 'pci_enable_ptm()' API during probe. This series was tested with enabling PTM in the MHI host driver with a local change (which will be upstreamed later). Technically, PTM could also be enabled in the pci_endpoint_test driver, but I didn't add the change as I'm not sure we'd want to add random PCIe features in the test driver without corresponding code in pci-epf-test driver. Merging Strategy ================ I'd like to have an ACK from the perf maintainers to take the whole series through PCI tree. [1] https://lore.kernel.org/linux-pci/20250214105007.97582-1-shradha.t@samsung.com [2] https://lore.kernel.org/linux-pci/20250214105007.97582-2-shradha.t@samsung.com Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> --- Manivannan Sadhasivam (4): perf/dwc_pcie: Move common DWC struct definitions to 'pcie-dwc.h' PCI: dwc: Add helper to find the Vendor Specific Extended Capability (VSEC) PCI: dwc: Add sysfs support for PTM PCI: qcom-ep: Mask PTM_UPDATING interrupt Documentation/ABI/testing/sysfs-platform-dwc-pcie | 70 ++++++ MAINTAINERS | 2 + drivers/pci/controller/dwc/Makefile | 2 +- drivers/pci/controller/dwc/pcie-designware-ep.c | 3 + drivers/pci/controller/dwc/pcie-designware-host.c | 4 + drivers/pci/controller/dwc/pcie-designware-sysfs.c | 278 +++++++++++++++++++++ drivers/pci/controller/dwc/pcie-designware.c | 46 ++++ drivers/pci/controller/dwc/pcie-designware.h | 22 ++ drivers/pci/controller/dwc/pcie-qcom-ep.c | 8 + drivers/perf/dwc_pcie_pmu.c | 23 +- include/linux/pcie-dwc.h | 42 ++++ 11 files changed, 478 insertions(+), 22 deletions(-) --- base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b change-id: 20250218-pcie-qcom-ptm-bf6952f5c4e5 Best regards,