mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 0/6] PCI/DPC: Decide DPC ownership with host_bridge->native_dpc
@ 2026-11-18 18:17 Kuppuswamy Sathyanarayanan
  2026-11-18 18:17 ` [PATCH v3 1/6] PCI/DPC: Avoid access to non-existent AER capability Kuppuswamy Sathyanarayanan
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Kuppuswamy Sathyanarayanan @ 2026-11-18 18:17 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Lukas Wunner, Yazen Ghannam, Rafael J . Wysocki,
	Mahesh J Salgaonkar, Oliver O'Halloran, Len Brown, linux-pci,
	linux-acpi, linux-kernel

This series makes host_bridge->native_dpc the single decider for whether
Linux uses DPC, as Bjorn asked during the review of "Simplify PCIe native
ownership".

  https://lore.kernel.org/r/20261001221408.GA2731929@bhelgaas

Today the DPC service binds on host_bridge->native_aer, AER availability
and "pcie_ports=dpc-native".  host_bridge->native_dpc is only consulted
by pci_dpc_recovered().  After this series, native_dpc is the end result
of everything that decides DPC ownership, and portdrv binds the DPC
service on it.

Patches 1-2 are the two DPC patches from v2 of Lukas's "Error reporting
for AER-incapable devices", which are included here directly.

  https://lore.kernel.org/r/34c9ee153876bac953135b4518035194b7c07c6c.1794997749.git.lukas@wunner.de
  https://lore.kernel.org/r/58d8a99cc6c2ecba6dadc450ecb4501d47816732.1794997749.git.lukas@wunner.de

Patch 1 keeps the DPC driver from accessing a non-existent AER
capability.

Patch 2 drops the AER ownership check from dpc_probe(), so DPC also
works on ports without an AER capability.

Patch 3 builds EDR whenever DPC is enabled on ACPI, so CONFIG_PCIE_EDR
is no longer a separate knob in deciding whether to request DPC control.

Patch 4 stops requiring pci_aer_available() to bind the DPC service,
since the DPC driver does not depend on MSI or on the AER driver.

Patch 5 requests DPC control only together with AER control, as PCI
Firmware r3.3, sec 4.5.2.4, requires.

Patch 6 binds the DPC service on host_bridge->native_dpc and logs a
message when the OS assumes DPC control that _OSC did not grant.

Changes since v2:

  - Pick up v2 of Lukas's two DPC patches.  Patch 1 now uses the AER
    capability to find the error severity when the port has one.

  - Keep CONFIG_PCIE_EDR as a hidden option instead of removing it, and
    remove the pci_dpc_recovered() check that becomes dead (Yazen).

  - Fold the PCI Firmware spec reference into the existing comment in
    calculate_control() (Yazen).

  - Shorten the comment in acpi_pci_root_create() (Yazen).

  - Rebase on v7.4-rc1 and add Reviewed-by and Acked-by tags.

v2: https://lore.kernel.org/r/20261020181924.3003553-1-sathyanarayanan.kuppuswamy@linux.intel.com
v1: https://lore.kernel.org/r/20261007165840.1604136-1-sathyanarayanan.kuppuswamy@linux.intel.com

Kuppuswamy Sathyanarayanan (4):
  PCI/EDR: Build EDR whenever DPC is enabled on ACPI
  PCI/portdrv: Don't require AER to bind DPC service
  PCI/ACPI: Request DPC control only together with AER control
  PCI/portdrv: Bind DPC service based on host_bridge->native_dpc

Lukas Wunner (2):
  PCI/DPC: Avoid access to non-existent AER capability
  PCI/DPC: Reinstate support for AER-incapable ports

 drivers/acpi/pci_root.c    | 19 +++++++++++--
 drivers/pci/pcie/Kconfig   |  8 +-----
 drivers/pci/pcie/dpc.c     | 58 +++++++++++++++++++++-----------------
 drivers/pci/pcie/portdrv.c |  7 +----
 4 files changed, 51 insertions(+), 41 deletions(-)


base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
-- 
2.43.0


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

* [PATCH v3 1/6] PCI/DPC: Avoid access to non-existent AER capability
  2026-11-18 18:17 [PATCH v3 0/6] PCI/DPC: Decide DPC ownership with host_bridge->native_dpc Kuppuswamy Sathyanarayanan
@ 2026-11-18 18:17 ` Kuppuswamy Sathyanarayanan
  2026-11-18 18:17 ` [PATCH v3 2/6] PCI/DPC: Reinstate support for AER-incapable ports Kuppuswamy Sathyanarayanan
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Kuppuswamy Sathyanarayanan @ 2026-11-18 18:17 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Lukas Wunner, Yazen Ghannam, Rafael J . Wysocki,
	Mahesh J Salgaonkar, Oliver O'Halloran, Len Brown, linux-pci,
	linux-acpi, linux-kernel

From: Lukas Wunner <lukas@wunner.de>

Downstream Port Containment does not mandate presence of an Advanced Error
Reporting capability, so a Downstream Port may support DPC, but not AER
(PCIe r7.1 sec 6.2.11.2).

In February 2019, commit 9f08a5d896ce ("PCI/DPC: Fix print AER status in
DPC event handling") amended the DPC driver to access the AER capability
without checking for its presence.

This did not cause actual problems because in March 2018, commit
4e5fad429bd1 ("PCI/DPC: Do not enable DPC if AER control is not allowed by
the BIOS") had seemingly inadvertently prevented instantiation of a DPC
port service on AER-incapable ports.

However in October 2019, commit 35a0b2378c19 ("PCI/DPC: Add
"pcie_ports=dpc-native" to allow DPC without AER control") made it
possible to override this:  The DPC driver may access a non-existent AER
capability if "pcie_ports=dpc-native" is passed on the command line.

Fix it by making the DPC driver cope with AER-unsupporting Downstream
Ports.

There are two places where the AER capability is accessed:

- dpc_get_aer_uncorrect_severity() uses it to discern whether a Fatal or
  Non-Fatal Error triggered DPC.  Access the Device Status Register
  instead, in accordance with PCIe r7.1 sec 6.2.5.

- dpc_is_surprise_removal() uses it to detect whether a Surprise Down
  Error triggered DPC.  Return false on AER-unsupporting devices.  The
  function works around an AMD-specific quirk and it seems reasonable to
  assume that all affected products are AER-supporting.  In any case the
  detection is not possible without AER capability.

Insert a temporary check for an AER capability after the call to
aer_get_device_error_info() because the function currently returns false
for AER-unsupporting devices.  The check will become obsolete and will be
removed with the imminent baseline capability error reporting.

Fixes: 35a0b2378c19 ("PCI/DPC: Add "pcie_ports=dpc-native" to allow DPC without AER control")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: stable@vger.kernel.org # v5.5+
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
---
 drivers/pci/pcie/dpc.c | 45 ++++++++++++++++++++++++++++++------------
 1 file changed, 32 insertions(+), 13 deletions(-)

diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
index 2b779bd1d861..d02cbbbe3143 100644
--- a/drivers/pci/pcie/dpc.c
+++ b/drivers/pci/pcie/dpc.c
@@ -238,19 +238,35 @@ static int dpc_get_aer_uncorrect_severity(struct pci_dev *dev,
 {
 	int pos = dev->aer_cap;
 	u32 status, mask, sev;
+	u16 devsta;
 
-	pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
-	pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, &mask);
-	status &= ~mask;
-	if (!status)
-		return 0;
-
-	pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &sev);
-	status &= sev;
-	if (status)
-		info->severity = AER_FATAL;
-	else
-		info->severity = AER_NONFATAL;
+	/*
+	 * Infer severity from AER Extended Capability if present, else from
+	 * Device Status register.  The latter cannot be used on AER-capable
+	 * ports because it also logs masked errors (PCIe r7.1 sec 7.5.3.5).
+	 */
+	if (pos) {
+		pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
+		pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, &mask);
+		status &= ~mask;
+		if (!status)
+			return 0;
+
+		pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &sev);
+		status &= sev;
+		if (status)
+			info->severity = AER_FATAL;
+		else
+			info->severity = AER_NONFATAL;
+	} else {
+		pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &devsta);
+		if (devsta & PCI_EXP_DEVSTA_FED)
+			info->severity = AER_FATAL;
+		else if (devsta & PCI_EXP_DEVSTA_NFED)
+			info->severity = AER_NONFATAL;
+		else
+			return 0;
+	}
 
 	info->level = KERN_ERR;
 
@@ -275,7 +291,7 @@ void dpc_process_error(struct pci_dev *pdev)
 		pci_warn(pdev, "containment event, status:%#06x: unmasked uncorrectable error detected\n",
 			 status);
 		if (dpc_get_aer_uncorrect_severity(pdev, &info) &&
-		    aer_get_device_error_info(&info, 0)) {
+		    (aer_get_device_error_info(&info, 0) || !pdev->aer_cap)) {
 			aer_print_error(&info, 0);
 			pci_aer_clear_nonfatal_status(pdev);
 			pci_aer_clear_fatal_status(pdev);
@@ -353,6 +369,9 @@ static bool dpc_is_surprise_removal(struct pci_dev *pdev)
 	if (!pdev->is_hotplug_bridge)
 		return false;
 
+	if (!pdev->aer_cap)
+		return false;
+
 	if (pci_read_config_word(pdev, pdev->aer_cap + PCI_ERR_UNCOR_STATUS,
 				 &status))
 		return false;
-- 
2.43.0


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

* [PATCH v3 2/6] PCI/DPC: Reinstate support for AER-incapable ports
  2026-11-18 18:17 [PATCH v3 0/6] PCI/DPC: Decide DPC ownership with host_bridge->native_dpc Kuppuswamy Sathyanarayanan
  2026-11-18 18:17 ` [PATCH v3 1/6] PCI/DPC: Avoid access to non-existent AER capability Kuppuswamy Sathyanarayanan
