From: sashiko-bot@kernel.org
To: "Abhin Parekadan Jose" <abhinjoses@gmail.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH RFC 3/3] pciehp_hpc: workaround to not wait in pciehp_isr on surprise removal
Date: Sun, 23 Aug 2026 18:44:44 +0000 [thread overview]
Message-ID: <20260823184444.74E881F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260823183458.982699-4-abhinjoses@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Concurrent calls to `pci_hp_spurious_link_change()` corrupt state flags, breaking hot-plug recovery logic.
- [High] Lockless read of `pending_events` races with `atomic_xchg`, bypassing spurious link checks and causing premature disconnections.
- [Medium] Incorrect truthiness evaluation of `pciehp_card_present()` breaks the disconnect workaround during severe surprise removals.
--
--- Patch [3]: [PATCH RFC 3/3] pciehp_hpc: workaround to not wait in pciehp_isr on surprise removal ---
Note: The format of this review has been altered to provide a free-form
summary of the findings due to automated recitation restrictions. The original
patch diff is not quoted inline.
commit df7f3f7b5143de6a32373ccd864f5ca514636a79
Author: Abhin Parekadan Jose <abhinjoses@gmail.com>
pciehp_hpc: workaround to not wait in pciehp_isr on surprise removal
This patch adds a workqueue to handle PCIe hotplug device disconnects without
waiting in the interrupt service routine. It checks the presence detect state
bit to differentiate between safe and surprise removals, scheduling the
disconnect work if the card is no longer present.
[Severity: High]
Could the concurrent evaluation of pci_hp_spurious_link_change() in the new
disconnect workqueue corrupt state flags? The function
pci_hp_spurious_link_change() is stateful and clears the PCI_LINK_CHANGED bit
using test_and_clear_bit(). If the asynchronous workqueue destructively
consumes this flag before the primary hot-plug IRQ thread evaluates it, won't
the core handler erroneously tear down the device tree instead of safely
ignoring a transient link flap?
[Severity: High]
Does the lockless read of pending_events in pciehp_disconnect_work() race
with the IRQ thread? The workqueue reads ctrl->pending_events locklessly.
However, the threaded IRQ handler pciehp_ist() unconditionally clears these
events using atomic_xchg(&ctrl->pending_events, 0). If the workqueue executes
just after pciehp_ist() clears the events, it will observe a value of 0.
Wouldn't this cause the workqueue to completely bypass the spurious link down
safety checks and prematurely disconnect all devices on the bus?
[Severity: Medium]
Will the truthiness checks for pciehp_card_present() fail during an actual
hardware surprise removal? When a device is abruptly removed, configuration
space reads typically return 0xffff, causing pciehp_card_present() to return
-ENODEV. Because -ENODEV is a truthy value in C, the condition (!present) in
the interrupt handler will evaluate to false, meaning the disconnect work is
never scheduled. Furthermore, the check inside the workqueue evaluates
pciehp_card_present(ctrl) != 0, which is true for -ENODEV, causing an early
return. Does this logic inadvertently disable the workaround precisely when a
surprise removal happens?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260823183458.982699-1-abhinjoses@gmail.com?part=3
next prev parent reply other threads:[~2026-08-23 18:44 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-09 20:55 [PATCH RFC v5 0/5] pci,virtio: report surprise removal event Michael S. Tsirkin
2025-07-09 20:55 ` [PATCH RFC v5 1/5] pci: " Michael S. Tsirkin
2025-07-09 23:38 ` Bjorn Helgaas
2025-07-09 23:55 ` Keith Busch
2025-07-14 6:17 ` Michael S. Tsirkin
2025-07-14 6:26 ` Michael S. Tsirkin
2025-07-14 21:13 ` Bjorn Helgaas
2025-07-15 6:28 ` Michael S. Tsirkin
2025-07-16 22:29 ` Bjorn Helgaas
2025-07-17 15:15 ` Michael S. Tsirkin
2025-07-14 6:11 ` Lukas Wunner
2025-07-14 6:18 ` Michael S. Tsirkin
2025-07-14 6:54 ` Michael S. Tsirkin
2025-07-17 15:11 ` Michael S. Tsirkin
2025-07-17 20:12 ` Lukas Wunner
2025-07-17 23:31 ` Michael S. Tsirkin
2025-07-18 4:35 ` Lukas Wunner
2025-07-18 8:40 ` Michael S. Tsirkin
2025-07-09 20:55 ` [PATCH RFC v5 2/5] virtio: fix comments, readability Michael S. Tsirkin
2025-07-09 20:55 ` [PATCH RFC v5 3/5] virtio: pack config changed flags Michael S. Tsirkin
2025-07-09 20:55 ` [PATCH RFC v5 4/5] virtio: allow transports to suppress config change Michael S. Tsirkin
2025-07-09 20:55 ` [PATCH RFC v5 5/5] virtio: support device disconnect Michael S. Tsirkin
2026-08-23 18:34 ` [PATCH RFC 0/3] pci_hp: fix surprise removal hang during safe removal Abhin Parekadan Jose
2026-08-23 18:34 ` [PATCH RFC 1/3] misc: add edu_srpoc surprise removal POC driver Abhin Parekadan Jose
2026-08-23 18:44 ` sashiko-bot
2026-08-23 18:34 ` [PATCH RFC 2/3] pciehp: add disconnect_work work_struct Abhin Parekadan Jose
2026-08-23 18:44 ` sashiko-bot
2026-08-23 18:34 ` [PATCH RFC 3/3] pciehp_hpc: workaround to not wait in pciehp_isr on surprise removal Abhin Parekadan Jose
2026-08-23 18:44 ` sashiko-bot [this message]
2026-08-26 19:48 ` [PATCH RFC 0/3] pci_hp: fix surprise removal hang during safe removal Bjorn Helgaas
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=20260823184444.74E881F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=abhinjoses@gmail.com \
--cc=linux-pci@vger.kernel.org \
--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.