All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Xingui Yang" <yangxingui@huawei.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 1/2] scsi: scsi_lib: add spinup_notify callback for ASC/ASCQ=0x04/0x11
Date: Thu, 02 Jul 2026 04:12:15 +0000	[thread overview]
Message-ID: <20260702041216.15EE31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260702035724.2059166-2-yangxingui@huawei.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The `spinup_notify` API lacks context documentation, risking `scheduling while atomic` bugs in hardware drivers.
- [High] Unmitigated concurrent `spinup_notify` invocations could flood LLDD hardware queues.
--

commit 171fafeb5fbd92de731525186cc8f26d24a7be8e
Author: Xingui Yang <yangxingui@huawei.com>

scsi: scsi_lib: add spinup_notify callback for ASC/ASCQ=0x04/0x11

When a SCSI device returns NOT_READY with ASC/ASCQ = 0x04/0x11 ("notify
(enable spinup) required"), the device is in Active_Wait or Idle_Wait power
state. Add an optional spinup_notify callback to struct scsi_host_template
that is invoked before ACTION_DELAYED_RETRY.

> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index daeb3693fe559..140c41a2fe03b 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -905,6 +905,10 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
>  				case 0x1a: /* start stop unit in progress */
>  				case 0x1b: /* sanitize in progress */
>  				case 0x1d: /* configuration in progress */
> +					if (sshdr.ascq == 0x11 &&
> +					    cmd->device->host->hostt->spinup_notify)
> +						cmd->device->host->hostt->spinup_notify(
> +							cmd->device);

[Severity: High]
Could this cause a regression by flooding hardware queues with concurrent
spinup_notify invocations?

If multiple async commands are in flight when a device goes into a standby
state, they will all fail and return not ready with ascq == 0x11 almost
simultaneously.

Since scsi_io_completion_action() invokes spinup_notify unconditionally for
every command, this could cause a thundering herd.

For example, in the subsequent patch for hisi_sas, this triggers concurrent,
unlocked read-modify-write operations on the SL_CONTROL register:

hisi_sas_v3_hw.c:sl_notify_ssp_v3_hw() {
    ...
    sl_control |= SL_CONTROL_NOTIFY_EN_MSK;
    hisi_sas_phy_write32(hisi_hba, phy_no, SL_CONTROL, sl_control);
    ...
}

>  					action = ACTION_DELAYED_RETRY;
>  					break;
>  				case 0x0a: /* ALUA state transition */
> diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
> index 7e2011830ba4b..500fad5ffab68 100644
> --- a/include/scsi/scsi_host.h
> +++ b/include/scsi/scsi_host.h
> @@ -374,6 +374,15 @@ struct scsi_host_template {
>  #define SCSI_ADAPTER_RESET	1
>  #define SCSI_FIRMWARE_RESET	2
>  
> +	/*
> +	 * Optional callback invoked when a device returns NOT_READY with
> +	 * ASC/ASCQ = 0x04/0x11 ("notify (enable spinup) required").
> +	 * This allows LLDDs to perform controller-specific spinup
> +	 * notification before the mid-layer retries.
> +	 *
> +	 * Status: OPTIONAL
> +	 */
> +	void (*spinup_notify)(struct scsi_device *sdev);

[Severity: High]
Should this document the context constraints to prevent scheduling while
atomic regressions?

Since scsi_io_completion_action() is called from atomic context, any driver
implementing this callback must not sleep.

Without this documentation, it is easy to introduce bugs. For instance, the
subsequent patch in this series calls msleep(1) inside sl_notify_ssp_v3_hw()
via this callback:

hisi_sas_v3_hw.c:sl_notify_ssp_v3_hw() {
    ...
    msleep(1);
    ...
}

>  
>  	/*
>  	 * Name of proc directory

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260702035724.2059166-1-yangxingui@huawei.com?part=1

  reply	other threads:[~2026-07-02  4:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02  3:57 [PATCH 0/2] scsi: support spinup notification for SAS SSP devices in Active_Wait/Idle_Wait state Xingui Yang
2026-07-02  3:57 ` [PATCH 1/2] scsi: scsi_lib: add spinup_notify callback for ASC/ASCQ=0x04/0x11 Xingui Yang
2026-07-02  4:12   ` sashiko-bot [this message]
2026-07-02  3:57 ` [PATCH 2/2] scsi: hisi_sas: add spinup_notify callback to handle Active_Wait/Idle_Wait SSP devices Xingui Yang
2026-07-02  4:20   ` sashiko-bot
2026-07-02 12:24     ` yangxingui

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=20260702041216.15EE31F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=yangxingui@huawei.com \
    /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.