@ 2026-11-18 18:17 ` Kuppuswamy Sathyanarayanan
  2026-11-18 18:17 ` [PATCH v3 3/6] PCI/EDR: Build EDR whenever DPC is enabled on ACPI Kuppuswamy Sathyanarayanan
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Kuppuswamy Sathyanarayanan @ 2026-11-18 18:17 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Lukas Wunner, Yazen Ghannam, Rafael J . Wysocki,
	Mahesh J Salgaonkar, Oliver O'Halloran, Len Brown, linux-pci,
	linux-acpi, linux-kernel

From: Lukas Wunner <lukas@wunner.de>

Downstream Port Containment does not mandate presence of an Advanced Error
Reporting capability, so a Downstream Port may support DPC, but not AER
(PCIe r7.1 sec 6.2.11.2).

Commit 708b20003624 ("PCI/AER: Remove HEST/FIRMWARE_FIRST parsing for AER
ownership") seemingly inadvertently constrained DPC to AER-supporting
Downstream Ports by inserting a call to pcie_aer_is_native() in
dpc_probe(), which implicitly checks for presence of an AER capability.

Drop the call.  It is superfluous because it duplicates the conditions
applied by the PCIe port service driver when it decides whether to
instantiate a DPC port service (see get_port_device_capability()).
If the conditions are not met, no port service is instantiated and
dpc_probe() isn't executed.

The only difference between the conditions in dpc_probe() and the ones in
get_port_device_capability() is the check for the AER capability, so by
removing the checks from dpc_probe(), DPC is supported on AER-incapable
Downstream Ports again.

Fixes: 708b20003624 ("PCI/AER: Remove HEST/FIRMWARE_FIRST parsing for AER ownership")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Cc: stable@vger.kernel.org # v5.8+
---
 drivers/pci/pcie/dpc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
index d02cbbbe3143..a0880e3cd68c 100644
--- a/drivers/pci/pcie/dpc.c
+++ b/drivers/pci/pcie/dpc.c
@@ -496,9 +496,6 @@ static int dpc_probe(struct pcie_device *dev)
 	int status;
 	u16 cap;
 
-	if (!pcie_aer_is_native(pdev) && !pcie_ports_dpc_native)
-		return -ENOTSUPP;
-
 	status = devm_request_threaded_irq(device, dev->irq, dpc_irq,
 					   dpc_handler, IRQF_SHARED,
 					   "pcie-dpc", pdev);
-- 
2.43.0


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

* [PATCH v3 3/6] PCI/EDR: Build EDR whenever DPC is enabled on ACPI
  2026-11-18 18:17 [PATCH v3 0/6] PCI/DPC: Decide DPC ownership with host_bridge->native_dpc Kuppuswamy Sathyanarayanan
  2026-11-18 18:17 ` [PATCH v3 1/6] PCI/DPC: Avoid access to non-existent AER capability Kuppuswamy Sathyanarayanan
  2026-11-18 18:17 ` [PATCH v3 2/6] PCI/DPC: Reinstate support for AER-incapable ports Kuppuswamy Sathyanarayanan
@ 2026-11-18 18:17 ` Kuppuswamy Sathyanarayanan
  2026-11-18 18:17 ` [PATCH v3 4/6] PCI/portdrv: Don't require AER to bind DPC service Kuppuswamy Sathyanarayanan
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Kuppuswamy Sathyanarayanan @ 2026-11-18 18:17 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Lukas Wunner, Yazen Ghannam, Rafael J . Wysocki,
	Mahesh J Salgaonkar, Oliver O'Halloran, Len Brown, linux-pci,
	linux-acpi, linux-kernel

Error Disconnect Recover (EDR) is the ACPI half of the hybrid DPC model,
where firmware owns DPC and notifies the OS of containment events.

CONFIG_PCIE_EDR made EDR optional on top of CONFIG_PCIE_DPC.  This adds
another knob to the decision to request DPC control in _OSC.  The OS
requests DPC control only if it also supports EDR, so with
CONFIG_PCIE_EDR=n it never requests DPC control.  There is little reason
to build DPC without EDR on ACPI systems.

Make CONFIG_PCIE_EDR a hidden option that is enabled whenever
CONFIG_PCIE_DPC and CONFIG_ACPI are both enabled, like CONFIG_PCIE_PME.

pci_dpc_recovered() gave up if firmware owned DPC and EDR was not
enabled.  EDR is now always enabled with DPC on ACPI, and native_dpc is
only cleared by the _OSC negotiation, so remove that check.

Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
---
Changes since v2:
 - Keep CONFIG_PCIE_EDR as a hidden option instead of removing it (Yazen)
 - Remove the pci_dpc_recovered() check that becomes dead (Yazen)
 - New subject, was "PCI/EDR: Remove CONFIG_PCIE_EDR"

 drivers/pci/pcie/Kconfig |  8 +-------
 drivers/pci/pcie/dpc.c   | 10 ----------
 2 files changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig
index 207c2deae35f..4d097c53f140 100644
--- a/drivers/pci/pcie/Kconfig
+++ b/drivers/pci/pcie/Kconfig
@@ -138,11 +138,5 @@ config PCIE_PTM
 	  is safe to enable even if you don't.
 
 config PCIE_EDR
-	bool "PCI Express Error Disconnect Recover support"
+	def_bool y
 	depends on PCIE_DPC && ACPI
-	help
-	  This option adds Error Disconnect Recover support as specified
-	  in the Downstream Port Containment Related Enhancements ECN to
-	  the PCI Firmware Specification r3.2.  Enable this if you want to
-	  support hybrid DPC model which uses both firmware and OS to
-	  implement DPC.
diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
index a0880e3cd68c..1e917febcbf3 100644
--- a/drivers/pci/pcie/dpc.c
+++ b/drivers/pci/pcie/dpc.c
@@ -102,19 +102,9 @@ static bool dpc_completed(struct pci_dev *pdev)
  */
 bool pci_dpc_recovered(struct pci_dev *pdev)
 {
-	struct pci_host_bridge *host;
-
 	if (!pdev->dpc_cap)
 		return false;
 
-	/*
-	 * Synchronization between hotplug and DPC is not supported
-	 * if DPC is owned by firmware and EDR is not enabled.
-	 */
-	host = pci_find_host_bridge(pdev->bus);
-	if (!host->native_dpc && !IS_ENABLED(CONFIG_PCIE_EDR))
-		return false;
-
 	/*
 	 * Need a timeout in case DPC never completes due to failure of
 	 * dpc_wait_rp_inactive().  The spec doesn't mandate a time limit,
-- 
2.43.0


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

* [PATCH v3 4/6] PCI/portdrv: Don't require AER to bind DPC service
  2026-11-18 18:17 [PATCH v3 0/6] PCI/DPC: Decide DPC ownership with host_bridge->native_dpc Kuppuswamy Sathyanarayanan
                   ` (2 preceding siblings ...)
  2026-11-18 18:17 ` [PATCH v3 3/6] PCI/EDR: Build EDR whenever DPC is enabled on ACPI Kuppuswamy Sathyanarayanan
@ 2026-11-18 18:17 ` Kuppuswamy Sathyanarayanan
  2026-11-18 18:17 ` [PATCH v3 5/6] PCI/ACPI: Request DPC control only together with AER control Kuppuswamy Sathyanarayanan
  2026-11-18 18:17 ` [PATCH v3 6/6] PCI/portdrv: Bind DPC service based on host_bridge->native_dpc Kuppuswamy Sathyanarayanan
  5 siblings, 0 replies; 7+ messages in thread
From: Kuppuswamy Sathyanarayanan @ 2026-11-18 18:17 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Lukas Wunner, Yazen Ghannam, Rafael J . Wysocki,
	Mahesh J Salgaonkar, Oliver O'Halloran, Len Brown, linux-pci,
	linux-acpi, linux-kernel

get_port_device_capability() binds the DPC service only if
pci_aer_available() is true.  pci_aer_available() is false with
"pci=noaer" or when MSI is disabled.

The DPC driver does not need either of these.  pci_aer_available()
depends on MSI only because the AER driver does not work with INTx
(commit 3e77a3f7895e ("PCI: Disable AER with pci=nomsi")).  The DPC
driver does not depend on MSI or on the AER driver, and it works on
ports without an AER capability.

PCIe r7.0 sec 6.2.11 recommends that the OS link control of DPC to
control of AER.  PCI Firmware r3.3, sec 4.5.2.4, requires the same for
_OSC.  Both are about ownership, not about using the AER driver.
host->native_aer and the _OSC negotiation already cover ownership.

Drop the pci_aer_available() check.

The changes in behavior are:

  - ACPI systems booted with "pci=noaer" or with MSI disabled, and with
    "pcie_ports=native" or "pcie_ports=dpc-native".  The OS now uses DPC
    there, which is what those options ask for.  Without them nothing
    changes, because the OS does not request AER control in _OSC, so
    host->native_aer is not set.

  - Non-ACPI systems booted with "pci=noaer" or with MSI disabled.
    host->native_aer is set there, so the OS now uses DPC.  An
    uncorrectable error that used to be ignored with "pci=noaer" now
    triggers DPC, which takes the link down and resets the devices below
    the port.

Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com>
---
Changes since v2:
 - Add Reviewed-by from Yazen

 drivers/pci/pcie/portdrv.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c
index 32fc623dd410..b77680fd3b75 100644
--- a/drivers/pci/pcie/portdrv.c
+++ b/drivers/pci/pcie/portdrv.c
@@ -263,7 +263,6 @@ static int get_port_device_capability(struct pci_dev *dev)
 	 * permission to use AER.
 	 */
 	if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DPC) &&
-	    pci_aer_available() &&
 	    (pcie_ports_dpc_native || host->native_aer))
 		services |= PCIE_PORT_SERVICE_DPC;
 
