aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/libata.h
diff options
context:
space:
mode:
authorElias Oltmanns <eo@nebensachen.de>2008-09-21 05:54:08 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-09-29 00:27:54 -0400
commit45fabbb77bd95adff7a80bde1c7a0ace1075fde6 (patch)
tree0e98efc190b25a11f84b8ae7d1ee0a17c41d3da8 /include/linux/libata.h
parentea6ce53cd5d005455ec0a3cc1d45d3af0cb90919 (diff)
libata: Implement disk shock protection support
On user request (through sysfs), the IDLE IMMEDIATE command with UNLOAD FEATURE as specified in ATA-7 is issued to the device and processing of the request queue is stopped thereafter until the specified timeout expires or user space asks to resume normal operation. This is supposed to prevent the heads of a hard drive from accidentally crashing onto the platter when a heavy shock is anticipated (like a falling laptop expected to hit the floor). In fact, the whole port stops processing commands until the timeout has expired in order to avoid any resets due to failed commands on another device. Signed-off-by: Elias Oltmanns <eo@nebensachen.de> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'include/linux/libata.h')
-rw-r--r--include/linux/libata.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 244ff601559a..1f44cfb847e1 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -146,6 +146,7 @@ enum {
146 ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */ 146 ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */
147 ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */ 147 ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */
148 ATA_DFLAG_DUBIOUS_XFER = (1 << 16), /* data transfer not verified */ 148 ATA_DFLAG_DUBIOUS_XFER = (1 << 16), /* data transfer not verified */
149 ATA_DFLAG_NO_UNLOAD = (1 << 17), /* device doesn't support unload */
149 ATA_DFLAG_INIT_MASK = (1 << 24) - 1, 150 ATA_DFLAG_INIT_MASK = (1 << 24) - 1,
150 151
151 ATA_DFLAG_DETACH = (1 << 24), 152 ATA_DFLAG_DETACH = (1 << 24),
@@ -244,6 +245,7 @@ enum {
244 ATA_TMOUT_BOOT = 30000, /* heuristic */ 245 ATA_TMOUT_BOOT = 30000, /* heuristic */
245 ATA_TMOUT_BOOT_QUICK = 7000, /* heuristic */ 246 ATA_TMOUT_BOOT_QUICK = 7000, /* heuristic */
246 ATA_TMOUT_INTERNAL_QUICK = 5000, 247 ATA_TMOUT_INTERNAL_QUICK = 5000,
248 ATA_TMOUT_MAX_PARK = 30000,
247 249
248 /* FIXME: GoVault needs 2s but we can't afford that without 250 /* FIXME: GoVault needs 2s but we can't afford that without
249 * parallel probing. 800ms is enough for iVDR disk 251 * parallel probing. 800ms is enough for iVDR disk
@@ -319,8 +321,9 @@ enum {
319 ATA_EH_RESET = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, 321 ATA_EH_RESET = ATA_EH_SOFTRESET | ATA_EH_HARDRESET,
320 ATA_EH_ENABLE_LINK = (1 << 3), 322 ATA_EH_ENABLE_LINK = (1 << 3),
321 ATA_EH_LPM = (1 << 4), /* link power management action */ 323 ATA_EH_LPM = (1 << 4), /* link power management action */
324 ATA_EH_PARK = (1 << 5), /* unload heads and stop I/O */
322 325
323 ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE, 326 ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE | ATA_EH_PARK,
324 ATA_EH_ALL_ACTIONS = ATA_EH_REVALIDATE | ATA_EH_RESET | 327 ATA_EH_ALL_ACTIONS = ATA_EH_REVALIDATE | ATA_EH_RESET |
325 ATA_EH_ENABLE_LINK | ATA_EH_LPM, 328 ATA_EH_ENABLE_LINK | ATA_EH_LPM,
326 329
@@ -454,6 +457,7 @@ enum link_pm {
454 MEDIUM_POWER, 457 MEDIUM_POWER,
455}; 458};
456extern struct device_attribute dev_attr_link_power_management_policy; 459extern struct device_attribute dev_attr_link_power_management_policy;
460extern struct device_attribute dev_attr_unload_heads;
457extern struct device_attribute dev_attr_em_message_type; 461extern struct device_attribute dev_attr_em_message_type;
458extern struct device_attribute dev_attr_em_message; 462extern struct device_attribute dev_attr_em_message;
459extern struct device_attribute dev_attr_sw_activity; 463extern struct device_attribute dev_attr_sw_activity;
@@ -566,6 +570,7 @@ struct ata_device {
566 /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */ 570 /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */
567 u64 n_sectors; /* size of device, if ATA */ 571 u64 n_sectors; /* size of device, if ATA */
568 unsigned int class; /* ATA_DEV_xxx */ 572 unsigned int class; /* ATA_DEV_xxx */
573 unsigned long unpark_deadline;
569 574
570 u8 pio_mode; 575 u8 pio_mode;
571 u8 dma_mode; 576 u8 dma_mode;
@@ -623,6 +628,7 @@ struct ata_eh_context {
623 [ATA_EH_CMD_TIMEOUT_TABLE_SIZE]; 628 [ATA_EH_CMD_TIMEOUT_TABLE_SIZE];
624 unsigned int classes[ATA_MAX_DEVICES]; 629 unsigned int classes[ATA_MAX_DEVICES];
625 unsigned int did_probe_mask; 630 unsigned int did_probe_mask;
631 unsigned int unloaded_mask;
626 unsigned int saved_ncq_enabled; 632 unsigned int saved_ncq_enabled;
627 u8 saved_xfer_mode[ATA_MAX_DEVICES]; 633 u8 saved_xfer_mode[ATA_MAX_DEVICES];
628 /* timestamp for the last reset attempt or success */ 634 /* timestamp for the last reset attempt or success */
@@ -712,6 +718,7 @@ struct ata_port {
712 struct list_head eh_done_q; 718 struct list_head eh_done_q;
713 wait_queue_head_t eh_wait_q; 719 wait_queue_head_t eh_wait_q;
714 int eh_tries; 720 int eh_tries;
721 struct completion park_req_pending;
715 722
716 pm_message_t pm_mesg; 723 pm_message_t pm_mesg;
717 int *pm_result; 724 int *pm_result;
@@ -1102,6 +1109,7 @@ extern void ata_std_error_handler(struct ata_port *ap);
1102 */ 1109 */
1103extern const struct ata_port_operations ata_base_port_ops; 1110extern const struct ata_port_operations ata_base_port_ops;
1104extern const struct ata_port_operations sata_port_ops; 1111extern const struct ata_port_operations sata_port_ops;
1112extern struct device_attribute *ata_common_sdev_attrs[];
1105 1113
1106#define ATA_BASE_SHT(drv_name) \ 1114#define ATA_BASE_SHT(drv_name) \
1107 .module = THIS_MODULE, \ 1115 .module = THIS_MODULE, \
@@ -1116,7 +1124,8 @@ extern const struct ata_port_operations sata_port_ops;
1116 .proc_name = drv_name, \ 1124 .proc_name = drv_name, \
1117 .slave_configure = ata_scsi_slave_config, \ 1125 .slave_configure = ata_scsi_slave_config, \
1118 .slave_destroy = ata_scsi_slave_destroy, \ 1126 .slave_destroy = ata_scsi_slave_destroy, \
1119 .bios_param = ata_std_bios_param 1127 .bios_param = ata_std_bios_param, \
1128 .sdev_attrs = ata_common_sdev_attrs
1120 1129
1121#define ATA_NCQ_SHT(drv_name) \ 1130#define ATA_NCQ_SHT(drv_name) \
1122 ATA_BASE_SHT(drv_name), \ 1131 ATA_BASE_SHT(drv_name), \