PCI: cadence: Add LTSSM debugfs
Subsystems (4)
Hans Zhang
maintainerv8 cover PCI: cadence: Add LTSSM debugfs
Hi,
This series adds debugfs support to the Cadence PCIe controller driver, allowing users to read the current LTSSM state of the link for debugging purposes.
Patch 1 introduces a new flag 'is_hpa' in the cdns_pcie structure to distinguish HPA (High Performance Architecture) IP platforms from LGA (Legacy Architecture) IP platforms, as they have different register layouts for LTSSM status.
Patch 2 implements the debugfs file "ltssm_status" for HPA IP under a per-device directory. It reads the LTSSM state from the appropriate hardware register based on the 'is_hpa' flag and displays both a descriptive string and the raw value.
Patch 3 adds LTSSM debugfs support for LGA IP, utilizing a new callback 'get_lga_ltssm' in cdns_pcie_ops to read the LTSSM state from the LGA register. The debugfs interface now supports both IP types seamlessly.
=====================
Test:
root@orangepi6plus:~# ls -l /sys/kernel/debug/cdns_pcie_a0* /sys/kernel/debug/cdns_pcie_a010000.pcie: total 0 -r--r--r-- 1 root root 0 Jan 1 1970 ltssm_status
/sys/kernel/debug/cdns_pcie_a0c0000.pcie:
total 0
-r--r--r-- 1 root root 0 Jan 1 1970 ltssm_status
/sys/kernel/debug/cdns_pcie_a0e0000.pcie:
total 0
-r--r--r-- 1 root root 0 Jan 1 1970 ltssm_status root@orangepi6plus:~# root@orangepi6plus:~#
root@orangepi6plus:~# cat /sys/kernel/debug/cdns_pcie_a0*/ltss* L0_STATE (0x29) L0_STATE (0x29) L0_STATE (0x29) root@orangepi6plus:~# root@orangepi6plus:~# uname -a Linux orangepi6plus 7.2.0-rc1-00011-g6cd225cbbadd #69 SMP PREEMPT Wed Jul 1 15:26:53 CST 2026 aarch64 aarch64 aarch64 GNUx =====================
---
Changes for v8:
- Rebase to v7.2-rc1.
- patch 0002 s/tristate "Cadence PCIe debugfs entries"/bool "Cadence PCIe debugfs entries"/ (Mani & Sashiko)
debugfs-cdns-pcie: s/March 2026/July 2026/
Changes for v7:
- patch 0002 add MODULE_LICENSE and MODULE_DESCRIPTION (Sashiko and Aksh)
- s/#ifdef CONFIG_PCIE_CADENCE_DEBUGFS/#if IS_ENABLED(CONFIG_PCIE_CADENCE_DEBUGFS)/ (Aksh)
- base on branch: controller/rescan_lock
Changes for v6:
- The LTSSM status of the LGA IP no longer contains the "LTSSM_" character. (Aksh)
Changes for v5:
- Split LGA and HPA LTSSM debugfs support into separate patches as they have different register definitions and access methods. (Aksh, Manikandan)
- Add cdns_pcie_hpa_host_disable() to properly clean up debugfs on removal (Mani)
- Remove redundant copyright email address (Mani)
Changes for v4:
- Remove the copyright email address of the author of pcie-cadence-debugfs.c (Mani)
- Add cdns_pcie_hpa_host_disable() (Mani)
- Use DEFINE_SHOW_ATTRIBUTE() (Mani & Sashiko)
Changes for v3:
- Export cdns_pcie_debugfs_deinit (Mani)
- pcie-cadence-ep.c pcie-cadence-host.c pci-sky1.c call cdns_pcie_debugfs_deinit
Changes for v2:
- s/DW_PCIE_LTSSM_NAME/CDNS_PCIE_LTSSM_NAME/
- S/January 2026/March 2026/
- EXPORT_SYMBOL_GPL(cdns_pcie_debugfs_init); // Resolve the following error issues.
Quoted 2 lines
Quoted 2 lines
ERROR: modpost: "
cdns_pcie_debugfs_init" [drivers/pci/controller/cadence/pcie-cadence-host-mod.ko] undefined!
ERROR: modpost: "cdns_pcie_debugfs_init" [drivers/pci/controller/cadence/pcie-cadence-ep-mod.ko] undefined!
v7:
https://patchwork.kernel.org/project/linux-pci/cover/[email protected]/
v6:
https://patchwork.kernel.org/project/linux-pci/cover/[email protected]/
v5:
https://patchwork.kernel.org/project/linux-pci/patch/[email protected]/
v4:
https://patchwork.kernel.org/project/linux-pci/patch/[email protected]/
v3:
https://patchwork.kernel.org/project/linux-pci/patch/[email protected]/
v2:
https://patchwork.kernel.org/project/linux-pci/patch/[email protected]/
v1:
https://patchwork.kernel.org/project/linux-pci/cover/[email protected]/
Hans Zhang (3):
PCI: cadence: Add HPA architecture flag
PCI: cadence: Add HPA IP debugfs for LTSSM status
PCI: cadence: Add LGA IP debugfs for LTSSM status
Documentation/ABI/testing/debugfs-cdns-pcie | 5 + drivers/pci/controller/cadence/Kconfig | 9 + drivers/pci/controller/cadence/Makefile | 1 + drivers/pci/controller/cadence/pci-sky1.c | 5 + .../controller/cadence/pcie-cadence-debugfs.c | 266 ++++++++++++++++++ .../pci/controller/cadence/pcie-cadence-ep.c | 3 + .../cadence/pcie-cadence-host-hpa.c | 21 +- .../controller/cadence/pcie-cadence-host.c | 9 +- drivers/pci/controller/cadence/pcie-cadence.h | 198 +++++++++++++ 9 files changed, 515 insertions(+), 2 deletions(-) create mode 100644 Documentation/ABI/testing/debugfs-cdns-pcie create mode 100644 drivers/pci/controller/cadence/pcie-cadence-debugfs.c
base-commit: 665159e246749578d4e4bfe106ee3b74edcdab18
Signature · 1 line
2.43.0
Hans Zhang
maintainerPATCH v8 1/3 PCI: cadence: Add HPA architecture flag
Add a boolean flag 'is_hpa' to the cdns_pcie structure to indicate that the controller is part of a Heterogeneous Processor Architecture (HPA) system. This flag will be used by subsequent patches to handle HPA-specific register layouts and behaviors.
--- drivers/pci/controller/cadence/pci-sky1.c | 1 + drivers/pci/controller/cadence/pcie-cadence.h | 2 ++ 2 files changed, 3 insertions(+)
drivers/pci/controller/cadence/pci-sky1.c +1 -0
@@ -174,6 +174,7 @@ static int sky1_pcie_probe(struct platform_device *pdev) cdns_pcie->reg_base = pcie->reg_base; cdns_pcie->msg_res = pcie->msg_res; cdns_pcie->is_rc = true; + cdns_pcie->is_hpa = true; reg_off =devm_kzalloc (dev,sizeof (*reg_off),GFP_KERNEL );if (!reg_off) {
drivers/pci/controller/cadence/pcie-cadence.h +2 -0
@@ -80,6 +80,7 @@ struct cdns_plat_pcie_of_data {* @msg_res: Region for send message to map PCI accesses * @dev: PCIe controller * @is_rc: tell whether the PCIe controller mode is Root Complex or Endpoint. +* @is_hpa: indicates if the architecture is HPA * @phy_count: number of supported PHY devices * @phy: list of pointers to specific PHY control blocks * @link: list of pointers to corresponding device link representations
@@ -94,6 +95,7 @@ struct cdns_pcie {struct resource *msg_res;struct device *dev;bool is_rc; +bool is_hpa;int phy_count;struct phy **phy;struct device_link **link;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v8 1/3] PCI: cadence: Add HPA architecture flag
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 6 lines
Add a boolean flag '
is_hpa' to thecdns_pciestructure to indicate that the controller is part of a Heterogeneous Processor Architecture (HPA) system. This flag will be used by subsequent patches to handle HPA-specific register layouts and behaviors.Signed-off-by Hans Zhang <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Hans Zhang
maintainerPATCH v8 2/3 PCI: cadence: Add HPA IP debugfs for LTSSM status
In reply to Hans ZhangAdd debugfs support for HPA-based Cadence PCIe controllers. A new file 'ltssm_status' is created under debugfs, allowing users to read the current LTSSM state as a string and raw value.
--- Documentation/ABI/testing/debugfs-cdns-pcie | 5 + drivers/pci/controller/cadence/Kconfig | 9 + drivers/pci/controller/cadence/Makefile | 1 + drivers/pci/controller/cadence/pci-sky1.c | 4 + .../controller/cadence/pcie-cadence-debugfs.c | 211 ++++++++++++++++++ .../cadence/pcie-cadence-host-hpa.c | 21 +- drivers/pci/controller/cadence/pcie-cadence.h | 153 +++++++++++++ 7 files changed, 403 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/debugfs-cdns-pcie create mode 100644 drivers/pci/controller/cadence/pcie-cadence-debugfs.c
Documentation/ABI/testing/debugfs-cdns-pcie new file +5 -0
@@ -0,0 +1,5 @@ +What: /sys/kernel/debug/cdns_pcie_<dev>/ltssm_status +Date: July 2026 +Contact: Hans Zhang <[email protected]> +Description: (RO) Read will return the current PCIe LTSSM state in both + string and raw value.
drivers/pci/controller/cadence/Kconfig +9 -0
@@ -6,6 +6,15 @@ menu "Cadence-based PCIe controllers" config PCIE_CADENCE tristate +config PCIE_CADENCE_DEBUGFS + bool "Cadence PCIe debugfs entries" + depends on DEBUG_FS + depends on PCIE_CADENCE_HOST || PCIE_CADENCE_EP + help + Say Y here to enable debugfs entries for the PCIe controller. These + entries provide various debug features related to the controller and + the LTSSM status of link can be displayed. + config PCIE_CADENCE_HOST tristate depends on OF
drivers/pci/controller/cadence/Makefile +1 -0
@@ -4,6 +4,7 @@ pcie-cadence-host-mod-y := pcie-cadence-host-common.o pcie-cadence-host.o pcie-c pcie-cadence-ep-mod-y := pcie-cadence-ep.o obj-$(CONFIG_PCIE_CADENCE) = pcie-cadence-mod.o +obj-$(CONFIG_PCIE_CADENCE_DEBUGFS) += pcie-cadence-debugfs.o obj-$(CONFIG_PCIE_CADENCE_HOST) += pcie-cadence-host-mod.o obj-$(CONFIG_PCIE_CADENCE_EP) += pcie-cadence-ep-mod.o obj-$(CONFIG_PCIE_CADENCE_PLAT) += pcie-cadence-plat.o
drivers/pci/controller/cadence/pci-sky1.c +4 -0
@@ -221,6 +221,10 @@ MODULE_DEVICE_TABLE(of, of_sky1_pcie_match);static void sky1_pcie_remove (struct platform_device *pdev) {struct sky1_pcie *pcie =platform_get_drvdata (pdev); +struct cdns_pcie_rc *rc; + + rc = container_of(pcie->cdns_pcie, struct cdns_pcie_rc, pcie); +cdns_pcie_hpa_host_disable (rc);pci_ecam_free (pcie->cfg); }
drivers/pci/controller/cadence/pcie-cadence-debugfs.c new file +211 -0
211 lines not on this page · raw message
drivers/pci/controller/cadence/pcie-cadence-host-hpa.c +20 -1
@@ -313,6 +313,19 @@ int cdns_pcie_hpa_host_link_setup(struct cdns_pcie_rc *rc) }EXPORT_SYMBOL_GPL (cdns_pcie_hpa_host_link_setup); +void cdns_pcie_hpa_host_disable (struct cdns_pcie_rc *rc) +{ +struct pci_host_bridge *bridge; + +cdns_pcie_debugfs_deinit (&rc->pcie); + bridge =pci_host_bridge_from_priv (rc); +pci_lock_rescan_remove (); +pci_stop_root_bus (bridge->bus); +pci_remove_root_bus (bridge->bus); +pci_unlock_rescan_remove (); +} +EXPORT_SYMBOL_GPL (cdns_pcie_hpa_host_disable); +int cdns_pcie_hpa_host_setup (struct cdns_pcie_rc *rc) {struct device *dev = rc->pcie.dev;
@@ -368,7 +381,13 @@ int cdns_pcie_hpa_host_setup(struct cdns_pcie_rc *rc)if (!bridge->ops) bridge->ops = &cdns_pcie_hpa_host_ops; -return pci_host_probe (bridge); + ret =pci_host_probe (bridge); +if (ret) +return ret; + +cdns_pcie_debugfs_init (pcie); + +return 0 ; }EXPORT_SYMBOL_GPL (cdns_pcie_hpa_host_setup);
drivers/pci/controller/cadence/pcie-cadence.h +153 -0
193 lines not on this page · raw message
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v8 2/3] PCI: cadence: Add HPA IP debugfs for LTSSM status
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Modpost link error when building Cadence drivers as modules due to an orphaned debugfs object. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Modpost link error when building Cadence drivers as modules due to an orphaned debugfs object. --
commit 98a72e00615e702fb5448b12d14570527e38b67f
Author: Hans Zhang <[email protected]>
PCI: cadence: Add HPA IP debugfs for LTSSM status
This commit adds debugfs support for HPA-based Cadence PCIe controllers, exposing the current LTSSM state through a new ltssm_status file.
drivers/pci/controller/cadence/Makefile pcie-cadence-host-mod-y := pcie-cadence-host-common.o pcie-cadence-host.o pcie-c · line 7
Quoted 9 lines
drivers/pci/controller/cadence/Makefile +1
-0@@ -4,6 +4,7 @@ pcie-cadence-host-mod-y := pcie-cadence-host-common.o pcie-cadence-host.o pcie-c pcie-cadence-ep-mod-y := pcie-cadence-ep.o obj-$(CONFIG_PCIE_CADENCE) = pcie-cadence-mod.o +obj-$(CONFIG_PCIE_CADENCE_DEBUGFS) += pcie-cadence-debugfs.o
[Severity: Low]
Will this cause a link error during modpost when building the Cadence drivers as modules?
Since CONFIG_PCIE_CADENCE_DEBUGFS is a boolean, this adds the object directly to obj-y instead of appending it to a composite module target like pcie-cadence-mod-y. When the driver is configured as a module (e.g., CONFIG_PCIE_CADENCE=m), the object is compiled but left unlinked.
Could this lead to undefined symbol errors for cdns_pcie_debugfs_init and cdns_pcie_debugfs_deinit in the caller modules?
Quoted 2 lines
drivers/pci/controller/cadence/Makefile +0
-0obj-$(CONFIG_PCIE_CADENCE_HOST) += pcie-cadence-host-mod.o obj-$(CONFIG_PCIE_CADENCE_EP) += pcie-cadence-ep-mod.o
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Manivannan Sadhasivam
maintainerRe: [PATCH v8 2/3] PCI: cadence: Add HPA IP debugfs for LTSSM status
Quoted 26 lines · On Wed, Jul 01, 2026 at 07:48:18AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Modpost link error when building Cadence drivers as modules due to an orphaned debugfs object. --commit
98a72e00615e702fb5448b12d14570527e38b67f
Author: Hans Zhang <[email protected]>PCI: cadence: Add HPA IP debugfs for LTSSM status
This commit adds debugfs support for HPA-based Cadence PCIe controllers, exposing the current LTSSM state through a new
ltssm_statusfile.drivers/pci/controller/cadence/Makefile pcie-cadence-host-mod-y := pcie-cadence-host-common.o pcie-cadence-host.o pcie-c · line 7
Quoted 9 lines
drivers/pci/controller/cadence/Makefile +1
-0@@ -4,6 +4,7 @@ pcie-cadence-host-mod-y := pcie-cadence-host-common.o pcie-cadence-host.o pcie-c pcie-cadence-ep-mod-y := pcie-cadence-ep.o obj-$(CONFIG_PCIE_CADENCE) = pcie-cadence-mod.o +obj-$(CONFIG_PCIE_CADENCE_DEBUGFS) += pcie-cadence-debugfs.o[Severity: Low]
Will this cause a link error during modpost when building the Cadence drivers as modules?
Quoted 8 lines
Since
CONFIG_PCIE_CADENCE_DEBUGFSis a boolean, this adds the object directly to obj-y instead of appending it to a composite module target like pcie-cadence-mod-y. When the driver is configured as a module (e.g.,CONFIG_PCIE_CADENCE=m), the object is compiled but left unlinked.Could this lead to undefined symbol errors for
cdns_pcie_debugfs_initandcdns_pcie_debugfs_deinitin the caller modules?
This is a real concern. So I fixed the Makefile with below change while applying:
drivers/pci/controller/cadence/Makefile +1 -0
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 pcie-cadence-mod-y := pcie-cadence-hpa.o pcie-cadence.o +pcie-cadence-mod-$(CONFIG_PCIE_CADENCE_DEBUGFS) += pcie-cadence-debugfs.o pcie-cadence-host-mod-y := pcie-cadence-host-common.o pcie-cadence-host.o pcie-cadence-host-hpa.o pcie-cadence-ep-mod-y := pcie-cadence-ep.o
This will ensure that the debugfs functions are always built into the 'pcie-cadence-mod*' object.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Hans Zhang
maintainerRe: [PATCH v8 2/3] PCI: cadence: Add HPA IP debugfs for LTSSM status
Quoted 50 lines · Manivannan Sadhasivam
Quoted 26 lines · On Wed, Jul 01, 2026 at 07:48:18AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Modpost link error when building Cadence drivers as modules due to an orphaned debugfs object. --commit
98a72e00615e702fb5448b12d14570527e38b67f
Author: Hans Zhang <[email protected]>PCI: cadence: Add HPA IP debugfs for LTSSM status
This commit adds debugfs support for HPA-based Cadence PCIe controllers, exposing the current LTSSM state through a new
ltssm_statusfile.drivers/pci/controller/cadence/Makefile pcie-cadence-host-mod-y := pcie-cadence-host-common.o pcie-cadence-host.o pcie-c · line 7
Quoted 9 lines
drivers/pci/controller/cadence/Makefile +1
-0@@ -4,6 +4,7 @@ pcie-cadence-host-mod-y := pcie-cadence-host-common.o pcie-cadence-host.o pcie-c pcie-cadence-ep-mod-y := pcie-cadence-ep.o obj-$(CONFIG_PCIE_CADENCE) = pcie-cadence-mod.o +obj-$(CONFIG_PCIE_CADENCE_DEBUGFS) += pcie-cadence-debugfs.o[Severity: Low]
Will this cause a link error during modpost when building the Cadence drivers as modules?Quoted 8 lines
Since
CONFIG_PCIE_CADENCE_DEBUGFSis a boolean, this adds the object directly to obj-y instead of appending it to a composite module target like pcie-cadence-mod-y. When the driver is configured as a module (e.g.,CONFIG_PCIE_CADENCE=m), the object is compiled but left unlinked.Could this lead to undefined symbol errors for
cdns_pcie_debugfs_initandcdns_pcie_debugfs_deinitin the caller modules?This is a real concern. So I fixed the
Makefilewith below change while applying:drivers/pci/controller/cadence/Makefile +1
-0@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 pcie-cadence-mod-y := pcie-cadence-hpa.o pcie-cadence.o +pcie-cadence-mod-$(CONFIG_PCIE_CADENCE_DEBUGFS) += pcie-cadence-debugfs.o pcie-cadence-host-mod-y := pcie-cadence-host-common.o pcie-cadence-host.o pcie-cadence-host-hpa.o pcie-cadence-ep-mod-y := pcie-cadence-ep.o
Quoted 3 lines
This will ensure that the debugfs functions are always built into the 'pcie-cadence-mod*' object.
Hello Mani,
Thank you very much.
Best regards,
Hans
Quoted 2 lines
- Mani
Hans Zhang
maintainerPATCH v8 3/3 PCI: cadence: Add LGA IP debugfs for LTSSM status
In reply to Hans ZhangExtend debugfs support to LGA-based Cadence PCIe controllers. The 'ltssm_status' file now works for both HPA and LGA IP by selecting the appropriate register access based on the 'is_hpa' flag.
--- .../controller/cadence/pcie-cadence-debugfs.c | 61 ++++++++++++++++++- .../pci/controller/cadence/pcie-cadence-ep.c | 3 + .../controller/cadence/pcie-cadence-host.c | 9 ++- drivers/pci/controller/cadence/pcie-cadence.h | 43 +++++++++++++ 4 files changed, 112 insertions(+), 4 deletions(-)
drivers/pci/controller/cadence/pcie-cadence-debugfs.c +58 -3
@@ -13,6 +13,58 @@#define CDNS_DEBUGFS_BUF_MAX 128 +static const char *cdns_pcie_lga_ltssm_status_string (enum cdns_pcie_lga_ltssm ltssm) +{ +const char *str; + +switch (ltssm) { +#define CDNS_PCIE_LGA_LTSSM_NAME (n) case n: str = #n; break +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_DETECT_QUIET ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_DETECT_ACTIVE ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_POLLING_ACTIVE ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_POLLING_COMPLIANCE ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_POLLING_CONFIGURATION ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_CONFIGURATION_LINKWIDTH_START ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_CONFIGURATION_LINKWIDTH_ACCEPT ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_CONFIGURATION_LANENUM_ACCEPT ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_CONFIGURATION_LANENUM_WAIT ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_CONFIGURATION_COMPLETE ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_CONFIGURATION_IDLE ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_RECOVERY_RCVRLOCK ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_RECOVERY_SPEED ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_RECOVERY_RCVRCFG ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_RECOVERY_IDLE ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_L0 ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_RX_L0S_ENTRY ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_RX_L0S_IDLE ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_RX_L0S_FTS ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_TX_L0S_ENTRY ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_TX_L0S_IDLE ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_TX_L0S_FTS ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_L1_ENTRY ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_L1_IDLE ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_L2_IDLE ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_L2_TRANSMITWAKE ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_DISABLED ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_LOOPBACK_ENTRY_MASTER ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_LOOPBACK_ACTIVE_MASTER ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_LOOPBACK_EXIT_MASTER ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_LOOPBACK_ENTRY_SLAVE ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_LOOPBACK_ACTIVE_SLAVE ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_LOOPBACK_EXIT_SLAVE ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_HOT_RESET ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_RECOVERY_EQUALIZATION_PHASE_0 ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_RECOVERY_EQUALIZATION_PHASE_1 ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_RECOVERY_EQUALIZATION_PHASE_2 ); +CDNS_PCIE_LGA_LTSSM_NAME (CDNS_PCIE_LGA_LTSSM_RECOVERY_EQUALIZATION_PHASE_3 ); +default : + str ="CDNS_PCIE_LGA_LTSSM_UNKNOWN" ; +break ; + } + +return str +strlen ("CDNS_PCIE_LGA_LTSSM_" ); +} +static const char *cdns_pcie_hpa_ltssm_status_string (enum cdns_pcie_hpa_ltssm ltssm) {const char *str;
@@ -158,6 +210,7 @@ static const char *cdns_pcie_hpa_ltssm_status_string(enum cdns_pcie_hpa_ltssm ltstatic int ltssm_status_show (struct seq_file *s,void *v) {struct cdns_pcie *pci = s->private; +enum cdns_pcie_lga_ltssm lga_ltssm;enum cdns_pcie_hpa_ltssm hpa_ltssm;const char *str_ltssm;u32 val;
@@ -168,11 +221,13 @@ static int ltssm_status_show(struct seq_file *s, void *v) hpa_ltssm =FIELD_GET (CDNS_PCIE_HPA_LTSSM_STATUS_MASK , val); str_ltssm =cdns_pcie_hpa_ltssm_status_string (hpa_ltssm); }else { -/* TODO: LGA IP*/ -return 0 ; + val =cdns_pcie_readl (pci,CDNS_PCIE_LM_BASE ); + lga_ltssm =FIELD_GET (CDNS_PCIE_LGA_LTSSM_STATUS_MASK , val); + str_ltssm =cdns_pcie_lga_ltssm_status_string (lga_ltssm); } -seq_printf (s,"%s (0x%02x)\n" , str_ltssm, hpa_ltssm); +seq_printf (s,"%s (0x%02x)\n" , str_ltssm, + pci->is_hpa ? hpa_ltssm : lga_ltssm);return 0 ; }
drivers/pci/controller/cadence/pcie-cadence-ep.c +3 -0
@@ -655,6 +655,7 @@ void cdns_pcie_ep_disable(struct cdns_pcie_ep *ep)struct device *dev = ep->pcie.dev;struct pci_epc *epc =to_pci_epc (dev); +cdns_pcie_debugfs_deinit (&ep->pcie);pci_epc_deinit_notify (epc);pci_epc_mem_free_addr (epc, ep->irq_phys_addr, ep->irq_cpu_addr,SZ_128K );
@@ -761,6 +762,8 @@ int cdns_pcie_ep_setup(struct cdns_pcie_ep *ep)pci_epc_init_notify (epc); +cdns_pcie_debugfs_init (pcie); +return 0 ; free_epc_mem:
drivers/pci/controller/cadence/pcie-cadence-host.c +8 -1
@@ -365,6 +365,7 @@ void cdns_pcie_host_disable(struct cdns_pcie_rc *rc) {struct pci_host_bridge *bridge; +cdns_pcie_debugfs_deinit (&rc->pcie); bridge =pci_host_bridge_from_priv (rc);pci_lock_rescan_remove ();pci_stop_root_bus (bridge->bus);
@@ -429,7 +430,13 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)if (!bridge->ops) bridge->ops = &cdns_pcie_host_ops; -return pci_host_probe (bridge); + ret =pci_host_probe (bridge); +if (ret) +return ret; + +cdns_pcie_debugfs_init (pcie); + +return 0 ; }EXPORT_SYMBOL_GPL (cdns_pcie_host_setup);
drivers/pci/controller/cadence/pcie-cadence.h +43 -0
55 lines not on this page · raw message
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v8 3/3] PCI: cadence: Add LGA IP debugfs for LTSSM status
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the to_pci_epc() macro is incorrectly applied to the platform device's dev object in cdns_pcie_ep_disable(), resulting in type confusion and bogus pointer dereference. --
commit 21d2761732f07216945992f2fa129395035e6bda
Author: Hans Zhang <[email protected]>
PCI: cadence: Add LGA IP debugfs for LTSSM status
This commit extends debugfs support to LGA-based Cadence PCIe controllers. It makes the ltssm_status file work for both HPA and LGA IPs by selecting the appropriate register access based on the is_hpa flag.
drivers/pci/controller/cadence/pcie-cadence-ep.c void cdns_pcie_ep_disable(struct cdns_pcie_ep *ep) · line 656
Quoted 7 lines
drivers/pci/controller/cadence/pcie-cadence-ep.c +0
-0@@ -655,6 +655,7 @@ void cdns_pcie_ep_disable(struct cdns_pcie_ep *ep)struct device *dev = ep->pcie.dev;struct pci_epc *epc =to_pci_epc (dev);
[Severity: High]
This is a pre-existing issue, but does this code pass the correct dev to to_pci_epc()?
Because ep->pcie.dev represents the parent platform device rather than the device object embedded inside struct pci_epc, the container_of calculation inside to_pci_epc() yields an incorrect address.
Will this garbage pointer subsequently passed to pci_epc_mem_free_addr() and pci_epc_mem_exit() cause an invalid memory access during device teardown?
Quoted 5 lines
drivers/pci/controller/cadence/pcie-cadence-ep.c +1
-0+cdns_pcie_debugfs_deinit (&ep->pcie);pci_epc_deinit_notify (epc);pci_epc_mem_free_addr (epc, ep->irq_phys_addr, ep->irq_cpu_addr,SZ_128K );
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Quoted 10 lines · Hans Zhang
This series adds debugfs support to the Cadence PCIe controller driver, allowing users to read the current LTSSM state of the link for debugging purposes.
Patch 1 introduces a new flag '
is_hpa' in thecdns_pciestructure to distinguish HPA (High Performance Architecture) IP platforms from LGA (Legacy Architecture) IP platforms, as they have different register layouts for LTSSM status.[...]
Applied, thanks!
[1/3] PCI: cadence: Add HPA architecture flag
commit: b5672f9463f2ee184730daaa5c43b9b5e8fb9f86
[2/3] PCI: cadence: Add HPA IP debugfs for LTSSM status
commit: ea34744eb0949c7b1e53aea579f5a3e2d2b88d63
[3/3] PCI: cadence: Add LGA IP debugfs for LTSSM status
commit: d70e964dc099821f6c159d8f40aa7be2c62ecfd2Best regards,
Signature · 1 line
மணிவண்ணன் சதாசிவம்