Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Lukas Wunner <lukas@wunner.de>
Cc: Keith Busch <kbusch@meta.com>, linux-pci@vger.kernel.org
Subject: Re: [PATCH] pciehp: sync interrupts for bus resets
Date: Tue, 2 Sep 2025 11:59:11 -0600	[thread overview]
Message-ID: <aLcwb0TA0rMtu2kI@kbusch-mbp> (raw)
In-Reply-To: <aLRRh_4YhAZjWeEW@wunner.de>

On Sun, Aug 31, 2025 at 03:43:35PM +0200, Lukas Wunner wrote:
> On Wed, Aug 27, 2025 at 03:45:14PM -0700, Keith Busch wrote:
> > Synchronize the interrupt to ensure the reset isn't going to disrupt a
> > previously pending handler from igoring the reset's link flap. Back to
> > back secondary bus resets create a window when the previous reset
> > proceeds with DLLLA, waking the pending pciehp interrupt thread, but the
> > subsequent reset tears it down while the irq thread tries to confirm the
> > link is active, triggering unexpected re-enumeration.
> 
> Help me understand this:
> 
> I think what you mean is that pciehp_reset_slot() runs and the
> Secondary Bus Reset causes a spurious link change. So pciehp_ist() runs,
> waits for the reset to finish with pci_hp_spurious_link_change(),
> then calls pciehp_ignore_link_change(), which tests whether the link
> is active again by calling pciehp_check_link_active().
> 
> And you're saying that at the same time, pciehp_reset_slot() runs,
> performs a Secondary Bus Reset, thus brings down the link,
> confusing the concurrent pciehp_check_link_active().
> Did I understand that correctly?
> 
> I don't quite see how this can happen, given pciehp_reset_slot()
> acquires ctrl->reset_lock for writing and the same lock is held
> for reading for the call to pciehp_check_link_active().
> 
> Moreover pciehp_ist() ignores the link flap in the first iteration
> (it clears the flags in the local variable "events") and if
> pciehp_check_link_active() would indeed fail, then the bits would
> only be set in ctrl->pending_events and a rerun of pciehp_ist()
> would be triggered.  That second iteration of pciehp_ist() would
> then find the PCI_LINK_CHANGED flag set and ignore the link change
> (again).
> 
> So this should all work fine.

Hm, I think you're right. We are definitely seeing pciehp requeue itself
with the link/presence events that we want to be ignored, so we're
getting re-enumeration when we didn't expect it. I thought the
back-to-back resets that we're causing vfio to initiate was the problem,
but maybe not. I think the switch and/or end device we're using have
some unusual link timings that defeats the pciehp ignore logic.

  reply	other threads:[~2025-09-02 17:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-27 22:45 [PATCH] pciehp: sync interrupts for bus resets Keith Busch
2025-08-27 22:48 ` Keith Busch
2025-08-31 13:43 ` Lukas Wunner
2025-09-02 17:59   ` Keith Busch [this message]
2025-09-03  8:21     ` Lukas Wunner
2025-09-03 16:19       ` Keith Busch

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=aLcwb0TA0rMtu2kI@kbusch-mbp \
    --to=kbusch@kernel.org \
    --cc=kbusch@meta.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    /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