From: sashiko-bot@kernel.org
To: "Yazen Ghannam" <yazen.ghannam@amd.com>, linux-pci@vger.kernel.org
Subject: Re: [PATCH v3 3/6] PCI/FLIT: Add support for Flit Logging Extended Capability
Date: Fri, 04 Dec 2026 18:42:06 +0000 [thread overview]
Message-ID: <sashiko-outbox-250443@kernel.org> (raw)
In-Reply-To: <20261204181556.1418843-4-yazen.ghannam@amd.com>
Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [Medium] PCI/FLIT: flitdriver omits suspend and runtime_suspend
callbacks
- [Medium] PCI/FLIT: flit_cntr_enable() omits trigger update in saved
state buffer
- [Medium] PCI/FLIT: unratelimited pci_warn() in flit_report() can flood
logs
- [Medium] PCI/FLIT: restore and enable paths overwrite
flit_cntr_pause() mid-drain
- [Low] PCI/FLIT: pci_flit_init() ignores PCI_POSSIBLE_ERROR() from
flit_cntr_read()
--
commit 9ae9be8138a1e81dfc7aa4e70ca57f2664899c69
Author: Yazen Ghannam <yazen.ghannam@amd.com>
PCI/FLIT: Add support for Flit Logging Extended Capability
This commit adds a PCIe port service driver for the Flit Logging Extended
Capability, along with ACPI _OSC control negotiation and config state
save/restore support.
Link: https://pcisig.com/specification/extend-osc-negotiate-control-pcie-flit-logging-extended-capability
> diff --git a/drivers/pci/pcie/flit.c b/drivers/pci/pcie/flit.c
> new file mode 100644
> index 0000000000000..00409dd7bb956
> --- /dev/null
> +++ b/drivers/pci/pcie/flit.c
[ ... ]
> + ctrl = flit_cntr_read(pdev, info->cntr->ctrl);
> + trigger = field_get(info->cntr->trigger, ctrl);
> + info->trigger = trigger ? trigger : FLIT_DEFAULT_TRIGGER;
[Severity: Low]
Should pci_flit_init() check PCI_POSSIBLE_ERROR(ctrl) before extracting
trigger?
flit_cntr_read() translates a 0xffff config read error to ~0U for
PCI_POSSIBLE_ERROR(), so a failed read leaves trigger as 0xff instead of
falling back to FLIT_DEFAULT_TRIGGER (0xfe). Because an event requires the
count to exceed the trigger, 0xff prevents Flit events from ever firing on
that port.
[ ... ]
> +static void flit_cntr_enable(struct pci_dev *pdev)
> +{
> + struct flit_info *info = pdev->flit_info;
> + const struct flit_cntr *cntr = info->cntr;
> + u32 ctrl = cntr->en | cntr->intr_en;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&info->lock, flags);
> + info->cntr_enabled = true;
> +
> + /* A 0->1 transition of Counter Enable clears stale event status */
> + __flit_cntr_ctrl_update(pdev, cntr->en, 0);
> + __flit_cntr_ctrl_update(pdev, cntr->trigger | ctrl,
> + field_prep(cntr->trigger, info->trigger) |
> + info->enable);
> + __flit_save_state_update(pdev, cntr->slot, ctrl, info->enable);
> + spin_unlock_irqrestore(&info->lock, flags);
> +}
[Severity: Medium]
Should __flit_save_state_update() also update cntr->trigger with
field_prep(cntr->trigger, info->trigger)?
If flit_probe() runs after pci_save_state() captured the hardware reset
default trigger of 0 (for instance under driver_async_probe=flit or a manual
sysfs bind), slots[FLIT_SAVE_CNTR_CTRL] still holds trigger 0. During
pcie_portdrv_slot_reset(), flit_cntr_restore() runs before
pci_restore_state() with no save in between, so pci_restore_flit_state()
writes that stale 0 trigger back to PCI_FLIT_ERR_CNTR_CTRL and stops Flit
events from firing.
[ ... ]
> +/* Stop counting until the log is drained */
> +static void flit_cntr_pause(struct pci_dev *pdev)
> +{
> + struct flit_info *info = pdev->flit_info;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&info->lock, flags);
> + __flit_cntr_ctrl_update(pdev, info->cntr->en, 0);
> + spin_unlock_irqrestore(&info->lock, flags);
> +}
> +
> +/* Re-arm event generation, unless flit_cntr_disable() ran meanwhile */
> +static void flit_cntr_resume(struct pci_dev *pdev)
> +{
> + struct flit_info *info = pdev->flit_info;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&info->lock, flags);
> + if (info->cntr_enabled)
> + __flit_cntr_ctrl_update(pdev, 0, info->cntr->en);
> + spin_unlock_irqrestore(&info->lock, flags);
> +}
[Severity: Medium]
Can pci_restore_flit_state() and flit_cntr_enable() re-enable cntr->en while
flit_ist() is still draining the log?
flit_cntr_pause() clears cntr->en in hardware without recording paused state
in struct flit_info, so a concurrent restore or enable re-arms the counter
mid-drain:
CPU0 (slot_reset) CPU1 (flit_isr / flit_ist)
pcie_portdrv_slot_reset()
flit_cntr_restore()
flit_cntr_enable()
flit_isr()
flit_cntr_pause()
return IRQ_WAKE_THREAD
pci_restore_state()
pci_restore_flit_state() <-- re-enables cntr->en mid-drain
flit_ist() (draining log)
flit_isr() (2nd IRQ)
flit_cntr_pause()
return IRQ_WAKE_THREAD
flit_ist() finishes 1st pass
flit_cntr_resume() <-- unpauses early
The same race can happen during pci_pm_runtime_resume() or flit_probe() when
flit_isr() pauses the counter before flit_cntr_enable() runs, where the 0->1
toggle of cntr->en can also clear pending event status. Tracking whether an
event drain is in progress under info->lock would prevent restore and enable
paths from re-enabling cntr->en early.
> +static void flit_report(struct pci_dev *pdev, u32 err_log1, u32 err_log2)
> +{
> + if (!(err_log1 & FLIT_ERR_LOG1_ERROR) && !err_log2)
> + return;
> +
> + pci_warn(pdev, "ErrLog1: 0x%08x ErrLog2: 0x%08x\n", err_log1, err_log2);
> +}
[Severity: Medium]
Should pci_warn() in flit_report() be ratelimited?
flit_drain_log() can invoke flit_report() up to 255 times per interrupt,
including for FEC-correctable syndrome errors, and flit_ist() immediately
re-arms the counter via flit_cntr_resume(). On a noisy Flit Mode link this
can flood dmesg and slow serial consoles enough to cause latency spikes or
soft lockups. Draining the FIFO while ratelimiting the log messages (as AER
does with per-device ratelimit_state) would avoid this.
[ ... ]
> +/* No suspend callbacks: pci_save_state() would save the counter disabled */
> +static int flit_cntr_restore(struct pcie_device *dev)
> +{
> + flit_cntr_enable(dev->port);
> + return 0;
> +}
> +
> +/* Disable first, or an event can assert a shared INTx line with no handler */
> +static void flit_cntr_remove(struct pcie_device *dev)
> +{
> + flit_cntr_disable(dev->port);
> + free_irq(dev->irq, dev);
> +}
> +
> +static struct pcie_port_service_driver flitdriver = {
> + .name = "flit",
> + .port_type = PCIE_ANY_PORT,
> + .service = PCIE_PORT_SERVICE_FLIT,
> + .probe = flit_probe,
> + .resume = flit_cntr_restore,
> + .runtime_resume = flit_cntr_restore,
> + .slot_reset = flit_cntr_restore,
> + .remove = flit_cntr_remove,
> +};
[Severity: Medium]
Can omitting .suspend and .runtime_suspend on flitdriver cause spurious
wakeups and a D3cold config-write race with flit_ist()?
PCIE_PORT_SERVICE_FLIT is part of PCIE_PORT_SERVICES_EXPCAP and shares its
IRQ with PME, which calls enable_irq_wake() in pcie_pme_suspend(). Leaving
the Flit counter and its interrupt enabled across suspend allows Flit events
to fire the shared wakeup IRQ and spuriously wake the system during s2idle.
During runtime suspend, pci_pm_runtime_suspend() transitions the port to
D3hot/D3cold without synchronizing threaded IRQs, and flit_ist() holds no
runtime PM reference:
CPU0 (runtime suspend) CPU1 (flit_ist)
flit_isr()
return IRQ_WAKE_THREAD
pci_pm_runtime_suspend()
pci_save_state()
pci_finish_runtime_suspend()
(port enters D3cold)
flit_ist()
flit_drain_log()
flit_cntr_resume()
pci_clear_and_set_config_word()
<-- reads/writes 0xffff in D3cold
Saving the counter enabled also causes pci_restore_state() to re-enable Flit
interrupts in pci_restore_flit_state() before pci_restore_config_space() and
pci_restore_msi_state() restore PCI_COMMAND and MSI/MSI-X vectors. Since
flitdriver already re-enables the counter in .resume and .runtime_resume,
.suspend and .runtime_suspend can disable the hardware counter/interrupt and
call synchronize_irq(dev->irq).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204181556.1418843-1-yazen.ghannam@amd.com?part=3
next prev parent reply other threads:[~2026-12-04 18:42 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 [this message]
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
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-250443@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