Skip to content

Commit 28fc842

Browse files
wang-jianjunbjorn-helgaas
authored andcommitted
PCI: mediatek-gen3: Print LTSSM state when PCIe link down
Print current LTSSM state when PCIe link down instead of the register value to make it easier to get the link status. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jianjun Wang <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]>
1 parent bf03850 commit 28fc842

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

drivers/pci/controller/pcie-mediatek-gen3.c

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,37 @@ struct mtk_gen3_pcie {
153153
DECLARE_BITMAP(msi_irq_in_use, PCIE_MSI_IRQS_NUM);
154154
};
155155

156+
/* LTSSM state in PCIE_LTSSM_STATUS_REG bit[28:24] */
157+
static const char *const ltssm_str[] = {
158+
"detect.quiet", /* 0x00 */
159+
"detect.active", /* 0x01 */
160+
"polling.active", /* 0x02 */
161+
"polling.compliance", /* 0x03 */
162+
"polling.configuration", /* 0x04 */
163+
"config.linkwidthstart", /* 0x05 */
164+
"config.linkwidthaccept", /* 0x06 */
165+
"config.lanenumwait", /* 0x07 */
166+
"config.lanenumaccept", /* 0x08 */
167+
"config.complete", /* 0x09 */
168+
"config.idle", /* 0x0A */
169+
"recovery.receiverlock", /* 0x0B */
170+
"recovery.equalization", /* 0x0C */
171+
"recovery.speed", /* 0x0D */
172+
"recovery.receiverconfig", /* 0x0E */
173+
"recovery.idle", /* 0x0F */
174+
"L0", /* 0x10 */
175+
"L0s", /* 0x11 */
176+
"L1.entry", /* 0x12 */
177+
"L1.idle", /* 0x13 */
178+
"L2.idle", /* 0x14 */
179+
"L2.transmitwake", /* 0x15 */
180+
"disable", /* 0x16 */
181+
"loopback.entry", /* 0x17 */
182+
"loopback.active", /* 0x18 */
183+
"loopback.exit", /* 0x19 */
184+
"hotreset", /* 0x1A */
185+
};
186+
156187
/**
157188
* mtk_pcie_config_tlp_header() - Configure a configuration TLP header
158189
* @bus: PCI bus to query
@@ -327,8 +358,16 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie)
327358
!!(val & PCIE_PORT_LINKUP), 20,
328359
PCI_PM_D3COLD_WAIT * USEC_PER_MSEC);
329360
if (err) {
361+
const char *ltssm_state;
362+
int ltssm_index;
363+
330364
val = readl_relaxed(pcie->base + PCIE_LTSSM_STATUS_REG);
331-
dev_err(pcie->dev, "PCIe link down, ltssm reg val: %#x\n", val);
365+
ltssm_index = PCIE_LTSSM_STATE(val);
366+
ltssm_state = ltssm_index >= ARRAY_SIZE(ltssm_str) ?
367+
"Unknown state" : ltssm_str[ltssm_index];
368+
dev_err(pcie->dev,
369+
"PCIe link down, current LTSSM state: %s (%#x)\n",
370+
ltssm_state, val);
332371
return err;
333372
}
334373

0 commit comments

Comments
 (0)