All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex@shazbot.org>
To: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
Cc: sashiko-bot@kernel.org, linux-pci@vger.kernel.org,
	sashiko-reviews@lists.linux.dev, alex@shazbot.org
Subject: Re: [PATCH v12] PCI: Add device-specific reset for Qualcomm devices
Date: Mon, 20 Jul 2026 12:53:18 -0600	[thread overview]
Message-ID: <20260720125318.15508343@shazbot.org> (raw)
In-Reply-To: <20260713085233.411519-1-jtornosm@redhat.com>

On Mon, 13 Jul 2026 10:52:32 +0200
Jose Ignacio Tornos Martinez <jtornosm@redhat.com> wrote:

> > [Severity: Medium]
> > If the device is hung or the link is temporarily unresponsive, could the
> > initial ioread32() return PCI_ERROR_RESPONSE (0xFFFFFFFF)?
> >
> > If it does, this read-modify-write operation would write 0xFFFFFFFF (and
> > later 0xFFFFFFFE) back to the device. Could writing these values trigger
> > unintended resets across the SoC or leave the hardware in an invalid state?
> >
> > Would it be safer to verify !PCI_POSSIBLE_ERROR(val) before modifying
> > and writing it back?  
> 
> The read-modify-write on the SOC_GLOBAL_RESET register replicates
> the existing ath11k/ath12k driver reset sequence
> (ath11k_pci_soc_global_reset()). If the device already returns
> 0xFFFFFFFF at this point, it is unresponsive and writing to it
> will not make things worse - the purpose of this function is
> precisely to reset a device in a bad state. The link recovery
> loop below already handles the case where the device remains
> unresponsive after the reset attempt.

The "will not make things worse" claim is really the best case
scenario, there are platforms that won't silently swallow the write
error and could escalate this to a platform level APEI/GHES error.
Testing the initial ioread() value is a valid improvement in robustness.

> > [Severity: Medium]
> > Is this polling loop vulnerable to false timeouts due to scheduling delays?
> >
> > If the thread is preempted during msleep(20) and delayed for more than 5
> > seconds, time_before(jiffies, timeout) will evaluate to false upon waking
> > up. The loop will exit without a final check of the register, returning
> > -ETIMEDOUT even if the link successfully recovered during the delay.
> >
> > Should there be a final condition check after the loop, or perhaps use
> > read_poll_timeout() instead to handle preemption robustly?  
> 
> The time_before()/msleep() polling pattern replicates the existing
> driver recovery logic and is standard kernel practice, used
> throughout drivers/pci/quirks.c and PCI core. A scheduling delay
> exceeding 5 seconds would indicate a severe system issue beyond
> the scope of this reset function. The 5-second timeout is generous
> for what typically recovers in under 1 second.

IMO, this is also a valid finding and the suggestion to use
read_poll_timeout() actually simplifies the code.  The entire loop just
becomes something like:

	ret = read_poll_timeout(ioread32, val, !PCI_POSSIBLE_ERROR(val),
				20 * USEC_PER_MSEC, 5 * USEC_PER_SEC, false,
				bar + QUALCOMM_WLAN_PCIE_SOC_GLOBAL_RESET);

It might indeed only be a pathological case that behaves exactly as
sashiko identifies, but in fact any exit from the loop due to timeout
returns with a stale value in val.  The similar use cases in quirks.c
might well be improved in the same way.

> Since the implementation replicates existing driver behavior,
> both points were already discussed during review with the
> subsystem maintainer, and are handled in the code, no changes
> are needed.

Likewise, maybe an opportunity to improve the driver code.  Thanks,

Alex

  reply	other threads:[~2026-07-20 18:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30  6:58 [PATCH v12] PCI: Add device-specific reset for Qualcomm devices Jose Ignacio Tornos Martinez
2026-06-30  7:09 ` sashiko-bot
2026-07-13  8:52   ` Jose Ignacio Tornos Martinez
2026-07-20 18:53     ` Alex Williamson [this message]
2026-07-20  6:24 ` Jose Ignacio Tornos Martinez

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=20260720125318.15508343@shazbot.org \
    --to=alex@shazbot.org \
    --cc=jtornosm@redhat.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-bot@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.