* [PATCH] PCI/DPC: Use DPC if platform grants DPC control but not AER control
@ 2026-12-03 18:49 Mario Limonciello
2026-12-03 19:01 ` Kuppuswamy Sathyanarayanan
2026-12-03 19:20 ` sashiko-bot
0 siblings, 2 replies; 3+ messages in thread
From: Mario Limonciello @ 2026-12-03 18:49 UTC (permalink / raw)
To: Sourabh Jain, Oliver O'Halloran, Bjorn Helgaas,
Kuppuswamy Sathyanarayanan
Cc: linuxppc-dev, linux-pci, Mario Limonciello
PCIe r7.0, sec 6.2.11, "Implementation Note: Determination of DPC Control",
recommends that operating systems link control of DPC to control of AER.
Accordingly, since commit eed85ff4c0da ("PCI/DPC: Enable DPC only if AER
is available"), the DPC driver only binds to a Port if the OS controls AER
or the user specified "pcie_ports=dpc-native".
At the time, Linux did not negotiate DPC control with the platform at all.
Commit ac1c8e35a326 ("PCI/DPC: Add Error Disconnect Recover (EDR)
support") added a request for DPC control via _OSC, independent of AER
control, and recorded the result in host->native_dpc. But it didn't
update portdrv or the DPC driver to use host->native_dpc, so if the
platform grants DPC control while retaining AER control, we own DPC but
never use it. Nobody enables DPC, and errors below the Port are not
contained.
Some platforms grant DPC control without AER control and have no HEST or
other firmware-first error handling, e.g.:
acpi PNP0A08:00: _OSC: platform does not support [SHPCHotplug AER]
acpi PNP0A08:00: _OSC: OS now controls [PCIeHotplug PME PCIeCapability LTR DPC]
acpi PNP0A08:00: OS native features: SHPCHotplug- PCIeHotplug+ PME+ AER- DPC+ LTR+
Treat a platform grant of DPC control like "pcie_ports=dpc-native" and use
DPC if host->native_dpc is set, even if the OS doesn't control AER.
When handling a DPC event, the DPC driver reads and clears AER status in the
DPC Port. That's the same thing we already do in the EDR path, where
firmware has retained control of both AER and DPC, so it's not a new
intrusion on firmware-owned AER registers.
This has no effect on non-ACPI systems, where native_aer and native_dpc are
both initialized from the same default.
Fixes: ac1c8e35a326 ("PCI/DPC: Add Error Disconnect Recover (EDR) support")
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/pci/pcie/dpc.c | 4 +++-
drivers/pci/pcie/portdrv.c | 6 +++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
index 2b779bd1d861b..8218e57ca861d 100644
--- a/drivers/pci/pcie/dpc.c
+++ b/drivers/pci/pcie/dpc.c
@@ -473,11 +473,13 @@ static void dpc_disable(struct pcie_device *dev)
static int dpc_probe(struct pcie_device *dev)
{
struct pci_dev *pdev = dev->port;
+ struct pci_host_bridge *host = pci_find_host_bridge(pdev->bus);
struct device *device = &dev->device;
int status;
u16 cap;
- if (!pcie_aer_is_native(pdev) && !pcie_ports_dpc_native)
+ if (!pcie_aer_is_native(pdev) && !host->native_dpc &&
+ !pcie_ports_dpc_native)
return -ENOTSUPP;
status = devm_request_threaded_irq(device, dev->irq, dpc_irq,
diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c
index 32fc623dd4108..ffd695f8aff9a 100644
--- a/drivers/pci/pcie/portdrv.c
+++ b/drivers/pci/pcie/portdrv.c
@@ -259,12 +259,12 @@ static int get_port_device_capability(struct pci_dev *dev)
}
/*
- * With dpc-native, allow Linux to use DPC even if it doesn't have
- * permission to use AER.
+ * Use DPC if we control AER, if the platform granted us control of
+ * DPC, or if the user specified "pcie_ports=dpc-native".
*/
if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DPC) &&
pci_aer_available() &&
- (pcie_ports_dpc_native || host->native_aer))
+ (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. */
---
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
change-id: 20261203-superm1-pci-dpc-515ab9d3f25c
Best regards,
--
Mario Limonciello <mario.limonciello@amd.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] PCI/DPC: Use DPC if platform grants DPC control but not AER control
2026-12-03 18:49 [PATCH] PCI/DPC: Use DPC if platform grants DPC control but not AER control Mario Limonciello
@ 2026-12-03 19:01 ` Kuppuswamy Sathyanarayanan
2026-12-03 19:20 ` sashiko-bot
1 sibling, 0 replies; 3+ messages in thread
From: Kuppuswamy Sathyanarayanan @ 2026-12-03 19:01 UTC (permalink / raw)
To: Mario Limonciello, Sourabh Jain, Oliver O'Halloran,
Bjorn Helgaas
Cc: linuxppc-dev, linux-pci
Hi,
On 12/3/26 10:49, Mario Limonciello wrote:
> PCIe r7.0, sec 6.2.11, "Implementation Note: Determination of DPC Control",
> recommends that operating systems link control of DPC to control of AER.
> Accordingly, since commit eed85ff4c0da ("PCI/DPC: Enable DPC only if AER
> is available"), the DPC driver only binds to a Port if the OS controls AER
> or the user specified "pcie_ports=dpc-native".
>
> At the time, Linux did not negotiate DPC control with the platform at all.
> Commit ac1c8e35a326 ("PCI/DPC: Add Error Disconnect Recover (EDR)
> support") added a request for DPC control via _OSC, independent of AER
> control, and recorded the result in host->native_dpc. But it didn't
> update portdrv or the DPC driver to use host->native_dpc, so if the
> platform grants DPC control while retaining AER control, we own DPC but
> never use it. Nobody enables DPC, and errors below the Port are not
> contained.
>
> Some platforms grant DPC control without AER control and have no HEST or
> other firmware-first error handling, e.g.:
>
> acpi PNP0A08:00: _OSC: platform does not support [SHPCHotplug AER]
> acpi PNP0A08:00: _OSC: OS now controls [PCIeHotplug PME PCIeCapability LTR DPC]
> acpi PNP0A08:00: OS native features: SHPCHotplug- PCIeHotplug+ PME+ AER- DPC+ LTR+
>
> Treat a platform grant of DPC control like "pcie_ports=dpc-native" and use
> DPC if host->native_dpc is set, even if the OS doesn't control AER.
pci/next already does this with two commits from this series:
https://lore.kernel.org/r/20261118181718.3907441-1-sathyanarayanan.kuppuswamy@linux.intel.com/
db6bf75c52c3 ("PCI/DPC: Reinstate support for AER-incapable ports")
removes the pcie_aer_is_native() check from dpc_probe().
b7e91bf93854 ("PCI/portdrv: Bind DPC service based on
host_bridge->native_dpc") binds the DPC service based only on
host->native_dpc. "pcie_ports=native" and "pcie_ports=dpc-native"
are already folded into the _OSC mask, so they are reflected in
native_dpc.
So on pci/next, a platform that reports "AER- DPC+" should already get
the DPC service.
Can you test your use case it with pci/next kernel?
>
> When handling a DPC event, the DPC driver reads and clears AER status in the
> DPC Port. That's the same thing we already do in the EDR path, where
> firmware has retained control of both AER and DPC, so it's not a new
> intrusion on firmware-owned AER registers.
>
> This has no effect on non-ACPI systems, where native_aer and native_dpc are
> both initialized from the same default.
>
> Fixes: ac1c8e35a326 ("PCI/DPC: Add Error Disconnect Recover (EDR) support")
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/pci/pcie/dpc.c | 4 +++-
> drivers/pci/pcie/portdrv.c | 6 +++---
> 2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
> index 2b779bd1d861b..8218e57ca861d 100644
> --- a/drivers/pci/pcie/dpc.c
> +++ b/drivers/pci/pcie/dpc.c
> @@ -473,11 +473,13 @@ static void dpc_disable(struct pcie_device *dev)
> static int dpc_probe(struct pcie_device *dev)
> {
> struct pci_dev *pdev = dev->port;
> + struct pci_host_bridge *host = pci_find_host_bridge(pdev->bus);
> struct device *device = &dev->device;
> int status;
> u16 cap;
>
> - if (!pcie_aer_is_native(pdev) && !pcie_ports_dpc_native)
> + if (!pcie_aer_is_native(pdev) && !host->native_dpc &&
> + !pcie_ports_dpc_native)
> return -ENOTSUPP;
>
> status = devm_request_threaded_irq(device, dev->irq, dpc_irq,
> diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c
> index 32fc623dd4108..ffd695f8aff9a 100644
> --- a/drivers/pci/pcie/portdrv.c
> +++ b/drivers/pci/pcie/portdrv.c
> @@ -259,12 +259,12 @@ static int get_port_device_capability(struct pci_dev *dev)
> }
>
> /*
> - * With dpc-native, allow Linux to use DPC even if it doesn't have
> - * permission to use AER.
> + * Use DPC if we control AER, if the platform granted us control of
> + * DPC, or if the user specified "pcie_ports=dpc-native".
> */
> if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DPC) &&
> pci_aer_available() &&
> - (pcie_ports_dpc_native || host->native_aer))
> + (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. */
>
> ---
> base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
> change-id: 20261203-superm1-pci-dpc-515ab9d3f25c
>
> Best regards,
> --
> Mario Limonciello <mario.limonciello@amd.com>
--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PCI/DPC: Use DPC if platform grants DPC control but not AER control
2026-12-03 18:49 [PATCH] PCI/DPC: Use DPC if platform grants DPC control but not AER control Mario Limonciello
2026-12-03 19:01 ` Kuppuswamy Sathyanarayanan
@ 2026-12-03 19:20 ` sashiko-bot
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-12-03 19:20 UTC (permalink / raw)
To: Mario Limonciello; +Cc: linux-pci
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] PCI/DPC: AER status left uncleared when native_dpc set
without native_aer
- [Medium] PCI/DPC: dpc_probe() bypasses aer_cap check, causing wrong
config header reads
- [Medium] PCI/DPC: enabling DPC when !native_aer races with GHES
recovery and FW AER
- [Low] PCI/DPC: redundant pcie_ports_dpc_native check alongside
host->native_dpc
--
commit 7e9d77620762d00c0afd4d8efdb677a13fe25294
Author: Mario Limonciello <mario.limonciello@amd.com>
PCI/DPC: Use DPC if platform grants DPC control but not AER control
This commit enables the PCIe DPC port service and allows the DPC driver to
bind when host->native_dpc is set, even if the OS does not control AER.
> diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
> index 2b779bd1d861b..8218e57ca861d 100644
> --- a/drivers/pci/pcie/dpc.c
> +++ b/drivers/pci/pcie/dpc.c
> @@ -473,11 +473,13 @@ static void dpc_disable(struct pcie_device *dev)
> static int dpc_probe(struct pcie_device *dev)
> {
> struct pci_dev *pdev = dev->port;
> + struct pci_host_bridge *host = pci_find_host_bridge(pdev->bus);
> struct device *device = &dev->device;
> int status;
> u16 cap;
>
> - if (!pcie_aer_is_native(pdev) && !pcie_ports_dpc_native)
> + if (!pcie_aer_is_native(pdev) && !host->native_dpc &&
> + !pcie_ports_dpc_native)
> return -ENOTSUPP;
[Severity: Medium]
Does the DPC driver leave PCI_ERR_UNCOR_STATUS and PCI_EXP_DEVSTA uncleared
when host->native_dpc is set without host->native_aer?
On a PCI_EXP_DPC_STATUS_TRIGGER_RSN_UNCOR event, dpc_process_error() calls
pci_aer_clear_nonfatal_status() and pci_aer_clear_fatal_status(), both of
which return early without writing PCI_ERR_UNCOR_STATUS when
!pcie_aer_is_native(dev). pcie_do_recovery() likewise skips
pcie_clear_device_status() and pci_aer_clear_nonfatal_status() when
host->native_aer is clear.
Unlike edr_handle_event(), which explicitly calls
pci_aer_raw_clear_status() and pcie_clear_device_status(), dpc_handler()
never clears these sticky bits. As a result, the AER First Error Pointer
and TLP Header Log stay latched to the first error, subsequent DPC events
re-report stale status bits, and dpc_get_aer_uncorrect_severity() can
misclassify a later non-fatal error as fatal if a stale fatal bit remains
set.
[Severity: Medium]
Can checking host->native_dpc here allow dpc_probe() to bind to a port with
pdev->aer_cap == 0?
Previously, pcie_aer_is_native() rejected ports with !dev->aer_cap. With
host->native_dpc accepted directly in dpc_probe() and
get_port_device_capability(), a port that advertises DPC without AER (or
where pci_aer_init() failed to allocate dev->aer_info and cleared
dev->aer_cap) will now bind the DPC driver.
When a DPC interrupt fires on such a port, dpc_is_surprise_removal() reads
pdev->aer_cap + PCI_ERR_UNCOR_STATUS (offset 0x04, PCI_COMMAND) and tests
PCI_ERR_UNC_SURPDN (bit 5, which aliases PCI_COMMAND_VGA_PALETTE),
potentially treating a fatal DPC error as a surprise removal and skipping
pcie_do_recovery(). dpc_get_aer_uncorrect_severity() also reads standard
PCI header offsets 0x04, 0x08, and 0x0c as AER registers without checking
dev->aer_cap.
[Severity: Medium]
When firmware grants DPC control via _OSC while retaining AER control for
APEI GHES firmware-first error handling, can binding native DPC race with
GHES recovery?
pcie_do_recovery() has no bridge-level serialization across phases, and
pci_dev_set_io_state(dev, pci_channel_io_frozen) still returns true when
error_state is already pci_channel_io_frozen:
dpc_handler() (IRQ thread) aer_recover_work_func() (kworker)
pcie_do_recovery(..., pcie_do_recovery(...,
dpc_reset_link) aer_root_reset)
report_frozen_detected() report_frozen_detected()
pci_dev_set_io_state() -> true
aer_root_reset()
pci_bus_error_reset()
link still disabled by DPC
timeout -> DISCONNECT
report_perm_failure_detected()
dpc_reset_link()
clear DPC_STATUS_TRIGGER
report_slot_reset()
report_resume() <-- races with perm failure teardown
If aer_root_reset() runs while PCI_EXP_DPC_STATUS_TRIGGER still holds the
link disabled, the secondary bus wait times out and broadcasts permanent
failure to subordinate devices while dpc_handler() concurrently runs
slot_reset() and resume().
In addition, on surprise removal dpc_handle_surprise_removal()
unconditionally calls pci_aer_raw_clear_status() and
pci_clear_surpdn_errors() outside any firmware-coordinated EDR/_OST window,
which can clear firmware-owned AER status registers while firmware is
reading them.
> diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c
> index 32fc623dd4108..ffd695f8aff9a 100644
> --- a/drivers/pci/pcie/portdrv.c
> +++ b/drivers/pci/pcie/portdrv.c
> @@ -259,12 +259,12 @@ static int get_port_device_capability(struct pci_dev *dev)
> }
>
> /*
> - * With dpc-native, allow Linux to use DPC even if it doesn't have
> - * permission to use AER.
> + * Use DPC if we control AER, if the platform granted us control of
> + * DPC, or if the user specified "pcie_ports=dpc-native".
> */
> if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DPC) &&
> pci_aer_available() &&
> - (pcie_ports_dpc_native || host->native_aer))
> + (pcie_ports_dpc_native || host->native_aer || host->native_dpc))
> services |= PCIE_PORT_SERVICE_DPC;
[Severity: Low]
Is the explicit pcie_ports_dpc_native check still needed here and in
dpc_probe() now that host->native_dpc is checked?
Since commit 4fe37866b0d9 ("PCI/ACPI: Centralize pcie_ports_native
checking"), acpi_pci_root_create() folds pcie_ports_dpc_native into the
_OSC control mask so host->native_dpc is already set whenever
pcie_ports_dpc_native is true, and pci_init_host_bridge() sets native_dpc
to 1 on non-ACPI systems when CONFIG_PCIEPORTBUS is enabled. (Keeping it
would only matter if this patch is backported to stable trees lacking that
commit.)
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-superm1-pci-dpc-v1-1-6e5dcd5b5fe9@amd.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-03 19:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 18:49 [PATCH] PCI/DPC: Use DPC if platform grants DPC control but not AER control Mario Limonciello
2026-12-03 19:01 ` Kuppuswamy Sathyanarayanan
2026-12-03 19:20 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox