Re: [PATCH v2 2/2] PCI: cadence: Add debugfs property to provide LTSSM status of the PCIe link
From: Hans Zhang
Date: Sun Apr 05 2026 - 22:21:12 EST
On 4/5/26 00:30, Manivannan Sadhasivam wrote:
On Sat, Mar 21, 2026 at 11:30:35AM +0800, Hans Zhang wrote:
Add the debugfs property to provide a view of the current link's LTSSM
status from the Root Port device.
Test example:
# cat /sys/kernel/debug/cdns_pcie_a0c0000.pcie/ltssm_status
L0_STATE (0x29)
Signed-off-by: Hans Zhang <18255117159@xxxxxxx>
---
Documentation/ABI/testing/debugfs-cdns-pcie | 5 +
drivers/pci/controller/cadence/Kconfig | 9 +
drivers/pci/controller/cadence/Makefile | 1 +
.../controller/cadence/pcie-cadence-debugfs.c | 214 ++++++++++++++++++
.../pci/controller/cadence/pcie-cadence-ep.c | 2 +
.../cadence/pcie-cadence-host-hpa.c | 8 +-
.../controller/cadence/pcie-cadence-host.c | 8 +-
drivers/pci/controller/cadence/pcie-cadence.h | 145 ++++++++++++
8 files changed, 390 insertions(+), 2 deletions(-)
create mode 100644 Documentation/ABI/testing/debugfs-cdns-pcie
create mode 100644 drivers/pci/controller/cadence/pcie-cadence-debugfs.c
diff --git a/Documentation/ABI/testing/debugfs-cdns-pcie b/Documentation/ABI/testing/debugfs-cdns-pcie
new file mode 100644
index 000000000000..659ad2ab70e4
--- /dev/null
+++ b/Documentation/ABI/testing/debugfs-cdns-pcie
@@ -0,0 +1,5 @@
+What: /sys/kernel/debug/cdns_pcie_<dev>/ltssm_status
+Date: March 2026
+Contact: Hans Zhang <18255117159@xxxxxxx>
+Description: (RO) Read will return the current PCIe LTSSM state in both
+ string and raw value.
Entries should be aligned.
Hi Mani,
From my code, it seems to be that of it. The tab size is 8. And it was copied from the file /sys/kernel/debug/dwc_pcie_<dev>/ltssm_status in the Documentation/ABI/testing/debugfs-dwc-pcie directory that I previously submitted.
diff --git a/drivers/pci/controller/cadence/Kconfig b/drivers/pci/controller/cadence/Kconfig
index 9e651d545973..b277c5f6e196 100644
--- a/drivers/pci/controller/cadence/Kconfig
+++ b/drivers/pci/controller/cadence/Kconfig
@@ -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
diff --git a/drivers/pci/controller/cadence/Makefile b/drivers/pci/controller/cadence/Makefile
index b8ec1cecfaa8..2cdc4617e0c2 100644
--- a/drivers/pci/controller/cadence/Makefile
+++ b/drivers/pci/controller/cadence/Makefile
@@ -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
diff --git a/drivers/pci/controller/cadence/pcie-cadence-debugfs.c b/drivers/pci/controller/cadence/pcie-cadence-debugfs.c
new file mode 100644
index 000000000000..16addd919eae
--- /dev/null
+++ b/drivers/pci/controller/cadence/pcie-cadence-debugfs.c
@@ -0,0 +1,214 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Cadence PCIe controller debugfs driver
+ *
+ * Copyright (C) 2026 Hans Zhang <18255117159@xxxxxxx>
+ * Author: Hans Zhang <18255117159@xxxxxxx>
+ */
+
+#include <linux/debugfs.h>
+
+#include "pcie-cadence.h"
+
+#define CDNS_DEBUGFS_BUF_MAX 128
+#define CDNS_PCIE_LGA_LTSSM_STATUS_MASK GENMASK(29, 24)
+#define CDNS_PCIE_HPA_LTSSM_STATUS_MASK GENMASK(27, 20)
+
[...]
+static const struct file_operations cdns_pcie_ltssm_status_ops = {
+ .open = ltssm_status_open,
+ .read = seq_read,
+};
+
+static void cdns_pcie_ltssm_debugfs_init(struct cdns_pcie *pci, struct dentry *dir)
+{
+ debugfs_create_file("ltssm_status", 0444, dir, pci,
+ &cdns_pcie_ltssm_status_ops);
+}
+
+void cdns_pcie_debugfs_deinit(struct cdns_pcie *pci)
+{
+ if (!pci->debug_dir)
+ return;
+
+ debugfs_remove_recursive(pci->debug_dir);
+}
You've never called this API in any controller driver. So the debugfs entries
are not cleaned up properly.
If you do so, please export this function also.
Thank you for pointing out the issue. It seems that the call to cdns_pcie_debugfs_deinit was omitted, and it needs to be exported as well. It will be fixed in the next version.
Best regards,
Hans
- Mani