linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: dw-rockchip: Configure max payload size on host init
@ 2025-04-16 15:19 Hans Zhang
  2025-04-16 20:40 ` Bjorn Helgaas
  2025-04-17  7:04 ` Niklas Cassel
  0 siblings, 2 replies; 23+ messages in thread
From: Hans Zhang @ 2025-04-16 15:19 UTC (permalink / raw)
  To: lpieralisi, kw, bhelgaas, heiko
  Cc: manivannan.sadhasivam, robh, jingoohan1, thomas.richard,
	linux-pci, linux-kernel, linux-arm-kernel, linux-rockchip,
	Hans Zhang

The RK3588's PCIe controller defaults to a 128-byte max payload size,
but its hardware capability actually supports 256 bytes. This results
in suboptimal performance with devices that support larger payloads.

Signed-off-by: Hans Zhang <18255117159@163.com>
---
 drivers/pci/controller/dwc/pcie-dw-rockchip.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
index c624b7ebd118..5bbb536a2576 100644
--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
+++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -477,6 +477,22 @@ static irqreturn_t rockchip_pcie_ep_sys_irq_thread(int irq, void *arg)
 	return IRQ_HANDLED;
 }
 
+static void rockchip_pcie_set_max_payload(struct rockchip_pcie *rockchip)
+{
+	struct dw_pcie *pci = &rockchip->pci;
+	u32 dev_cap, dev_ctrl;
+	u16 offset;
+
+	offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
+	dev_cap = dw_pcie_readl_dbi(pci, offset + PCI_EXP_DEVCAP);
+	dev_cap &= PCI_EXP_DEVCAP_PAYLOAD;
+
+	dev_ctrl = dw_pcie_readl_dbi(pci, offset + PCI_EXP_DEVCTL);
+	dev_ctrl &= ~PCI_EXP_DEVCTL_PAYLOAD;
+	dev_ctrl |= dev_cap << 5;
+	dw_pcie_writel_dbi(pci, offset + PCI_EXP_DEVCTL, dev_ctrl);
+}
+
 static int rockchip_pcie_configure_rc(struct platform_device *pdev,
 				      struct rockchip_pcie *rockchip)
 {
@@ -511,6 +527,8 @@ static int rockchip_pcie_configure_rc(struct platform_device *pdev,
 	pp->ops = &rockchip_pcie_host_ops;
 	pp->use_linkup_irq = true;
 
+	rockchip_pcie_set_max_payload(rockchip);
+
 	ret = dw_pcie_host_init(pp);
 	if (ret) {
 		dev_err(dev, "failed to initialize host\n");

base-commit: a24588245776dafc227243a01bfbeb8a59bafba9
-- 
2.25.1



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

end of thread, other threads:[~2025-04-21 16:02 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-16 15:19 [PATCH] PCI: dw-rockchip: Configure max payload size on host init Hans Zhang
2025-04-16 20:40 ` Bjorn Helgaas
2025-04-17  2:19   ` Hans Zhang
2025-04-17  6:01     ` Niklas Cassel
2025-04-17  6:47       ` Hans Zhang
2025-04-17  6:53         ` Niklas Cassel
2025-04-17  7:04 ` Niklas Cassel
2025-04-17  7:08   ` Shawn Lin
2025-04-17  7:22     ` Niklas Cassel
2025-04-17  7:25       ` Shawn Lin
2025-04-17  7:48         ` Niklas Cassel
2025-04-17  8:07           ` Hans Zhang
2025-04-17  8:39             ` Niklas Cassel
2025-04-17  9:48               ` Hans Zhang
2025-04-17  9:54                 ` Niklas Cassel
2025-04-17 16:52               ` Bjorn Helgaas
2025-04-18 12:33                 ` Hans Zhang
2025-04-18 14:55                   ` Niklas Cassel
2025-04-18 16:21                     ` Bjorn Helgaas
2025-04-18 17:21                     ` Hans Zhang
2025-04-21 14:53                       ` Manivannan Sadhasivam
2025-04-21 15:59                         ` Hans Zhang
2025-04-21 14:48               ` Manivannan Sadhasivam

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).