Skip to content

Commit 17cf866

Browse files
Xiaowei BaoLorenzo Pieralisi
authored andcommitted
PCI: layerscape: Add workaround for lost link capabilities during reset
The endpoint controller loses the Maximum Link Width and Supported Link Speed value from the Link Capabilities Register - initially configured by the Reset Configuration Word (RCW) - during a link-down or hot reset event. Address this issue in the endpoint event handler. Link: https://lore.kernel.org/r/20230720135834.1977616-2-Frank.Li@nxp.com Fixes: a805770 ("PCI: layerscape: Add EP mode support") Signed-off-by: Xiaowei Bao <xiaowei.bao@nxp.com> Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com> Signed-off-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org> Acked-by: Manivannan Sadhasivam <mani@kernel.org>
1 parent d28c0d8 commit 17cf866

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

drivers/pci/controller/dwc/pci-layerscape-ep.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct ls_pcie_ep {
4545
struct pci_epc_features *ls_epc;
4646
const struct ls_pcie_ep_drvdata *drvdata;
4747
int irq;
48+
u32 lnkcap;
4849
bool big_endian;
4950
};
5051

@@ -73,6 +74,7 @@ static irqreturn_t ls_pcie_ep_event_handler(int irq, void *dev_id)
7374
struct ls_pcie_ep *pcie = dev_id;
7475
struct dw_pcie *pci = pcie->pci;
7576
u32 val, cfg;
77+
u8 offset;
7678

7779
val = ls_lut_readl(pcie, PEX_PF0_PME_MES_DR);
7880
ls_lut_writel(pcie, PEX_PF0_PME_MES_DR, val);
@@ -81,6 +83,19 @@ static irqreturn_t ls_pcie_ep_event_handler(int irq, void *dev_id)
8183
return IRQ_NONE;
8284

8385
if (val & PEX_PF0_PME_MES_DR_LUD) {
86+
87+
offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
88+
89+
/*
90+
* The values of the Maximum Link Width and Supported Link
91+
* Speed from the Link Capabilities Register will be lost
92+
* during link down or hot reset. Restore initial value
93+
* that configured by the Reset Configuration Word (RCW).
94+
*/
95+
dw_pcie_dbi_ro_wr_en(pci);
96+
dw_pcie_writel_dbi(pci, offset + PCI_EXP_LNKCAP, pcie->lnkcap);
97+
dw_pcie_dbi_ro_wr_dis(pci);
98+
8499
cfg = ls_lut_readl(pcie, PEX_PF0_CONFIG);
85100
cfg |= PEX_PF0_CFG_READY;
86101
ls_lut_writel(pcie, PEX_PF0_CONFIG, cfg);
@@ -216,6 +231,7 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev)
216231
struct ls_pcie_ep *pcie;
217232
struct pci_epc_features *ls_epc;
218233
struct resource *dbi_base;
234+
u8 offset;
219235
int ret;
220236

221237
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
@@ -252,6 +268,9 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev)
252268

253269
platform_set_drvdata(pdev, pcie);
254270

271+
offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
272+
pcie->lnkcap = dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCAP);
273+
255274
ret = dw_pcie_ep_init(&pci->ep);
256275
if (ret)
257276
return ret;

0 commit comments

Comments
 (0)