-- 
2.43.0


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

* [PATCH v3 5/6] PCI/ACPI: Request DPC control only together with AER control
  2026-11-18 18:17 [PATCH v3 0/6] PCI/DPC: Decide DPC ownership with host_bridge->native_dpc Kuppuswamy Sathyanarayanan
                   ` (3 preceding siblings ...)
  2026-11-18 18:17 ` [PATCH v3 4/6] PCI/portdrv: Don't require AER to bind DPC service Kuppuswamy Sathyanarayanan
@ 2026-11-18 18:17 ` Kuppuswamy Sathyanarayanan
  2026-11-18 18:17 ` [PATCH v3 6/6] PCI/portdrv: Bind DPC service based on host_bridge->native_dpc Kuppuswamy Sathyanarayanan
  5 siblings, 0 replies; 7+ messages in thread
From: Kuppuswamy Sathyanarayanan @ 2026-11-18 18:17 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Lukas Wunner, Yazen Ghannam, Rafael J . Wysocki,
	Mahesh J Salgaonkar, Oliver O'Halloran, Len Brown, linux-pci,
	linux-acpi, linux-kernel

PCI Firmware r3.3, sec 4.5.2.4, requires the OS to request AER control
when it requests DPC control.  calculate_control() requests DPC control
whenever CONFIG_PCIE_DPC and CONFIG_PCIE_EDR are enabled, even if it
does not request AER control, e.g., with "pci=noaer" or when MSI is
disabled.

