Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Abhin Parekadan Jose" <abhinjoses@gmail.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH RFC v2 2/5] PCI: pciehp: Add pci_hp_wait_link_change()
Date: Sun, 27 Sep 2026 17:03:55 +0000	[thread overview]
Message-ID: <20260927170355.759301F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260927165459.829900-3-abhinjoses@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] pci: missing acquire barrier in pci_hp_wait_link_change()
--

commit 4a9f36e746ab6c768961f1d34f724895b17c9def
Author: Abhin Parekadan Jose <abhinjoses@gmail.com>

PCI: pciehp: Add pci_hp_wait_link_change()

pci_hp_spurious_link_change() awaits the end of a code section causing
spurious link changes, such as a Secondary Bus Reset. This patch splits the
wait out into a new function pci_hp_wait_link_change() to allow hotplug
drivers to wait for the link to settle without clearing the changed state.

> diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
> index fadcf98a8a660..c3e0ee8b36381 100644
> --- a/drivers/pci/hotplug/pci_hotplug_core.c
> +++ b/drivers/pci/hotplug/pci_hotplug_core.c

[ ... ]

> @@ -528,6 +528,24 @@ void pci_hp_unignore_link_change(struct pci_dev *pdev)
>  	wake_up_all(&pci_hp_link_change_wq);
>  }
>  
> +/**
> + * pci_hp_wait_link_change - await end of code section causing spurious link changes
> + * @pdev: PCI hotplug bridge
> + *
> + * Await the end of a concurrently executing code section which is causing
> + * spurious link changes on the Secondary Bus of @pdev, if there is one.
> + *
> + * Unlike pci_hp_spurious_link_change(), leave the record that such a code
> + * section has executed in place.  May be called by hotplug drivers which need
> + * the link to have settled, but not the cause of a link change, so that they
> + * don't take the answer away from the caller of pci_hp_spurious_link_change().
> + */
> +void pci_hp_wait_link_change(struct pci_dev *pdev)
> +{
> +	wait_event(pci_hp_link_change_wq,
> +		   !test_bit(PCI_LINK_CHANGING, &pdev->priv_flags));
> +}
> +

[Severity: High]
Does this wait_event() condition check need an explicit acquire barrier?

If !test_bit(PCI_LINK_CHANGING, ...) evaluates to true immediately,
wait_event() returns without executing any memory barriers.

On weakly ordered architectures like ARM64, could this allow the CPU or
compiler to reorder the caller's subsequent state reads before the test_bit()
load?

For instance, if thread A clears PCI_LINK_CHANGING and wakes waiters, and
thread B calls pci_hp_wait_link_change() and returns immediately without a
barrier, could thread B's subsequent PCIe config reads execute before observing
the link state change, even if inside an acquire lock like down_read_nested()?

Would using test_bit_acquire() or an explicit smp_mb() prevent stale reads
here?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260927165459.829900-1-abhinjoses@gmail.com?part=2

  reply	other threads:[~2026-09-27 17:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-27 16:54 [PATCH RFC v2 0/5] PCI: pciehp: Report surprise removal during safe removal Abhin Parekadan Jose
2026-09-27 16:54 ` [PATCH RFC v2 1/5] PCI: Report surprise removal event Abhin Parekadan Jose
2026-09-27 17:07   ` sashiko-bot
2026-09-27 16:54 ` [PATCH RFC v2 2/5] PCI: pciehp: Add pci_hp_wait_link_change() Abhin Parekadan Jose
2026-09-27 17:03   ` sashiko-bot [this message]
2026-09-27 16:54 ` [PATCH RFC v2 3/5] PCI/DPC: Add pci_dpc_wait_recovery() Abhin Parekadan Jose
2026-09-27 16:59   ` sashiko-bot
2026-09-27 16:54 ` [PATCH RFC v2 4/5] PCI: pciehp: Report surprise removal from pciehp_isr() Abhin Parekadan Jose
2026-09-27 17:02   ` sashiko-bot
2026-09-27 16:54 ` [PATCH RFC v2 5/5] misc: Add edu_srpoc surprise removal POC driver Abhin Parekadan Jose
2026-09-27 17:00   ` 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=20260927170355.759301F000FF@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox