Skip to content

Commit 05b450d

Browse files
Salomon Dushimirimanagregkh
authored andcommitted
scsi: sd: Make sd shutdown issue START STOP UNIT appropriately
[ Upstream commit 8e48727 ] Commit aa3998d ("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: aa3998d ("ata: libata-scsi: Disable scsi device manage_system_start_stop") Signed-off-by: Salomon Dushimirimana <salomondush@google.com> Link: https://lore.kernel.org/r/20250724214520.112927-1-salomondush@google.com Tested-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 450b2a5 commit 05b450d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/scsi/sd.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3895,7 +3895,9 @@ static void sd_shutdown(struct device *dev)
38953895
if ((system_state != SYSTEM_RESTART &&
38963896
sdkp->device->manage_system_start_stop) ||
38973897
(system_state == SYSTEM_POWER_OFF &&
3898-
sdkp->device->manage_shutdown)) {
3898+
sdkp->device->manage_shutdown) ||
3899+
(system_state == SYSTEM_RUNNING &&
3900+
sdkp->device->manage_runtime_start_stop)) {
38993901
sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
39003902
sd_start_stop_device(sdkp, 0);
39013903
}

0 commit comments

Comments
 (0)