* [PATCH v4 0/3] PCI Controller event and LTSSM tracepoint support
@ 2026-01-22 2:02 Shawn Lin
2026-01-22 2:02 ` [PATCH v4 1/3] PCI: trace: Add PCI controller LTSSM transition tracepoint Shawn Lin
` (3 more replies)
0 siblings, 4 replies; 18+ messages in thread
From: Shawn Lin @ 2026-01-22 2:02 UTC (permalink / raw)
To: Manivannan Sadhasivam, Bjorn Helgaas
Cc: linux-rockchip, linux-pci, linux-trace-kernel, linux-doc,
Steven Rostedt, Masami Hiramatsu, Shawn Lin
This patch-set adds new pci controller event and LTSSM tracepoint used by host drivers
which provide LTSSM trace functionality. The first user is pcie-dw-rockchip with a 256
Bytes FIFO for recording LTSSM transition.
Testing
=========
This series was tested on RK3588/RK3588s EVB1 with NVMe SSD connected to PCIe3 and PCIe2
root ports.
echo 1 > /sys/kernel/debug/tracing/events/pci_controller/pcie_ltssm_state_transition/enable
cat /sys/kernel/debug/tracing/trace_pipe
# tracer: nop
#
# entries-in-buffer/entries-written: 64/64 #P:8
#
# _-----=> irqs-off/BH-disabled
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / _-=> migrate-disable
# |||| / delay
# TASK-PID CPU# ||||| TIMESTAMP FUNCTION
# | | | ||||| | |
kworker/0:0-9 [000] ..... 5.600194: pcie_ltssm_state_transition: dev: a40000000.pcie state: DETECT_ACT rate: Unknown
kworker/0:0-9 [000] ..... 5.600198: pcie_ltssm_state_transition: dev: a40000000.pcie state: DETECT_WAIT rate: Unknown
kworker/0:0-9 [000] ..... 5.600199: pcie_ltssm_state_transition: dev: a40000000.pcie state: DETECT_ACT rate: Unknown
kworker/0:0-9 [000] ..... 5.600201: pcie_ltssm_state_transition: dev: a40000000.pcie state: POLL_ACTIVE rate: Unknown
kworker/0:0-9 [000] ..... 5.600202: pcie_ltssm_state_transition: dev: a40000000.pcie state: POLL_CONFIG rate: Unknown
kworker/0:0-9 [000] ..... 5.600204: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_LINKWD_START rate: Unknown
kworker/0:0-9 [000] ..... 5.600206: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_LINKWD_ACEPT rate: Unknown
kworker/0:0-9 [000] ..... 5.600207: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_LANENUM_WAI rate: Unknown
kworker/0:0-9 [000] ..... 5.600208: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_LANENUM_ACEPT rate: Unknown
kworker/0:0-9 [000] ..... 5.600210: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_COMPLETE rate: Unknown
kworker/0:0-9 [000] ..... 5.600212: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_IDLE rate: Unknown
kworker/0:0-9 [000] ..... 5.600213: pcie_ltssm_state_transition: dev: a40000000.pcie state: L0 rate: 2.5 GT/s
kworker/0:0-9 [000] ..... 5.600214: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: Unknown
kworker/0:0-9 [000] ..... 5.600216: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_RCVRCFG rate: Unknown
kworker/0:0-9 [000] ..... 5.600217: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_SPEED rate: Unknown
kworker/0:0-9 [000] ..... 5.600218: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: Unknown
kworker/0:0-9 [000] ..... 5.600220: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_EQ1 rate: Unknown
kworker/0:0-9 [000] ..... 5.600221: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_EQ2 rate: 8.0 GT/s
kworker/0:0-9 [000] ..... 5.600222: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_EQ3 rate: 8.0 GT/s
kworker/0:0-9 [000] ..... 5.600224: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: 8.0 GT/s
kworker/0:0-9 [000] ..... 5.600225: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_RCVRCFG rate: 8.0 GT/s
kworker/0:0-9 [000] ..... 5.600226: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_IDLE rate: 8.0 GT/s
kworker/0:0-9 [000] ..... 5.600227: pcie_ltssm_state_transition: dev: a40000000.pcie state: L0 rate: 8.0 GT/s
kworker/0:0-9 [000] ..... 5.600228: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: 8.0 GT/s
kworker/0:0-9 [000] ..... 5.600229: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_RCVRCFG rate: 8.0 GT/s
kworker/0:0-9 [000] ..... 5.600231: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_IDLE rate: 8.0 GT/s
kworker/0:0-9 [000] ..... 5.600232: pcie_ltssm_state_transition: dev: a40000000.pcie state: L0 rate: 8.0 GT/s
kworker/0:0-9 [000] ..... 5.600233: pcie_ltssm_state_transition: dev: a40000000.pcie state: L123_SEND_EIDLE rate: 8.0 GT/s
kworker/0:0-9 [000] ..... 5.600234: pcie_ltssm_state_transition: dev: a40000000.pcie state: L1_IDLE rate: 8.0 GT/s
kworker/0:0-9 [000] ..... 5.600236: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: 8.0 GT/s
kworker/0:0-9 [000] ..... 5.600237: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_RCVRCFG rate: 8.0 GT/s
kworker/0:0-9 [000] ..... 5.600238: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_IDLE rate: 8.0 GT/s
kworker/0:0-9 [000] ..... 5.600239: pcie_ltssm_state_transition: dev: a40000000.pcie state: L0 rate: 8.0 GT/s
Changes in v4:
- use TRACE_EVENT_FN to notify when to start and stop the tracepoint,
and export pci_ltssm_tp_enabled() for host drivers to use
- skip trace if pci_ltssm_tp_enabled() is false.(Steven)
- wrap into 80 columns(Bjorn)
Changes in v3:
- add TRACE_DEFINE_ENUM for all enums(Steven Rostedt)
- Add toctree entry in Documentation/trace/index.rst(Bagas Sanjaya)
- fix mismatch section underline length(Bagas Sanjaya)
- Make example snippets in code block(Bagas Sanjaya)
- warp context into 80 columns and fix the file name(Bjorn)
- reorder variables(Mani)
- rename loop to i; rename en to enable(Mani)
- use FIELD_GET(Mani)
- add comment about how the FIFO works(Mani)
Changes in v2:
- use tracepoint
Shawn Lin (3):
PCI: trace: Add PCI controller LTSSM transition tracepoint
Documentation: tracing: Add PCI controller event documentation
PCI: dw-rockchip: Add pcie_ltssm_state_transition trace support
Documentation/trace/events-pci-controller.rst | 42 ++++++++++
Documentation/trace/index.rst | 1 +
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 111 ++++++++++++++++++++++++++
drivers/pci/trace.c | 20 +++++
include/linux/pci.h | 4 +
include/trace/events/pci_controller.h | 57 +++++++++++++
6 files changed, 235 insertions(+)
create mode 100644 Documentation/trace/events-pci-controller.rst
create mode 100644 include/trace/events/pci_controller.h
--
2.7.4
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v4 1/3] PCI: trace: Add PCI controller LTSSM transition tracepoint
2026-01-22 2:02 [PATCH v4 0/3] PCI Controller event and LTSSM tracepoint support Shawn Lin
@ 2026-01-22 2:02 ` Shawn Lin
2026-02-24 14:08 ` Steven Rostedt
2026-02-24 15:22 ` Ilpo Järvinen
2026-01-22 2:02 ` [PATCH v4 2/3] Documentation: tracing: Add PCI controller event documentation Shawn Lin
` (2 subsequent siblings)
3 siblings, 2 replies; 18+ messages in thread
From: Shawn Lin @ 2026-01-22 2:02 UTC (permalink / raw)
To: Manivannan Sadhasivam, Bjorn Helgaas
Cc: linux-rockchip, linux-pci, linux-trace-kernel, linux-doc,
Steven Rostedt, Masami Hiramatsu, Shawn Lin
Some platforms may provide LTSSM trace functionality, recording historical
LTSSM state transition information. This is very useful for debugging, such
as when certain devices cannot be recognized or link broken during test.
Implement the pci controller tracepoint for recording LTSSM and rate.
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
Changes in v4:
- use TRACE_EVENT_FN to notify when to start and stop the tracepoint,
and export pci_ltssm_tp_enabled() for host drivers to use
Changes in v3:
- add TRACE_DEFINE_ENUM for all enums(Steven Rostedt)
Changes in v2: None
drivers/pci/trace.c | 20 ++++++++++++
include/linux/pci.h | 4 +++
include/trace/events/pci_controller.h | 57 +++++++++++++++++++++++++++++++++++
3 files changed, 81 insertions(+)
create mode 100644 include/trace/events/pci_controller.h
diff --git a/drivers/pci/trace.c b/drivers/pci/trace.c
index cf11abc..d351a51 100644
--- a/drivers/pci/trace.c
+++ b/drivers/pci/trace.c
@@ -9,3 +9,23 @@
#define CREATE_TRACE_POINTS
#include <trace/events/pci.h>
+#include <trace/events/pci_controller.h>
+
+static atomic_t pcie_ltssm_tp_enabled = ATOMIC_INIT(0);
+
+bool pci_ltssm_tp_enabled(void)
+{
+ return atomic_read(&pcie_ltssm_tp_enabled) > 0;
+}
+EXPORT_SYMBOL(pci_ltssm_tp_enabled);
+
+int pci_ltssm_tp_reg(void)
+{
+ atomic_inc(&pcie_ltssm_tp_enabled);
+ return 0;
+}
+
+void pci_ltssm_tp_unreg(void)
+{
+ atomic_dec(&pcie_ltssm_tp_enabled);
+}
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e7cb527..ac25a3e 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -2770,6 +2770,10 @@ static inline struct eeh_dev *pci_dev_to_eeh_dev(struct pci_dev *pdev)
}
#endif
+#ifdef CONFIG_TRACING
+bool pci_ltssm_tp_enabled(void);
+#endif
+
void pci_add_dma_alias(struct pci_dev *dev, u8 devfn_from, unsigned nr_devfns);
bool pci_devs_are_dma_aliases(struct pci_dev *dev1, struct pci_dev *dev2);
int pci_for_each_dma_alias(struct pci_dev *pdev,
diff --git a/include/trace/events/pci_controller.h b/include/trace/events/pci_controller.h
new file mode 100644
index 0000000..db4a960
--- /dev/null
+++ b/include/trace/events/pci_controller.h
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM pci_controller
+
+#if !defined(_TRACE_HW_EVENT_PCI_CONTROLLER_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_HW_EVENT_PCI_CONTROLLER_H
+
+#include <uapi/linux/pci_regs.h>
+#include <linux/tracepoint.h>
+
+TRACE_DEFINE_ENUM(PCIE_SPEED_2_5GT);
+TRACE_DEFINE_ENUM(PCIE_SPEED_5_0GT);
+TRACE_DEFINE_ENUM(PCIE_SPEED_8_0GT);
+TRACE_DEFINE_ENUM(PCIE_SPEED_16_0GT);
+TRACE_DEFINE_ENUM(PCIE_SPEED_32_0GT);
+TRACE_DEFINE_ENUM(PCIE_SPEED_64_0GT);
+TRACE_DEFINE_ENUM(PCI_SPEED_UNKNOWN);
+
+extern int pci_ltssm_tp_reg(void);
+extern void pci_ltssm_tp_unreg(void);
+
+TRACE_EVENT_FN(pcie_ltssm_state_transition,
+ TP_PROTO(const char *dev_name, const char *state, u32 rate),
+ TP_ARGS(dev_name, state, rate),
+
+ TP_STRUCT__entry(
+ __string(dev_name, dev_name)
+ __string(state, state)
+ __field(u32, rate)
+ ),
+
+ TP_fast_assign(
+ __assign_str(dev_name);
+ __assign_str(state);
+ __entry->rate = rate;
+ ),
+
+ TP_printk("dev: %s state: %s rate: %s",
+ __get_str(dev_name), __get_str(state),
+ __print_symbolic(__entry->rate,
+ { PCIE_SPEED_2_5GT, "2.5 GT/s" },
+ { PCIE_SPEED_5_0GT, "5.0 GT/s" },
+ { PCIE_SPEED_8_0GT, "8.0 GT/s" },
+ { PCIE_SPEED_16_0GT, "16.0 GT/s" },
+ { PCIE_SPEED_32_0GT, "32.0 GT/s" },
+ { PCIE_SPEED_64_0GT, "64.0 GT/s" },
+ { PCI_SPEED_UNKNOWN, "Unknown" }
+ )
+ ),
+
+ pci_ltssm_tp_reg, pci_ltssm_tp_unreg
+);
+
+#endif /* _TRACE_HW_EVENT_PCI_CONTROLLER_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
--
2.7.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v4 2/3] Documentation: tracing: Add PCI controller event documentation
2026-01-22 2:02 [PATCH v4 0/3] PCI Controller event and LTSSM tracepoint support Shawn Lin
2026-01-22 2:02 ` [PATCH v4 1/3] PCI: trace: Add PCI controller LTSSM transition tracepoint Shawn Lin
@ 2026-01-22 2:02 ` Shawn Lin
2026-01-22 2:02 ` [PATCH v4 3/3] PCI: dw-rockchip: Add pcie_ltssm_state_transition trace support Shawn Lin
2026-02-11 13:13 ` [PATCH v4 0/3] PCI Controller event and LTSSM tracepoint support Shawn Lin
3 siblings, 0 replies; 18+ messages in thread
From: Shawn Lin @ 2026-01-22 2:02 UTC (permalink / raw)
To: Manivannan Sadhasivam, Bjorn Helgaas
Cc: linux-rockchip, linux-pci, linux-trace-kernel, linux-doc,
Steven Rostedt, Masami Hiramatsu, Shawn Lin
The available tracepoint, pcie_ltssm_state_transition, monitors the LTSSM state
transition for debugging purpose. Add description about it.
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
Changes in v4: None
Changes in v3:
- Add toctree entry in Documentation/trace/index.rst(Bagas Sanjaya)
- fix mismatch section underline length(Bagas Sanjaya)
- Make example snippets in code block(Bagas Sanjaya)
- warp context into 80 columns and fix the file name(Bjorn)
Changes in v2: None
Documentation/trace/events-pci-controller.rst | 42 +++++++++++++++++++++++++++
Documentation/trace/index.rst | 1 +
2 files changed, 43 insertions(+)
create mode 100644 Documentation/trace/events-pci-controller.rst
diff --git a/Documentation/trace/events-pci-controller.rst b/Documentation/trace/events-pci-controller.rst
new file mode 100644
index 0000000..cb9f715
--- /dev/null
+++ b/Documentation/trace/events-pci-controller.rst
@@ -0,0 +1,42 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+======================================
+Subsystem Trace Points: PCI Controller
+======================================
+
+Overview
+========
+The PCI controller tracing system provides tracepoints to monitor controller
+level information for debugging purpose. The events normally show up here:
+
+ /sys/kernel/tracing/events/pci_controller
+
+Cf. include/trace/events/pci_controller.h for the events definitions.
+
+Available Tracepoints
+=====================
+
+pcie_ltssm_state_transition
+---------------------------
+
+Monitors PCIe LTSSM state transition including state and rate information
+::
+
+ pcie_ltssm_state_transition "dev: %s state: %s rate: %s\n"
+
+**Parameters**:
+
+* ``dev`` - PCIe controller instance
+* ``state`` - PCIe LTSSM state
+* ``rate`` - PCIe date rate
+
+**Example Usage**:
+
+.. code-block:: shell
+
+ # Enable the tracepoint
+ echo 1 > /sys/kernel/debug/tracing/events/pci_controller/pcie_ltssm_state_transition/enable
+
+ # Monitor events (the following output is generated when a device is linking)
+ cat /sys/kernel/debug/tracing/trace_pipe
+ kworker/0:0-9 [000] ..... 5.600221: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_EQ2 rate: 8.0 GT/s
diff --git a/Documentation/trace/index.rst b/Documentation/trace/index.rst
index 0a40bfa..6101317 100644
--- a/Documentation/trace/index.rst
+++ b/Documentation/trace/index.rst
@@ -55,6 +55,7 @@ applications.
events-nmi
events-msr
events-pci
+ events-pci-controller
boottime-trace
histogram
histogram-design
--
2.7.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v4 3/3] PCI: dw-rockchip: Add pcie_ltssm_state_transition trace support
2026-01-22 2:02 [PATCH v4 0/3] PCI Controller event and LTSSM tracepoint support Shawn Lin
2026-01-22 2:02 ` [PATCH v4 1/3] PCI: trace: Add PCI controller LTSSM transition tracepoint Shawn Lin
2026-01-22 2:02 ` [PATCH v4 2/3] Documentation: tracing: Add PCI controller event documentation Shawn Lin
@ 2026-01-22 2:02 ` Shawn Lin
2026-02-24 14:11 ` Steven Rostedt
2026-02-11 13:13 ` [PATCH v4 0/3] PCI Controller event and LTSSM tracepoint support Shawn Lin
3 siblings, 1 reply; 18+ messages in thread
From: Shawn Lin @ 2026-01-22 2:02 UTC (permalink / raw)
To: Manivannan Sadhasivam, Bjorn Helgaas
Cc: linux-rockchip, linux-pci, linux-trace-kernel, linux-doc,
Steven Rostedt, Masami Hiramatsu, Shawn Lin
Rockchip platforms provide a 64x4 bytes debug FIFO to trace the
LTSSM history. Any LTSSM change will be recorded. It's useful
for debug purpose, for example link failure, etc.
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
Changes in v4:
- skip trace if pci_ltssm_tp_enabled() is false.(Steven)
- wrap into 80 columns(Bjorn)
Changes in v3:
- reorder variables(Mani)
- rename loop to i; rename en to enable(Mani)
- use FIELD_GET(Mani)
- add comment about how the FIFO works(Mani)
Changes in v2:
- use tracepoint
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 111 ++++++++++++++++++++++++++
1 file changed, 111 insertions(+)
diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
index 0fd7bb9..135326c 100644
--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
+++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -22,6 +22,8 @@
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/reset.h>
+#include <linux/workqueue.h>
+#include <trace/events/pci_controller.h>
#include "../../pci.h"
#include "pcie-designware.h"
@@ -73,6 +75,20 @@
#define PCIE_CLIENT_CDM_RASDES_TBA_L1_1 BIT(4)
#define PCIE_CLIENT_CDM_RASDES_TBA_L1_2 BIT(5)
+/* Debug FIFO information */
+#define PCIE_CLIENT_DBG_FIFO_MODE_CON 0x310
+#define PCIE_CLIENT_DBG_EN 0xffff0007
+#define PCIE_CLIENT_DBG_DIS 0xffff0000
+#define PCIE_CLIENT_DBG_FIFO_PTN_HIT_D0 0x320
+#define PCIE_CLIENT_DBG_FIFO_PTN_HIT_D1 0x324
+#define PCIE_CLIENT_DBG_FIFO_TRN_HIT_D0 0x328
+#define PCIE_CLIENT_DBG_FIFO_TRN_HIT_D1 0x32c
+#define PCIE_CLIENT_DBG_TRANSITION_DATA 0xffff0000
+#define PCIE_CLIENT_DBG_FIFO_STATUS 0x350
+#define PCIE_DBG_FIFO_RATE_MASK GENMASK(22, 20)
+#define PCIE_DBG_FIFO_L1SUB_MASK GENMASK(10, 8)
+#define PCIE_DBG_LTSSM_HISTORY_CNT 64
+
/* Hot Reset Control Register */
#define PCIE_CLIENT_HOT_RESET_CTRL 0x180
#define PCIE_LTSSM_APP_DLY2_EN BIT(1)
@@ -98,6 +114,7 @@ struct rockchip_pcie {
struct irq_domain *irq_domain;
const struct rockchip_pcie_of_data *data;
bool supports_clkreq;
+ struct delayed_work trace_work;
};
struct rockchip_pcie_of_data {
@@ -208,6 +225,96 @@ static enum dw_pcie_ltssm rockchip_pcie_get_ltssm(struct dw_pcie *pci)
return rockchip_pcie_get_ltssm_reg(rockchip) & PCIE_LTSSM_STATUS_MASK;
}
+#ifdef CONFIG_TRACING
+static void rockchip_pcie_ltssm_trace_work(struct work_struct *work)
+{
+ struct rockchip_pcie *rockchip = container_of(work,
+ struct rockchip_pcie,
+ trace_work.work);
+ struct dw_pcie *pci = &rockchip->pci;
+ enum dw_pcie_ltssm state;
+ u32 i, l1ss, prev_val = DW_PCIE_LTSSM_UNKNOWN, rate, val;
+
+ if (!pci_ltssm_tp_enabled())
+ goto skip_trace;
+
+ for (i = 0; i < PCIE_DBG_LTSSM_HISTORY_CNT; i++) {
+ val = rockchip_pcie_readl_apb(rockchip,
+ PCIE_CLIENT_DBG_FIFO_STATUS);
+ rate = FIELD_GET(PCIE_DBG_FIFO_RATE_MASK, val);
+ l1ss = FIELD_GET(PCIE_DBG_FIFO_L1SUB_MASK, val);
+ val = FIELD_GET(PCIE_LTSSM_STATUS_MASK, val);
+
+ /*
+ * Hardware Mechanism: The ring FIFO employs two tracking
+ * counters:
+ * - 'last-read-point': maintains the user's last read position
+ * - 'last-valid-point': tracks the HW's last state update
+ *
+ * Software Handling: When two consecutive LTSSM states are
+ * identical, it indicates invalid subsequent data in the FIFO.
+ * In this case, we skip the remaining entries. The dual counter
+ * design ensures that on the next state transition, reading can
+ * resume from the last user position.
+ */
+ if ((i > 0 && val == prev_val) || val > DW_PCIE_LTSSM_RCVRY_EQ3)
+ break;
+
+ state = prev_val = val;
+ if (val == DW_PCIE_LTSSM_L1_IDLE) {
+ if (l1ss == 2)
+ state = DW_PCIE_LTSSM_L1_2;
+ else if (l1ss == 1)
+ state = DW_PCIE_LTSSM_L1_1;
+ }
+
+ trace_pcie_ltssm_state_transition(dev_name(pci->dev),
+ dw_pcie_ltssm_status_string(state),
+ ((rate + 1) > pci->max_link_speed) ?
+ PCI_SPEED_UNKNOWN : PCIE_SPEED_2_5GT + rate);
+ }
+
+skip_trace:
+ schedule_delayed_work(&rockchip->trace_work, msecs_to_jiffies(5000));
+}
+
+static void rockchip_pcie_ltssm_trace(struct rockchip_pcie *rockchip,
+ bool enable)
+{
+ if (enable) {
+ rockchip_pcie_writel_apb(rockchip,
+ PCIE_CLIENT_DBG_TRANSITION_DATA,
+ PCIE_CLIENT_DBG_FIFO_PTN_HIT_D0);
+ rockchip_pcie_writel_apb(rockchip,
+ PCIE_CLIENT_DBG_TRANSITION_DATA,
+ PCIE_CLIENT_DBG_FIFO_PTN_HIT_D1);
+ rockchip_pcie_writel_apb(rockchip,
+ PCIE_CLIENT_DBG_TRANSITION_DATA,
+ PCIE_CLIENT_DBG_FIFO_TRN_HIT_D0);
+ rockchip_pcie_writel_apb(rockchip,
+ PCIE_CLIENT_DBG_TRANSITION_DATA,
+ PCIE_CLIENT_DBG_FIFO_TRN_HIT_D1);
+ rockchip_pcie_writel_apb(rockchip,
+ PCIE_CLIENT_DBG_EN,
+ PCIE_CLIENT_DBG_FIFO_MODE_CON);
+
+ INIT_DELAYED_WORK(&rockchip->trace_work,
+ rockchip_pcie_ltssm_trace_work);
+ schedule_delayed_work(&rockchip->trace_work, 0);
+ } else {
+ rockchip_pcie_writel_apb(rockchip,
+ PCIE_CLIENT_DBG_DIS,
+ PCIE_CLIENT_DBG_FIFO_MODE_CON);
+ cancel_delayed_work_sync(&rockchip->trace_work);
+ }
+}
+#else
+static void rockchip_pcie_ltssm_trace(struct rockchip_pcie *rockchip,
+ bool enable)
+{
+}
+#endif
+
static void rockchip_pcie_enable_ltssm(struct rockchip_pcie *rockchip)
{
rockchip_pcie_writel_apb(rockchip, PCIE_CLIENT_ENABLE_LTSSM,
@@ -291,6 +398,9 @@ static int rockchip_pcie_start_link(struct dw_pcie *pci)
* 100us as we don't know how long should the device need to reset.
*/
msleep(PCIE_T_PVPERL_MS);
+
+ rockchip_pcie_ltssm_trace(rockchip, true);
+
gpiod_set_value_cansleep(rockchip->rst_gpio, 1);
return 0;
@@ -301,6 +411,7 @@ static void rockchip_pcie_stop_link(struct dw_pcie *pci)
struct rockchip_pcie *rockchip = to_rockchip_pcie(pci);
rockchip_pcie_disable_ltssm(rockchip);
+ rockchip_pcie_ltssm_trace(rockchip, false);
}
static int rockchip_pcie_host_init(struct dw_pcie_rp *pp)
--
2.7.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v4 0/3] PCI Controller event and LTSSM tracepoint support
2026-01-22 2:02 [PATCH v4 0/3] PCI Controller event and LTSSM tracepoint support Shawn Lin
` (2 preceding siblings ...)
2026-01-22 2:02 ` [PATCH v4 3/3] PCI: dw-rockchip: Add pcie_ltssm_state_transition trace support Shawn Lin
@ 2026-02-11 13:13 ` Shawn Lin
2026-02-11 15:40 ` Manivannan Sadhasivam
3 siblings, 1 reply; 18+ messages in thread
From: Shawn Lin @ 2026-02-11 13:13 UTC (permalink / raw)
To: Manivannan Sadhasivam, Bjorn Helgaas
Cc: shawn.lin, linux-rockchip, linux-pci, linux-trace-kernel,
linux-doc, Steven Rostedt, Masami Hiramatsu
在 2026/01/22 星期四 10:02, Shawn Lin 写道:
> This patch-set adds new pci controller event and LTSSM tracepoint used by host drivers
> which provide LTSSM trace functionality. The first user is pcie-dw-rockchip with a 256
> Bytes FIFO for recording LTSSM transition.
>
Gentle ping...
> Testing
> =========
>
> This series was tested on RK3588/RK3588s EVB1 with NVMe SSD connected to PCIe3 and PCIe2
> root ports.
>
> echo 1 > /sys/kernel/debug/tracing/events/pci_controller/pcie_ltssm_state_transition/enable
> cat /sys/kernel/debug/tracing/trace_pipe
>
> # tracer: nop
> #
> # entries-in-buffer/entries-written: 64/64 #P:8
> #
> # _-----=> irqs-off/BH-disabled
> # / _----=> need-resched
> # | / _---=> hardirq/softirq
> # || / _--=> preempt-depth
> # ||| / _-=> migrate-disable
> # |||| / delay
> # TASK-PID CPU# ||||| TIMESTAMP FUNCTION
> # | | | ||||| | |
> kworker/0:0-9 [000] ..... 5.600194: pcie_ltssm_state_transition: dev: a40000000.pcie state: DETECT_ACT rate: Unknown
> kworker/0:0-9 [000] ..... 5.600198: pcie_ltssm_state_transition: dev: a40000000.pcie state: DETECT_WAIT rate: Unknown
> kworker/0:0-9 [000] ..... 5.600199: pcie_ltssm_state_transition: dev: a40000000.pcie state: DETECT_ACT rate: Unknown
> kworker/0:0-9 [000] ..... 5.600201: pcie_ltssm_state_transition: dev: a40000000.pcie state: POLL_ACTIVE rate: Unknown
> kworker/0:0-9 [000] ..... 5.600202: pcie_ltssm_state_transition: dev: a40000000.pcie state: POLL_CONFIG rate: Unknown
> kworker/0:0-9 [000] ..... 5.600204: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_LINKWD_START rate: Unknown
> kworker/0:0-9 [000] ..... 5.600206: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_LINKWD_ACEPT rate: Unknown
> kworker/0:0-9 [000] ..... 5.600207: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_LANENUM_WAI rate: Unknown
> kworker/0:0-9 [000] ..... 5.600208: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_LANENUM_ACEPT rate: Unknown
> kworker/0:0-9 [000] ..... 5.600210: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_COMPLETE rate: Unknown
> kworker/0:0-9 [000] ..... 5.600212: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_IDLE rate: Unknown
> kworker/0:0-9 [000] ..... 5.600213: pcie_ltssm_state_transition: dev: a40000000.pcie state: L0 rate: 2.5 GT/s
> kworker/0:0-9 [000] ..... 5.600214: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: Unknown
> kworker/0:0-9 [000] ..... 5.600216: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_RCVRCFG rate: Unknown
> kworker/0:0-9 [000] ..... 5.600217: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_SPEED rate: Unknown
> kworker/0:0-9 [000] ..... 5.600218: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: Unknown
> kworker/0:0-9 [000] ..... 5.600220: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_EQ1 rate: Unknown
> kworker/0:0-9 [000] ..... 5.600221: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_EQ2 rate: 8.0 GT/s
> kworker/0:0-9 [000] ..... 5.600222: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_EQ3 rate: 8.0 GT/s
> kworker/0:0-9 [000] ..... 5.600224: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: 8.0 GT/s
> kworker/0:0-9 [000] ..... 5.600225: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_RCVRCFG rate: 8.0 GT/s
> kworker/0:0-9 [000] ..... 5.600226: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_IDLE rate: 8.0 GT/s
> kworker/0:0-9 [000] ..... 5.600227: pcie_ltssm_state_transition: dev: a40000000.pcie state: L0 rate: 8.0 GT/s
> kworker/0:0-9 [000] ..... 5.600228: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: 8.0 GT/s
> kworker/0:0-9 [000] ..... 5.600229: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_RCVRCFG rate: 8.0 GT/s
> kworker/0:0-9 [000] ..... 5.600231: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_IDLE rate: 8.0 GT/s
> kworker/0:0-9 [000] ..... 5.600232: pcie_ltssm_state_transition: dev: a40000000.pcie state: L0 rate: 8.0 GT/s
> kworker/0:0-9 [000] ..... 5.600233: pcie_ltssm_state_transition: dev: a40000000.pcie state: L123_SEND_EIDLE rate: 8.0 GT/s
> kworker/0:0-9 [000] ..... 5.600234: pcie_ltssm_state_transition: dev: a40000000.pcie state: L1_IDLE rate: 8.0 GT/s
> kworker/0:0-9 [000] ..... 5.600236: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: 8.0 GT/s
> kworker/0:0-9 [000] ..... 5.600237: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_RCVRCFG rate: 8.0 GT/s
> kworker/0:0-9 [000] ..... 5.600238: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_IDLE rate: 8.0 GT/s
> kworker/0:0-9 [000] ..... 5.600239: pcie_ltssm_state_transition: dev: a40000000.pcie state: L0 rate: 8.0 GT/s
>
>
> Changes in v4:
> - use TRACE_EVENT_FN to notify when to start and stop the tracepoint,
> and export pci_ltssm_tp_enabled() for host drivers to use
> - skip trace if pci_ltssm_tp_enabled() is false.(Steven)
> - wrap into 80 columns(Bjorn)
>
> Changes in v3:
> - add TRACE_DEFINE_ENUM for all enums(Steven Rostedt)
> - Add toctree entry in Documentation/trace/index.rst(Bagas Sanjaya)
> - fix mismatch section underline length(Bagas Sanjaya)
> - Make example snippets in code block(Bagas Sanjaya)
> - warp context into 80 columns and fix the file name(Bjorn)
> - reorder variables(Mani)
> - rename loop to i; rename en to enable(Mani)
> - use FIELD_GET(Mani)
> - add comment about how the FIFO works(Mani)
>
> Changes in v2:
> - use tracepoint
>
> Shawn Lin (3):
> PCI: trace: Add PCI controller LTSSM transition tracepoint
> Documentation: tracing: Add PCI controller event documentation
> PCI: dw-rockchip: Add pcie_ltssm_state_transition trace support
>
> Documentation/trace/events-pci-controller.rst | 42 ++++++++++
> Documentation/trace/index.rst | 1 +
> drivers/pci/controller/dwc/pcie-dw-rockchip.c | 111 ++++++++++++++++++++++++++
> drivers/pci/trace.c | 20 +++++
> include/linux/pci.h | 4 +
> include/trace/events/pci_controller.h | 57 +++++++++++++
> 6 files changed, 235 insertions(+)
> create mode 100644 Documentation/trace/events-pci-controller.rst
> create mode 100644 include/trace/events/pci_controller.h
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 0/3] PCI Controller event and LTSSM tracepoint support
2026-02-11 13:13 ` [PATCH v4 0/3] PCI Controller event and LTSSM tracepoint support Shawn Lin
@ 2026-02-11 15:40 ` Manivannan Sadhasivam
2026-02-24 8:49 ` Shawn Lin
0 siblings, 1 reply; 18+ messages in thread
From: Manivannan Sadhasivam @ 2026-02-11 15:40 UTC (permalink / raw)
To: Shawn Lin
Cc: Bjorn Helgaas, linux-rockchip, linux-pci, linux-trace-kernel,
linux-doc, Steven Rostedt, Masami Hiramatsu
On Wed, Feb 11, 2026 at 09:13:50PM +0800, Shawn Lin wrote:
> 在 2026/01/22 星期四 10:02, Shawn Lin 写道:
> > This patch-set adds new pci controller event and LTSSM tracepoint used by host drivers
> > which provide LTSSM trace functionality. The first user is pcie-dw-rockchip with a 256
> > Bytes FIFO for recording LTSSM transition.
> >
>
> Gentle ping...
>
Merge window is open now, so we can't accept any patches until -rc1. And I'm
also waiting for an Ack from Steven for the tracing part.
- Mani
> > Testing
> > =========
> >
> > This series was tested on RK3588/RK3588s EVB1 with NVMe SSD connected to PCIe3 and PCIe2
> > root ports.
> >
> > echo 1 > /sys/kernel/debug/tracing/events/pci_controller/pcie_ltssm_state_transition/enable
> > cat /sys/kernel/debug/tracing/trace_pipe
> >
> > # tracer: nop
> > #
> > # entries-in-buffer/entries-written: 64/64 #P:8
> > #
> > # _-----=> irqs-off/BH-disabled
> > # / _----=> need-resched
> > # | / _---=> hardirq/softirq
> > # || / _--=> preempt-depth
> > # ||| / _-=> migrate-disable
> > # |||| / delay
> > # TASK-PID CPU# ||||| TIMESTAMP FUNCTION
> > # | | | ||||| | |
> > kworker/0:0-9 [000] ..... 5.600194: pcie_ltssm_state_transition: dev: a40000000.pcie state: DETECT_ACT rate: Unknown
> > kworker/0:0-9 [000] ..... 5.600198: pcie_ltssm_state_transition: dev: a40000000.pcie state: DETECT_WAIT rate: Unknown
> > kworker/0:0-9 [000] ..... 5.600199: pcie_ltssm_state_transition: dev: a40000000.pcie state: DETECT_ACT rate: Unknown
> > kworker/0:0-9 [000] ..... 5.600201: pcie_ltssm_state_transition: dev: a40000000.pcie state: POLL_ACTIVE rate: Unknown
> > kworker/0:0-9 [000] ..... 5.600202: pcie_ltssm_state_transition: dev: a40000000.pcie state: POLL_CONFIG rate: Unknown
> > kworker/0:0-9 [000] ..... 5.600204: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_LINKWD_START rate: Unknown
> > kworker/0:0-9 [000] ..... 5.600206: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_LINKWD_ACEPT rate: Unknown
> > kworker/0:0-9 [000] ..... 5.600207: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_LANENUM_WAI rate: Unknown
> > kworker/0:0-9 [000] ..... 5.600208: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_LANENUM_ACEPT rate: Unknown
> > kworker/0:0-9 [000] ..... 5.600210: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_COMPLETE rate: Unknown
> > kworker/0:0-9 [000] ..... 5.600212: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_IDLE rate: Unknown
> > kworker/0:0-9 [000] ..... 5.600213: pcie_ltssm_state_transition: dev: a40000000.pcie state: L0 rate: 2.5 GT/s
> > kworker/0:0-9 [000] ..... 5.600214: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: Unknown
> > kworker/0:0-9 [000] ..... 5.600216: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_RCVRCFG rate: Unknown
> > kworker/0:0-9 [000] ..... 5.600217: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_SPEED rate: Unknown
> > kworker/0:0-9 [000] ..... 5.600218: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: Unknown
> > kworker/0:0-9 [000] ..... 5.600220: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_EQ1 rate: Unknown
> > kworker/0:0-9 [000] ..... 5.600221: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_EQ2 rate: 8.0 GT/s
> > kworker/0:0-9 [000] ..... 5.600222: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_EQ3 rate: 8.0 GT/s
> > kworker/0:0-9 [000] ..... 5.600224: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: 8.0 GT/s
> > kworker/0:0-9 [000] ..... 5.600225: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_RCVRCFG rate: 8.0 GT/s
> > kworker/0:0-9 [000] ..... 5.600226: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_IDLE rate: 8.0 GT/s
> > kworker/0:0-9 [000] ..... 5.600227: pcie_ltssm_state_transition: dev: a40000000.pcie state: L0 rate: 8.0 GT/s
> > kworker/0:0-9 [000] ..... 5.600228: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: 8.0 GT/s
> > kworker/0:0-9 [000] ..... 5.600229: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_RCVRCFG rate: 8.0 GT/s
> > kworker/0:0-9 [000] ..... 5.600231: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_IDLE rate: 8.0 GT/s
> > kworker/0:0-9 [000] ..... 5.600232: pcie_ltssm_state_transition: dev: a40000000.pcie state: L0 rate: 8.0 GT/s
> > kworker/0:0-9 [000] ..... 5.600233: pcie_ltssm_state_transition: dev: a40000000.pcie state: L123_SEND_EIDLE rate: 8.0 GT/s
> > kworker/0:0-9 [000] ..... 5.600234: pcie_ltssm_state_transition: dev: a40000000.pcie state: L1_IDLE rate: 8.0 GT/s
> > kworker/0:0-9 [000] ..... 5.600236: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: 8.0 GT/s
> > kworker/0:0-9 [000] ..... 5.600237: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_RCVRCFG rate: 8.0 GT/s
> > kworker/0:0-9 [000] ..... 5.600238: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_IDLE rate: 8.0 GT/s
> > kworker/0:0-9 [000] ..... 5.600239: pcie_ltssm_state_transition: dev: a40000000.pcie state: L0 rate: 8.0 GT/s
> >
> >
> > Changes in v4:
> > - use TRACE_EVENT_FN to notify when to start and stop the tracepoint,
> > and export pci_ltssm_tp_enabled() for host drivers to use
> > - skip trace if pci_ltssm_tp_enabled() is false.(Steven)
> > - wrap into 80 columns(Bjorn)
> >
> > Changes in v3:
> > - add TRACE_DEFINE_ENUM for all enums(Steven Rostedt)
> > - Add toctree entry in Documentation/trace/index.rst(Bagas Sanjaya)
> > - fix mismatch section underline length(Bagas Sanjaya)
> > - Make example snippets in code block(Bagas Sanjaya)
> > - warp context into 80 columns and fix the file name(Bjorn)
> > - reorder variables(Mani)
> > - rename loop to i; rename en to enable(Mani)
> > - use FIELD_GET(Mani)
> > - add comment about how the FIFO works(Mani)
> >
> > Changes in v2:
> > - use tracepoint
> >
> > Shawn Lin (3):
> > PCI: trace: Add PCI controller LTSSM transition tracepoint
> > Documentation: tracing: Add PCI controller event documentation
> > PCI: dw-rockchip: Add pcie_ltssm_state_transition trace support
> >
> > Documentation/trace/events-pci-controller.rst | 42 ++++++++++
> > Documentation/trace/index.rst | 1 +
> > drivers/pci/controller/dwc/pcie-dw-rockchip.c | 111 ++++++++++++++++++++++++++
> > drivers/pci/trace.c | 20 +++++
> > include/linux/pci.h | 4 +
> > include/trace/events/pci_controller.h | 57 +++++++++++++
> > 6 files changed, 235 insertions(+)
> > create mode 100644 Documentation/trace/events-pci-controller.rst
> > create mode 100644 include/trace/events/pci_controller.h
> >
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 0/3] PCI Controller event and LTSSM tracepoint support
2026-02-11 15:40 ` Manivannan Sadhasivam
@ 2026-02-24 8:49 ` Shawn Lin
2026-02-24 14:06 ` Steven Rostedt
0 siblings, 1 reply; 18+ messages in thread
From: Shawn Lin @ 2026-02-24 8:49 UTC (permalink / raw)
To: Steven Rostedt
Cc: shawn.lin, Bjorn Helgaas, linux-rockchip, linux-pci,
linux-trace-kernel, linux-doc, Masami Hiramatsu,
Manivannan Sadhasivam
Hi Steven,
在 2026/02/11 星期三 23:40, Manivannan Sadhasivam 写道:
> On Wed, Feb 11, 2026 at 09:13:50PM +0800, Shawn Lin wrote:
>> 在 2026/01/22 星期四 10:02, Shawn Lin 写道:
>>> This patch-set adds new pci controller event and LTSSM tracepoint used by host drivers
>>> which provide LTSSM trace functionality. The first user is pcie-dw-rockchip with a 256
>>> Bytes FIFO for recording LTSSM transition.
>>>
>>
>> Gentle ping...
>>
>
> Merge window is open now, so we can't accept any patches until -rc1. And I'm
> also waiting for an Ack from Steven for the tracing part.
>
I'd appreciate it if you could share any concerns you might have about
v4. :)
Thanks.
> - Mani
>
>>> Testing
>>> =========
>>>
>>> This series was tested on RK3588/RK3588s EVB1 with NVMe SSD connected to PCIe3 and PCIe2
>>> root ports.
>>>
>>> echo 1 > /sys/kernel/debug/tracing/events/pci_controller/pcie_ltssm_state_transition/enable
>>> cat /sys/kernel/debug/tracing/trace_pipe
>>>
>>> # tracer: nop
>>> #
>>> # entries-in-buffer/entries-written: 64/64 #P:8
>>> #
>>> # _-----=> irqs-off/BH-disabled
>>> # / _----=> need-resched
>>> # | / _---=> hardirq/softirq
>>> # || / _--=> preempt-depth
>>> # ||| / _-=> migrate-disable
>>> # |||| / delay
>>> # TASK-PID CPU# ||||| TIMESTAMP FUNCTION
>>> # | | | ||||| | |
>>> kworker/0:0-9 [000] ..... 5.600194: pcie_ltssm_state_transition: dev: a40000000.pcie state: DETECT_ACT rate: Unknown
>>> kworker/0:0-9 [000] ..... 5.600198: pcie_ltssm_state_transition: dev: a40000000.pcie state: DETECT_WAIT rate: Unknown
>>> kworker/0:0-9 [000] ..... 5.600199: pcie_ltssm_state_transition: dev: a40000000.pcie state: DETECT_ACT rate: Unknown
>>> kworker/0:0-9 [000] ..... 5.600201: pcie_ltssm_state_transition: dev: a40000000.pcie state: POLL_ACTIVE rate: Unknown
>>> kworker/0:0-9 [000] ..... 5.600202: pcie_ltssm_state_transition: dev: a40000000.pcie state: POLL_CONFIG rate: Unknown
>>> kworker/0:0-9 [000] ..... 5.600204: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_LINKWD_START rate: Unknown
>>> kworker/0:0-9 [000] ..... 5.600206: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_LINKWD_ACEPT rate: Unknown
>>> kworker/0:0-9 [000] ..... 5.600207: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_LANENUM_WAI rate: Unknown
>>> kworker/0:0-9 [000] ..... 5.600208: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_LANENUM_ACEPT rate: Unknown
>>> kworker/0:0-9 [000] ..... 5.600210: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_COMPLETE rate: Unknown
>>> kworker/0:0-9 [000] ..... 5.600212: pcie_ltssm_state_transition: dev: a40000000.pcie state: CFG_IDLE rate: Unknown
>>> kworker/0:0-9 [000] ..... 5.600213: pcie_ltssm_state_transition: dev: a40000000.pcie state: L0 rate: 2.5 GT/s
>>> kworker/0:0-9 [000] ..... 5.600214: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: Unknown
>>> kworker/0:0-9 [000] ..... 5.600216: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_RCVRCFG rate: Unknown
>>> kworker/0:0-9 [000] ..... 5.600217: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_SPEED rate: Unknown
>>> kworker/0:0-9 [000] ..... 5.600218: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: Unknown
>>> kworker/0:0-9 [000] ..... 5.600220: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_EQ1 rate: Unknown
>>> kworker/0:0-9 [000] ..... 5.600221: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_EQ2 rate: 8.0 GT/s
>>> kworker/0:0-9 [000] ..... 5.600222: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_EQ3 rate: 8.0 GT/s
>>> kworker/0:0-9 [000] ..... 5.600224: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: 8.0 GT/s
>>> kworker/0:0-9 [000] ..... 5.600225: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_RCVRCFG rate: 8.0 GT/s
>>> kworker/0:0-9 [000] ..... 5.600226: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_IDLE rate: 8.0 GT/s
>>> kworker/0:0-9 [000] ..... 5.600227: pcie_ltssm_state_transition: dev: a40000000.pcie state: L0 rate: 8.0 GT/s
>>> kworker/0:0-9 [000] ..... 5.600228: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: 8.0 GT/s
>>> kworker/0:0-9 [000] ..... 5.600229: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_RCVRCFG rate: 8.0 GT/s
>>> kworker/0:0-9 [000] ..... 5.600231: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_IDLE rate: 8.0 GT/s
>>> kworker/0:0-9 [000] ..... 5.600232: pcie_ltssm_state_transition: dev: a40000000.pcie state: L0 rate: 8.0 GT/s
>>> kworker/0:0-9 [000] ..... 5.600233: pcie_ltssm_state_transition: dev: a40000000.pcie state: L123_SEND_EIDLE rate: 8.0 GT/s
>>> kworker/0:0-9 [000] ..... 5.600234: pcie_ltssm_state_transition: dev: a40000000.pcie state: L1_IDLE rate: 8.0 GT/s
>>> kworker/0:0-9 [000] ..... 5.600236: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_LOCK rate: 8.0 GT/s
>>> kworker/0:0-9 [000] ..... 5.600237: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_RCVRCFG rate: 8.0 GT/s
>>> kworker/0:0-9 [000] ..... 5.600238: pcie_ltssm_state_transition: dev: a40000000.pcie state: RCVRY_IDLE rate: 8.0 GT/s
>>> kworker/0:0-9 [000] ..... 5.600239: pcie_ltssm_state_transition: dev: a40000000.pcie state: L0 rate: 8.0 GT/s
>>>
>>>
>>> Changes in v4:
>>> - use TRACE_EVENT_FN to notify when to start and stop the tracepoint,
>>> and export pci_ltssm_tp_enabled() for host drivers to use
>>> - skip trace if pci_ltssm_tp_enabled() is false.(Steven)
>>> - wrap into 80 columns(Bjorn)
>>>
>>> Changes in v3:
>>> - add TRACE_DEFINE_ENUM for all enums(Steven Rostedt)
>>> - Add toctree entry in Documentation/trace/index.rst(Bagas Sanjaya)
>>> - fix mismatch section underline length(Bagas Sanjaya)
>>> - Make example snippets in code block(Bagas Sanjaya)
>>> - warp context into 80 columns and fix the file name(Bjorn)
>>> - reorder variables(Mani)
>>> - rename loop to i; rename en to enable(Mani)
>>> - use FIELD_GET(Mani)
>>> - add comment about how the FIFO works(Mani)
>>>
>>> Changes in v2:
>>> - use tracepoint
>>>
>>> Shawn Lin (3):
>>> PCI: trace: Add PCI controller LTSSM transition tracepoint
>>> Documentation: tracing: Add PCI controller event documentation
>>> PCI: dw-rockchip: Add pcie_ltssm_state_transition trace support
>>>
>>> Documentation/trace/events-pci-controller.rst | 42 ++++++++++
>>> Documentation/trace/index.rst | 1 +
>>> drivers/pci/controller/dwc/pcie-dw-rockchip.c | 111 ++++++++++++++++++++++++++
>>> drivers/pci/trace.c | 20 +++++
>>> include/linux/pci.h | 4 +
>>> include/trace/events/pci_controller.h | 57 +++++++++++++
>>> 6 files changed, 235 insertions(+)
>>> create mode 100644 Documentation/trace/events-pci-controller.rst
>>> create mode 100644 include/trace/events/pci_controller.h
>>>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 0/3] PCI Controller event and LTSSM tracepoint support
2026-02-24 8:49 ` Shawn Lin
@ 2026-02-24 14:06 ` Steven Rostedt
0 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2026-02-24 14:06 UTC (permalink / raw)
To: Shawn Lin
Cc: Bjorn Helgaas, linux-rockchip, linux-pci, linux-trace-kernel,
linux-doc, Masami Hiramatsu, Manivannan Sadhasivam
On Tue, 24 Feb 2026 16:49:47 +0800
Shawn Lin <shawn.lin@rock-chips.com> wrote:
> I'd appreciate it if you could share any concerns you might have about
> v4. :)
Sure. I'll reply to the patches.
-- Steve
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 1/3] PCI: trace: Add PCI controller LTSSM transition tracepoint
2026-01-22 2:02 ` [PATCH v4 1/3] PCI: trace: Add PCI controller LTSSM transition tracepoint Shawn Lin
@ 2026-02-24 14:08 ` Steven Rostedt
2026-02-24 15:22 ` Ilpo Järvinen
1 sibling, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2026-02-24 14:08 UTC (permalink / raw)
To: Shawn Lin
Cc: Manivannan Sadhasivam, Bjorn Helgaas, linux-rockchip, linux-pci,
linux-trace-kernel, linux-doc, Masami Hiramatsu
On Thu, 22 Jan 2026 10:02:18 +0800
Shawn Lin <shawn.lin@rock-chips.com> wrote:
> +bool pci_ltssm_tp_enabled(void)
> +{
> + return atomic_read(&pcie_ltssm_tp_enabled) > 0;
> +}
> +EXPORT_SYMBOL(pci_ltssm_tp_enabled);
> +
> +int pci_ltssm_tp_reg(void)
> +{
> + atomic_inc(&pcie_ltssm_tp_enabled);
> + return 0;
> +}
> +
> +void pci_ltssm_tp_unreg(void)
> +{
> + atomic_dec(&pcie_ltssm_tp_enabled);
> +}
This seems totally unnecessary. Why the atomic operations? Why not just
use:
if (trace_pcie_ltssm_state_transition_enabled()) ...
?
-- Steve
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 3/3] PCI: dw-rockchip: Add pcie_ltssm_state_transition trace support
2026-01-22 2:02 ` [PATCH v4 3/3] PCI: dw-rockchip: Add pcie_ltssm_state_transition trace support Shawn Lin
@ 2026-02-24 14:11 ` Steven Rostedt
2026-02-24 14:16 ` Steven Rostedt
0 siblings, 1 reply; 18+ messages in thread
From: Steven Rostedt @ 2026-02-24 14:11 UTC (permalink / raw)
To: Shawn Lin
Cc: Manivannan Sadhasivam, Bjorn Helgaas, linux-rockchip, linux-pci,
linux-trace-kernel, linux-doc, Masami Hiramatsu
On Thu, 22 Jan 2026 10:02:20 +0800
Shawn Lin <shawn.lin@rock-chips.com> wrote:
>
> +#ifdef CONFIG_TRACING
> +static void rockchip_pcie_ltssm_trace_work(struct work_struct *work)
> +{
> + struct rockchip_pcie *rockchip = container_of(work,
> + struct rockchip_pcie,
> + trace_work.work);
> + struct dw_pcie *pci = &rockchip->pci;
> + enum dw_pcie_ltssm state;
> + u32 i, l1ss, prev_val = DW_PCIE_LTSSM_UNKNOWN, rate, val;
> +
> + if (!pci_ltssm_tp_enabled())
> + goto skip_trace;
You can use:
if (!trace_pcie_ltssm_state_transition_enabled())
goto skip_trace;
The above is a static branch. That means when tracing is disabled, it is
basically:
goto skip_trace;
and when tracing is enabled it is a nop.
-- Steve
> +
> + for (i = 0; i < PCIE_DBG_LTSSM_HISTORY_CNT; i++) {
> + val = rockchip_pcie_readl_apb(rockchip,
> + PCIE_CLIENT_DBG_FIFO_STATUS);
> + rate = FIELD_GET(PCIE_DBG_FIFO_RATE_MASK, val);
> + l1ss = FIELD_GET(PCIE_DBG_FIFO_L1SUB_MASK, val);
> + val = FIELD_GET(PCIE_LTSSM_STATUS_MASK, val);
> +
> + /*
> + * Hardware Mechanism: The ring FIFO employs two tracking
> + * counters:
> + * - 'last-read-point': maintains the user's last read position
> + * - 'last-valid-point': tracks the HW's last state update
> + *
> + * Software Handling: When two consecutive LTSSM states are
> + * identical, it indicates invalid subsequent data in the FIFO.
> + * In this case, we skip the remaining entries. The dual counter
> + * design ensures that on the next state transition, reading can
> + * resume from the last user position.
> + */
> + if ((i > 0 && val == prev_val) || val > DW_PCIE_LTSSM_RCVRY_EQ3)
> + break;
> +
> + state = prev_val = val;
> + if (val == DW_PCIE_LTSSM_L1_IDLE) {
> + if (l1ss == 2)
> + state = DW_PCIE_LTSSM_L1_2;
> + else if (l1ss == 1)
> + state = DW_PCIE_LTSSM_L1_1;
> + }
> +
> + trace_pcie_ltssm_state_transition(dev_name(pci->dev),
> + dw_pcie_ltssm_status_string(state),
> + ((rate + 1) > pci->max_link_speed) ?
> + PCI_SPEED_UNKNOWN : PCIE_SPEED_2_5GT + rate);
> + }
> +
> +skip_trace:
> + schedule_delayed_work(&rockchip->trace_work, msecs_to_jiffies(5000));
> +}
> +
> +static void rockchip_pcie_ltssm_trace(struct rockchip_pcie *rockchip,
> + bool enable)
> +{
> + if (enable) {
> + rockchip_pcie_writel_apb(rockchip,
> + PCIE_CLIENT_DBG_TRANSITION_DATA,
> + PCIE_CLIENT_DBG_FIFO_PTN_HIT_D0);
> + rockchip_pcie_writel_apb(rockchip,
> + PCIE_CLIENT_DBG_TRANSITION_DATA,
> + PCIE_CLIENT_DBG_FIFO_PTN_HIT_D1);
> + rockchip_pcie_writel_apb(rockchip,
> + PCIE_CLIENT_DBG_TRANSITION_DATA,
> + PCIE_CLIENT_DBG_FIFO_TRN_HIT_D0);
> + rockchip_pcie_writel_apb(rockchip,
> + PCIE_CLIENT_DBG_TRANSITION_DATA,
> + PCIE_CLIENT_DBG_FIFO_TRN_HIT_D1);
> + rockchip_pcie_writel_apb(rockchip,
> + PCIE_CLIENT_DBG_EN,
> + PCIE_CLIENT_DBG_FIFO_MODE_CON);
> +
> + INIT_DELAYED_WORK(&rockchip->trace_work,
> + rockchip_pcie_ltssm_trace_work);
> + schedule_delayed_work(&rockchip->trace_work, 0);
> + } else {
> + rockchip_pcie_writel_apb(rockchip,
> + PCIE_CLIENT_DBG_DIS,
> + PCIE_CLIENT_DBG_FIFO_MODE_CON);
> + cancel_delayed_work_sync(&rockchip->trace_work);
> + }
> +}
> +#else
> +static void rockchip_pcie_ltssm_trace(struct rockchip_pcie *rockchip,
> + bool enable)
> +{
> +}
> +#endif
> +
> static void rockchip_pcie_enable_ltssm(struct rockchip_pcie *rockchip)
> {
> rockchip_pcie_writel_apb(rockchip, PCIE_CLIENT_ENABLE_LTSSM,
> @@ -291,6 +398,9 @@ static int rockchip_pcie_start_link(struct dw_pcie *pci)
> * 100us as we don't know how long should the device need to reset.
> */
> msleep(PCIE_T_PVPERL_MS);
> +
> + rockchip_pcie_ltssm_trace(rockchip, true);
> +
> gpiod_set_value_cansleep(rockchip->rst_gpio, 1);
>
> return 0;
> @@ -301,6 +411,7 @@ static void rockchip_pcie_stop_link(struct dw_pcie *pci)
> struct rockchip_pcie *rockchip = to_rockchip_pcie(pci);
>
> rockchip_pcie_disable_ltssm(rockchip);
> + rockchip_pcie_ltssm_trace(rockchip, false);
> }
>
> static int rockchip_pcie_host_init(struct dw_pcie_rp *pp)
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 3/3] PCI: dw-rockchip: Add pcie_ltssm_state_transition trace support
2026-02-24 14:11 ` Steven Rostedt
@ 2026-02-24 14:16 ` Steven Rostedt
2026-02-25 1:25 ` Shawn Lin
2026-03-03 3:25 ` Shawn Lin
0 siblings, 2 replies; 18+ messages in thread
From: Steven Rostedt @ 2026-02-24 14:16 UTC (permalink / raw)
To: Shawn Lin
Cc: Manivannan Sadhasivam, Bjorn Helgaas, linux-rockchip, linux-pci,
linux-trace-kernel, linux-doc, Masami Hiramatsu
On Tue, 24 Feb 2026 09:11:15 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:
> > +#ifdef CONFIG_TRACING
> > +static void rockchip_pcie_ltssm_trace_work(struct work_struct *work)
> > +{
> > + struct rockchip_pcie *rockchip = container_of(work,
> > + struct rockchip_pcie,
> > + trace_work.work);
> > + struct dw_pcie *pci = &rockchip->pci;
> > + enum dw_pcie_ltssm state;
> > + u32 i, l1ss, prev_val = DW_PCIE_LTSSM_UNKNOWN, rate, val;
> > +
> > + if (!pci_ltssm_tp_enabled())
> > + goto skip_trace;
>
> You can use:
>
> if (!trace_pcie_ltssm_state_transition_enabled())
> goto skip_trace;
>
> The above is a static branch. That means when tracing is disabled, it is
> basically:
>
> goto skip_trace;
>
> and when tracing is enabled it is a nop.
>
> -- Steve
>
>
> > +
> > + for (i = 0; i < PCIE_DBG_LTSSM_HISTORY_CNT; i++) {
> > + val = rockchip_pcie_readl_apb(rockchip,
> > + PCIE_CLIENT_DBG_FIFO_STATUS);
> > + rate = FIELD_GET(PCIE_DBG_FIFO_RATE_MASK, val);
> > + l1ss = FIELD_GET(PCIE_DBG_FIFO_L1SUB_MASK, val);
> > + val = FIELD_GET(PCIE_LTSSM_STATUS_MASK, val);
> > +
> > + /*
> > + * Hardware Mechanism: The ring FIFO employs two tracking
> > + * counters:
> > + * - 'last-read-point': maintains the user's last read position
> > + * - 'last-valid-point': tracks the HW's last state update
> > + *
> > + * Software Handling: When two consecutive LTSSM states are
> > + * identical, it indicates invalid subsequent data in the FIFO.
> > + * In this case, we skip the remaining entries. The dual counter
> > + * design ensures that on the next state transition, reading can
> > + * resume from the last user position.
> > + */
> > + if ((i > 0 && val == prev_val) || val > DW_PCIE_LTSSM_RCVRY_EQ3)
> > + break;
> > +
> > + state = prev_val = val;
> > + if (val == DW_PCIE_LTSSM_L1_IDLE) {
> > + if (l1ss == 2)
> > + state = DW_PCIE_LTSSM_L1_2;
> > + else if (l1ss == 1)
> > + state = DW_PCIE_LTSSM_L1_1;
> > + }
> > +
> > + trace_pcie_ltssm_state_transition(dev_name(pci->dev),
> > + dw_pcie_ltssm_status_string(state),
> > + ((rate + 1) > pci->max_link_speed) ?
> > + PCI_SPEED_UNKNOWN : PCIE_SPEED_2_5GT + rate);
> > + }
> > +
> > +skip_trace:
> > + schedule_delayed_work(&rockchip->trace_work, msecs_to_jiffies(5000));
> > +}
> > +
Hmm, so basically you only want to call the work when tracing is
enabled? That's what I was thinking should be enabled by the reg and
unreg functions. That is, the reg should enabled the delayed work, and
the unreg should disable it from being called.
This looks like it calls the work regardless of if tracing is enabled
or not. Why waste the cycles when tracing is disabled?
-- Steve
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 1/3] PCI: trace: Add PCI controller LTSSM transition tracepoint
2026-01-22 2:02 ` [PATCH v4 1/3] PCI: trace: Add PCI controller LTSSM transition tracepoint Shawn Lin
2026-02-24 14:08 ` Steven Rostedt
@ 2026-02-24 15:22 ` Ilpo Järvinen
2026-02-24 15:35 ` Manivannan Sadhasivam
1 sibling, 1 reply; 18+ messages in thread
From: Ilpo Järvinen @ 2026-02-24 15:22 UTC (permalink / raw)
To: Shawn Lin
Cc: Manivannan Sadhasivam, Bjorn Helgaas, linux-rockchip, linux-pci,
linux-trace-kernel, linux-doc, Steven Rostedt, Masami Hiramatsu
On Thu, 22 Jan 2026, Shawn Lin wrote:
> Some platforms may provide LTSSM trace functionality, recording historical
> LTSSM state transition information. This is very useful for debugging, such
> as when certain devices cannot be recognized or link broken during test.
> Implement the pci controller tracepoint for recording LTSSM and rate.
>
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
>
> Changes in v4:
> - use TRACE_EVENT_FN to notify when to start and stop the tracepoint,
> and export pci_ltssm_tp_enabled() for host drivers to use
>
> Changes in v3:
> - add TRACE_DEFINE_ENUM for all enums(Steven Rostedt)
>
> Changes in v2: None
>
> drivers/pci/trace.c | 20 ++++++++++++
> include/linux/pci.h | 4 +++
> include/trace/events/pci_controller.h | 57 +++++++++++++++++++++++++++++++++++
> 3 files changed, 81 insertions(+)
> create mode 100644 include/trace/events/pci_controller.h
>
> diff --git a/drivers/pci/trace.c b/drivers/pci/trace.c
> index cf11abc..d351a51 100644
> --- a/drivers/pci/trace.c
> +++ b/drivers/pci/trace.c
> @@ -9,3 +9,23 @@
>
> #define CREATE_TRACE_POINTS
> #include <trace/events/pci.h>
> +#include <trace/events/pci_controller.h>
> +
> +static atomic_t pcie_ltssm_tp_enabled = ATOMIC_INIT(0);
> +
> +bool pci_ltssm_tp_enabled(void)
> +{
> + return atomic_read(&pcie_ltssm_tp_enabled) > 0;
> +}
> +EXPORT_SYMBOL(pci_ltssm_tp_enabled);
> +
> +int pci_ltssm_tp_reg(void)
> +{
> + atomic_inc(&pcie_ltssm_tp_enabled);
> + return 0;
> +}
> +
> +void pci_ltssm_tp_unreg(void)
> +{
> + atomic_dec(&pcie_ltssm_tp_enabled);
> +}
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index e7cb527..ac25a3e 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -2770,6 +2770,10 @@ static inline struct eeh_dev *pci_dev_to_eeh_dev(struct pci_dev *pdev)
> }
> #endif
>
> +#ifdef CONFIG_TRACING
> +bool pci_ltssm_tp_enabled(void);
> +#endif
> +
> void pci_add_dma_alias(struct pci_dev *dev, u8 devfn_from, unsigned nr_devfns);
> bool pci_devs_are_dma_aliases(struct pci_dev *dev1, struct pci_dev *dev2);
> int pci_for_each_dma_alias(struct pci_dev *pdev,
> diff --git a/include/trace/events/pci_controller.h b/include/trace/events/pci_controller.h
> new file mode 100644
> index 0000000..db4a960
> --- /dev/null
> +++ b/include/trace/events/pci_controller.h
> @@ -0,0 +1,57 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#undef TRACE_SYSTEM
> +#define TRACE_SYSTEM pci_controller
I find putting this into "pci_controller" little odd as LTSSM is related
to PCIe links/ports. To me looks something that belongs to the existing
include/trace/events/pci.h.
> +#if !defined(_TRACE_HW_EVENT_PCI_CONTROLLER_H) || defined(TRACE_HEADER_MULTI_READ)
> +#define _TRACE_HW_EVENT_PCI_CONTROLLER_H
> +
> +#include <uapi/linux/pci_regs.h>
> +#include <linux/tracepoint.h>
> +
> +TRACE_DEFINE_ENUM(PCIE_SPEED_2_5GT);
> +TRACE_DEFINE_ENUM(PCIE_SPEED_5_0GT);
> +TRACE_DEFINE_ENUM(PCIE_SPEED_8_0GT);
> +TRACE_DEFINE_ENUM(PCIE_SPEED_16_0GT);
> +TRACE_DEFINE_ENUM(PCIE_SPEED_32_0GT);
> +TRACE_DEFINE_ENUM(PCIE_SPEED_64_0GT);
> +TRACE_DEFINE_ENUM(PCI_SPEED_UNKNOWN);
> +
> +extern int pci_ltssm_tp_reg(void);
> +extern void pci_ltssm_tp_unreg(void);
> +
> +TRACE_EVENT_FN(pcie_ltssm_state_transition,
> + TP_PROTO(const char *dev_name, const char *state, u32 rate),
> + TP_ARGS(dev_name, state, rate),
> +
> + TP_STRUCT__entry(
> + __string(dev_name, dev_name)
> + __string(state, state)
> + __field(u32, rate)
> + ),
> +
> + TP_fast_assign(
> + __assign_str(dev_name);
> + __assign_str(state);
> + __entry->rate = rate;
> + ),
> +
> + TP_printk("dev: %s state: %s rate: %s",
> + __get_str(dev_name), __get_str(state),
> + __print_symbolic(__entry->rate,
> + { PCIE_SPEED_2_5GT, "2.5 GT/s" },
> + { PCIE_SPEED_5_0GT, "5.0 GT/s" },
> + { PCIE_SPEED_8_0GT, "8.0 GT/s" },
> + { PCIE_SPEED_16_0GT, "16.0 GT/s" },
> + { PCIE_SPEED_32_0GT, "32.0 GT/s" },
> + { PCIE_SPEED_64_0GT, "64.0 GT/s" },
> + { PCI_SPEED_UNKNOWN, "Unknown" }
Why are these done inline instead of using EM/EMe()? Or simply with
pci_speed_string()?
Unrelated to this, sadly I failed to notice Shuai's version of
pcie_link_event() did not translate link speeds (my own version used
pci_speed_string()).
> + )
> + ),
> +
> + pci_ltssm_tp_reg, pci_ltssm_tp_unreg
> +);
> +
> +#endif /* _TRACE_HW_EVENT_PCI_CONTROLLER_H */
> +
> +/* This part must be outside protection */
> +#include <trace/define_trace.h>
>
--
i.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 1/3] PCI: trace: Add PCI controller LTSSM transition tracepoint
2026-02-24 15:22 ` Ilpo Järvinen
@ 2026-02-24 15:35 ` Manivannan Sadhasivam
2026-02-24 15:46 ` Ilpo Järvinen
0 siblings, 1 reply; 18+ messages in thread
From: Manivannan Sadhasivam @ 2026-02-24 15:35 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: Shawn Lin, Bjorn Helgaas, linux-rockchip, linux-pci,
linux-trace-kernel, linux-doc, Steven Rostedt, Masami Hiramatsu
On Tue, Feb 24, 2026 at 05:22:35PM +0200, Ilpo Järvinen wrote:
> On Thu, 22 Jan 2026, Shawn Lin wrote:
>
> > Some platforms may provide LTSSM trace functionality, recording historical
> > LTSSM state transition information. This is very useful for debugging, such
> > as when certain devices cannot be recognized or link broken during test.
> > Implement the pci controller tracepoint for recording LTSSM and rate.
> >
> > Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> > ---
> >
> > Changes in v4:
> > - use TRACE_EVENT_FN to notify when to start and stop the tracepoint,
> > and export pci_ltssm_tp_enabled() for host drivers to use
> >
> > Changes in v3:
> > - add TRACE_DEFINE_ENUM for all enums(Steven Rostedt)
> >
> > Changes in v2: None
> >
> > drivers/pci/trace.c | 20 ++++++++++++
> > include/linux/pci.h | 4 +++
> > include/trace/events/pci_controller.h | 57 +++++++++++++++++++++++++++++++++++
> > 3 files changed, 81 insertions(+)
> > create mode 100644 include/trace/events/pci_controller.h
> >
> > diff --git a/drivers/pci/trace.c b/drivers/pci/trace.c
> > index cf11abc..d351a51 100644
> > --- a/drivers/pci/trace.c
> > +++ b/drivers/pci/trace.c
> > @@ -9,3 +9,23 @@
> >
> > #define CREATE_TRACE_POINTS
> > #include <trace/events/pci.h>
> > +#include <trace/events/pci_controller.h>
> > +
> > +static atomic_t pcie_ltssm_tp_enabled = ATOMIC_INIT(0);
> > +
> > +bool pci_ltssm_tp_enabled(void)
> > +{
> > + return atomic_read(&pcie_ltssm_tp_enabled) > 0;
> > +}
> > +EXPORT_SYMBOL(pci_ltssm_tp_enabled);
> > +
> > +int pci_ltssm_tp_reg(void)
> > +{
> > + atomic_inc(&pcie_ltssm_tp_enabled);
> > + return 0;
> > +}
> > +
> > +void pci_ltssm_tp_unreg(void)
> > +{
> > + atomic_dec(&pcie_ltssm_tp_enabled);
> > +}
> > diff --git a/include/linux/pci.h b/include/linux/pci.h
> > index e7cb527..ac25a3e 100644
> > --- a/include/linux/pci.h
> > +++ b/include/linux/pci.h
> > @@ -2770,6 +2770,10 @@ static inline struct eeh_dev *pci_dev_to_eeh_dev(struct pci_dev *pdev)
> > }
> > #endif
> >
> > +#ifdef CONFIG_TRACING
> > +bool pci_ltssm_tp_enabled(void);
> > +#endif
> > +
> > void pci_add_dma_alias(struct pci_dev *dev, u8 devfn_from, unsigned nr_devfns);
> > bool pci_devs_are_dma_aliases(struct pci_dev *dev1, struct pci_dev *dev2);
> > int pci_for_each_dma_alias(struct pci_dev *pdev,
> > diff --git a/include/trace/events/pci_controller.h b/include/trace/events/pci_controller.h
> > new file mode 100644
> > index 0000000..db4a960
> > --- /dev/null
> > +++ b/include/trace/events/pci_controller.h
> > @@ -0,0 +1,57 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +#undef TRACE_SYSTEM
> > +#define TRACE_SYSTEM pci_controller
>
> I find putting this into "pci_controller" little odd as LTSSM is related
> to PCIe links/ports. To me looks something that belongs to the existing
> include/trace/events/pci.h.
>
I suggested 'pci_controller.h' since these tracepoints are only going to be used
by the controller drivers. Putting it under 'pci.h' will imply that these can be
used by the client drivers also.
- Mani
> > +#if !defined(_TRACE_HW_EVENT_PCI_CONTROLLER_H) || defined(TRACE_HEADER_MULTI_READ)
> > +#define _TRACE_HW_EVENT_PCI_CONTROLLER_H
> > +
> > +#include <uapi/linux/pci_regs.h>
> > +#include <linux/tracepoint.h>
> > +
> > +TRACE_DEFINE_ENUM(PCIE_SPEED_2_5GT);
> > +TRACE_DEFINE_ENUM(PCIE_SPEED_5_0GT);
> > +TRACE_DEFINE_ENUM(PCIE_SPEED_8_0GT);
> > +TRACE_DEFINE_ENUM(PCIE_SPEED_16_0GT);
> > +TRACE_DEFINE_ENUM(PCIE_SPEED_32_0GT);
> > +TRACE_DEFINE_ENUM(PCIE_SPEED_64_0GT);
> > +TRACE_DEFINE_ENUM(PCI_SPEED_UNKNOWN);
> > +
> > +extern int pci_ltssm_tp_reg(void);
> > +extern void pci_ltssm_tp_unreg(void);
> > +
> > +TRACE_EVENT_FN(pcie_ltssm_state_transition,
> > + TP_PROTO(const char *dev_name, const char *state, u32 rate),
> > + TP_ARGS(dev_name, state, rate),
> > +
> > + TP_STRUCT__entry(
> > + __string(dev_name, dev_name)
> > + __string(state, state)
> > + __field(u32, rate)
> > + ),
> > +
> > + TP_fast_assign(
> > + __assign_str(dev_name);
> > + __assign_str(state);
> > + __entry->rate = rate;
> > + ),
> > +
> > + TP_printk("dev: %s state: %s rate: %s",
> > + __get_str(dev_name), __get_str(state),
> > + __print_symbolic(__entry->rate,
> > + { PCIE_SPEED_2_5GT, "2.5 GT/s" },
> > + { PCIE_SPEED_5_0GT, "5.0 GT/s" },
> > + { PCIE_SPEED_8_0GT, "8.0 GT/s" },
> > + { PCIE_SPEED_16_0GT, "16.0 GT/s" },
> > + { PCIE_SPEED_32_0GT, "32.0 GT/s" },
> > + { PCIE_SPEED_64_0GT, "64.0 GT/s" },
> > + { PCI_SPEED_UNKNOWN, "Unknown" }
>
> Why are these done inline instead of using EM/EMe()? Or simply with
> pci_speed_string()?
>
>
> Unrelated to this, sadly I failed to notice Shuai's version of
> pcie_link_event() did not translate link speeds (my own version used
> pci_speed_string()).
>
> > + )
> > + ),
> > +
> > + pci_ltssm_tp_reg, pci_ltssm_tp_unreg
> > +);
> > +
> > +#endif /* _TRACE_HW_EVENT_PCI_CONTROLLER_H */
> > +
> > +/* This part must be outside protection */
> > +#include <trace/define_trace.h>
> >
>
> --
> i.
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 1/3] PCI: trace: Add PCI controller LTSSM transition tracepoint
2026-02-24 15:35 ` Manivannan Sadhasivam
@ 2026-02-24 15:46 ` Ilpo Järvinen
2026-02-26 5:52 ` Manivannan Sadhasivam
0 siblings, 1 reply; 18+ messages in thread
From: Ilpo Järvinen @ 2026-02-24 15:46 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: Shawn Lin, Bjorn Helgaas, linux-rockchip, linux-pci,
linux-trace-kernel, linux-doc, Steven Rostedt, Masami Hiramatsu
[-- Attachment #1: Type: text/plain, Size: 5896 bytes --]
On Tue, 24 Feb 2026, Manivannan Sadhasivam wrote:
> On Tue, Feb 24, 2026 at 05:22:35PM +0200, Ilpo Järvinen wrote:
> > On Thu, 22 Jan 2026, Shawn Lin wrote:
> >
> > > Some platforms may provide LTSSM trace functionality, recording historical
> > > LTSSM state transition information. This is very useful for debugging, such
> > > as when certain devices cannot be recognized or link broken during test.
> > > Implement the pci controller tracepoint for recording LTSSM and rate.
> > >
> > > Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> > > ---
> > >
> > > Changes in v4:
> > > - use TRACE_EVENT_FN to notify when to start and stop the tracepoint,
> > > and export pci_ltssm_tp_enabled() for host drivers to use
> > >
> > > Changes in v3:
> > > - add TRACE_DEFINE_ENUM for all enums(Steven Rostedt)
> > >
> > > Changes in v2: None
> > >
> > > drivers/pci/trace.c | 20 ++++++++++++
> > > include/linux/pci.h | 4 +++
> > > include/trace/events/pci_controller.h | 57 +++++++++++++++++++++++++++++++++++
> > > 3 files changed, 81 insertions(+)
> > > create mode 100644 include/trace/events/pci_controller.h
> > >
> > > diff --git a/drivers/pci/trace.c b/drivers/pci/trace.c
> > > index cf11abc..d351a51 100644
> > > --- a/drivers/pci/trace.c
> > > +++ b/drivers/pci/trace.c
> > > @@ -9,3 +9,23 @@
> > >
> > > #define CREATE_TRACE_POINTS
> > > #include <trace/events/pci.h>
> > > +#include <trace/events/pci_controller.h>
> > > +
> > > +static atomic_t pcie_ltssm_tp_enabled = ATOMIC_INIT(0);
> > > +
> > > +bool pci_ltssm_tp_enabled(void)
> > > +{
> > > + return atomic_read(&pcie_ltssm_tp_enabled) > 0;
> > > +}
> > > +EXPORT_SYMBOL(pci_ltssm_tp_enabled);
> > > +
> > > +int pci_ltssm_tp_reg(void)
> > > +{
> > > + atomic_inc(&pcie_ltssm_tp_enabled);
> > > + return 0;
> > > +}
> > > +
> > > +void pci_ltssm_tp_unreg(void)
> > > +{
> > > + atomic_dec(&pcie_ltssm_tp_enabled);
> > > +}
> > > diff --git a/include/linux/pci.h b/include/linux/pci.h
> > > index e7cb527..ac25a3e 100644
> > > --- a/include/linux/pci.h
> > > +++ b/include/linux/pci.h
> > > @@ -2770,6 +2770,10 @@ static inline struct eeh_dev *pci_dev_to_eeh_dev(struct pci_dev *pdev)
> > > }
> > > #endif
> > >
> > > +#ifdef CONFIG_TRACING
> > > +bool pci_ltssm_tp_enabled(void);
> > > +#endif
> > > +
> > > void pci_add_dma_alias(struct pci_dev *dev, u8 devfn_from, unsigned nr_devfns);
> > > bool pci_devs_are_dma_aliases(struct pci_dev *dev1, struct pci_dev *dev2);
> > > int pci_for_each_dma_alias(struct pci_dev *pdev,
> > > diff --git a/include/trace/events/pci_controller.h b/include/trace/events/pci_controller.h
> > > new file mode 100644
> > > index 0000000..db4a960
> > > --- /dev/null
> > > +++ b/include/trace/events/pci_controller.h
> > > @@ -0,0 +1,57 @@
> > > +/* SPDX-License-Identifier: GPL-2.0 */
> > > +#undef TRACE_SYSTEM
> > > +#define TRACE_SYSTEM pci_controller
> >
> > I find putting this into "pci_controller" little odd as LTSSM is related
> > to PCIe links/ports. To me looks something that belongs to the existing
> > include/trace/events/pci.h.
>
> I suggested 'pci_controller.h' since these tracepoints are only going to be used
> by the controller drivers. Putting it under 'pci.h' will imply that these can be
> used by the client drivers also.
PCIe r7 spec has Flit Performance Measurement Extended Capability that
seems to have something for LTSSM tracking and those seem more generic
than just for controllers (I've not spent much time on trying to fully
understand those capabilities, just recalled seeing them earlier).
--
i.
> > > +#if !defined(_TRACE_HW_EVENT_PCI_CONTROLLER_H) || defined(TRACE_HEADER_MULTI_READ)
> > > +#define _TRACE_HW_EVENT_PCI_CONTROLLER_H
> > > +
> > > +#include <uapi/linux/pci_regs.h>
> > > +#include <linux/tracepoint.h>
> > > +
> > > +TRACE_DEFINE_ENUM(PCIE_SPEED_2_5GT);
> > > +TRACE_DEFINE_ENUM(PCIE_SPEED_5_0GT);
> > > +TRACE_DEFINE_ENUM(PCIE_SPEED_8_0GT);
> > > +TRACE_DEFINE_ENUM(PCIE_SPEED_16_0GT);
> > > +TRACE_DEFINE_ENUM(PCIE_SPEED_32_0GT);
> > > +TRACE_DEFINE_ENUM(PCIE_SPEED_64_0GT);
> > > +TRACE_DEFINE_ENUM(PCI_SPEED_UNKNOWN);
> > > +
> > > +extern int pci_ltssm_tp_reg(void);
> > > +extern void pci_ltssm_tp_unreg(void);
> > > +
> > > +TRACE_EVENT_FN(pcie_ltssm_state_transition,
> > > + TP_PROTO(const char *dev_name, const char *state, u32 rate),
> > > + TP_ARGS(dev_name, state, rate),
> > > +
> > > + TP_STRUCT__entry(
> > > + __string(dev_name, dev_name)
> > > + __string(state, state)
> > > + __field(u32, rate)
> > > + ),
> > > +
> > > + TP_fast_assign(
> > > + __assign_str(dev_name);
> > > + __assign_str(state);
> > > + __entry->rate = rate;
> > > + ),
> > > +
> > > + TP_printk("dev: %s state: %s rate: %s",
> > > + __get_str(dev_name), __get_str(state),
> > > + __print_symbolic(__entry->rate,
> > > + { PCIE_SPEED_2_5GT, "2.5 GT/s" },
> > > + { PCIE_SPEED_5_0GT, "5.0 GT/s" },
> > > + { PCIE_SPEED_8_0GT, "8.0 GT/s" },
> > > + { PCIE_SPEED_16_0GT, "16.0 GT/s" },
> > > + { PCIE_SPEED_32_0GT, "32.0 GT/s" },
> > > + { PCIE_SPEED_64_0GT, "64.0 GT/s" },
> > > + { PCI_SPEED_UNKNOWN, "Unknown" }
> >
> > Why are these done inline instead of using EM/EMe()? Or simply with
> > pci_speed_string()?
> >
> >
> > Unrelated to this, sadly I failed to notice Shuai's version of
> > pcie_link_event() did not translate link speeds (my own version used
> > pci_speed_string()).
> >
> > > + )
> > > + ),
> > > +
> > > + pci_ltssm_tp_reg, pci_ltssm_tp_unreg
> > > +);
> > > +
> > > +#endif /* _TRACE_HW_EVENT_PCI_CONTROLLER_H */
> > > +
> > > +/* This part must be outside protection */
> > > +#include <trace/define_trace.h>
> > >
> >
> > --
> > i.
> >
>
>
--
i.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 3/3] PCI: dw-rockchip: Add pcie_ltssm_state_transition trace support
2026-02-24 14:16 ` Steven Rostedt
@ 2026-02-25 1:25 ` Shawn Lin
2026-02-26 0:13 ` Steven Rostedt
2026-03-03 3:25 ` Shawn Lin
1 sibling, 1 reply; 18+ messages in thread
From: Shawn Lin @ 2026-02-25 1:25 UTC (permalink / raw)
To: Steven Rostedt
Cc: shawn.lin, Manivannan Sadhasivam, Bjorn Helgaas, linux-rockchip,
linux-pci, linux-trace-kernel, linux-doc, Masami Hiramatsu
Hi Steven,
在 2026/02/24 星期二 22:16, Steven Rostedt 写道:
> On Tue, 24 Feb 2026 09:11:15 -0500
> Steven Rostedt <rostedt@goodmis.org> wrote:
>
>>> +#ifdef CONFIG_TRACING
>>> +static void rockchip_pcie_ltssm_trace_work(struct work_struct *work)
>>> +{
>>> + struct rockchip_pcie *rockchip = container_of(work,
>>> + struct rockchip_pcie,
>>> + trace_work.work);
>>> + struct dw_pcie *pci = &rockchip->pci;
>>> + enum dw_pcie_ltssm state;
>>> + u32 i, l1ss, prev_val = DW_PCIE_LTSSM_UNKNOWN, rate, val;
>>> +
>>> + if (!pci_ltssm_tp_enabled())
>>> + goto skip_trace;
>>
>> You can use:
>>
>> if (!trace_pcie_ltssm_state_transition_enabled())
>> goto skip_trace;
>>
>> The above is a static branch. That means when tracing is disabled, it is
>> basically:
>>
>> goto skip_trace;
>>
>> and when tracing is enabled it is a nop.
I must admit I borrow it from arch/powerpc/include/asm/trace.h and
include/trace/events/i2c.h for reference, where the reg and unreg
just increase and decrease the ref count to indicate if the tp
should be continued. Sure, the static branch could be used instead,
even without reg and unreg implementation.
>>
..
>>> +}
>>> +
>
> Hmm, so basically you only want to call the work when tracing is
> enabled? That's what I was thinking should be enabled by the reg and
> unreg functions. That is, the reg should enabled the delayed work, and
> the unreg should disable it from being called.
>
> This looks like it calls the work regardless of if tracing is enabled
> or not. Why waste the cycles when tracing is disabled?
I looked into implementing reg and unreg callbacks to directly schedule
and cancel the delayed work. The challenge is that this tracepoint
belongs to the shared PCI subsystem trace hierarchy, while the polling
work itself is per-controller. I haven't found a clean way to register
per-driver callbacks in this common context.
Creating a separate Rockchip-specific tracepoint via
tracepoint_probe_register() would detach it from the standard PCIe trace
event hierarchy, which seems undesirable.
As a practical middle ground, I implement reg and unreg to maintain a
user count like this v4. All drivers using this tracepoint would then
rely on the count to gate their work execution, making the delayed work
essentially a no-op when tracing is disabled.
Alternatively, we could simply revert to the V3 approach and rely
entirely on the trace_pcie_ltssm_state_transition_enabled() static
branch check, which would remove the need for reg and unreg altogether.
If you have better suggestions or can point me to a preferred pattern
for this, I'd appreciate your advice.
>
> -- Steve
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 3/3] PCI: dw-rockchip: Add pcie_ltssm_state_transition trace support
2026-02-25 1:25 ` Shawn Lin
@ 2026-02-26 0:13 ` Steven Rostedt
0 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2026-02-26 0:13 UTC (permalink / raw)
To: Shawn Lin
Cc: Manivannan Sadhasivam, Bjorn Helgaas, linux-rockchip, linux-pci,
linux-trace-kernel, linux-doc, Masami Hiramatsu
On Wed, 25 Feb 2026 09:25:16 +0800
Shawn Lin <shawn.lin@rock-chips.com> wrote:
> I must admit I borrow it from arch/powerpc/include/asm/trace.h and
> include/trace/events/i2c.h for reference, where the reg and unreg
> just increase and decrease the ref count to indicate if the tp
> should be continued. Sure, the static branch could be used instead,
> even without reg and unreg implementation.
The i2c.h looks like it should be switched over to the
trace_<tracepoint>_enabled(), but the powerpc enables a static branch
in assembly, so that one does make sense to do it the way it did it.
-- Steve
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 1/3] PCI: trace: Add PCI controller LTSSM transition tracepoint
2026-02-24 15:46 ` Ilpo Järvinen
@ 2026-02-26 5:52 ` Manivannan Sadhasivam
0 siblings, 0 replies; 18+ messages in thread
From: Manivannan Sadhasivam @ 2026-02-26 5:52 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: Shawn Lin, Bjorn Helgaas, linux-rockchip, linux-pci,
linux-trace-kernel, linux-doc, Steven Rostedt, Masami Hiramatsu
On Tue, Feb 24, 2026 at 05:46:29PM +0200, Ilpo Järvinen wrote:
> On Tue, 24 Feb 2026, Manivannan Sadhasivam wrote:
>
> > On Tue, Feb 24, 2026 at 05:22:35PM +0200, Ilpo Järvinen wrote:
> > > On Thu, 22 Jan 2026, Shawn Lin wrote:
> > >
> > > > Some platforms may provide LTSSM trace functionality, recording historical
> > > > LTSSM state transition information. This is very useful for debugging, such
> > > > as when certain devices cannot be recognized or link broken during test.
> > > > Implement the pci controller tracepoint for recording LTSSM and rate.
> > > >
> > > > Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> > > > ---
> > > >
> > > > Changes in v4:
> > > > - use TRACE_EVENT_FN to notify when to start and stop the tracepoint,
> > > > and export pci_ltssm_tp_enabled() for host drivers to use
> > > >
> > > > Changes in v3:
> > > > - add TRACE_DEFINE_ENUM for all enums(Steven Rostedt)
> > > >
> > > > Changes in v2: None
> > > >
> > > > drivers/pci/trace.c | 20 ++++++++++++
> > > > include/linux/pci.h | 4 +++
> > > > include/trace/events/pci_controller.h | 57 +++++++++++++++++++++++++++++++++++
> > > > 3 files changed, 81 insertions(+)
> > > > create mode 100644 include/trace/events/pci_controller.h
> > > >
> > > > diff --git a/drivers/pci/trace.c b/drivers/pci/trace.c
> > > > index cf11abc..d351a51 100644
> > > > --- a/drivers/pci/trace.c
> > > > +++ b/drivers/pci/trace.c
> > > > @@ -9,3 +9,23 @@
> > > >
> > > > #define CREATE_TRACE_POINTS
> > > > #include <trace/events/pci.h>
> > > > +#include <trace/events/pci_controller.h>
> > > > +
> > > > +static atomic_t pcie_ltssm_tp_enabled = ATOMIC_INIT(0);
> > > > +
> > > > +bool pci_ltssm_tp_enabled(void)
> > > > +{
> > > > + return atomic_read(&pcie_ltssm_tp_enabled) > 0;
> > > > +}
> > > > +EXPORT_SYMBOL(pci_ltssm_tp_enabled);
> > > > +
> > > > +int pci_ltssm_tp_reg(void)
> > > > +{
> > > > + atomic_inc(&pcie_ltssm_tp_enabled);
> > > > + return 0;
> > > > +}
> > > > +
> > > > +void pci_ltssm_tp_unreg(void)
> > > > +{
> > > > + atomic_dec(&pcie_ltssm_tp_enabled);
> > > > +}
> > > > diff --git a/include/linux/pci.h b/include/linux/pci.h
> > > > index e7cb527..ac25a3e 100644
> > > > --- a/include/linux/pci.h
> > > > +++ b/include/linux/pci.h
> > > > @@ -2770,6 +2770,10 @@ static inline struct eeh_dev *pci_dev_to_eeh_dev(struct pci_dev *pdev)
> > > > }
> > > > #endif
> > > >
> > > > +#ifdef CONFIG_TRACING
> > > > +bool pci_ltssm_tp_enabled(void);
> > > > +#endif
> > > > +
> > > > void pci_add_dma_alias(struct pci_dev *dev, u8 devfn_from, unsigned nr_devfns);
> > > > bool pci_devs_are_dma_aliases(struct pci_dev *dev1, struct pci_dev *dev2);
> > > > int pci_for_each_dma_alias(struct pci_dev *pdev,
> > > > diff --git a/include/trace/events/pci_controller.h b/include/trace/events/pci_controller.h
> > > > new file mode 100644
> > > > index 0000000..db4a960
> > > > --- /dev/null
> > > > +++ b/include/trace/events/pci_controller.h
> > > > @@ -0,0 +1,57 @@
> > > > +/* SPDX-License-Identifier: GPL-2.0 */
> > > > +#undef TRACE_SYSTEM
> > > > +#define TRACE_SYSTEM pci_controller
> > >
> > > I find putting this into "pci_controller" little odd as LTSSM is related
> > > to PCIe links/ports. To me looks something that belongs to the existing
> > > include/trace/events/pci.h.
> >
> > I suggested 'pci_controller.h' since these tracepoints are only going to be used
> > by the controller drivers. Putting it under 'pci.h' will imply that these can be
> > used by the client drivers also.
>
> PCIe r7 spec has Flit Performance Measurement Extended Capability that
> seems to have something for LTSSM tracking and those seem more generic
> than just for controllers (I've not spent much time on trying to fully
> understand those capabilities, just recalled seeing them earlier).
>
Even so, we don't know how that is going to look until someone implements it. So
I'd prefer we put this in pci_controller.h in the meantime to avoid confusion.
We can always come back later when the Flit based LTSSM tracing patch appears in
the list.
- Mani
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v4 3/3] PCI: dw-rockchip: Add pcie_ltssm_state_transition trace support
2026-02-24 14:16 ` Steven Rostedt
2026-02-25 1:25 ` Shawn Lin
@ 2026-03-03 3:25 ` Shawn Lin
1 sibling, 0 replies; 18+ messages in thread
From: Shawn Lin @ 2026-03-03 3:25 UTC (permalink / raw)
To: Steven Rostedt
Cc: shawn.lin, Manivannan Sadhasivam, Bjorn Helgaas, linux-rockchip,
linux-pci, linux-trace-kernel, linux-doc, Masami Hiramatsu
Hi Steven,
在 2026/02/24 星期二 22:16, Steven Rostedt 写道:
> On Tue, 24 Feb 2026 09:11:15 -0500
> Steven Rostedt <rostedt@goodmis.org> wrote:
>
...
>>> + }
>>> +
>>> +skip_trace:
>>> + schedule_delayed_work(&rockchip->trace_work, msecs_to_jiffies(5000));
>>> +}
>>> +
>
> Hmm, so basically you only want to call the work when tracing is
> enabled? That's what I was thinking should be enabled by the reg and
> unreg functions. That is, the reg should enabled the delayed work, and
> the unreg should disable it from being called.
>
> This looks like it calls the work regardless of if tracing is enabled
> or not. Why waste the cycles when tracing is disabled?
>
I looked into implementing reg and unreg callbacks to directly schedule
and cancel the delayed work. The challenge is that this tracepoint
belongs to the shared PCI subsystem trace hierarchy, while the polling
work itself is per-controller. I haven't found a clean way to register
per-driver callbacks in this common context.
Creating a separate Rockchip-specific tracepoint via
tracepoint_probe_register() would detach it from the standard PCIe trace
event hierarchy, which seems undesirable.
As a practical middle ground, I implement reg and unreg to maintain a
user count like this v4. All drivers using this tracepoint would then
rely on the count to gate their work execution, making the delayed work
essentially a no-op when tracing is disabled.
Alternatively, we could simply revert to the V3 approach and rely
entirely on the trace_pcie_ltssm_state_transition_enabled() static
branch check, which would remove the need for reg and unreg altogether.
If you have better suggestions or can point me to a preferred pattern
for this, I'd appreciate your advice.
> -- Steve
>
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2026-03-03 4:00 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-22 2:02 [PATCH v4 0/3] PCI Controller event and LTSSM tracepoint support Shawn Lin
2026-01-22 2:02 ` [PATCH v4 1/3] PCI: trace: Add PCI controller LTSSM transition tracepoint Shawn Lin
2026-02-24 14:08 ` Steven Rostedt
2026-02-24 15:22 ` Ilpo Järvinen
2026-02-24 15:35 ` Manivannan Sadhasivam
2026-02-24 15:46 ` Ilpo Järvinen
2026-02-26 5:52 ` Manivannan Sadhasivam
2026-01-22 2:02 ` [PATCH v4 2/3] Documentation: tracing: Add PCI controller event documentation Shawn Lin
2026-01-22 2:02 ` [PATCH v4 3/3] PCI: dw-rockchip: Add pcie_ltssm_state_transition trace support Shawn Lin
2026-02-24 14:11 ` Steven Rostedt
2026-02-24 14:16 ` Steven Rostedt
2026-02-25 1:25 ` Shawn Lin
2026-02-26 0:13 ` Steven Rostedt
2026-03-03 3:25 ` Shawn Lin
2026-02-11 13:13 ` [PATCH v4 0/3] PCI Controller event and LTSSM tracepoint support Shawn Lin
2026-02-11 15:40 ` Manivannan Sadhasivam
2026-02-24 8:49 ` Shawn Lin
2026-02-24 14:06 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox