linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rockchip: Increase the Max Credit update interval.
@ 2016-09-22 21:00 Rajat Jain
  2016-09-22 21:14 ` Brian Norris
  2016-09-22 22:38 ` [PATCH v2] PCI: " Rajat Jain
  0 siblings, 2 replies; 9+ messages in thread
From: Rajat Jain @ 2016-09-22 21:00 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Shawn Lin, Jeffy Chen, Wenrui Li,
	Brian Norris
  Cc: Rajat Jain

This increases the likelihood of link state to automatically go to L1
and save some power.

The default credit update interval of 7.5 us results in the rootport
sending UpdateFC packets too often, thus reulting in the link never
going to L1, and always staying in L0/L0s. The value 24 us was chosen
after some experiments and peeking over the PCIe bus to see that we do
enter L1 substate when there is not enough traffic on the PCIe bus.

The register value gets lost on a Link speed/width change, and the
ideal fix should reprogram this on that event (refer "Link Bandwidth
Management Interrupt Enable" & "Link Autonomous Bandwidth Interrupt Enable"
in link control reg?). But the rockchip platforms doesn't support hotplug
and I've verified that the retraining doesn't work as well, so this
should be OK.

Signed-off-by: Rajat Jain <rajatja@google.com>
---
 drivers/pci/host/pcie-rockchip.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/pci/host/pcie-rockchip.c b/drivers/pci/host/pcie-rockchip.c
index c3593e6..e537413 100644
--- a/drivers/pci/host/pcie-rockchip.c
+++ b/drivers/pci/host/pcie-rockchip.c
@@ -95,6 +95,11 @@
 #define   PCIE_CORE_PL_CONF_SPEED_MASK		0x00000018
 #define   PCIE_CORE_PL_CONF_LANE_MASK		0x00000006
 #define   PCIE_CORE_PL_CONF_LANE_SHIFT		1
+#define PCIE_CORE_TXCREDIT_CFG1		(PCIE_CORE_CTRL_MGMT_BASE + 0x020)
+#define   PCIE_CORE_TXCREDIT_CFG1_MUI_MASK	0xFFFF0000
+#define   PCIE_CORE_TXCREDIT_CFG1_MUI_SHIFT	16
+#define   PCIE_CORE_TXCREDIT_CFG1_MUI_ENCODE(x) \
+		(((x) >> 3) << PCIE_CORE_TXCREDIT_CFG1_MUI_SHIFT)
 #define PCIE_CORE_INT_STATUS		(PCIE_CORE_CTRL_MGMT_BASE + 0x20c)
 #define   PCIE_CORE_INT_PRFPE			BIT(0)
 #define   PCIE_CORE_INT_CRFPE			BIT(1)
@@ -523,6 +528,12 @@ static int rockchip_pcie_init_port(struct rockchip_pcie *rockchip)
 			  PCIE_CORE_PL_CONF_LANE_MASK);
 	dev_dbg(dev, "current link width is x%d\n", status);
 
+	/* Update credit update interval */
+	status = rockchip_pcie_read(rockchip, PCIE_CORE_TXCREDIT_CFG1);
+	status &= ~PCIE_CORE_TXCREDIT_CFG1_MUI_MASK;
+	status |= PCIE_CORE_TXCREDIT_CFG1_MUI_ENCODE(24000);	/* ns */
+	rockchip_pcie_write(rockchip, status, PCIE_CORE_TXCREDIT_CFG1);
+
 	rockchip_pcie_write(rockchip, ROCKCHIP_VENDOR_ID,
 			    PCIE_RC_CONFIG_VENDOR);
 	rockchip_pcie_write(rockchip,
-- 
2.8.0.rc3.226.g39d4020


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-10-04 17:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-22 21:00 [PATCH] rockchip: Increase the Max Credit update interval Rajat Jain
2016-09-22 21:14 ` Brian Norris
2016-09-22 21:56   ` Rajat Jain
2016-09-22 22:37     ` Rajat Jain
2016-09-22 22:38 ` [PATCH v2] PCI: " Rajat Jain
2016-09-23  0:42   ` Shawn Lin
2016-09-23  0:50     ` [PATCH v3] " Rajat Jain
2016-09-23  1:07       ` Shawn Lin
2016-10-04 17:17       ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).