Request DPC control only if AER control is also requested.

Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Acked-by: Rafael J. Wysocki (Intel) <rafael@kernel.org>
Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com>
---
Changes since v2:
 - Fold the PCI Firmware spec reference into the existing comment (Yazen)
 - Keep the CONFIG_PCIE_EDR test and mention it in the commit log
 - Add Reviewed-by from Yazen

 drivers/acpi/pci_root.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index a1a9c06012f8..510943649b41 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -515,9 +515,11 @@ static u32 calculate_control(void)
 	 * Per the Downstream Port Containment Related Enhancements ECN to
 	 * the PCI Firmware Spec, r3.2, sec 4.5.1, table 4-5,
 	 * OSC_PCI_EXPRESS_DPC_CONTROL indicates the OS supports both DPC
-	 * and EDR.
+	 * and EDR.  PCI Firmware r3.3, sec 4.5.2.4, also requires the OS to
+	 * request AER control along with DPC control.
 	 */
-	if (IS_ENABLED(CONFIG_PCIE_DPC) && IS_ENABLED(CONFIG_PCIE_EDR))
+	if (IS_ENABLED(CONFIG_PCIE_DPC) && IS_ENABLED(CONFIG_PCIE_EDR) &&
+	    (control & OSC_PCI_EXPRESS_AER_CONTROL))
 		control |= OSC_PCI_EXPRESS_DPC_CONTROL;
 
 	return control;
