From: sashiko-bot@kernel.org
To: "Yazen Ghannam" <yazen.ghannam@amd.com>, linux-pci@vger.kernel.org
Subject: Re: [PATCH v3 6/6] PCI/FLIT: Manage Flit Logging on Endpoint Upstream Ports
Date: Fri, 04 Dec 2026 18:53:30 +0000 [thread overview]
Message-ID: <sashiko-outbox-250466@kernel.org> (raw)
In-Reply-To: <20261204181556.1418843-7-yazen.ghannam@amd.com>
Thank you for your contribution! Sashiko AI review found 7 potential
issues to consider:
- [High] vfio/pci: host-managed Endpoint Flit Logging capability left
raw RW
- [Medium] PCI/FLIT: aer_root_reset() clears PCI_ERR_ROOT_STATUS without
re-arming Flit
- [Medium] PCI/FLIT: pci_flit_init() enables ERR_COR before bus->devices
insertion
- [Medium] PCI/FLIT: pci_flit_init() ignores pcie_ports_disabled on
non-ACPI hosts
- [Medium] PCI/FLIT: flit_report() emits unratelimited pci_warn() in
drain loop
- [Medium] PCI/FLIT: pci_flit_rearm() accesses config space of D3cold
Endpoints
- [Medium] PCI/FLIT: aerdriver lacks runtime_resume to re-arm ERR_COR
Flit counters
--
commit 3b2b4ec344229286e14d4e998c43a9ee5c0536f6
Author: Yazen Ghannam <yazen.ghannam@amd.com>
PCI/FLIT: Manage Flit Logging on Endpoint Upstream Ports
This commit extends pci_flit_init() to manage the Flit Logging Extended
Capability on PCIe Endpoints when ERR_COR signaling is usable, leaving
other Endpoints untouched.
> diff --git a/drivers/pci/pcie/flit.c b/drivers/pci/pcie/flit.c
> index 83a6b50221ef1..050360295f2f7 100644
> --- a/drivers/pci/pcie/flit.c
> +++ b/drivers/pci/pcie/flit.c
[ ... ]
> @@ -229,7 +244,8 @@ void pci_flit_init(struct pci_dev *pdev)
> u16 trigger;
> u32 ctrl;
>
> - if (!flit_is_port(pdev) || !flit_is_native(pdev))
> + if (!(flit_is_port(pdev) || flit_is_endpoint(pdev)) ||
> + !flit_is_native(pdev))
> return;
[Severity: High]
Does vfio-pci leave the host-managed Flit Logging capability registers
directly writable by an assigned guest?
PCI_EXT_CAP_ID_FLIT is missing from pci_ext_cap_length[] in
drivers/vfio/pci/vfio_pci_config.c, so vfio_ecap_init() leaves its
registers unmapped (PCI_CAP_ID_INVALID) in vdev->pci_config_map.
vfio_pci_config_rw_single() then routes accesses to unassigned_perms,
allowing raw hardware reads and writes.
An untrusted guest assigned a Flit-capable Endpoint can lower the trigger
threshold to 1 to amplify host ERR_COR interrupts and kernel warnings, set
PCI_FLIT_ERR_CNTR_CTRL_SIG_SFW_EN to redirect events to host firmware, or
disable host Flit monitoring. Adding PCI_EXT_CAP_ID_FLIT to
pci_ext_cap_length[] and vfio_ext_cap_len() would map the capability under
default read-only ecap_perms.
[Severity: Medium]
Should flit_is_native() or flit_err_cor_usable() check pcie_ports_disabled?
On non-ACPI hosts where pcie_ports_disabled is true (such as PowerNV, where
pnv_pci_init() sets it unconditionally for EEH, or DT hosts booted with
pcie_ports=compat), pci_init_host_bridge() still sets native_aer and
native_flit, and pci_aer_available() does not check pcie_ports_disabled.
pci_flit_init() therefore enables ERR_COR signaling on Endpoints and Ports
even though pcie_portdrv_init() aborts and no AER driver ever binds to
service the generated ERR_COR messages.
[Severity: Medium]
Can aer_enable_rootport() access config space on a D3cold Endpoint via
pci_flit_rearm() during system resume?
Unlike pcieport devices, a runtime-suspended Endpoint in PCI_D3cold can
skip pci_pm_resume_noirq() via direct_complete or DPM_FLAG_MAY_SKIP_RESUME
(for example amdgpu with BOCO). When dpm_resume() runs aer_resume() ->
aer_enable_rootport() on the Root Port, flit_rearm_iter() unconditionally
calls pci_flit_rearm() -> flit_service() on subordinate Endpoints.
flit_service() then issues config reads and unchecked read-modify-write
config writes to the powered-off Endpoint right after aer_enable_rootport()
clears Root Port AER status and before aer_enable_irq(), which can latch
Unsupported Request completions and trigger spurious AER errors on resume.
Skipping pci_flit_rearm() when pdev->current_state != PCI_D0 would avoid
touching powered-off Endpoints.
[Severity: Medium]
What re-arms ERR_COR Flit Error Counters after a Root Port runtime-resumes
from D3hot?
When an unbound Endpoint runtime-suspends, pci_pm_runtime_suspend() leaves
it in D0 with its Flit Error Counter active, allowing the parent Root Port
to enter D3hot. If the Endpoint triggers an ERR_COR while the Root Port is
in D3hot, PCI_ERR_ROOT_STATUS latches the event without delivering an
interrupt.
On Root Port runtime resume, pci_pm_runtime_resume() -> pci_restore_state()
-> pci_aer_clear_status() clears PCI_ERR_ROOT_STATUS, discarding the
pending ERR_COR. Because aerdriver has no .runtime_resume callback to
invoke pci_flit_rearm() and pci_restore_flit_state() does not clear status
or toggle Counter Enable, the Endpoint's Flit Error Counter stays
permanently silent until a full system suspend/resume.
> @@ -247,6 +263,12 @@ void pci_flit_init(struct pci_dev *pdev)
> info->cntr_cap = flit_read_cntr_cap(pdev);
> info->err_cor = flit_err_cor_usable(pdev);
>
> + /* Leave an Endpoint without ERR_COR as found */
> + if (!info->err_cor && flit_is_endpoint(pdev)) {
> + pci_flit_exit(pdev);
> + return;
> + }
> +
> spin_lock_init(&info->lock);
> mutex_init(&info->service_lock);
[Severity: Medium]
Does aer_root_reset() need to call pci_flit_rearm() after clearing
PCI_ERR_ROOT_STATUS?
aer_root_reset() disables AER IRQs on root, resets the device or link,
unconditionally clears PCI_ERR_ROOT_STATUS, and re-enables AER IRQs without
calling pci_flit_rearm() on root or its subordinate hierarchy.
If a Flit Error Counter on root, a sibling Endpoint under the same root, or
the retrained link triggers an ERR_COR while AER IRQs are masked, clearing
PCI_ERR_ROOT_STATUS discards it. Endpoints have no flitdriver slot_reset
callback, so the ERR_COR Generated status bit remains latched and the
counter stays permanently silent.
[Severity: Medium]
Can a hotplugged Endpoint lose its first Flit ERR_COR if it fires before
pci_device_add() inserts the device onto bus->devices?
CPU0 (hotplug) CPU1 (Root Port AER)
pci_device_add()
pci_init_capabilities()
pci_flit_init()
flit_cntr_enable()
pci_doe_init() / ...
aer_irq()
clear PCI_ERR_ROOT_STATUS
aer_isr()
find_source_device()
pci_walk_bus() <-- dev not listed
list_add_tail(&dev->bus_list,
&bus->devices)
pci_flit_init() enables the ERR_COR counter inside pci_init_capabilities(),
before dev is added to bus->devices. Under an already-probed Root Port,
aer_enable_rootport() does not run again for a hotplugged Endpoint, so a
missed ERR_COR leaves ERR_COR_GEN latched and the counter permanently
silent.
Enabling or re-arming the ERR_COR counter after
list_add_tail(&dev->bus_list, &bus->devices) would close this window.
[Severity: Medium]
Is flit_report() missing ratelimiting in the drain loop?
flit_drain_log() can call flit_report() -> pci_warn() up to
FLIT_MAX_LOG_ENTRIES (255) times per ERR_COR event before flit_service()
immediately re-arms the counter. In aer_process_err_devices(),
pci_flit_handle_err_cor() is also called without checking
e_info->ratelimit_print[i], bypassing AER's per-device ratelimiting.
On a degrading link or malfunctioning Endpoint, repeated Flit ERR_COR
events can flood the kernel log buffer and stall serial consoles.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204181556.1418843-1-yazen.ghannam@amd.com?part=6
next prev parent reply other threads:[~2026-12-04 18:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 18:15 [PATCH v3 0/6] PCIe Flit Logging Ext Capability Support Yazen Ghannam
2026-12-04 18:15 ` [PATCH v3 1/6] PCI/portdrv: Group PCI Exp Cap services into a single mask Yazen Ghannam
2026-12-04 18:15 ` [PATCH v3 2/6] PCI: Add pci_clear_and_set_config_word() Yazen Ghannam
2026-12-04 18:35 ` sashiko-bot
2026-12-04 18:15 ` [PATCH v3 3/6] PCI/FLIT: Add support for Flit Logging Extended Capability Yazen Ghannam
2026-12-04 18:42 ` sashiko-bot
2026-12-04 18:15 ` [PATCH v3 4/6] PCI/FLIT: Add support for the Extended Flit Error Counter Yazen Ghannam
2026-12-04 18:40 ` sashiko-bot
2026-12-04 18:15 ` [PATCH v3 5/6] PCI/FLIT: Signal Flit Error Counter events with ERR_COR Yazen Ghannam
2026-12-04 18:46 ` sashiko-bot
2026-12-04 18:15 ` [PATCH v3 6/6] PCI/FLIT: Manage Flit Logging on Endpoint Upstream Ports Yazen Ghannam
2026-12-04 18:53 ` sashiko-bot [this message]
2026-12-04 18:53 ` [PATCH v3 0/6] PCIe Flit Logging Ext Capability Support sashiko-bot
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-250466@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yazen.ghannam@amd.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox