Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'ata-6.6-final' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata

Pull ATA fix from Damien Le Moal:
"A single patch to fix a regression introduced by the recent
suspend/resume fixes.

The regression is that ATA disks are not stopped on system shutdown,
which is not recommended and increases the disks SMART counters for
unclean power off events.

This patch fixes this by refining the recent rework of the scsi device
manage_xxx flags"

* tag 'ata-6.6-final' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata:
scsi: sd: Introduce manage_shutdown device flag

+58 -7
+3 -2
drivers/ata/libata-scsi.c
··· 1053 1053 1054 1054 /* 1055 1055 * Ask the sd driver to issue START STOP UNIT on runtime suspend 1056 - * and resume only. For system level suspend/resume, devices 1057 - * power state is handled directly by libata EH. 1056 + * and resume and shutdown only. For system level suspend/resume, 1057 + * devices power state is handled directly by libata EH. 1058 1058 */ 1059 1059 sdev->manage_runtime_start_stop = true; 1060 + sdev->manage_shutdown = true; 1060 1061 } 1061 1062 1062 1063 /*
+1
drivers/firewire/sbp2.c
··· 1521 1521 if (sbp2_param_exclusive_login) { 1522 1522 sdev->manage_system_start_stop = true; 1523 1523 sdev->manage_runtime_start_stop = true; 1524 + sdev->manage_shutdown = true; 1524 1525 } 1525 1526 1526 1527 if (sdev->type == TYPE_ROM)
+36 -3
drivers/scsi/sd.c
··· 209 209 210 210 return sysfs_emit(buf, "%u\n", 211 211 sdp->manage_system_start_stop && 212 - sdp->manage_runtime_start_stop); 212 + sdp->manage_runtime_start_stop && 213 + sdp->manage_shutdown); 213 214 } 214 215 static DEVICE_ATTR_RO(manage_start_stop); 215 216 ··· 275 274 return count; 276 275 } 277 276 static DEVICE_ATTR_RW(manage_runtime_start_stop); 277 + 278 + static ssize_t manage_shutdown_show(struct device *dev, 279 + struct device_attribute *attr, char *buf) 280 + { 281 + struct scsi_disk *sdkp = to_scsi_disk(dev); 282 + struct scsi_device *sdp = sdkp->device; 283 + 284 + return sysfs_emit(buf, "%u\n", sdp->manage_shutdown); 285 + } 286 + 287 + static ssize_t manage_shutdown_store(struct device *dev, 288 + struct device_attribute *attr, 289 + const char *buf, size_t count) 290 + { 291 + struct scsi_disk *sdkp = to_scsi_disk(dev); 292 + struct scsi_device *sdp = sdkp->device; 293 + bool v; 294 + 295 + if (!capable(CAP_SYS_ADMIN)) 296 + return -EACCES; 297 + 298 + if (kstrtobool(buf, &v)) 299 + return -EINVAL; 300 + 301 + sdp->manage_shutdown = v; 302 + 303 + return count; 304 + } 305 + static DEVICE_ATTR_RW(manage_shutdown); 278 306 279 307 static ssize_t 280 308 allow_restart_show(struct device *dev, struct device_attribute *attr, char *buf) ··· 637 607 &dev_attr_manage_start_stop.attr, 638 608 &dev_attr_manage_system_start_stop.attr, 639 609 &dev_attr_manage_runtime_start_stop.attr, 610 + &dev_attr_manage_shutdown.attr, 640 611 &dev_attr_protection_type.attr, 641 612 &dev_attr_protection_mode.attr, 642 613 &dev_attr_app_tag_own.attr, ··· 3850 3819 sd_sync_cache(sdkp, NULL); 3851 3820 } 3852 3821 3853 - if (system_state != SYSTEM_RESTART && 3854 - sdkp->device->manage_system_start_stop) { 3822 + if ((system_state != SYSTEM_RESTART && 3823 + sdkp->device->manage_system_start_stop) || 3824 + (system_state == SYSTEM_POWER_OFF && 3825 + sdkp->device->manage_shutdown)) { 3855 3826 sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); 3856 3827 sd_start_stop_device(sdkp, 0); 3857 3828 }
+18 -2
include/scsi/scsi_device.h
··· 162 162 * core. */ 163 163 unsigned int eh_timeout; /* Error handling timeout */ 164 164 165 - bool manage_system_start_stop; /* Let HLD (sd) manage system start/stop */ 166 - bool manage_runtime_start_stop; /* Let HLD (sd) manage runtime start/stop */ 165 + /* 166 + * If true, let the high-level device driver (sd) manage the device 167 + * power state for system suspend/resume (suspend to RAM and 168 + * hibernation) operations. 169 + */ 170 + bool manage_system_start_stop; 171 + 172 + /* 173 + * If true, let the high-level device driver (sd) manage the device 174 + * power state for runtime device suspand and resume operations. 175 + */ 176 + bool manage_runtime_start_stop; 177 + 178 + /* 179 + * If true, let the high-level device driver (sd) manage the device 180 + * power state for system shutdown (power off) operations. 181 + */ 182 + bool manage_shutdown; 167 183 168 184 unsigned removable:1; 169 185 unsigned changed:1; /* Data invalid due to media change */