From: sashiko-bot@kernel.org
To: "Paul Cercueil" <paul.cercueil@bootlin.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: Fix root port reset lock ordering
Date: Mon, 30 Nov 2026 15:45:50 +0000 [thread overview]
Message-ID: <sashiko-outbox-241514@kernel.org> (raw)
In-Reply-To: <20261130153218.189926-1-paul.cercueil@bootlin.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] PCI: pciehp: ABBA deadlock with pci_slot_mutex in
pciehp_lock_rescan_remove()
--
commit 70e71b321e54d0d7c6157b8dbdebfb52c2965df1
Author: Paul Cercueil <paul.cercueil@bootlin.com>
PCI: Fix root port reset lock ordering
This commit adds pciehp_lock_rescan_remove() to temporarily release
ctrl->reset_lock while acquiring pci_rescan_remove_lock in
pciehp_configure_device() and pciehp_unconfigure_device().
> diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
> index 65e50bee1a8c0..20549c83870e2 100644
> --- a/drivers/pci/hotplug/pciehp_pci.c
> +++ b/drivers/pci/hotplug/pciehp_pci.c
> @@ -21,11 +21,28 @@
> #include "../pci.h"
> #include "pciehp.h"
>
> +static inline void pciehp_lock_rescan_remove(struct controller *ctrl)
> +{
> + /*
> + * pciehp_ist() calls us holding reset_lock, whereas the error-reset
> + * path takes pci_rescan_remove_lock before reset_lock. Drop the
> + * reader to acquire the rescan lock as the outermost lock, then
> + * reacquire reset_lock below it so the order rescan lock ->
> + * reset_lock is preserved.
> + */
> + lockdep_assert_held_read(&ctrl->reset_lock);
> + up_read(&ctrl->reset_lock);
> +
> + pci_lock_rescan_remove();
> + down_read_nested(&ctrl->reset_lock, ctrl->depth);
> +}
[Severity: High]
Does re-acquiring ctrl->reset_lock here leave an ABBA deadlock with
pci_slot_mutex?
CPU0 CPU1
---- ----
down_read(&ctrl->reset_lock)
mutex_lock(&pci_slot_mutex)
mutex_lock(&pci_slot_mutex)
down_write(&ctrl->reset_lock)
*** DEADLOCK ***
CPU0: pciehp_ist() -> ... -> pciehp_configure_device() ->
pciehp_lock_rescan_remove() -> pci_scan_slot() -> ... ->
pci_setup_device() -> pci_dev_assign_slot()
CPU1: aer_root_reset() -> pci_bus_error_reset() -> pci_reset_bridge() ->
pci_slot_reset() -> pci_reset_hotplug_slot() -> pciehp_reset_slot()
In pciehp_configure_device(), pci_scan_slot() and pci_hp_add_bridge() run
while ctrl->reset_lock is held and take pci_slot_mutex via
pci_dev_assign_slot(). Meanwhile, pci_reset_bridge() takes pci_slot_mutex
before calling into pciehp_reset_slot(), which takes ctrl->reset_lock for
writing.
In pci_host_reset_root_port(), where pci_rescan_remove_lock is held around
pci_bus_error_reset(), the lock order is pci_rescan_remove_lock ->
pci_slot_mutex -> ctrl->reset_lock, which triggers a lockdep circular
locking splat against pciehp_configure_device() (pci_rescan_remove_lock ->
ctrl->reset_lock -> pci_slot_mutex). Callers of pci_reset_bridge() that do
not hold pci_rescan_remove_lock, such as aer_root_reset() and
reset_subordinate_store(), can deadlock at runtime with
pciehp_configure_device().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130153218.189926-1-paul.cercueil@bootlin.com?part=1
prev parent reply other threads:[~2026-11-30 15:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 15:32 [PATCH] PCI: Fix root port reset lock ordering Paul Cercueil
2026-11-30 15:45 ` 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-241514@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=paul.cercueil@bootlin.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox