aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2008-05-10 18:34:07 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2008-07-14 07:00:17 -0400
commitd2886ea368a67704ecc13e69075f18a9d74cb12b (patch)
tree54593ba6b45d1a4cdec66da4aa7d8d813cc49a3a
parentbce7f793daec3e65ec5c5705d2457b81fe7b5725 (diff)
scsi: sd: optionally set power condition in START STOP UNIT
Adds a new scsi_device flag, start_stop_pwr_cond: If enabled, the sd driver will not send plain START STOP UNIT commands but ones with the power condition field set to 3 (standby) or 1 (active) respectively. Some FireWire disk firmwares do not stop the motor if power condition is zero. Or worse, they become unresponsive after a START STOP UNIT with power condition = 0 and start = 0. http://lkml.org/lkml/2008/4/29/704 This patch only adds the necessary code to sd_mod but doesn't activate it. Follow-up patches to the FireWire drivers will add detection of affected devices and enable the code for them. I did not add power condition values to scsi_error.c::scsi_eh_try_stu() for now. The three firmwares which suffer from above mentioned problems do not need START STOP UNIT in the error handler, and they are not adversely affected by START STOP UNIT with power condition = 0 and start = 1 (like scsi_eh_try_stu() sends it if scsi_device.allow_restart is enabled). Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> Tested-by: Tino Keitel <tino.keitel@gmx.de>
-rw-r--r--drivers/scsi/sd.c5
-rw-r--r--include/scsi/scsi_device.h1
2 files changed, 6 insertions, 0 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 01cefbb2d539..d53312c42547 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1124,6 +1124,8 @@ sd_spinup_disk(struct scsi_disk *sdkp)
1124 cmd[1] = 1; /* Return immediately */ 1124 cmd[1] = 1; /* Return immediately */
1125 memset((void *) &cmd[2], 0, 8); 1125 memset((void *) &cmd[2], 0, 8);
1126 cmd[4] = 1; /* Start spin cycle */ 1126 cmd[4] = 1; /* Start spin cycle */
1127 if (sdkp->device->start_stop_pwr_cond)
1128 cmd[4] |= 1 << 4;
1127 scsi_execute_req(sdkp->device, cmd, DMA_NONE, 1129 scsi_execute_req(sdkp->device, cmd, DMA_NONE,
1128 NULL, 0, &sshdr, 1130 NULL, 0, &sshdr,
1129 SD_TIMEOUT, SD_MAX_RETRIES); 1131 SD_TIMEOUT, SD_MAX_RETRIES);
@@ -1790,6 +1792,9 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
1790 if (start) 1792 if (start)
1791 cmd[4] |= 1; /* START */ 1793 cmd[4] |= 1; /* START */
1792 1794
1795 if (sdp->start_stop_pwr_cond)
1796 cmd[4] |= start ? 1 << 4 : 3 << 4; /* Active or Standby */
1797
1793 if (!scsi_device_online(sdp)) 1798 if (!scsi_device_online(sdp))
1794 return -ENODEV; 1799 return -ENODEV;
1795 1800
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index f6a9fe0ef09c..00b78763a1bf 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -134,6 +134,7 @@ struct scsi_device {
134 unsigned no_start_on_add:1; /* do not issue start on add */ 134 unsigned no_start_on_add:1; /* do not issue start on add */
135 unsigned allow_restart:1; /* issue START_UNIT in error handler */ 135 unsigned allow_restart:1; /* issue START_UNIT in error handler */
136 unsigned manage_start_stop:1; /* Let HLD (sd) manage start/stop */ 136 unsigned manage_start_stop:1; /* Let HLD (sd) manage start/stop */
137 unsigned start_stop_pwr_cond:1; /* Set power cond. in START_STOP_UNIT */
137 unsigned no_uld_attach:1; /* disable connecting to upper level drivers */ 138 unsigned no_uld_attach:1; /* disable connecting to upper level drivers */
138 unsigned select_no_atn:1; 139 unsigned select_no_atn:1;
139 unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */ 140 unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */