Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] PCI/DPC: Honor "pcie_ports=native" when enabling DPC
@ 2026-09-01  6:45 Guixin Liu
  2026-09-01  6:57 ` sashiko-bot
  2026-09-03 23:05 ` Bjorn Helgaas
  0 siblings, 2 replies; 4+ messages in thread
From: Guixin Liu @ 2026-09-01  6:45 UTC (permalink / raw)
  To: Bjorn Helgaas, Uwe Kleine-König, Jonathan Cameron,
	Lukas Wunner, Ilpo Järvinen, Kees Cook, Darshit Shah,
	Brian Norris, Kuppuswamy Sathyanarayanan
  Cc: linux-pci, stable

Commit 97ca178c899d ("PCI/DPC: Allow DPC on all Downstream Ports when
OS controls AER") replaced the AER service bit with host->native_aer
when deciding whether to create a DPC service device.  Unlike the AER
service bit, host->native_aer does not reflect the "pcie_ports=native"
command-line override.

Consequently, if firmware retains AER control, "pcie_ports=native" no
longer enables DPC on Root Ports that advertise both AER and DPC, even
though the option is documented to force native DPC handling.

Check pcie_ports_native explicitly so both command-line overrides
continue to work.

Fixes: 97ca178c899d ("PCI/DPC: Allow DPC on all Downstream Ports when OS controls AER")
Cc: stable@vger.kernel.org
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---
 drivers/pci/pcie/portdrv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c
index a9cbfc1d2bc7..a05ee7980fb2 100644
--- a/drivers/pci/pcie/portdrv.c
+++ b/drivers/pci/pcie/portdrv.c
@@ -264,7 +264,7 @@ static int get_port_device_capability(struct pci_dev *dev)
 	 */
 	if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DPC) &&
 	    pci_aer_available() &&
-	    (pcie_ports_dpc_native || host->native_aer))
+	    (pcie_ports_native || pcie_ports_dpc_native || host->native_aer))
 		services |= PCIE_PORT_SERVICE_DPC;
 
 	/* Enable bandwidth control if more than one speed is supported. */
-- 
2.43.7


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

* Re: [PATCH] PCI/DPC: Honor "pcie_ports=native" when enabling DPC
  2026-09-01  6:45 [PATCH] PCI/DPC: Honor "pcie_ports=native" when enabling DPC Guixin Liu
@ 2026-09-01  6:57 ` sashiko-bot
  2026-09-03 23:05 ` Bjorn Helgaas
  1 sibling, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-09-01  6:57 UTC (permalink / raw)
  To: Guixin Liu; +Cc: linux-pci

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but pre-existed in the codebase. Various PCI and CXL subsystems incorrectly check `host->native_*` flags directly without honoring the `pcie_ports=native` or `pcie_ports_dpc_native` command-line overrides.
--

commit bed1438fd8fcfc05e1122790665a4045a06281cf
Author: Guixin Liu <kanie@linux.alibaba.com>

PCI/DPC: Honor "pcie_ports=native" when enabling DPC
    
This commit fixes an issue where the "pcie_ports=native" command-line
override was ignored when deciding whether to create a DPC service
device. This ensures both command-line overrides continue to work when
firmware retains AER control.

Cc: stable@vger.kernel.org

> diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c
> index a9cbfc1d2bc75..a05ee7980fb27 100644
> --- a/drivers/pci/pcie/portdrv.c
> +++ b/drivers/pci/pcie/portdrv.c
> @@ -264,7 +264,7 @@ static int get_port_device_capability(struct pci_dev *dev)
>  	 */
>  	if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DPC) &&
>  	    pci_aer_available() &&
> -	    (pcie_ports_dpc_native || host->native_aer))
> +	    (pcie_ports_native || pcie_ports_dpc_native || host->native_aer))
>  		services |= PCIE_PORT_SERVICE_DPC;

[Severity: High]
This isn't a bug introduced by this patch, but pre-existed in the codebase.
Since this patch correctly restores the pcie_ports_native override here,
should we also fix other subsystems that incorrectly check host->native_*
flags directly without honoring the command-line overrides?

For example, in drivers/cxl/core/ras.c:devm_cxl_dport_rch_ras_setup(),
the code drops the override, which can lead to broken error reporting for
uncorrectable errors:

	host_bridge = to_pci_host_bridge(dport->dport_dev);
	if (!host_bridge->native_aer)
		return;

	cxl_dport_map_rch_aer(dport);

Similarly, in drivers/pci/pci-acpi.c:pci_acpi_program_hpx_type2(), it
fails to account for the command line override which should prevent
programming when the OS forces AER:

	/*
	 * Only do the _HPX Type 2 programming if OS owns PCIe native
	 * hotplug but not AER.
	 */
	if (!host->native_pcie_hotplug || host->native_aer)
		return;

Also, in drivers/pci/pcie/dpc.c:pci_dpc_recovered(), this check bypasses
the synchronization wait if it fails to recognize OS-forced DPC
ownership:

	host = pci_find_host_bridge(pdev->bus);
	if (!host->native_dpc && !IS_ENABLED(CONFIG_PCIE_EDR))
		return false;

Because pci_dpc_recovered() prematurely returns false, the pciehp driver
will not ignore spurious Link Down/Up events during DPC. Does this cause
hotplug to incorrectly race with DPC recovery?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260901064554.2178688-1-kanie@linux.alibaba.com?part=1

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

* Re: [PATCH] PCI/DPC: Honor "pcie_ports=native" when enabling DPC
  2026-09-01  6:45 [PATCH] PCI/DPC: Honor "pcie_ports=native" when enabling DPC Guixin Liu
  2026-09-01  6:57 ` sashiko-bot
@ 2026-09-03 23:05 ` Bjorn Helgaas
  2026-09-04  2:34   ` Guixin Liu
  1 sibling, 1 reply; 4+ messages in thread
From: Bjorn Helgaas @ 2026-09-03 23:05 UTC (permalink / raw)
  To: Guixin Liu
  Cc: Bjorn Helgaas, Uwe Kleine-König, Jonathan Cameron,
	Lukas Wunner, Ilpo Järvinen, Kees Cook, Darshit Shah,
	Brian Norris, Kuppuswamy Sathyanarayanan, linux-pci, stable

On Tue, Sep 01, 2026 at 02:45:54PM +0800, Guixin Liu wrote:
> Commit 97ca178c899d ("PCI/DPC: Allow DPC on all Downstream Ports when
> OS controls AER") replaced the AER service bit with host->native_aer
> when deciding whether to create a DPC service device.  Unlike the AER
> service bit, host->native_aer does not reflect the "pcie_ports=native"
> command-line override.
> 
> Consequently, if firmware retains AER control, "pcie_ports=native" no
> longer enables DPC on Root Ports that advertise both AER and DPC, even
> though the option is documented to force native DPC handling.
> 
> Check pcie_ports_native explicitly so both command-line overrides
> continue to work.
> 
> Fixes: 97ca178c899d ("PCI/DPC: Allow DPC on all Downstream Ports when OS controls AER")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
> ---
>  drivers/pci/pcie/portdrv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c
> index a9cbfc1d2bc7..a05ee7980fb2 100644
> --- a/drivers/pci/pcie/portdrv.c
> +++ b/drivers/pci/pcie/portdrv.c
> @@ -264,7 +264,7 @@ static int get_port_device_capability(struct pci_dev *dev)
>  	 */
>  	if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DPC) &&
>  	    pci_aer_available() &&
> -	    (pcie_ports_dpc_native || host->native_aer))
> +	    (pcie_ports_native || pcie_ports_dpc_native || host->native_aer))

Oh my goodness.  I think I completely dropped ball on this YEARS ago.

It's crazy that we have "pcie_ports_native" checking littered all
over.  I think we should instead treat host->native_* as the single
source of truth, and pay attention to pcie_ports_native when setting
host->native_*.

Sathy did some great work to do exactly that in 2020, and I never got
it merged.  I wish I had some great excuse, but I looked at my 2020
calendar and couldn't find one.  I think I just blew it.

So I think we should resurrect that series and update it as needed and
solve the problem that way.  I dug out the links just for
completeness, but we should probably just start with the most recent
ones (v11 or v12):

  # v2 https://lore.kernel.org/r/cover.1590355211.git.sathyanarayanan.kuppuswamy@linux.intel.com/
  # v3 https://lore.kernel.org/r/cover.1590355824.git.sathyanarayanan.kuppuswamy@linux.intel.com/
  # v4 https://lore.kernel.org/r/cover.1590534843.git.sathyanarayanan.kuppuswamy@linux.intel.com/
  # v5 https://lore.kernel.org/r/cover.1591545462.git.sathyanarayanan.kuppuswamy@linux.intel.com/
  # v6 https://lore.kernel.org/r/cover.1593195899.git.sathyanarayanan.kuppuswamy@linux.intel.com/
  # v7 https://lore.kernel.org/r/cover.1595006564.git.sathyanarayanan.kuppuswamy@linux.intel.com/
  # v8 https://lore.kernel.org/r/cover.1595649348.git.sathyanarayanan.kuppuswamy@linux.intel.com/
  # v9 https://lore.kernel.org/r/cover.1600457297.git.sathyanarayanan.kuppuswamy@linux.intel.com/
  # v9 https://lore.kernel.org/r/20200928011131.MI-pJpJNRQw6c35j_O6019flLWHe08C4WvKPmKEbnik@z/
  # v10 https://lore.kernel.org/r/cover.1603738449.git.sathyanarayanan.kuppuswamy@linux.intel.com/
  # v11 https://lore.kernel.org/r/cover.1603766889.git.sathyanarayanan.kuppuswamy@linux.intel.com/
  # v12 https://lore.kernel.org/r/20201126011816.711106-1-helgaas@kernel.org/

>  		services |= PCIE_PORT_SERVICE_DPC;
>  
>  	/* Enable bandwidth control if more than one speed is supported. */
> -- 
> 2.43.7
> 

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

* Re: [PATCH] PCI/DPC: Honor "pcie_ports=native" when enabling DPC
  2026-09-03 23:05 ` Bjorn Helgaas
@ 2026-09-04  2:34   ` Guixin Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Guixin Liu @ 2026-09-04  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Bjorn Helgaas, Uwe Kleine-König, Jonathan Cameron,
	Lukas Wunner, Ilpo Järvinen, Kees Cook, Darshit Shah,
	Brian Norris, Kuppuswamy Sathyanarayanan, linux-pci, stable



在 2026/9/4 07:05, Bjorn Helgaas 写道:
> On Tue, Sep 01, 2026 at 02:45:54PM +0800, Guixin Liu wrote:
>> Commit 97ca178c899d ("PCI/DPC: Allow DPC on all Downstream Ports when
>> OS controls AER") replaced the AER service bit with host->native_aer
>> when deciding whether to create a DPC service device.  Unlike the AER
>> service bit, host->native_aer does not reflect the "pcie_ports=native"
>> command-line override.
>>
>> Consequently, if firmware retains AER control, "pcie_ports=native" no
>> longer enables DPC on Root Ports that advertise both AER and DPC, even
>> though the option is documented to force native DPC handling.
>>
>> Check pcie_ports_native explicitly so both command-line overrides
>> continue to work.
>>
>> Fixes: 97ca178c899d ("PCI/DPC: Allow DPC on all Downstream Ports when OS controls AER")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
>> ---
>>   drivers/pci/pcie/portdrv.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c
>> index a9cbfc1d2bc7..a05ee7980fb2 100644
>> --- a/drivers/pci/pcie/portdrv.c
>> +++ b/drivers/pci/pcie/portdrv.c
>> @@ -264,7 +264,7 @@ static int get_port_device_capability(struct pci_dev *dev)
>>   	 */
>>   	if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DPC) &&
>>   	    pci_aer_available() &&
>> -	    (pcie_ports_dpc_native || host->native_aer))
>> +	    (pcie_ports_native || pcie_ports_dpc_native || host->native_aer))
> Oh my goodness.  I think I completely dropped ball on this YEARS ago.
>
> It's crazy that we have "pcie_ports_native" checking littered all
> over.  I think we should instead treat host->native_* as the single
> source of truth, and pay attention to pcie_ports_native when setting
> host->native_*.
>
> Sathy did some great work to do exactly that in 2020, and I never got
> it merged.  I wish I had some great excuse, but I looked at my 2020
> calendar and couldn't find one.  I think I just blew it.
>
> So I think we should resurrect that series and update it as needed and
> solve the problem that way.  I dug out the links just for
> completeness, but we should probably just start with the most recent
> ones (v11 or v12):
>
>    # v2 https://lore.kernel.org/r/cover.1590355211.git.sathyanarayanan.kuppuswamy@linux.intel.com/
>    # v3 https://lore.kernel.org/r/cover.1590355824.git.sathyanarayanan.kuppuswamy@linux.intel.com/
>    # v4 https://lore.kernel.org/r/cover.1590534843.git.sathyanarayanan.kuppuswamy@linux.intel.com/
>    # v5 https://lore.kernel.org/r/cover.1591545462.git.sathyanarayanan.kuppuswamy@linux.intel.com/
>    # v6 https://lore.kernel.org/r/cover.1593195899.git.sathyanarayanan.kuppuswamy@linux.intel.com/
>    # v7 https://lore.kernel.org/r/cover.1595006564.git.sathyanarayanan.kuppuswamy@linux.intel.com/
>    # v8 https://lore.kernel.org/r/cover.1595649348.git.sathyanarayanan.kuppuswamy@linux.intel.com/
>    # v9 https://lore.kernel.org/r/cover.1600457297.git.sathyanarayanan.kuppuswamy@linux.intel.com/
>    # v9 https://lore.kernel.org/r/20200928011131.MI-pJpJNRQw6c35j_O6019flLWHe08C4WvKPmKEbnik@z/
>    # v10 https://lore.kernel.org/r/cover.1603738449.git.sathyanarayanan.kuppuswamy@linux.intel.com/
>    # v11 https://lore.kernel.org/r/cover.1603766889.git.sathyanarayanan.kuppuswamy@linux.intel.com/
>    # v12 https://lore.kernel.org/r/20201126011816.711106-1-helgaas@kernel.org/
Yeah, this series is better than mine, wait for your to recover them.

In addition, we should add "Fixes: 97ca178c899d ("PCI/DPC: Allow DPC on 
all Downstream Ports when OS controls AER")" also.

Best Regards,
Guixin Liu
>>   		services |= PCIE_PORT_SERVICE_DPC;
>>   
>>   	/* Enable bandwidth control if more than one speed is supported. */
>> -- 
>> 2.43.7
>>


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

end of thread, other threads:[~2026-09-04  2:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-01  6:45 [PATCH] PCI/DPC: Honor "pcie_ports=native" when enabling DPC Guixin Liu
2026-09-01  6:57 ` sashiko-bot
2026-09-03 23:05 ` Bjorn Helgaas
2026-09-04  2:34   ` Guixin Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox