Skip to contentSkip to conversation

PCI/DPC: Honor "pcie_ports=native" when enabling DPC

PATCH In review Guixin Liu 5 participants 7 messages Sep 1 – Sep 16

Subsystems (2)
lore
Share & tools
lore

Guixin Liu

author
#0 lore raw

PATCH 1/1 PCI/DPC: Honor "pcie_ports=native" when enabling DPC

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")
---
 drivers/pci/pcie/portdrv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pcie/portdrv.c +1 -1
index a9cbfc1d2bc7..a05ee7980fb2 100644
@@ -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. */
Signature · 1 line
2.43.7
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

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 <[email protected]>

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.

drivers/pci/pcie/portdrv.c static int get_port_device_capability(struct pci_dev *dev) · line 268

Quoted 11 lines
drivers/pci/pcie/portdrv.c +1 -1
index a9cbfc1d2bc75..a05ee7980fb27 100644
@@ -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?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Guixin Liu
Quoted 25 lines · Guixin Liu

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")
---
 drivers/pci/pcie/portdrv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pcie/portdrv.c +0 -0
index a9cbfc1d2bc7..a05ee7980fb2 100644

drivers/pci/pcie/portdrv.c static int get_port_device_capability(struct pci_dev *dev) · line 267

Quoted 5 lines
drivers/pci/pcie/portdrv.c +1 -1
@@ -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/[email protected]/
  # v3 https://lore.kernel.org/r/[email protected]/
  # v4 https://lore.kernel.org/r/[email protected]/
  # v5 https://lore.kernel.org/r/[email protected]/
  # v6 https://lore.kernel.org/r/[email protected]/
  # v7 https://lore.kernel.org/r/[email protected]/
  # v8 https://lore.kernel.org/r/[email protected]/
  # v9 https://lore.kernel.org/r/[email protected]/
  # v9 https://lore.kernel.org/r/20200928011131.MI-pJpJNRQw6c35j_O6019flLWHe08C4WvKPmKEbnik@z/
  # v10 https://lore.kernel.org/r/[email protected]/
  # v11 https://lore.kernel.org/r/[email protected]/
  # v12 https://lore.kernel.org/r/[email protected]/
Quoted 6 lines
drivers/pci/pcie/portdrv.c +0 -0
 		services |= PCIE_PORT_SERVICE_DPC;
 
 	/* Enable bandwidth control if more than one speed is supported. */
Signature · 1 line
2.43.7
author
#3 lore raw
Quoted 47 lines · Bjorn Helgaas
Quoted 25 lines · Guixin Liu

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")
---
  drivers/pci/pcie/portdrv.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pcie/portdrv.c +0 -0
index a9cbfc1d2bc7..a05ee7980fb2 100644

drivers/pci/pcie/portdrv.c static int get_port_device_capability(struct pci_dev *dev) · line 267

Quoted 5 lines
drivers/pci/pcie/portdrv.c +1 -1
@@ -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):

Quoted 12 lines
   # v2 https://lore.kernel.org/r/[email protected]/
   # v3 https://lore.kernel.org/r/[email protected]/
   # v4 https://lore.kernel.org/r/[email protected]/
   # v5 https://lore.kernel.org/r/[email protected]/
   # v6 https://lore.kernel.org/r/[email protected]/
   # v7 https://lore.kernel.org/r/[email protected]/
   # v8 https://lore.kernel.org/r/[email protected]/
   # v9 https://lore.kernel.org/r/[email protected]/
   # v9 https://lore.kernel.org/r/20200928011131.MI-pJpJNRQw6c35j_O6019flLWHe08C4WvKPmKEbnik@z/
   # v10 https://lore.kernel.org/r/[email protected]/
   # v11 https://lore.kernel.org/r/[email protected]/
   # v12 https://lore.kernel.org/r/[email protected]/

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

Quoted 6 lines
Quoted 6 lines
drivers/pci/pcie/portdrv.c +0 -0
  		services |= PCIE_PORT_SERVICE_DPC;
 
  	/* Enable bandwidth control if more than one speed is supported. */
Signature · 1 line
2.43.7
author
#4 lore raw
Quoted 52 lines · Guixin Liu
Quoted 49 lines · Bjorn Helgaas
Quoted 27 lines · Guixin Liu

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")

---
  drivers/pci/pcie/portdrv.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pcie/portdrv.c +0 -0
index a9cbfc1d2bc7..a05ee7980fb2 100644
@@ -264,7 +264,7 @@ static int get_port_device_capability(struct 
 pci_dev *dev)
        */
Quoted 5 lines

      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):

Quoted 12 lines
Quoted 4 lines
   # v2 https://lore.kernel.org/r/[email protected]/
   # v3 https://lore.kernel.org/r/[email protected]/
   # v4 https://lore.kernel.org/r/[email protected]/
   # v5 https://lore.kernel.org/r/[email protected]/
Quoted 8 lines
   # v6 https://lore.kernel.org/r/[email protected]/
   # v7 https://lore.kernel.org/r/[email protected]/
   # v8 https://lore.kernel.org/r/[email protected]/
   # v9 https://lore.kernel.org/r/[email protected]/
   # v9 https://lore.kernel.org/r/20200928011131.MI-pJpJNRQw6c35j_O6019flLWHe08C4WvKPmKEbnik@z/
   # v10 https://lore.kernel.org/r/[email protected]/
   # v11 https://lore.kernel.org/r/[email protected]/
   # v12 https://lore.kernel.org/r/[email protected]/

Hi Bjorn, still not see you resurrect this series.

Best Regards,
Guixin Liu

Quoted 11 lines

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

Quoted 5 lines
Quoted 5 lines

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

Signature · 1 line
2.43.7
#5 lore raw

Hi Guixin,

(I've rearranged the quoting a bit, to follow bottom-posting properly)

Quoted 9 lines · Guixin Liu
Quoted 7 lines · Guixin Liu
Quoted 5 lines · Bjorn Helgaas

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):

[...]

Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
   # v12
https://lore.kernel.org/r/[email protected]/

Yeah, this series is better than mine, wait for your to recover them.

Hi Bjorn, still not see you resurrect this series.

In general, I believe the Linux community tends to move by people doing the work and sending patches, not as much by asking someone else to do something for you. Maintainers may provide advice, suggestions, tips, reviews, etc., but that doesn't mean those suggestions translate to work items the maintainer will do. So...

I'm not Bjorn, but I interpret the above "I think we should resurrect that series" as, "if somebody wants this problem solved, they should try reworking and resending that series again". i.e., you should do this, if you want this problem solved.

That's just my interpretation. I hope it's helpful to you.

Regards,
Brian

#6 lore raw
In reply to Guixin Liu

Hi Liu,

Quoted 65 lines · Guixin Liu
Quoted 50 lines · Guixin Liu
Quoted 47 lines · Bjorn Helgaas
Quoted 26 lines · Guixin Liu

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")

---
  drivers/pci/pcie/portdrv.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pcie/portdrv.c +0 -0
index a9cbfc1d2bc7..a05ee7980fb2 100644
@@ -264,7 +264,7 @@ static int get_port_device_capability(struct pci_dev *dev)
        */
Quoted 4 lines

      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):

Quoted 12 lines
Quoted 4 lines
   # v2 https://lore.kernel.org/r/[email protected]/
   # v3 https://lore.kernel.org/r/[email protected]/
   # v4 https://lore.kernel.org/r/[email protected]/
   # v5 https://lore.kernel.org/r/[email protected]/
Quoted 8 lines
   # v6 https://lore.kernel.org/r/[email protected]/
   # v7 https://lore.kernel.org/r/[email protected]/
   # v8 https://lore.kernel.org/r/[email protected]/
   # v9 https://lore.kernel.org/r/[email protected]/
   # v9 https://lore.kernel.org/r/20200928011131.MI-pJpJNRQw6c35j_O6019flLWHe08C4WvKPmKEbnik@z/
   # v10 https://lore.kernel.org/r/[email protected]/
   # v11 https://lore.kernel.org/r/[email protected]/
   # v12 https://lore.kernel.org/r/[email protected]/
Quoted 1 line

Hi Bjorn, still not see you resurrect this series.

I am working on this. I will post the rebased version soon.

Quoted 15 lines

Best Regards,
Guixin Liu

Quoted 11 lines

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

Quoted 5 lines
Quoted 5 lines

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

Signature · 2 lines
Sathyanarayanan Kuppuswamy
Linux Kernel Developer