PCI: dw-rockchip: Enable L0S capability
Subsystems (3)
PATCH v3 1/2 PCI: dw-rockchip: Enable L0S capability
L0S capability isn't enabled on all SoCs by default, so enabling it in order to make ASPM L0S work on Rockchip platforms. We have been testing it for quite a long time and found the default FTS number provided by DWC core doesn't work stable and make LTSSM switch between L0S and Recovery, leading to long exit latency, even fail to link sometimes. So override it to the max 255 which seems work fine under test for both PHYs used by Rockchip platforms.
---
Changes in v3:
- Add rockchip_pcie_enable_l0s() and called from .init()
Changes in v2:
- Move n_fts to probe function
- rewrite the commit message
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/pci/controller/dwc/pcie-dw-rockchip.c +22 -0
@@ -182,6 +182,21 @@ static int rockchip_pcie_link_up(struct dw_pcie *pci)return 0 ; } +static void rockchip_pcie_enable_l0s (struct dw_pcie *pci) +{ +u32 cap, lnkcap; + +/* Enable L0S capability for all SoCs */ + cap =dw_pcie_find_capability (pci,PCI_CAP_ID_EXP ); +if (cap) { + lnkcap =dw_pcie_readl_dbi (pci, cap +PCI_EXP_LNKCAP ); + lnkcap |=PCI_EXP_LNKCAP_ASPM_L0S ; +dw_pcie_dbi_ro_wr_en (pci); +dw_pcie_writel_dbi (pci, cap +PCI_EXP_LNKCAP , lnkcap); +dw_pcie_dbi_ro_wr_dis (pci); + } +} +static int rockchip_pcie_start_link (struct dw_pcie *pci) {struct rockchip_pcie *rockchip =to_rockchip_pcie (pci);
@@ -231,6 +246,8 @@ static int rockchip_pcie_host_init(struct dw_pcie_rp *pp)irq_set_chained_handler_and_data (irq, rockchip_pcie_intx_handler, rockchip); +rockchip_pcie_enable_l0s (pci); +return 0 ; }
@@ -271,6 +288,8 @@ static void rockchip_pcie_ep_init(struct dw_pcie_ep *ep)struct dw_pcie *pci =to_dw_pcie_from_ep (ep);enum pci_barno bar; +rockchip_pcie_enable_l0s (pci); +for (bar =0 ; bar <PCI_STD_NUM_BARS ; bar++)dw_pcie_ep_reset_bar (pci, bar); };
@@ -598,6 +617,9 @@ static int rockchip_pcie_probe(struct platform_device *pdev) rockchip->pci.dev = dev; rockchip->pci.ops = &dw_pcie_ops; rockchip->data = data; +/* Default fts number(210) is broken, override it to 255 */ + rockchip->pci.n_fts[0 ] =255 ;/* Gen1 */ + rockchip->pci.n_fts[1 ] =255 ;/* Gen2+ */ ret =rockchip_pcie_resource_get (pdev, rockchip);if (ret)
Signature · 1 line
2.7.4
PATCH v3 2/2 PCI: dw-rockchip: Move rockchip_pcie_ep_hide_broken_ats_cap_rk3588() to .init()
Iif there is a core reset, _init() is called again, but _pre_init() is not.
---
Changes in v3: None
Changes in v2: None
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/pci/controller/dwc/pcie-dw-rockchip.c +1 -6
@@ -278,17 +278,13 @@ static void rockchip_pcie_ep_hide_broken_ats_cap_rk3588(struct dw_pcie_ep *ep)dev_err (dev,"failed to hide ATS capability\n" ); } -static void rockchip_pcie_ep_pre_init (struct dw_pcie_ep *ep) -{ -rockchip_pcie_ep_hide_broken_ats_cap_rk3588 (ep); -} -static void rockchip_pcie_ep_init (struct dw_pcie_ep *ep) {struct dw_pcie *pci =to_dw_pcie_from_ep (ep);enum pci_barno bar;rockchip_pcie_enable_l0s (pci); +rockchip_pcie_ep_hide_broken_ats_cap_rk3588 (ep);for (bar =0 ; bar <PCI_STD_NUM_BARS ; bar++)dw_pcie_ep_reset_bar (pci, bar);
@@ -359,7 +355,6 @@ rockchip_pcie_get_features(struct dw_pcie_ep *ep)static const struct dw_pcie_ep_ops rockchip_pcie_ep_ops = { .init = rockchip_pcie_ep_init, - .pre_init = rockchip_pcie_ep_pre_init, .raise_irq = rockchip_pcie_raise_irq, .get_features = rockchip_pcie_get_features, };
Signature · 7 lines
2.7.4 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
Re: [PATCH v3 2/2] PCI: dw-rockchip: Move rockchip_pcie_ep_hide_broken_ats_cap_rk3588() to .init()
Quoted 3 lines · Shawn Lin
Iif there is a core reset,
_init()is called again, but_pre_init()is not.
Hi Shawn,
Iif ---> If ? The spelling is wrong.
Best regards,
Hans
Quoted 34 lines
Suggested-by Niklas Cassel <[email protected]>Signed-off-by Shawn Lin <[email protected]>---
Changes in v3: None
Changes in v2: Nonedrivers/pci/controller/dwc/pcie-dw-rockchip.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)drivers/pci/controller/dwc/pcie-dw-rockchip.c +1
-5@@ -278,17 +278,13 @@ static void rockchip_pcie_ep_hide_broken_ats_cap_rk3588(struct dw_pcie_ep *ep)dev_err (dev,"failed to hide ATS capability\n" ); } -static void rockchip_pcie_ep_pre_init (struct dw_pcie_ep *ep) -{ -rockchip_pcie_ep_hide_broken_ats_cap_rk3588 (ep); -} -static void rockchip_pcie_ep_init (struct dw_pcie_ep *ep) {struct dw_pcie *pci =to_dw_pcie_from_ep (ep);enum pci_barno bar;rockchip_pcie_enable_l0s (pci); +rockchip_pcie_ep_hide_broken_ats_cap_rk3588 (ep);for (bar =0 ; bar <PCI_STD_NUM_BARS ; bar++)dw_pcie_ep_reset_bar (pci, bar);
drivers/pci/controller/dwc/pcie-dw-rockchip.c rockchip_pcie_get_features(struct dw_pcie_ep *ep) · line 360
Quoted 7 lines
drivers/pci/controller/dwc/pcie-dw-rockchip.c +0
-1@@ -359,7 +355,6 @@ rockchip_pcie_get_features(struct dw_pcie_ep *ep)static const struct dw_pcie_ep_ops rockchip_pcie_ep_ops = { .init = rockchip_pcie_ep_init, - .pre_init = rockchip_pcie_ep_pre_init, .raise_irq = rockchip_pcie_raise_irq, .get_features = rockchip_pcie_get_features, };
_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Re: [PATCH v3 2/2] PCI: dw-rockchip: Move rockchip_pcie_ep_hide_broken_ats_cap_rk3588() to .init()
In reply to Shawn LinQuoted 2 lines · Shawn Lin
Iif there is a core reset,
_init()is called again, but_pre_init()is not.
I think a better commit message would be:
There is no reason to call rockchip_pcie_ep_hide_broken_ats_cap_rk3588() from the pre_init() callback, instead of the normal init() callback.
Thus, move the rockchip_pcie_ep_hide_broken_ats_cap_rk3588() call from the pre_init() callback to the init() callback, as:
1) init() will still be called before link training is enabled, so the quirk will still be applied before the host has can see our device.
2) This allows us to remove the pre_init() callback, as it is now unused.
3) It is a more robust design, as the init() callback is called by dw_pcie_ep_init_registers(), which will always be called after a core reset. The pre_init() callback is only called once, at probe time.
No functional changes.
Quoted 3 lines
Suggested-by Niklas Cassel <[email protected]>Signed-off-by Shawn Lin <[email protected]>
Quoted 42 lines
---
Changes in v3: None
Changes in v2: Nonedrivers/pci/controller/dwc/pcie-dw-rockchip.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)drivers/pci/controller/dwc/pcie-dw-rockchip.c +1
-6@@ -278,17 +278,13 @@ static void rockchip_pcie_ep_hide_broken_ats_cap_rk3588(struct dw_pcie_ep *ep)dev_err (dev,"failed to hide ATS capability\n" ); } -static void rockchip_pcie_ep_pre_init (struct dw_pcie_ep *ep) -{ -rockchip_pcie_ep_hide_broken_ats_cap_rk3588 (ep); -} -static void rockchip_pcie_ep_init (struct dw_pcie_ep *ep) {struct dw_pcie *pci =to_dw_pcie_from_ep (ep);enum pci_barno bar;rockchip_pcie_enable_l0s (pci); +rockchip_pcie_ep_hide_broken_ats_cap_rk3588 (ep);for (bar =0 ; bar <PCI_STD_NUM_BARS ; bar++)dw_pcie_ep_reset_bar (pci, bar);@@ -359,7 +355,6 @@ rockchip_pcie_get_features(struct dw_pcie_ep *ep)static const struct dw_pcie_ep_ops rockchip_pcie_ep_ops = { .init = rockchip_pcie_ep_init, - .pre_init = rockchip_pcie_ep_pre_init, .raise_irq = rockchip_pcie_raise_irq, .get_features = rockchip_pcie_get_features, };Signature · 1 line
2.7.4
Quoted 9 lines · Shawn Lin
L0S capability isn't enabled on all SoCs by default, so enabling it in order to make ASPM L0S work on Rockchip platforms. We have been testing it for quite a long time and found the default FTS number provided by DWC core doesn't work stable and make LTSSM switch between L0S and Recovery, leading to long exit latency, even fail to link sometimes. So override it to the max 255 which seems work fine under test for both PHYs used by Rockchip platforms.
Signed-off-by Shawn Lin <[email protected]>