All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Salomon Dushimirimana <salomondush@google.com>
Cc: James.Bottomley@hansenpartnership.com, dlemoal@kernel.org,
	ipylypiv@google.com, linux-kernel@vger.kernel.org,
	linux-scsi@vger.kernel.org, martin.petersen@oracle.com,
	vishakhavc@google.com
Subject: Re: [PATCH v3] scsi: sd: fix sd shutdown to issue START STOP UNIT command appropriately
Date: Mon, 28 Jul 2025 08:47:38 -0700	[thread overview]
Message-ID: <325a7f60-955c-4e3d-bd16-e5377462fa33@acm.org> (raw)
In-Reply-To: <20250724214520.112927-1-salomondush@google.com>

On 7/24/25 2:45 PM, Salomon Dushimirimana wrote:
> Commit aa3998dbeb3a ("ata: libata-scsi: Disable scsi device
> manage_system_start_stop") enabled libata EH to manage device power mode
> trasitions for system suspend/resume and removed the flag from
> ata_scsi_dev_config. However, since the sd_shutdown() function still
> relies on the manage_system_start_stop flag, a spin-down command is not
> issued to the disk with command "echo 1 > /sys/block/sdb/device/delete"
> 
> sd_shutdown() can be called for both system/runtime start stop
> operations, so utilize the manage_run_time_start_stop flag set in the
> ata_scsi_dev_config and issue a spin-down command during disk removal
> when the system is running. This is in addition to when the system is
> powering off and manage_shutdown flag is set. The
> manage_system_start_stop flag will still be used for drivers that still
> set the flag.
> 
> Fixes: aa3998dbeb3a ("ata: libata-scsi: Disable scsi device manage_system_start_stop")
> Signed-off-by: Salomon Dushimirimana <salomondush@google.com>
> ---
> Changes in v3:
> - Removed unnecessary tag
> 
>   drivers/scsi/sd.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index eeaa6af294b81..282000c761f8e 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -4173,7 +4173,9 @@ static void sd_shutdown(struct device *dev)
>   	if ((system_state != SYSTEM_RESTART &&
>   	     sdkp->device->manage_system_start_stop) ||
>   	    (system_state == SYSTEM_POWER_OFF &&
> -	     sdkp->device->manage_shutdown)) {
> +	     sdkp->device->manage_shutdown) ||
> +	    (system_state == SYSTEM_RUNNING &&
> +	     sdkp->device->manage_runtime_start_stop)) {
>   		sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
>   		sd_start_stop_device(sdkp, 0);
>   	}

Runtime power management is not related at all to deleting a LUN through
sysfs. This patch makes it impossible to understand the sd_shutdown()
implementation without studying the ATA subsystem and its history.
Additionally, this patch makes the documentation of
.manage_runtime_start_stop incorrect.

There are only two drivers that set .manage_runtime_start_stop: libata
and the unmaintained sbp2 driver. Has it been considered to test
sdkp->device->is_ata instead of sdkp->device->manage_runtime_start_stop?

Thanks,

Bart.

  parent reply	other threads:[~2025-07-28 15:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-24 20:38 [PATCH] scsi: sd: fix sd shutdown to issue START STOP UNIT command appropriately Salomon Dushimirimana
2025-07-24 20:46 ` Bart Van Assche
2025-07-24 21:05   ` Salomon Dushimirimana
2025-07-24 21:21     ` [PATCH v2] " Salomon Dushimirimana
2025-07-24 21:45       ` [PATCH v3] " Salomon Dushimirimana
2025-07-25 10:49         ` Damien Le Moal
2025-07-25 13:06         ` Martin K. Petersen
2025-07-28 15:47         ` Bart Van Assche [this message]
2025-07-28 23:15           ` Damien Le Moal

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=325a7f60-955c-4e3d-bd16-e5377462fa33@acm.org \
    --to=bvanassche@acm.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=dlemoal@kernel.org \
    --cc=ipylypiv@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=salomondush@google.com \
    --cc=vishakhavc@google.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.