-- 
2.43.0


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

* [PATCH v3 6/6] PCI/portdrv: Bind DPC service based on host_bridge->native_dpc
  2026-11-18 18:17 [PATCH v3 0/6] PCI/DPC: Decide DPC ownership with host_bridge->native_dpc Kuppuswamy Sathyanarayanan
                   ` (4 preceding siblings ...)
  2026-11-18 18:17 ` [PATCH v3 5/6] PCI/ACPI: Request DPC control only together with AER control Kuppuswamy Sathyanarayanan
@ 2026-11-18 18:17 ` Kuppuswamy Sathyanarayanan
  5 siblings, 0 replies; 7+ messages in thread
From: Kuppuswamy Sathyanarayanan @ 2026-11-18 18:17 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Lukas Wunner, Yazen Ghannam, Rafael J . Wysocki,
	Mahesh J Salgaonkar, Oliver O'Halloran, Len Brown, linux-pci,
	linux-acpi, linux-kernel

get_port_device_capability() binds the DPC service if the port has a DPC
capability and either "pcie_ports=dpc-native" was given or the OS
controls AER.  This repeats decisions that are already made elsewhere.
It also ignores host_bridge->native_dpc, which is meant to say whether
the OS owns DPC.

Make host_bridge->native_dpc the single decider:

  - In acpi_pci_root_create(), assume DPC control whenever _OSC grants
    AER control.  PCI Firmware r3.3, sec 4.5.2.4, requires platforms to
    retain AER if they retain DPC.  Put the other way, firmware that
    grants AER does not keep DPC.  PCIe r7.0 sec 6.2.11 recommends that
    the OS link control of DPC to control of AER.  Commit 97ca178c899d
    ("PCI/DPC: Allow DPC on all Downstream Ports when OS controls AER")
    relied on this link.  Keeping it means DPC still works with firmware
    that predates the _OSC DPC control bit.  Such firmware grants AER but
    masks DPC.  The OS cannot tell such firmware from firmware that
    retains DPC on purpose, so log a message when it assumes DPC control
    that _OSC did not grant.  Only do this if the OS requested DPC
    control, i.e., if CONFIG_PCIE_DPC is enabled.

  - "pcie_ports=native" and "pcie_ports=dpc-native" are already folded
    into the _OSC control mask, so they are reflected in native_dpc.

Then bind the DPC service if the port has a DPC capability and
host_bridge->native_dpc is set.

The only change in behavior is for firmware that grants DPC control but
retains AER control.  PCI Firmware r3.3, sec 4.5.2.4, does not forbid
this.  The OS now uses DPC there because firmware granted it.  Since
"PCI/DPC: Reinstate support for AER-incapable ports", dpc_probe() no
longer requires AER control.

Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com>
---
Changes since v2:
 - Shorten the comment in acpi_pci_root_create() (Yazen)
 - Add Reviewed-by from Yazen

 drivers/acpi/pci_root.c    | 13 +++++++++++++
 drivers/pci/pcie/portdrv.c |  6 +-----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 510943649b41..b08261b6372f 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -1054,6 +1054,19 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,
 	ctrl = root->osc_control_set;
 	ext_ctrl = root->osc_ext_control_set;
 
+	/*
+	 * Firmware that predates the _OSC DPC control bit grants AER but
+	 * masks DPC.  Link DPC control to AER control, as PCIe r7.0 sec
+	 * 6.2.11 recommends.
+	 */
+	if (IS_ENABLED(CONFIG_PCIE_DPC) &&
+	    (ctrl & OSC_PCI_EXPRESS_AER_CONTROL) &&
+	    !(ctrl & OSC_PCI_EXPRESS_DPC_CONTROL)) {
+		decode_osc_control(root, "OS assuming control (AER granted) of",
+				   OSC_PCI_EXPRESS_DPC_CONTROL);
+		ctrl |= OSC_PCI_EXPRESS_DPC_CONTROL;
+	}
+
 	/*
 	 * If the user specified "pcie_ports=native", use the PCIe port
 	 * services regardless of what _OSC says, i.e., proceed as though the
diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c
index b77680fd3b75..f1beb440a3dc 100644
--- a/drivers/pci/pcie/portdrv.c
+++ b/drivers/pci/pcie/portdrv.c
@@ -258,12 +258,8 @@ static int get_port_device_capability(struct pci_dev *dev)
 		pcie_pme_interrupt_enable(dev, false);
 	}
 
-	/*
-	 * With dpc-native, allow Linux to use DPC even if it doesn't have
-	 * permission to use AER.
-	 */
 	if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DPC) &&
-	    (pcie_ports_dpc_native || host->native_aer))
+	    host->native_dpc)
 		services |= PCIE_PORT_SERVICE_DPC;
 
 	/* Enable bandwidth control if more than one speed is supported. */
-- 
2.43.0


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

end of thread, other threads:[~2026-11-18 18:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 18:17 [PATCH v3 0/6] PCI/DPC: Decide DPC ownership with host_bridge->native_dpc Kuppuswamy Sathyanarayanan
2026-11-18 18:17 ` [PATCH v3 1/6] PCI/DPC: Avoid access to non-existent AER capability Kuppuswamy Sathyanarayanan
2026-11-18 18:17 ` [PATCH v3 2/6] PCI/DPC: Reinstate support for AER-incapable ports Kuppuswamy Sathyanarayanan
2026-11-18 18:17 ` [PATCH v3 3/6] PCI/EDR: Build EDR whenever DPC is enabled on ACPI Kuppuswamy Sathyanarayanan
2026-11-18 18:17 ` [PATCH v3 4/6] PCI/portdrv: Don't require AER to bind DPC service Kuppuswamy Sathyanarayanan
2026-11-18 18:17 ` [PATCH v3 5/6] PCI/ACPI: Request DPC control only together with AER control Kuppuswamy Sathyanarayanan
2026-11-18 18:17 ` [PATCH v3 6/6] PCI/portdrv: Bind DPC service based on host_bridge->native_dpc Kuppuswamy Sathyanarayanan

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

all inboxes | Powered by JetHome®