* [PATCH v6 0/2] PCI: Configure Root Port MPS during host probing
@ 2025-11-04 16:51 Hans Zhang
2025-11-04 16:51 ` [PATCH v6 1/2] " Hans Zhang
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Hans Zhang @ 2025-11-04 16:51 UTC (permalink / raw)
To: lpieralisi, kwilczynski, bhelgaas, helgaas, heiko, mani, yue.wang
Cc: pali, neil.armstrong, robh, jingoohan1, khilman, jbrunet,
martin.blumenstingl, cassel, linux-pci, linux-kernel,
linux-arm-kernel, linux-amlogic, linux-rockchip, Hans Zhang
Current PCIe initialization exhibits a key optimization gap: Root Ports
may operate 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 often fail
to utilize the full capabilities supported by controller hardware. This
results in suboptimal data transfer efficiency throughout the PCIe
hierarchy.
This patch series addresses this by:
1. Core PCI enhancement (Patch 1):
- Proactively configures Root Port MPS during host controller probing
- Sets initial MPS to hardware maximum (128 << dev->pcie_mpss)
- Conditional on PCIe bus tuning being enabled (PCIE_BUS_TUNE_OFF unset)
- Maintains backward compatibility via PCIE_BUS_TUNE_OFF check
- Preserves standard MPS negotiation during downstream enumeration
2. Driver cleanup (Patch 2):
- Removes redundant MPS configuration from Meson PCIe controller driver
- Functionality is now centralized in PCI core
- Simplifies driver maintenance long-term
---
Changes for v6:
- Modify the commit message and comments. (Bjorn)
- Patch 1/2 code logic: Add !bridge check to configure MPS only for Root Ports
without an upstream bridge (root bridges), avoiding incorrect handling of
non-root-bridge Root Ports (Niklas).
Changes for v5:
https://patchwork.kernel.org/project/linux-pci/patch/20250620155507.1022099-1-18255117159@163.com/
- Use pcie_set_mps directly instead of pcie_write_mps.
- The patch 1 commit message were modified.
Changes for v4:
https://patchwork.kernel.org/project/linux-pci/patch/20250510155607.390687-1-18255117159@163.com/
- The patch [v4 1/2] add a comment to explain why it was done this way.
- The patch [v4 2/2] have not been modified.
- Drop patch [v3 3/3]. The Maintainer of the pci-aardvark.c file suggests
that this patch cannot be submitted. In addition, Mani also suggests
dropping this patch until this series of issues is resolved.
Changes for v3:
https://patchwork.kernel.org/project/linux-pci/patch/20250506173439.292460-1-18255117159@163.com/
- The new split is patch 2/3 and 3/3.
- Modify the patch 1/3 according to Niklas' suggestion.
Changes for v2:
https://patchwork.kernel.org/project/linux-pci/patch/20250425095708.32662-1-18255117159@163.com/
- According to the Maintainer's suggestion, limit the setting of MPS
changes to platforms with controller drivers.
- Delete the MPS code set by the SOC manufacturer.
---
Hans Zhang (2):
PCI: Configure Root Port MPS during host probing
PCI: dwc: Remove redundant MPS configuration
drivers/pci/controller/dwc/pci-meson.c | 17 -----------------
drivers/pci/probe.c | 12 ++++++++++++
2 files changed, 12 insertions(+), 17 deletions(-)
base-commit: 691d401c7e0e5ea34ac6f8151bc0696db1b2500a
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v6 1/2] PCI: Configure Root Port MPS during host probing
2025-11-04 16:51 [PATCH v6 0/2] PCI: Configure Root Port MPS during host probing Hans Zhang
@ 2025-11-04 16:51 ` Hans Zhang
2025-11-12 8:31 ` Shawn Lin
2025-11-26 23:54 ` Bjorn Helgaas
2025-11-04 16:51 ` [PATCH v6 2/2] PCI: dwc: Remove redundant MPS configuration Hans Zhang
` (2 subsequent siblings)
3 siblings, 2 replies; 10+ messages in thread
From: Hans Zhang @ 2025-11-04 16:51 UTC (permalink / raw)
To: lpieralisi, kwilczynski, bhelgaas, helgaas, heiko, mani, yue.wang
Cc: pali, neil.armstrong, robh, jingoohan1, khilman, jbrunet,
martin.blumenstingl, cassel, linux-pci, linux-kernel,
linux-arm-kernel, linux-amlogic, linux-rockchip, Hans Zhang
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.
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. 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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v6 2/2] PCI: dwc: Remove redundant MPS configuration
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-04 16:51 ` Hans Zhang
2025-11-12 8:06 ` [PATCH v6 0/2] PCI: Configure Root Port MPS during host probing Mahesh Vaidya
2025-11-24 9:49 ` Niklas Cassel
3 siblings, 0 replies; 10+ messages in thread
From: Hans Zhang @ 2025-11-04 16:51 UTC (permalink / raw)
To: lpieralisi, kwilczynski, bhelgaas, helgaas, heiko, mani, yue.wang
Cc: pali, neil.armstrong, robh, jingoohan1, khilman, jbrunet,
martin.blumenstingl, cassel, linux-pci, linux-kernel,
linux-arm-kernel, linux-amlogic, linux-rockchip, Hans Zhang
The Meson PCIe controller driver manually configures maximum payload
size (MPS) through meson_set_max_payload, duplicating functionality now
centralized in the PCI core. Deprecating redundant code simplifies the
driver and aligns it with the consolidated MPS management strategy,
improving long-term maintainability.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/controller/dwc/pci-meson.c | 17 -----------------
1 file changed, 17 deletions(-)
diff --git a/drivers/pci/controller/dwc/pci-meson.c b/drivers/pci/controller/dwc/pci-meson.c
index 787469d1b396..3d12e1a9bb0c 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;
}
-static void meson_set_max_payload(struct meson_pcie *mp, int size)
-{
- struct dw_pcie *pci = &mp->pci;
- u32 val;
- u16 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
- int max_payload_size = meson_size_to_payload(mp, size);
-
- val = dw_pcie_readl_dbi(pci, offset + PCI_EXP_DEVCTL);
- val &= ~PCI_EXP_DEVCTL_PAYLOAD;
- dw_pcie_writel_dbi(pci, offset + PCI_EXP_DEVCTL, val);
-
- val = dw_pcie_readl_dbi(pci, offset + PCI_EXP_DEVCTL);
- val |= 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 = &mp->pci;
@@ -381,7 +365,6 @@ static int meson_pcie_host_init(struct dw_pcie_rp *pp)
pp->bridge->ops = &meson_pci_ops;
- meson_set_max_payload(mp, MAX_PAYLOAD_SIZE);
meson_set_max_rd_req_size(mp, MAX_READ_REQ_SIZE);
return 0;
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v6 0/2] PCI: Configure Root Port MPS during host probing
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-04 16:51 ` [PATCH v6 2/2] PCI: dwc: Remove redundant MPS configuration Hans Zhang
@ 2025-11-12 8:06 ` Mahesh Vaidya
2025-11-12 8:16 ` Hans Zhang
2025-11-24 9:49 ` Niklas Cassel
3 siblings, 1 reply; 10+ messages in thread
From: Mahesh Vaidya @ 2025-11-12 8:06 UTC (permalink / raw)
To: Hans Zhang, lpieralisi, kwilczynski, bhelgaas, helgaas, heiko,
mani, yue.wang
Cc: pali, neil.armstrong, robh, jingoohan1, khilman, jbrunet,
martin.blumenstingl, cassel, linux-pci, linux-kernel,
linux-arm-kernel, linux-amlogic, linux-rockchip
On 04-11-2025 22:21, Hans Zhang wrote:
> Current PCIe initialization exhibits a key optimization gap: Root Ports
> may operate 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 often fail
> to utilize the full capabilities supported by controller hardware. This
> results in suboptimal data transfer efficiency throughout the PCIe
> hierarchy.
>
> This patch series addresses this by:
>
> 1. Core PCI enhancement (Patch 1):
> - Proactively configures Root Port MPS during host controller probing
> - Sets initial MPS to hardware maximum (128 << dev->pcie_mpss)
> - Conditional on PCIe bus tuning being enabled (PCIE_BUS_TUNE_OFF unset)
> - Maintains backward compatibility via PCIE_BUS_TUNE_OFF check
> - Preserves standard MPS negotiation during downstream enumeration
>
> 2. Driver cleanup (Patch 2):
> - Removes redundant MPS configuration from Meson PCIe controller driver
> - Functionality is now centralized in PCI core
> - Simplifies driver maintenance long-term
>
> ---
> Changes for v6:
> - Modify the commit message and comments. (Bjorn)
> - Patch 1/2 code logic: Add !bridge check to configure MPS only for Root Ports
> without an upstream bridge (root bridges), avoiding incorrect handling of
> non-root-bridge Root Ports (Niklas).
Tested this patch series on Agilex 7.
Tested-by: Mahesh Vaidya <mahesh.vaidya@altera.com>
>
> Changes for v5:
> https://patchwork.kernel.org/project/linux-pci/patch/20250620155507.1022099-1-18255117159@163.com/
>
> - Use pcie_set_mps directly instead of pcie_write_mps.
> - The patch 1 commit message were modified.
>
> Changes for v4:
> https://patchwork.kernel.org/project/linux-pci/patch/20250510155607.390687-1-18255117159@163.com/
>
> - The patch [v4 1/2] add a comment to explain why it was done this way.
> - The patch [v4 2/2] have not been modified.
> - Drop patch [v3 3/3]. The Maintainer of the pci-aardvark.c file suggests
> that this patch cannot be submitted. In addition, Mani also suggests
> dropping this patch until this series of issues is resolved.
>
> Changes for v3:
> https://patchwork.kernel.org/project/linux-pci/patch/20250506173439.292460-1-18255117159@163.com/
>
> - The new split is patch 2/3 and 3/3.
> - Modify the patch 1/3 according to Niklas' suggestion.
>
> Changes for v2:
> https://patchwork.kernel.org/project/linux-pci/patch/20250425095708.32662-1-18255117159@163.com/
>
> - According to the Maintainer's suggestion, limit the setting of MPS
> changes to platforms with controller drivers.
> - Delete the MPS code set by the SOC manufacturer.
> ---
>
> Hans Zhang (2):
> PCI: Configure Root Port MPS during host probing
> PCI: dwc: Remove redundant MPS configuration
>
> drivers/pci/controller/dwc/pci-meson.c | 17 -----------------
> drivers/pci/probe.c | 12 ++++++++++++
> 2 files changed, 12 insertions(+), 17 deletions(-)
>
>
> base-commit: 691d401c7e0e5ea34ac6f8151bc0696db1b2500a
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v6 0/2] PCI: Configure Root Port MPS during host probing
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
0 siblings, 0 replies; 10+ messages in thread
From: Hans Zhang @ 2025-11-12 8:16 UTC (permalink / raw)
To: Mahesh Vaidya, Hans Zhang, lpieralisi, kwilczynski, bhelgaas,
helgaas, heiko, mani, yue.wang
Cc: pali, neil.armstrong, robh, jingoohan1, khilman, jbrunet,
martin.blumenstingl, cassel, linux-pci, linux-kernel,
linux-arm-kernel, linux-amlogic, linux-rockchip
On 11/12/2025 4:06 PM, Mahesh Vaidya wrote:
> [You don't often get email from mahesh.vaidya@altera.com. Learn why this
> is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> EXTERNAL EMAIL
>
> On 04-11-2025 22:21, Hans Zhang wrote:
>> Current PCIe initialization exhibits a key optimization gap: Root Ports
>> may operate 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 often fail
>> to utilize the full capabilities supported by controller hardware. This
>> results in suboptimal data transfer efficiency throughout the PCIe
>> hierarchy.
>>
>> This patch series addresses this by:
>>
>> 1. Core PCI enhancement (Patch 1):
>> - Proactively configures Root Port MPS during host controller probing
>> - Sets initial MPS to hardware maximum (128 << dev->pcie_mpss)
>> - Conditional on PCIe bus tuning being enabled (PCIE_BUS_TUNE_OFF unset)
>> - Maintains backward compatibility via PCIE_BUS_TUNE_OFF check
>> - Preserves standard MPS negotiation during downstream enumeration
>>
>> 2. Driver cleanup (Patch 2):
>> - Removes redundant MPS configuration from Meson PCIe controller driver
>> - Functionality is now centralized in PCI core
>> - Simplifies driver maintenance long-term
>>
>> ---
>> Changes for v6:
>> - Modify the commit message and comments. (Bjorn)
>> - Patch 1/2 code logic: Add !bridge check to configure MPS only for
>> Root Ports
>> without an upstream bridge (root bridges), avoiding incorrect
>> handling of
>> non-root-bridge Root Ports (Niklas).
> Tested this patch series on Agilex 7.
>
> Tested-by: Mahesh Vaidya <mahesh.vaidya@altera.com>
>
Hi Mahesh,
Thank you for your test.
Best regards,
Hans
>>
>> Changes for v5:
>> https://patchwork.kernel.org/project/linux-pci/
>> patch/20250620155507.1022099-1-18255117159@163.com/
>>
>> - Use pcie_set_mps directly instead of pcie_write_mps.
>> - The patch 1 commit message were modified.
>>
>> Changes for v4:
>> https://patchwork.kernel.org/project/linux-pci/
>> patch/20250510155607.390687-1-18255117159@163.com/
>>
>> - The patch [v4 1/2] add a comment to explain why it was done this way.
>> - The patch [v4 2/2] have not been modified.
>> - Drop patch [v3 3/3]. The Maintainer of the pci-aardvark.c file suggests
>> that this patch cannot be submitted. In addition, Mani also suggests
>> dropping this patch until this series of issues is resolved.
>>
>> Changes for v3:
>> https://patchwork.kernel.org/project/linux-pci/
>> patch/20250506173439.292460-1-18255117159@163.com/
>>
>> - The new split is patch 2/3 and 3/3.
>> - Modify the patch 1/3 according to Niklas' suggestion.
>>
>> Changes for v2:
>> https://patchwork.kernel.org/project/linux-pci/
>> patch/20250425095708.32662-1-18255117159@163.com/
>>
>> - According to the Maintainer's suggestion, limit the setting of MPS
>> changes to platforms with controller drivers.
>> - Delete the MPS code set by the SOC manufacturer.
>> ---
>>
>> Hans Zhang (2):
>> PCI: Configure Root Port MPS during host probing
>> PCI: dwc: Remove redundant MPS configuration
>>
>> drivers/pci/controller/dwc/pci-meson.c | 17 -----------------
>> drivers/pci/probe.c | 12 ++++++++++++
>> 2 files changed, 12 insertions(+), 17 deletions(-)
>>
>>
>> base-commit: 691d401c7e0e5ea34ac6f8151bc0696db1b2500a
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v6 1/2] PCI: Configure Root Port MPS during host probing
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
1 sibling, 1 reply; 10+ messages in thread
From: Shawn Lin @ 2025-11-12 8:31 UTC (permalink / raw)
To: Hans Zhang, lpieralisi, kwilczynski, bhelgaas, helgaas, heiko,
mani, yue.wang
Cc: shawn.lin, pali, neil.armstrong, robh, jingoohan1, khilman,
jbrunet, martin.blumenstingl, cassel, linux-pci, linux-kernel,
linux-arm-kernel, linux-amlogic, linux-rockchip
在 2025/11/05 星期三 0:51, Hans Zhang 写道:
> 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.
>
Tested-by: Shawn Lin <shawn.lin@rock-chips.com>
> 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. 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;
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v6 1/2] PCI: Configure Root Port MPS during host probing
2025-11-12 8:31 ` Shawn Lin
@ 2025-11-12 11:04 ` Hans Zhang
0 siblings, 0 replies; 10+ messages in thread
From: Hans Zhang @ 2025-11-12 11:04 UTC (permalink / raw)
To: Shawn Lin, Hans Zhang, lpieralisi, kwilczynski, bhelgaas, helgaas,
heiko, mani, yue.wang
Cc: pali, neil.armstrong, robh, jingoohan1, khilman, jbrunet,
martin.blumenstingl, cassel, linux-pci, linux-kernel,
linux-arm-kernel, linux-amlogic, linux-rockchip
On 11/12/2025 4:31 PM, Shawn Lin wrote:
> EXTERNAL EMAIL
>
> 在 2025/11/05 星期三 0:51, Hans Zhang 写道:
>> 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.
>>
>
> Tested-by: Shawn Lin <shawn.lin@rock-chips.com>
Hi Shawn,
Thank you for your test.
Best regards,
Hans
>
>> 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. 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;
>>
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v6 0/2] PCI: Configure Root Port MPS during host probing
2025-11-04 16:51 [PATCH v6 0/2] PCI: Configure Root Port MPS during host probing Hans Zhang
` (2 preceding siblings ...)
2025-11-12 8:06 ` [PATCH v6 0/2] PCI: Configure Root Port MPS during host probing Mahesh Vaidya
@ 2025-11-24 9:49 ` Niklas Cassel
3 siblings, 0 replies; 10+ messages in thread
From: Niklas Cassel @ 2025-11-24 9:49 UTC (permalink / raw)
To: Hans Zhang
Cc: lpieralisi, kwilczynski, bhelgaas, helgaas, heiko, mani, yue.wang,
pali, neil.armstrong, robh, jingoohan1, khilman, jbrunet,
martin.blumenstingl, linux-pci, linux-kernel, linux-arm-kernel,
linux-amlogic, linux-rockchip
On Wed, Nov 05, 2025 at 12:51:23AM +0800, Hans Zhang wrote:
> Current PCIe initialization exhibits a key optimization gap: Root Ports
> may operate 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 often fail
> to utilize the full capabilities supported by controller hardware. This
> results in suboptimal data transfer efficiency throughout the PCIe
> hierarchy.
Hello PCI maintainers,
Merge window is opening soon,
what is the status of this series?
Kind regards,
Niklas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v6 1/2] PCI: Configure Root Port MPS during host probing
2025-11-04 16:51 ` [PATCH v6 1/2] " Hans Zhang
2025-11-12 8:31 ` Shawn Lin
@ 2025-11-26 23:54 ` Bjorn Helgaas
2025-11-27 16:58 ` Hans Zhang
1 sibling, 1 reply; 10+ messages in thread
From: Bjorn Helgaas @ 2025-11-26 23:54 UTC (permalink / raw)
To: Hans Zhang
Cc: lpieralisi, kwilczynski, bhelgaas, heiko, mani, yue.wang, pali,
neil.armstrong, robh, jingoohan1, khilman, jbrunet,
martin.blumenstingl, cassel, linux-pci, linux-kernel,
linux-arm-kernel, linux-amlogic, linux-rockchip
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
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v6 1/2] PCI: Configure Root Port MPS during host probing
2025-11-26 23:54 ` Bjorn Helgaas
@ 2025-11-27 16:58 ` Hans Zhang
0 siblings, 0 replies; 10+ messages in thread
From: Hans Zhang @ 2025-11-27 16:58 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: lpieralisi, kwilczynski, bhelgaas, heiko, mani, yue.wang, pali,
neil.armstrong, robh, jingoohan1, khilman, jbrunet,
martin.blumenstingl, cassel, linux-pci, linux-kernel,
linux-arm-kernel, linux-amlogic, linux-rockchip
Hi Bjorn,
Thank you very much for your reply and the problems you pointed out. The
next version will modify it.
Best regards,
Hans
On 2025/11/27 07:54, Bjorn Helgaas wrote:
> 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
>>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-11-27 16:59 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).