From nobody Mon Feb 9 01:17:15 2026 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.3]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC6D82367A7; Fri, 25 Apr 2025 09:58:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.3 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745575129; cv=none; b=FOhuYXgp8PA/lz1FFcg1q+YggMUhupqUdI6PeBVqXaftwmCbWmdiCPTaxxMMmQ71oguw1DfCShdAU/cvDAR8nV6b/GmsA56ZNwZCCHuNbmcBluGB8KdLWOjKa8u0AwegOS/yqQ2PeF4ksdyVK9XNOP5TOIbfS0P9AjveKvMnRQ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745575129; c=relaxed/simple; bh=a5Q2NDtt9juFbbGm6oBY4b2wE1/JswxDiFchnEZWsHE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NNff2yFhPUuCGsl8bsxxvMH8sNc97ugWWmPZSzn1iBLiayixMiGiI/pkyhWz10Iz0MbnKnZ+Ml15fl09fGsg/yp27bll8cdhjwEYym6Jpvh2hhBCDed+/huy8P6itMc20TjdayGq4hbSiqwQ7aEZGtEcviwE4r4BiRQbk9ilFMY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=Jehkz7ub; arc=none smtp.client-ip=220.197.31.3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="Jehkz7ub" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=xmLII sSXZlE0yxGj02mf0oBCyw8RS0RVRfp2xWsIfpc=; b=Jehkz7ubRygGolxPxQNMg IcYsez6GN8mfFRtntr2kdYWZZL9Mf4Ws8fTuBicJ2wzAm6aAfXAk3Arew7yZjCx9 0V4tO6BIsp3/cNDwrs2rcnWdDFjVQyDXSlmhsgYNBlpofAyO8OQeq3t9R7TbZNfM zQIrlFpvQQA/2+FIGlGpZ0= Received: from localhost.localdomain (unknown []) by gzsmtp3 (Coremail) with SMTP id PigvCgAnfJt2XAtowU4iAw--.17018S3; Fri, 25 Apr 2025 17:57:14 +0800 (CST) From: Hans Zhang <18255117159@163.com> To: lpieralisi@kernel.org, kw@linux.com, bhelgaas@google.com, heiko@sntech.de, thomas.petazzoni@bootlin.com, manivannan.sadhasivam@linaro.org, yue.wang@Amlogic.com Cc: pali@kernel.org, neil.armstrong@linaro.org, robh@kernel.org, jingoohan1@gmail.com, khilman@baylibre.com, jbrunet@baylibre.com, martin.blumenstingl@googlemail.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-rockchip@lists.infradead.org, Hans Zhang <18255117159@163.com> Subject: [PATCH v2 1/2] PCI: Configure root port MPS to hardware maximum during host probing Date: Fri, 25 Apr 2025 17:57:07 +0800 Message-Id: <20250425095708.32662-2-18255117159@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250425095708.32662-1-18255117159@163.com> References: <20250425095708.32662-1-18255117159@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: PigvCgAnfJt2XAtowU4iAw--.17018S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxCw1rKw18Cw47Wr1ftFWUurg_yoW5Jw1Upa yYkw48Jr48Gry3Wa1kt3Wv9rWYqFn5CrW3trZ8XwnIv3W5Aa4jqrW2ka1rXF97GFZayryY qr4qqFyUuanYvF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0ziZYFAUUUUU= X-CM-SenderInfo: rpryjkyvrrlimvzbiqqrwthudrp/1tbiOhI6o2gLWelYOwABsA Content-Type: text/plain; charset="utf-8" Current PCIe initialization logic may leave root ports operating with non-optimal Maximum Payload Size (MPS) settings. While downstream device configuration is handled during bus enumeration, root port MPS values inherited from firmware or hardware defaults might not utilize the full capabilities supported by the controller hardware. This can result in suboptimal data transfer efficiency across the PCIe hierarchy. During host controller probing phase, when PCIe bus tuning is enabled, the implementation now configures root port MPS settings to their hardware-supported maximum values. By iterating through bridge devices under the root bus and identifying PCIe root ports, each port's MPS is set to 128 << pcie_mpss to match the device's maximum supported payload size. The Max Read Request Size (MRRS) is subsequently adjusted through existing companion logic to maintain compatibility with PCIe specifications. Explicit initialization at host probing stage ensures consistent PCIe topology configuration before downstream devices perform their own MPS negotiations. This proactive approach addresses platform-specific requirements where controller drivers depend on properly initialized root port settings, while maintaining backward compatibility through PCIE_BUS_TUNE_OFF conditional checks. Hardware capabilities are fully utilized without altering existing device negotiation behaviors. Signed-off-by: Hans Zhang <18255117159@163.com> --- drivers/pci/probe.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 364fa2a514f8..3973c593fdcf 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -3206,6 +3206,7 @@ EXPORT_SYMBOL_GPL(pci_create_root_bus); int pci_host_probe(struct pci_host_bridge *bridge) { struct pci_bus *bus, *child; + struct pci_dev *dev; int ret; =20 pci_lock_rescan_remove(); @@ -3228,6 +3229,17 @@ int pci_host_probe(struct pci_host_bridge *bridge) */ pci_assign_unassigned_root_bus_resources(bus); =20 + if (pcie_bus_config !=3D PCIE_BUS_TUNE_OFF) { + /* Configure root ports MPS to be MPSS by default */ + for_each_pci_bridge(dev, bus) { + if (pci_pcie_type(dev) !=3D PCI_EXP_TYPE_ROOT_PORT) + continue; + + pcie_write_mps(dev, 128 << dev->pcie_mpss); + pcie_write_mrrs(dev); + } + } + list_for_each_entry(child, &bus->children, node) pcie_bus_configure_settings(child); =20 --=20 2.25.1 From nobody Mon Feb 9 01:17:15 2026 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.5]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 022CB2367A7; Fri, 25 Apr 2025 09:58:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745575098; cv=none; b=XP72e/H7INma8P6YR+KVwbV+lhr6HkHvh1HMCFpDRMkU3Ejr1tT+C/LO8dtiDMI7I+V6K3iH5/rAxck2NYeu34E4/Elz3jAGHAevbl81PO8b3S/KSvW79c9uU71Q8zPMOWX4TBZSAcAy4P7NIZh4LUphd+es5qkGCw8k1Uw02BY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745575098; c=relaxed/simple; bh=OhLGSBuQVLXaIk4wy2LU6O6nHuMtPkRCcZXq8EDJPHc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tOvho+z4/p4DZbnDXUCbVy8YCJZhoqtmyJCSdLnOmqFDMErGXWrpkFKGPziDcGIexEkF6RHbkG+4+lqSv8qeKOZAShphW9vkmNa5Rr2U2lAKrRBY3R1x407QQYxn/ilJ+0P5Vrhomw58iXnKAgGmiBKxf0AjDhK0hPZRhZGXYBg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=BQHi4oT8; arc=none smtp.client-ip=220.197.31.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="BQHi4oT8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=9P6dx 24LcPTLqnmztGQ81vANm+nUct9U80WqazHI54k=; b=BQHi4oT8vGRbvvroE56N0 AyIgktZ1DIttAFQxJtXGIVB8Trkxgsa6kh6Wa8DIwPPKu0xxZt1HE5lCJrL0hYMv IngkQlKeaVuS67pE9u3zJJKIKQCD48Ne1OIhtZfTkTBscBgKlUcvVy8ejuSQ0U0f VZI0sp+ruS5VmlAlC+r/rw= Received: from localhost.localdomain (unknown []) by gzsmtp3 (Coremail) with SMTP id PigvCgAnfJt2XAtowU4iAw--.17018S4; Fri, 25 Apr 2025 17:57:16 +0800 (CST) From: Hans Zhang <18255117159@163.com> To: lpieralisi@kernel.org, kw@linux.com, bhelgaas@google.com, heiko@sntech.de, thomas.petazzoni@bootlin.com, manivannan.sadhasivam@linaro.org, yue.wang@Amlogic.com Cc: pali@kernel.org, neil.armstrong@linaro.org, robh@kernel.org, jingoohan1@gmail.com, khilman@baylibre.com, jbrunet@baylibre.com, martin.blumenstingl@googlemail.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-rockchip@lists.infradead.org, Hans Zhang <18255117159@163.com> Subject: [PATCH v2 2/2] PCI: Remove redundant MPS configuration Date: Fri, 25 Apr 2025 17:57:08 +0800 Message-Id: <20250425095708.32662-3-18255117159@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250425095708.32662-1-18255117159@163.com> References: <20250425095708.32662-1-18255117159@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: PigvCgAnfJt2XAtowU4iAw--.17018S4 X-Coremail-Antispam: 1Uf129KBjvJXoWxJFWUWr43Zry8Gr13Kr1DGFg_yoW5Ww17pF W3XrsayF4rtr45ua1DAa1rCFW3JasIkry7J39xW34fZF9IyFW7JFyayFWSka4fJr40gF10 yF15t3y8A3W5trUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0z_EfYiUUUUU= X-CM-SenderInfo: rpryjkyvrrlimvzbiqqrwthudrp/xtbBDw06o2gLWGyMnQAAsd Content-Type: text/plain; charset="utf-8" With the PCI core now centrally configuring root port MPS to hardware-supported maximums (via 128 << pcie_mpss) during host probing, platform-specific MPS adjustments are redundant. This patch removes the custom the configuration of the max payload logic to align with the standardized initialization flow. By eliminating redundant code, this change prevents conflicts with global PCIe hierarchy tuning policies and reduces maintenance overhead. The Meson driver now fully relies on the core PCI framework for MPS configuration, ensuring consistency across the PCIe topology while preserving hardware-specific MRRS handling. Signed-off-by: Hans Zhang <18255117159@163.com> --- drivers/pci/controller/dwc/pci-meson.c | 17 ----------------- drivers/pci/controller/pci-aardvark.c | 2 -- 2 files changed, 19 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-meson.c b/drivers/pci/controlle= r/dwc/pci-meson.c index db9482a113e9..126f38ed453d 100644 --- a/drivers/pci/controller/dwc/pci-meson.c +++ b/drivers/pci/controller/dwc/pci-meson.c @@ -261,22 +261,6 @@ static int meson_size_to_payload(struct meson_pcie *mp= , int size) return fls(size) - 8; } =20 -static void meson_set_max_payload(struct meson_pcie *mp, int size) -{ - struct dw_pcie *pci =3D &mp->pci; - u32 val; - u16 offset =3D dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); - int max_payload_size =3D meson_size_to_payload(mp, size); - - val =3D dw_pcie_readl_dbi(pci, offset + PCI_EXP_DEVCTL); - val &=3D ~PCI_EXP_DEVCTL_PAYLOAD; - dw_pcie_writel_dbi(pci, offset + PCI_EXP_DEVCTL, val); - - val =3D dw_pcie_readl_dbi(pci, offset + PCI_EXP_DEVCTL); - val |=3D PCIE_CAP_MAX_PAYLOAD_SIZE(max_payload_size); - dw_pcie_writel_dbi(pci, offset + PCI_EXP_DEVCTL, val); -} - static void meson_set_max_rd_req_size(struct meson_pcie *mp, int size) { struct dw_pcie *pci =3D &mp->pci; @@ -381,7 +365,6 @@ static int meson_pcie_host_init(struct dw_pcie_rp *pp) =20 pp->bridge->ops =3D &meson_pci_ops; =20 - meson_set_max_payload(mp, MAX_PAYLOAD_SIZE); meson_set_max_rd_req_size(mp, MAX_READ_REQ_SIZE); =20 return 0; diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller= /pci-aardvark.c index a29796cce420..d8852892994a 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -549,9 +549,7 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) reg =3D advk_readl(pcie, PCIE_CORE_PCIEXP_CAP + PCI_EXP_DEVCTL); reg &=3D ~PCI_EXP_DEVCTL_RELAX_EN; reg &=3D ~PCI_EXP_DEVCTL_NOSNOOP_EN; - reg &=3D ~PCI_EXP_DEVCTL_PAYLOAD; reg &=3D ~PCI_EXP_DEVCTL_READRQ; - reg |=3D PCI_EXP_DEVCTL_PAYLOAD_512B; reg |=3D PCI_EXP_DEVCTL_READRQ_512B; advk_writel(pcie, reg, PCIE_CORE_PCIEXP_CAP + PCI_EXP_DEVCTL); =20 --=20 2.25.1