From: Bjorn Helgaas <helgaas@kernel.org>
To: Hans Zhang <18255117159@163.com>
Cc: lpieralisi@kernel.org, kwilczynski@kernel.org,
bhelgaas@google.com, heiko@sntech.de, mani@kernel.org,
yue.wang@amlogic.com, pali@kernel.org, neil.armstrong@linaro.org,
robh@kernel.org, jingoohan1@gmail.com, khilman@baylibre.com,
jbrunet@baylibre.com, martin.blumenstingl@googlemail.com,
cassel@kernel.org, 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
Subject: Re: [PATCH v6 1/2] PCI: Configure Root Port MPS during host probing
Date: Wed, 26 Nov 2025 17:54:32 -0600 [thread overview]
Message-ID: <20251126235432.GA2726707@bhelgaas> (raw)
In-Reply-To: <20251104165125.174168-2-18255117159@163.com>
On Wed, Nov 05, 2025 at 12:51:24AM +0800, Hans Zhang wrote:
> Current PCIe initialization logic may leave Root Ports (root bridges)
> operating with non-optimal Maximum Payload Size (MPS) settings. Existing
> code in pci_configure_mps() returns early for devices without an upstream
> bridge (!bridge) which includes Root Ports, so their MPS values remain
> at firmware/hardware defaults. This fails to utilize the controller's full
> capabilities, leading to suboptimal data transfer efficiency across the
> PCIe hierarchy.
>
> With this patch, during the host controller probing phase:
> - When PCIe bus tuning is enabled (not PCIE_BUS_TUNE_OFF), and
> - The device is a Root Port without an upstream bridge (!bridge),
> The Root Port's MPS is set to its hardware-supported maximum value
> (128 << dev->pcie_mpss).
>
> Note that this initial maximum MPS setting may be reduced later, during
> downstream device enumeration, if any downstream device does not suppor
> the Root Port's maximum MPS.
>
> This change ensures Root Ports are properly initialized before downstream
> devices negotiate MPS, while maintaining backward compatibility via the
> PCIE_BUS_TUNE_OFF check.
"Properly" is sort of a junk word for me because all it really says is
we were stupid before, and we're smarter now, but it doesn't explain
exactly *what* was wrong and why this new thing is "proper."
It's obvious that the Max_Payload_Size power-on default (128 bytes) is
suboptimal in some situations, so you don't even need to say that.
And I think 128 bytes *is* optimal in the PCIE_BUS_PEER2PEER case.
s/Root Ports (root bridges)/Root Ports/
s/bridge (!bridge)/bridge/ # a couple times
s/hardware-supported// # unnecessary
s/(128 << dev->pcie_mpss)// # we can read the spec
s/suppor/support/
> Suggested-by: Niklas Cassel <cassel@kernel.org>
> Suggested-by: Manivannan Sadhasivam <mani@kernel.org>
> 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 0ce98e18b5a8..2459def3af9b 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -2196,6 +2196,18 @@ static void pci_configure_mps(struct pci_dev *dev)
> return;
> }
>
> + /*
> + * Unless MPS strategy is PCIE_BUS_TUNE_OFF (don't touch MPS at all),
> + * start off by setting Root Ports' MPS to MPSS. This only applies to
> + * Root Ports without an upstream bridge (root bridges), as other Root
> + * Ports will have downstream bridges.
I can't parse this sentence. *No* Root Port has an upstream bridge.
So I don't know what "other Root Ports" would be or why they would
have downstream bridges (any Root Port is likely to have downstream
endpoints or bridges).
> + ... Depending on the MPS strategy
> + * and MPSS of downstream devices, the Root Port's MPS may be
> + * overridden later.
> + */
> + if (!bridge && pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT &&
> + pcie_bus_config != PCIE_BUS_TUNE_OFF)
> + pcie_set_mps(dev, 128 << dev->pcie_mpss);
> +
> if (!bridge || !pci_is_pcie(bridge))
> return;
>
> --
> 2.34.1
>
next prev parent reply other threads:[~2025-11-26 23:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-04 16:51 [PATCH v6 0/2] PCI: Configure Root Port MPS during host probing Hans Zhang
2025-11-04 16:51 ` [PATCH v6 1/2] " Hans Zhang
2025-11-12 8:31 ` Shawn Lin
2025-11-12 11:04 ` Hans Zhang
2025-11-26 23:54 ` Bjorn Helgaas [this message]
2025-11-27 16:58 ` Hans Zhang
2025-11-04 16:51 ` [PATCH v6 2/2] PCI: dwc: Remove redundant MPS configuration Hans Zhang
2025-11-12 8:06 ` [PATCH v6 0/2] PCI: Configure Root Port MPS during host probing Mahesh Vaidya
2025-11-12 8:16 ` Hans Zhang
2025-11-24 9:49 ` Niklas Cassel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251126235432.GA2726707@bhelgaas \
--to=helgaas@kernel.org \
--cc=18255117159@163.com \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=heiko@sntech.de \
--cc=jbrunet@baylibre.com \
--cc=jingoohan1@gmail.com \
--cc=khilman@baylibre.com \
--cc=kwilczynski@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=neil.armstrong@linaro.org \
--cc=pali@kernel.org \
--cc=robh@kernel.org \
--cc=yue.wang@amlogic.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).