From: sashiko-bot@kernel.org
To: "Mario Limonciello" <mario.limonciello@amd.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI/DPC: Use DPC if platform grants DPC control but not AER control
Date: Thu, 03 Dec 2026 19:20:22 +0000 [thread overview]
Message-ID: <sashiko-outbox-248485@kernel.org> (raw)
In-Reply-To: <20261203-superm1-pci-dpc-v1-1-6e5dcd5b5fe9@amd.com>
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
prev parent reply other threads:[~2026-12-03 19:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 20:22 ` Mario Limonciello
2026-12-03 21:08 ` Kuppuswamy Sathyanarayanan
2026-12-03 19:20 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-248485@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.