From: sashiko-bot@kernel.org
To: "Hongjie Fang" <hongjiefang@asrmicro.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3] scsi: core: pair EH runtime PM get and put
Date: Wed, 29 Jul 2026 11:27:26 +0000 [thread overview]
Message-ID: <20260729112726.ACBF61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260729111614.2407559-1-hongjiefang@asrmicro.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the SCSI error handler thread enters an infinite CPU spin (livelock) if `scsi_autopm_get_host(shost)` persistently fails.
--
--- Patch [1]: [PATCH v3] scsi: core: pair EH runtime PM get and put ---
commit c29848e943092f2d5f259d4461009f3a5aa7ad12
Author: Hongjie Fang <hongjiefang@asrmicro.com>
scsi: core: pair EH runtime PM get and put
This commit modifies the SCSI error handler to snapshot the eh_noresume
flag using READ_ONCE() at the start of each EH iteration. This ensures
that runtime PM get and put operations remain balanced even if the flag
changes concurrently. It also changes eh_noresume from a bitfield to a
regular bool.
> diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
> index 453a2232452db..74b70801269bd 100644
> --- a/drivers/scsi/scsi_error.c
> +++ b/drivers/scsi/scsi_error.c
[ ... ]
> @@ -2403,7 +2404,8 @@ int scsi_error_handler(void *data)
> * what we need to do to get it up and online again (if we can).
> * If we fail, we end up taking the thing offline.
> */
> - if (!shost->eh_noresume && scsi_autopm_get_host(shost) != 0) {
> + eh_noresume = READ_ONCE(shost->eh_noresume);
> + if (!eh_noresume && scsi_autopm_get_host(shost) != 0) {
> SCSI_LOG_ERROR_RECOVERY(1,
> shost_printk(KERN_ERR, shost,
> "scsi_eh_%d: unable to autoresume\n",
> shost->host_no));
> continue;
^^^^^^^^
[Severity: High]
This isn't a bug introduced by this patch, but does this continue statement
cause an infinite CPU spin if scsi_autopm_get_host() persistently fails?
If the SCSI host encounters an error, shost->host_failed == scsi_host_busy(shost)
becomes true, and the error handler thread wakes up. If the PM resume returns
a non-zero error (like -ENODEV during hot-unplug), the code logs an error and
hits this continue statement.
This skips the scsi_unjam_host() call and the shost->host_failed = 0
assignment. On the next loop iteration in scsi_error_handler(), host_failed
still equals host_busy, so the sleep condition remains false. This causes
the thread to immediately loop and retry the PM resume, spinning endlessly
on a CPU core.
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260729111614.2407559-1-hongjiefang@asrmicro.com?part=1
prev parent reply other threads:[~2026-07-29 11:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 11:16 [PATCH v3] scsi: core: pair EH runtime PM get and put Hongjie Fang
2026-07-29 11:27 ` 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=20260729112726.ACBF61F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=hongjiefang@asrmicro.com \
--cc=linux-scsi@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