* [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs
@ 2026-01-06 9:18 Shawn Lin
2026-01-06 9:18 ` [PATCH 2/2] PCI: dw-rockchip: Add .ltssm_trace() support Shawn Lin
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Shawn Lin @ 2026-01-06 9:18 UTC (permalink / raw)
To: Manivannan Sadhasivam, Jingoo Han, Bjorn Helgaas
Cc: linux-rockchip, Niklas Cassel, linux-pci, 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. Add an ltssm_trace operation
node in debugfs for platform which could provide these information to show
the LTSSM history.
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
.../controller/dwc/pcie-designware-debugfs.c | 44 +++++++++++++++++++
drivers/pci/controller/dwc/pcie-designware.h | 6 +++
2 files changed, 50 insertions(+)
diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
index df98fee69892..569e8e078ef2 100644
--- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c
+++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
@@ -511,6 +511,38 @@ static int ltssm_status_open(struct inode *inode, struct file *file)
return single_open(file, ltssm_status_show, inode->i_private);
}
+static struct dw_pcie_ltssm_history *dw_pcie_ltssm_trace(struct dw_pcie *pci)
+{
+ if (pci->ops && pci->ops->ltssm_trace)
+ return pci->ops->ltssm_trace(pci);
+
+ return NULL;
+}
+
+static int ltssm_trace_show(struct seq_file *s, void *v)
+{
+ struct dw_pcie *pci = s->private;
+ struct dw_pcie_ltssm_history *history;
+ enum dw_pcie_ltssm val;
+ u32 loop;
+
+ history = dw_pcie_ltssm_trace(pci);
+ if (!history)
+ return 0;
+
+ for (loop = 0; loop < history->count; loop++) {
+ val = history->states[loop];
+ seq_printf(s, "%s (0x%02x)\n", ltssm_status_string(val), val);
+ }
+
+ return 0;
+}
+
+static int ltssm_trace_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, ltssm_trace_show, inode->i_private);
+}
+
#define dwc_debugfs_create(name) \
debugfs_create_file(#name, 0644, rasdes_debug, pci, \
&dbg_ ## name ## _fops)
@@ -552,6 +584,11 @@ static const struct file_operations dwc_pcie_ltssm_status_ops = {
.read = seq_read,
};
+static const struct file_operations dwc_pcie_ltssm_trace_ops = {
+ .open = ltssm_trace_open,
+ .read = seq_read,
+};
+
static void dwc_pcie_rasdes_debugfs_deinit(struct dw_pcie *pci)
{
struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
@@ -644,6 +681,12 @@ static void dwc_pcie_ltssm_debugfs_init(struct dw_pcie *pci, struct dentry *dir)
&dwc_pcie_ltssm_status_ops);
}
+static void dwc_pcie_ltssm_trace_debugfs_init(struct dw_pcie *pci, struct dentry *dir)
+{
+ debugfs_create_file("ltssm_trace", 0444, dir, pci,
+ &dwc_pcie_ltssm_trace_ops);
+}
+
static int dw_pcie_ptm_check_capability(void *drvdata)
{
struct dw_pcie *pci = drvdata;
@@ -922,6 +965,7 @@ void dwc_pcie_debugfs_init(struct dw_pcie *pci, enum dw_pcie_device_mode mode)
err);
dwc_pcie_ltssm_debugfs_init(pci, dir);
+ dwc_pcie_ltssm_trace_debugfs_init(pci, dir);
pci->mode = mode;
pci->ptm_debugfs = pcie_ptm_create_debugfs(pci->dev, pci,
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index 5cd27f5739f1..0df18995b7fe 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -395,6 +395,11 @@ enum dw_pcie_ltssm {
DW_PCIE_LTSSM_UNKNOWN = 0xFFFFFFFF,
};
+struct dw_pcie_ltssm_history {
+ enum dw_pcie_ltssm *states;
+ u32 count;
+};
+
struct dw_pcie_ob_atu_cfg {
int index;
int type;
@@ -499,6 +504,7 @@ struct dw_pcie_ops {
size_t size, u32 val);
bool (*link_up)(struct dw_pcie *pcie);
enum dw_pcie_ltssm (*get_ltssm)(struct dw_pcie *pcie);
+ struct dw_pcie_ltssm_history * (*ltssm_trace)(struct dw_pcie *pcie);
int (*start_link)(struct dw_pcie *pcie);
void (*stop_link)(struct dw_pcie *pcie);
int (*assert_perst)(struct dw_pcie *pcie, bool assert);
--
2.43.0
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/2] PCI: dw-rockchip: Add .ltssm_trace() support
2026-01-06 9:18 [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs Shawn Lin
@ 2026-01-06 9:18 ` Shawn Lin
2026-01-07 9:12 ` [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs Krishna Chaitanya Chundru
2026-01-07 12:41 ` Manivannan Sadhasivam
2 siblings, 0 replies; 11+ messages in thread
From: Shawn Lin @ 2026-01-06 9:18 UTC (permalink / raw)
To: Manivannan Sadhasivam, Jingoo Han, Bjorn Helgaas
Cc: linux-rockchip, Niklas Cassel, linux-pci, Shawn Lin
Rockchip platforms provide a 64x4 bytes debug FIFO to trace the
LTSSM history. Any LTSSM change will be recorded. It's userful
for debug purpose, for example link failure, etc.
cat /sys/kernel/debug/dwc_pcie_a40c00000.pcie/ltssm_trace
DETECT_QUIET (0x00)
DETECT_ACT (0x01)
POLL_ACTIVE (0x02)
POLL_COMPLIANCE (0x03)
POLL_ACTIVE (0x02)
POLL_CONFIG (0x04)
CFG_LINKWD_START (0x07)
...
RCVRY_IDLE (0x10)
L0 (0x11)
L123_SEND_EIDLE (0x13)
L1_IDLE (0x14)
RCVRY_LOCK (0x0d)
...
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 49 +++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
index 352f513ebf03..0f7430e686b2 100644
--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
+++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -73,6 +73,17 @@
#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_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_LTSSM_HISTORY_CNT 64
+
/* Hot Reset Control Register */
#define PCIE_CLIENT_HOT_RESET_CTRL 0x180
#define PCIE_LTSSM_APP_DLY2_EN BIT(1)
@@ -96,6 +107,7 @@ struct rockchip_pcie {
struct irq_domain *irq_domain;
const struct rockchip_pcie_of_data *data;
bool supports_clkreq;
+ struct dw_pcie_ltssm_history ltssm_history;
};
struct rockchip_pcie_of_data {
@@ -206,6 +218,34 @@ static enum dw_pcie_ltssm rockchip_pcie_get_ltssm(struct dw_pcie *pci)
return rockchip_pcie_get_ltssm_reg(rockchip) & PCIE_LTSSM_STATUS_MASK;
}
+static void rockchip_pcie_enable_ltssm_trace(struct rockchip_pcie *rockchip)
+{
+ 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);
+}
+
+static struct dw_pcie_ltssm_history* rockchip_pcie_ltssm_trace(struct dw_pcie *pci)
+{
+ struct rockchip_pcie *rockchip = to_rockchip_pcie(pci);
+ u32 loop, val;
+
+ for (loop = 0; loop < PCIE_DBG_LTSSM_HISTORY_CNT; loop++) {
+ val = rockchip_pcie_readl_apb(rockchip, PCIE_CLIENT_DBG_FIFO_STATUS) &
+ PCIE_LTSSM_STATUS_MASK;
+ rockchip->ltssm_history.states[loop] = val;
+ }
+
+ return &rockchip->ltssm_history;
+}
+
static void rockchip_pcie_enable_ltssm(struct rockchip_pcie *rockchip)
{
rockchip_pcie_writel_apb(rockchip, PCIE_CLIENT_ENABLE_LTSSM,
@@ -277,6 +317,8 @@ static int rockchip_pcie_start_link(struct dw_pcie *pci)
/* Reset device */
gpiod_set_value_cansleep(rockchip->rst_gpio, 0);
+ rockchip_pcie_enable_ltssm_trace(rockchip);
+
rockchip_pcie_enable_ltssm(rockchip);
/*
@@ -506,6 +548,7 @@ static const struct dw_pcie_ops dw_pcie_ops = {
.start_link = rockchip_pcie_start_link,
.stop_link = rockchip_pcie_stop_link,
.get_ltssm = rockchip_pcie_get_ltssm,
+ .ltssm_trace = rockchip_pcie_ltssm_trace,
};
static irqreturn_t rockchip_pcie_ep_sys_irq_thread(int irq, void *arg)
@@ -645,6 +688,12 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
rockchip->pci.ops = &dw_pcie_ops;
rockchip->data = data;
+ rockchip->ltssm_history.count = PCIE_DBG_LTSSM_HISTORY_CNT;
+ rockchip->ltssm_history.states = devm_kzalloc(dev,
+ PCIE_DBG_LTSSM_HISTORY_CNT * sizeof(u32), GFP_KERNEL);
+ if (!rockchip->ltssm_history.states)
+ return -ENOMEM;
+
/* Default N_FTS value (210) is broken, override it to 255 */
rockchip->pci.n_fts[0] = 255; /* Gen1 */
rockchip->pci.n_fts[1] = 255; /* Gen2+ */
--
2.43.0
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs
2026-01-06 9:18 [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs Shawn Lin
2026-01-06 9:18 ` [PATCH 2/2] PCI: dw-rockchip: Add .ltssm_trace() support Shawn Lin
@ 2026-01-07 9:12 ` Krishna Chaitanya Chundru
2026-01-07 9:41 ` Shawn Lin
2026-01-07 12:40 ` Manivannan Sadhasivam
2026-01-07 12:41 ` Manivannan Sadhasivam
2 siblings, 2 replies; 11+ messages in thread
From: Krishna Chaitanya Chundru @ 2026-01-07 9:12 UTC (permalink / raw)
To: Shawn Lin, Manivannan Sadhasivam, Jingoo Han, Bjorn Helgaas
Cc: linux-rockchip, Niklas Cassel, linux-pci
On 1/6/2026 2:48 PM, 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. Add an ltssm_trace operation
> node in debugfs for platform which could provide these information to show
> the LTSSM history.
>
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
> .../controller/dwc/pcie-designware-debugfs.c | 44 +++++++++++++++++++
> drivers/pci/controller/dwc/pcie-designware.h | 6 +++
> 2 files changed, 50 insertions(+)
>
> diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> index df98fee69892..569e8e078ef2 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> @@ -511,6 +511,38 @@ static int ltssm_status_open(struct inode *inode, struct file *file)
> return single_open(file, ltssm_status_show, inode->i_private);
> }
>
> +static struct dw_pcie_ltssm_history *dw_pcie_ltssm_trace(struct dw_pcie *pci)
> +{
> + if (pci->ops && pci->ops->ltssm_trace)
> + return pci->ops->ltssm_trace(pci);
> +
> + return NULL;
> +}
> +
> +static int ltssm_trace_show(struct seq_file *s, void *v)
> +{
> + struct dw_pcie *pci = s->private;
> + struct dw_pcie_ltssm_history *history;
> + enum dw_pcie_ltssm val;
> + u32 loop;
> +
> + history = dw_pcie_ltssm_trace(pci);
> + if (!history)
> + return 0;
> +
> + for (loop = 0; loop < history->count; loop++) {
> + val = history->states[loop];
> + seq_printf(s, "%s (0x%02x)\n", ltssm_status_string(val), val);
> + }
> +
> + return 0;
> +}
> +
> +static int ltssm_trace_open(struct inode *inode, struct file *file)
> +{
> + return single_open(file, ltssm_trace_show, inode->i_private);
> +}
> +
> #define dwc_debugfs_create(name) \
> debugfs_create_file(#name, 0644, rasdes_debug, pci, \
> &dbg_ ## name ## _fops)
> @@ -552,6 +584,11 @@ static const struct file_operations dwc_pcie_ltssm_status_ops = {
> .read = seq_read,
> };
>
> +static const struct file_operations dwc_pcie_ltssm_trace_ops = {
> + .open = ltssm_trace_open,
> + .read = seq_read,
> +};
> +
> static void dwc_pcie_rasdes_debugfs_deinit(struct dw_pcie *pci)
> {
> struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
> @@ -644,6 +681,12 @@ static void dwc_pcie_ltssm_debugfs_init(struct dw_pcie *pci, struct dentry *dir)
> &dwc_pcie_ltssm_status_ops);
> }
>
> +static void dwc_pcie_ltssm_trace_debugfs_init(struct dw_pcie *pci, struct dentry *dir)
> +{
> + debugfs_create_file("ltssm_trace", 0444, dir, pci,
> + &dwc_pcie_ltssm_trace_ops);
Can we have this as the sysfs, so that if there is some issue in
production devices where debugfs is not available,
we can use this to see LTSSM state figure out the issue.
- Krishna Chaitanya.
> +}
> +
> static int dw_pcie_ptm_check_capability(void *drvdata)
> {
> struct dw_pcie *pci = drvdata;
> @@ -922,6 +965,7 @@ void dwc_pcie_debugfs_init(struct dw_pcie *pci, enum dw_pcie_device_mode mode)
> err);
>
> dwc_pcie_ltssm_debugfs_init(pci, dir);
> + dwc_pcie_ltssm_trace_debugfs_init(pci, dir);
>
> pci->mode = mode;
> pci->ptm_debugfs = pcie_ptm_create_debugfs(pci->dev, pci,
> diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
> index 5cd27f5739f1..0df18995b7fe 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.h
> +++ b/drivers/pci/controller/dwc/pcie-designware.h
> @@ -395,6 +395,11 @@ enum dw_pcie_ltssm {
> DW_PCIE_LTSSM_UNKNOWN = 0xFFFFFFFF,
> };
>
> +struct dw_pcie_ltssm_history {
> + enum dw_pcie_ltssm *states;
> + u32 count;
> +};
> +
> struct dw_pcie_ob_atu_cfg {
> int index;
> int type;
> @@ -499,6 +504,7 @@ struct dw_pcie_ops {
> size_t size, u32 val);
> bool (*link_up)(struct dw_pcie *pcie);
> enum dw_pcie_ltssm (*get_ltssm)(struct dw_pcie *pcie);
> + struct dw_pcie_ltssm_history * (*ltssm_trace)(struct dw_pcie *pcie);
> int (*start_link)(struct dw_pcie *pcie);
> void (*stop_link)(struct dw_pcie *pcie);
> int (*assert_perst)(struct dw_pcie *pcie, bool assert);
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs
2026-01-07 9:12 ` [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs Krishna Chaitanya Chundru
@ 2026-01-07 9:41 ` Shawn Lin
2026-01-07 10:09 ` Krishna Chaitanya Chundru
2026-01-07 12:40 ` Manivannan Sadhasivam
1 sibling, 1 reply; 11+ messages in thread
From: Shawn Lin @ 2026-01-07 9:41 UTC (permalink / raw)
To: Krishna Chaitanya Chundru, Manivannan Sadhasivam, Jingoo Han,
Bjorn Helgaas
Cc: shawn.lin, linux-rockchip, Niklas Cassel, linux-pci
在 2026/01/07 星期三 17:12, Krishna Chaitanya Chundru 写道:
>
>
> On 1/6/2026 2:48 PM, 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. Add an ltssm_trace
>> operation
>> node in debugfs for platform which could provide these information to
>> show
>> the LTSSM history.
>>
>> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
>> ---
>> .../controller/dwc/pcie-designware-debugfs.c | 44 +++++++++++++++++++
>> drivers/pci/controller/dwc/pcie-designware.h | 6 +++
>> 2 files changed, 50 insertions(+)
>>
>> diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/
>> drivers/pci/controller/dwc/pcie-designware-debugfs.c
>> index df98fee69892..569e8e078ef2 100644
>> --- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c
>> +++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
>> @@ -511,6 +511,38 @@ static int ltssm_status_open(struct inode *inode,
>> struct file *file)
>> return single_open(file, ltssm_status_show, inode->i_private);
>> }
>> +static struct dw_pcie_ltssm_history *dw_pcie_ltssm_trace(struct
>> dw_pcie *pci)
>> +{
>> + if (pci->ops && pci->ops->ltssm_trace)
>> + return pci->ops->ltssm_trace(pci);
>> +
>> + return NULL;
>> +}
>> +
>> +static int ltssm_trace_show(struct seq_file *s, void *v)
>> +{
>> + struct dw_pcie *pci = s->private;
>> + struct dw_pcie_ltssm_history *history;
>> + enum dw_pcie_ltssm val;
>> + u32 loop;
>> +
>> + history = dw_pcie_ltssm_trace(pci);
>> + if (!history)
>> + return 0;
>> +
>> + for (loop = 0; loop < history->count; loop++) {
>> + val = history->states[loop];
>> + seq_printf(s, "%s (0x%02x)\n", ltssm_status_string(val), val);
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +static int ltssm_trace_open(struct inode *inode, struct file *file)
>> +{
>> + return single_open(file, ltssm_trace_show, inode->i_private);
>> +}
>> +
>> #define dwc_debugfs_create(name) \
>> debugfs_create_file(#name, 0644, rasdes_debug, pci, \
>> &dbg_ ## name ## _fops)
>> @@ -552,6 +584,11 @@ static const struct file_operations
>> dwc_pcie_ltssm_status_ops = {
>> .read = seq_read,
>> };
>> +static const struct file_operations dwc_pcie_ltssm_trace_ops = {
>> + .open = ltssm_trace_open,
>> + .read = seq_read,
>> +};
>> +
>> static void dwc_pcie_rasdes_debugfs_deinit(struct dw_pcie *pci)
>> {
>> struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
>> @@ -644,6 +681,12 @@ static void dwc_pcie_ltssm_debugfs_init(struct
>> dw_pcie *pci, struct dentry *dir)
>> &dwc_pcie_ltssm_status_ops);
>> }
>> +static void dwc_pcie_ltssm_trace_debugfs_init(struct dw_pcie *pci,
>> struct dentry *dir)
>> +{
>> + debugfs_create_file("ltssm_trace", 0444, dir, pci,
>> + &dwc_pcie_ltssm_trace_ops);
> Can we have this as the sysfs, so that if there is some issue in
> production devices where debugfs is not available,
> we can use this to see LTSSM state figure out the issue.
>
Thanks for the input. I think the ltssm_trace is debug in nature, just
like the existing ltssm and rasdes_debug nodes, so it probably fits
better under debugfs for consistency. Moreover, given most time we
combine rasdes_debug and ltssmm history to debug issues, if we split it
out, we’d end up with two separate debugging areas, which feels a bit
fragmented and less clear.
> - Krishna Chaitanya.
>> +}
>> +
>> static int dw_pcie_ptm_check_capability(void *drvdata)
>> {
>> struct dw_pcie *pci = drvdata;
>> @@ -922,6 +965,7 @@ void dwc_pcie_debugfs_init(struct dw_pcie *pci,
>> enum dw_pcie_device_mode mode)
>> err);
>> dwc_pcie_ltssm_debugfs_init(pci, dir);
>> + dwc_pcie_ltssm_trace_debugfs_init(pci, dir);
>> pci->mode = mode;
>> pci->ptm_debugfs = pcie_ptm_create_debugfs(pci->dev, pci,
>> diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/
>> pci/controller/dwc/pcie-designware.h
>> index 5cd27f5739f1..0df18995b7fe 100644
>> --- a/drivers/pci/controller/dwc/pcie-designware.h
>> +++ b/drivers/pci/controller/dwc/pcie-designware.h
>> @@ -395,6 +395,11 @@ enum dw_pcie_ltssm {
>> DW_PCIE_LTSSM_UNKNOWN = 0xFFFFFFFF,
>> };
>> +struct dw_pcie_ltssm_history {
>> + enum dw_pcie_ltssm *states;
>> + u32 count;
>> +};
>> +
>> struct dw_pcie_ob_atu_cfg {
>> int index;
>> int type;
>> @@ -499,6 +504,7 @@ struct dw_pcie_ops {
>> size_t size, u32 val);
>> bool (*link_up)(struct dw_pcie *pcie);
>> enum dw_pcie_ltssm (*get_ltssm)(struct dw_pcie *pcie);
>> + struct dw_pcie_ltssm_history * (*ltssm_trace)(struct dw_pcie *pcie);
>> int (*start_link)(struct dw_pcie *pcie);
>> void (*stop_link)(struct dw_pcie *pcie);
>> int (*assert_perst)(struct dw_pcie *pcie, bool assert);
>
>
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs
2026-01-07 9:41 ` Shawn Lin
@ 2026-01-07 10:09 ` Krishna Chaitanya Chundru
0 siblings, 0 replies; 11+ messages in thread
From: Krishna Chaitanya Chundru @ 2026-01-07 10:09 UTC (permalink / raw)
To: Shawn Lin
Cc: linux-rockchip, Niklas Cassel, linux-pci, Jingoo Han,
Bjorn Helgaas, Manivannan Sadhasivam
On 1/7/2026 3:11 PM, Shawn Lin wrote:
> 在 2026/01/07 星期三 17:12, Krishna Chaitanya Chundru 写道:
>>
>>
>> On 1/6/2026 2:48 PM, 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. Add an ltssm_trace
>>> operation
>>> node in debugfs for platform which could provide these information
>>> to show
>>> the LTSSM history.
>>>
>>> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
>>> ---
>>> .../controller/dwc/pcie-designware-debugfs.c | 44
>>> +++++++++++++++++++
>>> drivers/pci/controller/dwc/pcie-designware.h | 6 +++
>>> 2 files changed, 50 insertions(+)
>>>
>>> diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/
>>> drivers/pci/controller/dwc/pcie-designware-debugfs.c
>>> index df98fee69892..569e8e078ef2 100644
>>> --- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c
>>> +++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
>>> @@ -511,6 +511,38 @@ static int ltssm_status_open(struct inode
>>> *inode, struct file *file)
>>> return single_open(file, ltssm_status_show, inode->i_private);
>>> }
>>> +static struct dw_pcie_ltssm_history *dw_pcie_ltssm_trace(struct
>>> dw_pcie *pci)
>>> +{
>>> + if (pci->ops && pci->ops->ltssm_trace)
>>> + return pci->ops->ltssm_trace(pci);
>>> +
>>> + return NULL;
>>> +}
>>> +
>>> +static int ltssm_trace_show(struct seq_file *s, void *v)
>>> +{
>>> + struct dw_pcie *pci = s->private;
>>> + struct dw_pcie_ltssm_history *history;
>>> + enum dw_pcie_ltssm val;
>>> + u32 loop;
>>> +
>>> + history = dw_pcie_ltssm_trace(pci);
>>> + if (!history)
>>> + return 0;
>>> +
>>> + for (loop = 0; loop < history->count; loop++) {
>>> + val = history->states[loop];
>>> + seq_printf(s, "%s (0x%02x)\n", ltssm_status_string(val), val);
>>> + }
>>> +
>>> + return 0;
>>> +}
>>> +
>>> +static int ltssm_trace_open(struct inode *inode, struct file *file)
>>> +{
>>> + return single_open(file, ltssm_trace_show, inode->i_private);
>>> +}
>>> +
>>> #define dwc_debugfs_create(name) \
>>> debugfs_create_file(#name, 0644, rasdes_debug, pci, \
>>> &dbg_ ## name ## _fops)
>>> @@ -552,6 +584,11 @@ static const struct file_operations
>>> dwc_pcie_ltssm_status_ops = {
>>> .read = seq_read,
>>> };
>>> +static const struct file_operations dwc_pcie_ltssm_trace_ops = {
>>> + .open = ltssm_trace_open,
>>> + .read = seq_read,
>>> +};
>>> +
>>> static void dwc_pcie_rasdes_debugfs_deinit(struct dw_pcie *pci)
>>> {
>>> struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
>>> @@ -644,6 +681,12 @@ static void dwc_pcie_ltssm_debugfs_init(struct
>>> dw_pcie *pci, struct dentry *dir)
>>> &dwc_pcie_ltssm_status_ops);
>>> }
>>> +static void dwc_pcie_ltssm_trace_debugfs_init(struct dw_pcie *pci,
>>> struct dentry *dir)
>>> +{
>>> + debugfs_create_file("ltssm_trace", 0444, dir, pci,
>>> + &dwc_pcie_ltssm_trace_ops);
>> Can we have this as the sysfs, so that if there is some issue in
>> production devices where debugfs is not available,
>> we can use this to see LTSSM state figure out the issue.
>>
>
> Thanks for the input. I think the ltssm_trace is debug in nature, just
> like the existing ltssm and rasdes_debug nodes, so it probably fits
> better under debugfs for consistency. Moreover, given most time we
> combine rasdes_debug and ltssmm history to debug issues, if we split it
> out, we’d end up with two separate debugging areas, which feels a bit
> fragmented and less clear.
Rasdes has statistics and err injection along with debug feature, we can
have them
as debugfs only since they will not help in debugging production issues.
For others like
ltssm, lane_detect & rx_valid we can have in sysfs.
- Krishna Chaitanya.
>
>
>> - Krishna Chaitanya.
>>> +}
>>> +
>>> static int dw_pcie_ptm_check_capability(void *drvdata)
>>> {
>>> struct dw_pcie *pci = drvdata;
>>> @@ -922,6 +965,7 @@ void dwc_pcie_debugfs_init(struct dw_pcie *pci,
>>> enum dw_pcie_device_mode mode)
>>> err);
>>> dwc_pcie_ltssm_debugfs_init(pci, dir);
>>> + dwc_pcie_ltssm_trace_debugfs_init(pci, dir);
>>> pci->mode = mode;
>>> pci->ptm_debugfs = pcie_ptm_create_debugfs(pci->dev, pci,
>>> diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/
>>> pci/controller/dwc/pcie-designware.h
>>> index 5cd27f5739f1..0df18995b7fe 100644
>>> --- a/drivers/pci/controller/dwc/pcie-designware.h
>>> +++ b/drivers/pci/controller/dwc/pcie-designware.h
>>> @@ -395,6 +395,11 @@ enum dw_pcie_ltssm {
>>> DW_PCIE_LTSSM_UNKNOWN = 0xFFFFFFFF,
>>> };
>>> +struct dw_pcie_ltssm_history {
>>> + enum dw_pcie_ltssm *states;
>>> + u32 count;
>>> +};
>>> +
>>> struct dw_pcie_ob_atu_cfg {
>>> int index;
>>> int type;
>>> @@ -499,6 +504,7 @@ struct dw_pcie_ops {
>>> size_t size, u32 val);
>>> bool (*link_up)(struct dw_pcie *pcie);
>>> enum dw_pcie_ltssm (*get_ltssm)(struct dw_pcie *pcie);
>>> + struct dw_pcie_ltssm_history * (*ltssm_trace)(struct dw_pcie
>>> *pcie);
>>> int (*start_link)(struct dw_pcie *pcie);
>>> void (*stop_link)(struct dw_pcie *pcie);
>>> int (*assert_perst)(struct dw_pcie *pcie, bool assert);
>>
>>
>
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs
2026-01-07 9:12 ` [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs Krishna Chaitanya Chundru
2026-01-07 9:41 ` Shawn Lin
@ 2026-01-07 12:40 ` Manivannan Sadhasivam
1 sibling, 0 replies; 11+ messages in thread
From: Manivannan Sadhasivam @ 2026-01-07 12:40 UTC (permalink / raw)
To: Krishna Chaitanya Chundru
Cc: Shawn Lin, Jingoo Han, Bjorn Helgaas, linux-rockchip,
Niklas Cassel, linux-pci
On Wed, Jan 07, 2026 at 02:42:38PM +0530, Krishna Chaitanya Chundru wrote:
>
>
> On 1/6/2026 2:48 PM, 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. Add an ltssm_trace operation
> > node in debugfs for platform which could provide these information to show
> > the LTSSM history.
> >
> > Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> > ---
> > .../controller/dwc/pcie-designware-debugfs.c | 44 +++++++++++++++++++
> > drivers/pci/controller/dwc/pcie-designware.h | 6 +++
> > 2 files changed, 50 insertions(+)
> >
> > diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> > index df98fee69892..569e8e078ef2 100644
> > --- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> > +++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> > @@ -511,6 +511,38 @@ static int ltssm_status_open(struct inode *inode, struct file *file)
> > return single_open(file, ltssm_status_show, inode->i_private);
> > }
> > +static struct dw_pcie_ltssm_history *dw_pcie_ltssm_trace(struct dw_pcie *pci)
> > +{
> > + if (pci->ops && pci->ops->ltssm_trace)
> > + return pci->ops->ltssm_trace(pci);
> > +
> > + return NULL;
> > +}
> > +
> > +static int ltssm_trace_show(struct seq_file *s, void *v)
> > +{
> > + struct dw_pcie *pci = s->private;
> > + struct dw_pcie_ltssm_history *history;
> > + enum dw_pcie_ltssm val;
> > + u32 loop;
> > +
> > + history = dw_pcie_ltssm_trace(pci);
> > + if (!history)
> > + return 0;
> > +
> > + for (loop = 0; loop < history->count; loop++) {
> > + val = history->states[loop];
> > + seq_printf(s, "%s (0x%02x)\n", ltssm_status_string(val), val);
> > + }
> > +
> > + return 0;
> > +}
> > +
> > +static int ltssm_trace_open(struct inode *inode, struct file *file)
> > +{
> > + return single_open(file, ltssm_trace_show, inode->i_private);
> > +}
> > +
> > #define dwc_debugfs_create(name) \
> > debugfs_create_file(#name, 0644, rasdes_debug, pci, \
> > &dbg_ ## name ## _fops)
> > @@ -552,6 +584,11 @@ static const struct file_operations dwc_pcie_ltssm_status_ops = {
> > .read = seq_read,
> > };
> > +static const struct file_operations dwc_pcie_ltssm_trace_ops = {
> > + .open = ltssm_trace_open,
> > + .read = seq_read,
> > +};
> > +
> > static void dwc_pcie_rasdes_debugfs_deinit(struct dw_pcie *pci)
> > {
> > struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
> > @@ -644,6 +681,12 @@ static void dwc_pcie_ltssm_debugfs_init(struct dw_pcie *pci, struct dentry *dir)
> > &dwc_pcie_ltssm_status_ops);
> > }
> > +static void dwc_pcie_ltssm_trace_debugfs_init(struct dw_pcie *pci, struct dentry *dir)
> > +{
> > + debugfs_create_file("ltssm_trace", 0444, dir, pci,
> > + &dwc_pcie_ltssm_trace_ops);
> Can we have this as the sysfs, so that if there is some issue in production
> devices where debugfs is not available,
> we can use this to see LTSSM state figure out the issue.
'figure out' means 'debug'. If you want to debug an issue, you need to enable
debugfs. You should not introduce random sysfs ABI for debug interfaces.
- Mani
>
> - Krishna Chaitanya.
> > +}
> > +
> > static int dw_pcie_ptm_check_capability(void *drvdata)
> > {
> > struct dw_pcie *pci = drvdata;
> > @@ -922,6 +965,7 @@ void dwc_pcie_debugfs_init(struct dw_pcie *pci, enum dw_pcie_device_mode mode)
> > err);
> > dwc_pcie_ltssm_debugfs_init(pci, dir);
> > + dwc_pcie_ltssm_trace_debugfs_init(pci, dir);
> > pci->mode = mode;
> > pci->ptm_debugfs = pcie_ptm_create_debugfs(pci->dev, pci,
> > diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
> > index 5cd27f5739f1..0df18995b7fe 100644
> > --- a/drivers/pci/controller/dwc/pcie-designware.h
> > +++ b/drivers/pci/controller/dwc/pcie-designware.h
> > @@ -395,6 +395,11 @@ enum dw_pcie_ltssm {
> > DW_PCIE_LTSSM_UNKNOWN = 0xFFFFFFFF,
> > };
> > +struct dw_pcie_ltssm_history {
> > + enum dw_pcie_ltssm *states;
> > + u32 count;
> > +};
> > +
> > struct dw_pcie_ob_atu_cfg {
> > int index;
> > int type;
> > @@ -499,6 +504,7 @@ struct dw_pcie_ops {
> > size_t size, u32 val);
> > bool (*link_up)(struct dw_pcie *pcie);
> > enum dw_pcie_ltssm (*get_ltssm)(struct dw_pcie *pcie);
> > + struct dw_pcie_ltssm_history * (*ltssm_trace)(struct dw_pcie *pcie);
> > int (*start_link)(struct dw_pcie *pcie);
> > void (*stop_link)(struct dw_pcie *pcie);
> > int (*assert_perst)(struct dw_pcie *pcie, bool assert);
>
--
மணிவண்ணன் சதாசிவம்
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs
2026-01-06 9:18 [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs Shawn Lin
2026-01-06 9:18 ` [PATCH 2/2] PCI: dw-rockchip: Add .ltssm_trace() support Shawn Lin
2026-01-07 9:12 ` [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs Krishna Chaitanya Chundru
@ 2026-01-07 12:41 ` Manivannan Sadhasivam
2026-01-08 1:01 ` Shawn Lin
2 siblings, 1 reply; 11+ messages in thread
From: Manivannan Sadhasivam @ 2026-01-07 12:41 UTC (permalink / raw)
To: Shawn Lin
Cc: Jingoo Han, Bjorn Helgaas, linux-rockchip, Niklas Cassel,
linux-pci
On Tue, Jan 06, 2026 at 05:18:38PM +0800, 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. Add an ltssm_trace operation
> node in debugfs for platform which could provide these information to show
> the LTSSM history.
>
Why don't you implement it as a tracepoint since you want to expose traces?
- Mani
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
> .../controller/dwc/pcie-designware-debugfs.c | 44 +++++++++++++++++++
> drivers/pci/controller/dwc/pcie-designware.h | 6 +++
> 2 files changed, 50 insertions(+)
>
> diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> index df98fee69892..569e8e078ef2 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> @@ -511,6 +511,38 @@ static int ltssm_status_open(struct inode *inode, struct file *file)
> return single_open(file, ltssm_status_show, inode->i_private);
> }
>
> +static struct dw_pcie_ltssm_history *dw_pcie_ltssm_trace(struct dw_pcie *pci)
> +{
> + if (pci->ops && pci->ops->ltssm_trace)
> + return pci->ops->ltssm_trace(pci);
> +
> + return NULL;
> +}
> +
> +static int ltssm_trace_show(struct seq_file *s, void *v)
> +{
> + struct dw_pcie *pci = s->private;
> + struct dw_pcie_ltssm_history *history;
> + enum dw_pcie_ltssm val;
> + u32 loop;
> +
> + history = dw_pcie_ltssm_trace(pci);
> + if (!history)
> + return 0;
> +
> + for (loop = 0; loop < history->count; loop++) {
> + val = history->states[loop];
> + seq_printf(s, "%s (0x%02x)\n", ltssm_status_string(val), val);
> + }
> +
> + return 0;
> +}
> +
> +static int ltssm_trace_open(struct inode *inode, struct file *file)
> +{
> + return single_open(file, ltssm_trace_show, inode->i_private);
> +}
> +
> #define dwc_debugfs_create(name) \
> debugfs_create_file(#name, 0644, rasdes_debug, pci, \
> &dbg_ ## name ## _fops)
> @@ -552,6 +584,11 @@ static const struct file_operations dwc_pcie_ltssm_status_ops = {
> .read = seq_read,
> };
>
> +static const struct file_operations dwc_pcie_ltssm_trace_ops = {
> + .open = ltssm_trace_open,
> + .read = seq_read,
> +};
> +
> static void dwc_pcie_rasdes_debugfs_deinit(struct dw_pcie *pci)
> {
> struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
> @@ -644,6 +681,12 @@ static void dwc_pcie_ltssm_debugfs_init(struct dw_pcie *pci, struct dentry *dir)
> &dwc_pcie_ltssm_status_ops);
> }
>
> +static void dwc_pcie_ltssm_trace_debugfs_init(struct dw_pcie *pci, struct dentry *dir)
> +{
> + debugfs_create_file("ltssm_trace", 0444, dir, pci,
> + &dwc_pcie_ltssm_trace_ops);
> +}
> +
> static int dw_pcie_ptm_check_capability(void *drvdata)
> {
> struct dw_pcie *pci = drvdata;
> @@ -922,6 +965,7 @@ void dwc_pcie_debugfs_init(struct dw_pcie *pci, enum dw_pcie_device_mode mode)
> err);
>
> dwc_pcie_ltssm_debugfs_init(pci, dir);
> + dwc_pcie_ltssm_trace_debugfs_init(pci, dir);
>
> pci->mode = mode;
> pci->ptm_debugfs = pcie_ptm_create_debugfs(pci->dev, pci,
> diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
> index 5cd27f5739f1..0df18995b7fe 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.h
> +++ b/drivers/pci/controller/dwc/pcie-designware.h
> @@ -395,6 +395,11 @@ enum dw_pcie_ltssm {
> DW_PCIE_LTSSM_UNKNOWN = 0xFFFFFFFF,
> };
>
> +struct dw_pcie_ltssm_history {
> + enum dw_pcie_ltssm *states;
> + u32 count;
> +};
> +
> struct dw_pcie_ob_atu_cfg {
> int index;
> int type;
> @@ -499,6 +504,7 @@ struct dw_pcie_ops {
> size_t size, u32 val);
> bool (*link_up)(struct dw_pcie *pcie);
> enum dw_pcie_ltssm (*get_ltssm)(struct dw_pcie *pcie);
> + struct dw_pcie_ltssm_history * (*ltssm_trace)(struct dw_pcie *pcie);
> int (*start_link)(struct dw_pcie *pcie);
> void (*stop_link)(struct dw_pcie *pcie);
> int (*assert_perst)(struct dw_pcie *pcie, bool assert);
> --
> 2.43.0
>
>
--
மணிவண்ணன் சதாசிவம்
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs
2026-01-07 12:41 ` Manivannan Sadhasivam
@ 2026-01-08 1:01 ` Shawn Lin
2026-01-08 4:49 ` Manivannan Sadhasivam
0 siblings, 1 reply; 11+ messages in thread
From: Shawn Lin @ 2026-01-08 1:01 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: shawn.lin, Jingoo Han, Bjorn Helgaas, linux-rockchip,
Niklas Cassel, linux-pci
在 2026/01/07 星期三 20:41, Manivannan Sadhasivam 写道:
> On Tue, Jan 06, 2026 at 05:18:38PM +0800, 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. Add an ltssm_trace operation
>> node in debugfs for platform which could provide these information to show
>> the LTSSM history.
>>
>
> Why don't you implement it as a tracepoint since you want to expose traces?
>
I evaluated this option but didn't choose to do it just as I didn't
want to select CONFIG_TRACING_SUPPORT for dwc driver because of this
cheap function. But I'm fine to implement it as a tracepoint. Just to
make it clear, if a tracepoint is preferred, should I need to create a
new file like pcie-designware-trace?
> - Mani
>
>> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
>> ---
>> .../controller/dwc/pcie-designware-debugfs.c | 44 +++++++++++++++++++
>> drivers/pci/controller/dwc/pcie-designware.h | 6 +++
>> 2 files changed, 50 insertions(+)
>>
>> diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
>> index df98fee69892..569e8e078ef2 100644
>> --- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c
>> +++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
>> @@ -511,6 +511,38 @@ static int ltssm_status_open(struct inode *inode, struct file *file)
>> return single_open(file, ltssm_status_show, inode->i_private);
>> }
>>
>> +static struct dw_pcie_ltssm_history *dw_pcie_ltssm_trace(struct dw_pcie *pci)
>> +{
>> + if (pci->ops && pci->ops->ltssm_trace)
>> + return pci->ops->ltssm_trace(pci);
>> +
>> + return NULL;
>> +}
>> +
>> +static int ltssm_trace_show(struct seq_file *s, void *v)
>> +{
>> + struct dw_pcie *pci = s->private;
>> + struct dw_pcie_ltssm_history *history;
>> + enum dw_pcie_ltssm val;
>> + u32 loop;
>> +
>> + history = dw_pcie_ltssm_trace(pci);
>> + if (!history)
>> + return 0;
>> +
>> + for (loop = 0; loop < history->count; loop++) {
>> + val = history->states[loop];
>> + seq_printf(s, "%s (0x%02x)\n", ltssm_status_string(val), val);
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +static int ltssm_trace_open(struct inode *inode, struct file *file)
>> +{
>> + return single_open(file, ltssm_trace_show, inode->i_private);
>> +}
>> +
>> #define dwc_debugfs_create(name) \
>> debugfs_create_file(#name, 0644, rasdes_debug, pci, \
>> &dbg_ ## name ## _fops)
>> @@ -552,6 +584,11 @@ static const struct file_operations dwc_pcie_ltssm_status_ops = {
>> .read = seq_read,
>> };
>>
>> +static const struct file_operations dwc_pcie_ltssm_trace_ops = {
>> + .open = ltssm_trace_open,
>> + .read = seq_read,
>> +};
>> +
>> static void dwc_pcie_rasdes_debugfs_deinit(struct dw_pcie *pci)
>> {
>> struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
>> @@ -644,6 +681,12 @@ static void dwc_pcie_ltssm_debugfs_init(struct dw_pcie *pci, struct dentry *dir)
>> &dwc_pcie_ltssm_status_ops);
>> }
>>
>> +static void dwc_pcie_ltssm_trace_debugfs_init(struct dw_pcie *pci, struct dentry *dir)
>> +{
>> + debugfs_create_file("ltssm_trace", 0444, dir, pci,
>> + &dwc_pcie_ltssm_trace_ops);
>> +}
>> +
>> static int dw_pcie_ptm_check_capability(void *drvdata)
>> {
>> struct dw_pcie *pci = drvdata;
>> @@ -922,6 +965,7 @@ void dwc_pcie_debugfs_init(struct dw_pcie *pci, enum dw_pcie_device_mode mode)
>> err);
>>
>> dwc_pcie_ltssm_debugfs_init(pci, dir);
>> + dwc_pcie_ltssm_trace_debugfs_init(pci, dir);
>>
>> pci->mode = mode;
>> pci->ptm_debugfs = pcie_ptm_create_debugfs(pci->dev, pci,
>> diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
>> index 5cd27f5739f1..0df18995b7fe 100644
>> --- a/drivers/pci/controller/dwc/pcie-designware.h
>> +++ b/drivers/pci/controller/dwc/pcie-designware.h
>> @@ -395,6 +395,11 @@ enum dw_pcie_ltssm {
>> DW_PCIE_LTSSM_UNKNOWN = 0xFFFFFFFF,
>> };
>>
>> +struct dw_pcie_ltssm_history {
>> + enum dw_pcie_ltssm *states;
>> + u32 count;
>> +};
>> +
>> struct dw_pcie_ob_atu_cfg {
>> int index;
>> int type;
>> @@ -499,6 +504,7 @@ struct dw_pcie_ops {
>> size_t size, u32 val);
>> bool (*link_up)(struct dw_pcie *pcie);
>> enum dw_pcie_ltssm (*get_ltssm)(struct dw_pcie *pcie);
>> + struct dw_pcie_ltssm_history * (*ltssm_trace)(struct dw_pcie *pcie);
>> int (*start_link)(struct dw_pcie *pcie);
>> void (*stop_link)(struct dw_pcie *pcie);
>> int (*assert_perst)(struct dw_pcie *pcie, bool assert);
>> --
>> 2.43.0
>>
>>
>
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs
2026-01-08 1:01 ` Shawn Lin
@ 2026-01-08 4:49 ` Manivannan Sadhasivam
2026-01-08 4:58 ` Shawn Lin
0 siblings, 1 reply; 11+ messages in thread
From: Manivannan Sadhasivam @ 2026-01-08 4:49 UTC (permalink / raw)
To: Shawn Lin
Cc: Jingoo Han, Bjorn Helgaas, linux-rockchip, Niklas Cassel,
linux-pci
On Thu, Jan 08, 2026 at 09:01:43AM +0800, Shawn Lin wrote:
> 在 2026/01/07 星期三 20:41, Manivannan Sadhasivam 写道:
> > On Tue, Jan 06, 2026 at 05:18:38PM +0800, 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. Add an ltssm_trace operation
> > > node in debugfs for platform which could provide these information to show
> > > the LTSSM history.
> > >
> >
> > Why don't you implement it as a tracepoint since you want to expose traces?
> >
>
> I evaluated this option but didn't choose to do it just as I didn't
> want to select CONFIG_TRACING_SUPPORT for dwc driver because of this
> cheap function. But I'm fine to implement it as a tracepoint. Just to
> make it clear, if a tracepoint is preferred, should I need to create a new
> file like pcie-designware-trace?
>
I would prefer that, because that will allow us to add more tracepoints in the
future and not muddle pcie-designware.h. General convention is to define
trace events in a separate header.
- Mani
> > - Mani
> >
> > > Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> > > ---
> > > .../controller/dwc/pcie-designware-debugfs.c | 44 +++++++++++++++++++
> > > drivers/pci/controller/dwc/pcie-designware.h | 6 +++
> > > 2 files changed, 50 insertions(+)
> > >
> > > diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> > > index df98fee69892..569e8e078ef2 100644
> > > --- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> > > +++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> > > @@ -511,6 +511,38 @@ static int ltssm_status_open(struct inode *inode, struct file *file)
> > > return single_open(file, ltssm_status_show, inode->i_private);
> > > }
> > > +static struct dw_pcie_ltssm_history *dw_pcie_ltssm_trace(struct dw_pcie *pci)
> > > +{
> > > + if (pci->ops && pci->ops->ltssm_trace)
> > > + return pci->ops->ltssm_trace(pci);
> > > +
> > > + return NULL;
> > > +}
> > > +
> > > +static int ltssm_trace_show(struct seq_file *s, void *v)
> > > +{
> > > + struct dw_pcie *pci = s->private;
> > > + struct dw_pcie_ltssm_history *history;
> > > + enum dw_pcie_ltssm val;
> > > + u32 loop;
> > > +
> > > + history = dw_pcie_ltssm_trace(pci);
> > > + if (!history)
> > > + return 0;
> > > +
> > > + for (loop = 0; loop < history->count; loop++) {
> > > + val = history->states[loop];
> > > + seq_printf(s, "%s (0x%02x)\n", ltssm_status_string(val), val);
> > > + }
> > > +
> > > + return 0;
> > > +}
> > > +
> > > +static int ltssm_trace_open(struct inode *inode, struct file *file)
> > > +{
> > > + return single_open(file, ltssm_trace_show, inode->i_private);
> > > +}
> > > +
> > > #define dwc_debugfs_create(name) \
> > > debugfs_create_file(#name, 0644, rasdes_debug, pci, \
> > > &dbg_ ## name ## _fops)
> > > @@ -552,6 +584,11 @@ static const struct file_operations dwc_pcie_ltssm_status_ops = {
> > > .read = seq_read,
> > > };
> > > +static const struct file_operations dwc_pcie_ltssm_trace_ops = {
> > > + .open = ltssm_trace_open,
> > > + .read = seq_read,
> > > +};
> > > +
> > > static void dwc_pcie_rasdes_debugfs_deinit(struct dw_pcie *pci)
> > > {
> > > struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
> > > @@ -644,6 +681,12 @@ static void dwc_pcie_ltssm_debugfs_init(struct dw_pcie *pci, struct dentry *dir)
> > > &dwc_pcie_ltssm_status_ops);
> > > }
> > > +static void dwc_pcie_ltssm_trace_debugfs_init(struct dw_pcie *pci, struct dentry *dir)
> > > +{
> > > + debugfs_create_file("ltssm_trace", 0444, dir, pci,
> > > + &dwc_pcie_ltssm_trace_ops);
> > > +}
> > > +
> > > static int dw_pcie_ptm_check_capability(void *drvdata)
> > > {
> > > struct dw_pcie *pci = drvdata;
> > > @@ -922,6 +965,7 @@ void dwc_pcie_debugfs_init(struct dw_pcie *pci, enum dw_pcie_device_mode mode)
> > > err);
> > > dwc_pcie_ltssm_debugfs_init(pci, dir);
> > > + dwc_pcie_ltssm_trace_debugfs_init(pci, dir);
> > > pci->mode = mode;
> > > pci->ptm_debugfs = pcie_ptm_create_debugfs(pci->dev, pci,
> > > diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
> > > index 5cd27f5739f1..0df18995b7fe 100644
> > > --- a/drivers/pci/controller/dwc/pcie-designware.h
> > > +++ b/drivers/pci/controller/dwc/pcie-designware.h
> > > @@ -395,6 +395,11 @@ enum dw_pcie_ltssm {
> > > DW_PCIE_LTSSM_UNKNOWN = 0xFFFFFFFF,
> > > };
> > > +struct dw_pcie_ltssm_history {
> > > + enum dw_pcie_ltssm *states;
> > > + u32 count;
> > > +};
> > > +
> > > struct dw_pcie_ob_atu_cfg {
> > > int index;
> > > int type;
> > > @@ -499,6 +504,7 @@ struct dw_pcie_ops {
> > > size_t size, u32 val);
> > > bool (*link_up)(struct dw_pcie *pcie);
> > > enum dw_pcie_ltssm (*get_ltssm)(struct dw_pcie *pcie);
> > > + struct dw_pcie_ltssm_history * (*ltssm_trace)(struct dw_pcie *pcie);
> > > int (*start_link)(struct dw_pcie *pcie);
> > > void (*stop_link)(struct dw_pcie *pcie);
> > > int (*assert_perst)(struct dw_pcie *pcie, bool assert);
> > > --
> > > 2.43.0
> > >
> > >
> >
>
>
--
மணிவண்ணன் சதாசிவம்
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs
2026-01-08 4:49 ` Manivannan Sadhasivam
@ 2026-01-08 4:58 ` Shawn Lin
2026-01-08 17:05 ` Manivannan Sadhasivam
0 siblings, 1 reply; 11+ messages in thread
From: Shawn Lin @ 2026-01-08 4:58 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: shawn.lin, Jingoo Han, Bjorn Helgaas, linux-rockchip,
Niklas Cassel, linux-pci
在 2026/01/08 星期四 12:49, Manivannan Sadhasivam 写道:
> On Thu, Jan 08, 2026 at 09:01:43AM +0800, Shawn Lin wrote:
>> 在 2026/01/07 星期三 20:41, Manivannan Sadhasivam 写道:
>>> On Tue, Jan 06, 2026 at 05:18:38PM +0800, 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. Add an ltssm_trace operation
>>>> node in debugfs for platform which could provide these information to show
>>>> the LTSSM history.
>>>>
>>>
>>> Why don't you implement it as a tracepoint since you want to expose traces?
>>>
>>
>> I evaluated this option but didn't choose to do it just as I didn't
>> want to select CONFIG_TRACING_SUPPORT for dwc driver because of this
>> cheap function. But I'm fine to implement it as a tracepoint. Just to
>> make it clear, if a tracepoint is preferred, should I need to create a new
>> file like pcie-designware-trace?
>>
>
> I would prefer that, because that will allow us to add more tracepoints in the
> future and not muddle pcie-designware.h. General convention is to define
> trace events in a separate header.
>
I did a quick convention by adding it to the existing
include/trace/events/pci.h
The TRACE_EVENT is called pcie_ltssm_state_change, making it not just
for dwc-based but for all possible coming host drivers and the output
looks like below. Is that the way you expected?
root@debian:/#echo 1 >
/sys/kernel/debug/tracing/events/pci/pcie_ltssm_state_change/enable
root@debian:/# cat /sys/kernel/debug/tracing/trace
# tracer: nop
#
# entries-in-buffer/entries-written: 572/572 #P:8
#
# _-----=> irqs-off/BH-disabled
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / _-=> migrate-disable
# |||| / delay
# TASK-PID CPU# ||||| TIMESTAMP FUNCTION
# | | | ||||| | |
...
kworker/1:1-109 [001] ..... 4.719968: ltssm_state_change:
dev: a40000000.pcie state: 0x0d rate: 8.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719969: ltssm_state_change:
dev: a40000000.pcie state: 0x0f rate: 8.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719970: ltssm_state_change:
dev: a40000000.pcie state: 0x10 rate: 8.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719970: ltssm_state_change:
dev: a40000000.pcie state: 0x11 rate: 8.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719971: ltssm_state_change:
dev: a40000000.pcie state: 0x13 rate: 8.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719972: ltssm_state_change:
dev: a40000000.pcie state: 0x14 rate: 8.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719973: ltssm_state_change:
dev: a40000000.pcie state: 0x0d rate: 8.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719973: ltssm_state_change:
dev: a40000000.pcie state: 0x0f rate: 8.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719974: ltssm_state_change:
dev: a40000000.pcie state: 0x10 rate: 8.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719975: ltssm_state_change:
dev: a40000000.pcie state: 0x11 rate: 8.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719975: ltssm_state_change:
dev: a40000000.pcie state: 0x13 rate: 8.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719976: ltssm_state_change:
dev: a40000000.pcie state: 0x14 rate: 8.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719977: ltssm_state_change:
dev: a40000000.pcie state: 0x0d rate: 8.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719977: ltssm_state_change:
dev: a40000000.pcie state: 0x0f rate: 8.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719978: ltssm_state_change:
dev: a40000000.pcie state: 0x10 rate: 8.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719979: ltssm_state_change:
dev: a40000000.pcie state: 0x11 rate: 5.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719980: ltssm_state_change:
dev: a40000000.pcie state: 0x13 rate: 5.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719980: ltssm_state_change:
dev: a40000000.pcie state: 0x14 rate: 5.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719981: ltssm_state_change:
dev: a40000000.pcie state: 0x0d rate: 5.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719982: ltssm_state_change:
dev: a40000000.pcie state: 0x0f rate: 5.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719982: ltssm_state_change:
dev: a40000000.pcie state: 0x10 rate: 5.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719983: ltssm_state_change:
dev: a40000000.pcie state: 0x11 rate: 5.0 GT/s PCIe
kworker/1:1-109 [001] ..... 4.719984: ltssm_state_change:
dev: a40000000.pcie state: 0x13 rate: 5.0 GT/s PCIe
> - Mani
>
>>> - Mani
>>>
>>>> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
>>>> ---
>>>> .../controller/dwc/pcie-designware-debugfs.c | 44 +++++++++++++++++++
>>>> drivers/pci/controller/dwc/pcie-designware.h | 6 +++
>>>> 2 files changed, 50 insertions(+)
>>>>
>>>> diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
>>>> index df98fee69892..569e8e078ef2 100644
>>>> --- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c
>>>> +++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
>>>> @@ -511,6 +511,38 @@ static int ltssm_status_open(struct inode *inode, struct file *file)
>>>> return single_open(file, ltssm_status_show, inode->i_private);
>>>> }
>>>> +static struct dw_pcie_ltssm_history *dw_pcie_ltssm_trace(struct dw_pcie *pci)
>>>> +{
>>>> + if (pci->ops && pci->ops->ltssm_trace)
>>>> + return pci->ops->ltssm_trace(pci);
>>>> +
>>>> + return NULL;
>>>> +}
>>>> +
>>>> +static int ltssm_trace_show(struct seq_file *s, void *v)
>>>> +{
>>>> + struct dw_pcie *pci = s->private;
>>>> + struct dw_pcie_ltssm_history *history;
>>>> + enum dw_pcie_ltssm val;
>>>> + u32 loop;
>>>> +
>>>> + history = dw_pcie_ltssm_trace(pci);
>>>> + if (!history)
>>>> + return 0;
>>>> +
>>>> + for (loop = 0; loop < history->count; loop++) {
>>>> + val = history->states[loop];
>>>> + seq_printf(s, "%s (0x%02x)\n", ltssm_status_string(val), val);
>>>> + }
>>>> +
>>>> + return 0;
>>>> +}
>>>> +
>>>> +static int ltssm_trace_open(struct inode *inode, struct file *file)
>>>> +{
>>>> + return single_open(file, ltssm_trace_show, inode->i_private);
>>>> +}
>>>> +
>>>> #define dwc_debugfs_create(name) \
>>>> debugfs_create_file(#name, 0644, rasdes_debug, pci, \
>>>> &dbg_ ## name ## _fops)
>>>> @@ -552,6 +584,11 @@ static const struct file_operations dwc_pcie_ltssm_status_ops = {
>>>> .read = seq_read,
>>>> };
>>>> +static const struct file_operations dwc_pcie_ltssm_trace_ops = {
>>>> + .open = ltssm_trace_open,
>>>> + .read = seq_read,
>>>> +};
>>>> +
>>>> static void dwc_pcie_rasdes_debugfs_deinit(struct dw_pcie *pci)
>>>> {
>>>> struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
>>>> @@ -644,6 +681,12 @@ static void dwc_pcie_ltssm_debugfs_init(struct dw_pcie *pci, struct dentry *dir)
>>>> &dwc_pcie_ltssm_status_ops);
>>>> }
>>>> +static void dwc_pcie_ltssm_trace_debugfs_init(struct dw_pcie *pci, struct dentry *dir)
>>>> +{
>>>> + debugfs_create_file("ltssm_trace", 0444, dir, pci,
>>>> + &dwc_pcie_ltssm_trace_ops);
>>>> +}
>>>> +
>>>> static int dw_pcie_ptm_check_capability(void *drvdata)
>>>> {
>>>> struct dw_pcie *pci = drvdata;
>>>> @@ -922,6 +965,7 @@ void dwc_pcie_debugfs_init(struct dw_pcie *pci, enum dw_pcie_device_mode mode)
>>>> err);
>>>> dwc_pcie_ltssm_debugfs_init(pci, dir);
>>>> + dwc_pcie_ltssm_trace_debugfs_init(pci, dir);
>>>> pci->mode = mode;
>>>> pci->ptm_debugfs = pcie_ptm_create_debugfs(pci->dev, pci,
>>>> diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
>>>> index 5cd27f5739f1..0df18995b7fe 100644
>>>> --- a/drivers/pci/controller/dwc/pcie-designware.h
>>>> +++ b/drivers/pci/controller/dwc/pcie-designware.h
>>>> @@ -395,6 +395,11 @@ enum dw_pcie_ltssm {
>>>> DW_PCIE_LTSSM_UNKNOWN = 0xFFFFFFFF,
>>>> };
>>>> +struct dw_pcie_ltssm_history {
>>>> + enum dw_pcie_ltssm *states;
>>>> + u32 count;
>>>> +};
>>>> +
>>>> struct dw_pcie_ob_atu_cfg {
>>>> int index;
>>>> int type;
>>>> @@ -499,6 +504,7 @@ struct dw_pcie_ops {
>>>> size_t size, u32 val);
>>>> bool (*link_up)(struct dw_pcie *pcie);
>>>> enum dw_pcie_ltssm (*get_ltssm)(struct dw_pcie *pcie);
>>>> + struct dw_pcie_ltssm_history * (*ltssm_trace)(struct dw_pcie *pcie);
>>>> int (*start_link)(struct dw_pcie *pcie);
>>>> void (*stop_link)(struct dw_pcie *pcie);
>>>> int (*assert_perst)(struct dw_pcie *pcie, bool assert);
>>>> --
>>>> 2.43.0
>>>>
>>>>
>>>
>>
>>
>
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs
2026-01-08 4:58 ` Shawn Lin
@ 2026-01-08 17:05 ` Manivannan Sadhasivam
0 siblings, 0 replies; 11+ messages in thread
From: Manivannan Sadhasivam @ 2026-01-08 17:05 UTC (permalink / raw)
To: Shawn Lin
Cc: Jingoo Han, Bjorn Helgaas, linux-rockchip, Niklas Cassel,
linux-pci
On Thu, Jan 08, 2026 at 12:58:28PM +0800, Shawn Lin wrote:
> 在 2026/01/08 星期四 12:49, Manivannan Sadhasivam 写道:
> > On Thu, Jan 08, 2026 at 09:01:43AM +0800, Shawn Lin wrote:
> > > 在 2026/01/07 星期三 20:41, Manivannan Sadhasivam 写道:
> > > > On Tue, Jan 06, 2026 at 05:18:38PM +0800, 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. Add an ltssm_trace operation
> > > > > node in debugfs for platform which could provide these information to show
> > > > > the LTSSM history.
> > > > >
> > > >
> > > > Why don't you implement it as a tracepoint since you want to expose traces?
> > > >
> > >
> > > I evaluated this option but didn't choose to do it just as I didn't
> > > want to select CONFIG_TRACING_SUPPORT for dwc driver because of this
> > > cheap function. But I'm fine to implement it as a tracepoint. Just to
> > > make it clear, if a tracepoint is preferred, should I need to create a new
> > > file like pcie-designware-trace?
> > >
> >
> > I would prefer that, because that will allow us to add more tracepoints in the
> > future and not muddle pcie-designware.h. General convention is to define
> > trace events in a separate header.
> >
>
> I did a quick convention by adding it to the existing
> include/trace/events/pci.h
Is this an existing file? I couldn't see it. But anyway, I think it would be
better to create a separate file for controller drivers. PCI core may end up
having its own tracepoint in the future and mixing both will lead to confusion.
>
> The TRACE_EVENT is called pcie_ltssm_state_change, making it not just
> for dwc-based but for all possible coming host drivers and the output
> looks like below. Is that the way you expected?
>
> root@debian:/#echo 1 >
> /sys/kernel/debug/tracing/events/pci/pcie_ltssm_state_change/enable
/sys/kernel/debug/tracing/events/pci_controller/pcie_ltssm_state_transition/enable
> root@debian:/# cat /sys/kernel/debug/tracing/trace
> # tracer: nop
> #
> # entries-in-buffer/entries-written: 572/572 #P:8
> #
> # _-----=> irqs-off/BH-disabled
> # / _----=> need-resched
> # | / _---=> hardirq/softirq
> # || / _--=> preempt-depth
> # ||| / _-=> migrate-disable
> # |||| / delay
> # TASK-PID CPU# ||||| TIMESTAMP FUNCTION
> # | | | ||||| | |
>
> ...
> kworker/1:1-109 [001] ..... 4.719968: ltssm_state_change: dev:
> a40000000.pcie state: 0x0d rate: 8.0 GT/s PCIe
Can you print the state name using dw_pcie_ltssm_status_string() with:
https://lore.kernel.org/linux-pci/20260107-pci-dwc-suspend-rework-v4-2-9b5f3c72df0a@oss.qualcomm.com/
Also you can remove 'PCIe' at the end.
Rest LGTM, thanks!
- Mani
--
மணிவண்ணன் சதாசிவம்
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-01-08 17:05 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-06 9:18 [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs Shawn Lin
2026-01-06 9:18 ` [PATCH 2/2] PCI: dw-rockchip: Add .ltssm_trace() support Shawn Lin
2026-01-07 9:12 ` [PATCH 1/2] PCI: dwc: Add LTSSM tracing support to debugfs Krishna Chaitanya Chundru
2026-01-07 9:41 ` Shawn Lin
2026-01-07 10:09 ` Krishna Chaitanya Chundru
2026-01-07 12:40 ` Manivannan Sadhasivam
2026-01-07 12:41 ` Manivannan Sadhasivam
2026-01-08 1:01 ` Shawn Lin
2026-01-08 4:49 ` Manivannan Sadhasivam
2026-01-08 4:58 ` Shawn Lin
2026-01-08 17:05 ` Manivannan Sadhasivam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox