From patchwork Wed Apr 16 15:19:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Zhang <18255117159@163.com> X-Patchwork-Id: 14054163 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E6A6AC369BA for ; Wed, 16 Apr 2025 15:44:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=WxLWiELfPbXTlT3sWEwEnqjYqGLOi5WLENP9w386FFo=; b=4YQmx36stcRsC7 L0hjvU8TAjVMprq7kKV/T9tdQ/sFSZaeRtpficdQZ8wCUYaFVEg4+26ldxHvz9MDNh0b0LqfOIxOh 2Xec6UhfSCXC6GDfqIPcuckqqk+udE3OCLbiDJpkzaX8Q0Om8QyaepxwgPXzz7RZ9nkq051qixj8/ XuJTRwnDTL+WuYIuE3c4SlrYx855a5c1oIO4d2Dn/7iKvEDMQP4UKpx9ogOo6zRQrQD/vlffBADlD mDG5NiCRo1gwbgLK4TMzKdu0CUZ/k5H9Ho4XJL3sPEd9nA//Dc+9zygkX8qqwr8RH/PefkZH8KJTg B9uzl5vXh2IBAu/RG5LA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1u54vy-0000000A7YT-2Q2x; Wed, 16 Apr 2025 15:44:18 +0000 Received: from m16.mail.163.com ([117.135.210.2]) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1u54Yg-0000000A3Dh-1VY4; Wed, 16 Apr 2025 15:20:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=n/CrH Wu7/N0JbLzLhfGyYLZ28eCk9w7x/JfjK48Yd84=; b=VNOTY+dyHQg0QwO0e8psO 1EQh2MMGJQGnp3gE7RZOKgtSb5zfsTKfHHKKCNbUzvitXSSl3J0y5cC8cALMA47X 7rtM7Qw4JcH2MELzQEd1xPDKl+z/3X3mmD9+ZB+q/60izYZ7rlG28v4v628nHscN aiAFBgX+VVteVApJxz5dW8= Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g0-2 (Coremail) with SMTP id _____wDHrr6Ayv9nGGzuAQ--.32225S2; Wed, 16 Apr 2025 23:19:29 +0800 (CST) From: Hans Zhang <18255117159@163.com> To: lpieralisi@kernel.org, kw@linux.com, bhelgaas@google.com, heiko@sntech.de Cc: manivannan.sadhasivam@linaro.org, robh@kernel.org, jingoohan1@gmail.com, thomas.richard@bootlin.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, Hans Zhang <18255117159@163.com> Subject: [PATCH] PCI: dw-rockchip: Configure max payload size on host init Date: Wed, 16 Apr 2025 23:19:26 +0800 Message-Id: <20250416151926.140202-1-18255117159@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: _____wDHrr6Ayv9nGGzuAQ--.32225S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7WFWrZFWfWFy7CrWxtryDAwb_yoW8Cr4xpa yDAFW5Ary5GF4agFnrC3Zxur4rt3Zayay7Jws3Kw1I9Fy2yryDtFy3urnxta1fJF40kFy5 Cr45ta40kr43Xr7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pELvKUUUUUU= X-Originating-IP: [124.79.128.52] X-CM-SenderInfo: rpryjkyvrrlimvzbiqqrwthudrp/1tbiOhAxo2f-yS0qIAAAsO X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250416_082015_170888_665BCC02 X-CRM114-Status: UNSURE ( 8.48 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org 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(+) base-commit: a24588245776dafc227243a01bfbeb8a59bafba9 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");