aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-10-25 05:30:36 -0400
committerJeff Garzik <jeff@garzik.org>2007-10-29 06:15:25 -0400
commit054a5fbaceb2eb3a31ea843c1cf0b8e10b91478c (patch)
treecbf21985f3894b11fe00666cef8ac33bae4f007d
parent4dbfa39b6c95eb9d0aedb5bd00bb552b91c31e3d (diff)
libata: track SLEEP state and issue SRST to wake it up
ATA devices in SLEEP mode don't respond to any commands. SRST is necessary to wake it up. Till now, when a command is issued to a device in SLEEP mode, the command times out, which makes EH reset the device and retry the command after that, causing a long delay. This patch makes libata track SLEEP state and issue SRST automatically if a command is about to be issued to a device in SLEEP. Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: Bruce Allen <ballen@gravity.phys.uwm.edu> Cc: Andrew Paprocki <andrew@ishiboo.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r--drivers/ata/libata-core.c12
-rw-r--r--drivers/ata/libata-eh.c4
-rw-r--r--include/linux/ata.h1
-rw-r--r--include/linux/libata.h1
4 files changed, 17 insertions, 1 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 5aedd1af06e6..50ae20101d10 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -5630,6 +5630,10 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
5630 ehi->dev_action[dev->devno] |= ATA_EH_REVALIDATE; 5630 ehi->dev_action[dev->devno] |= ATA_EH_REVALIDATE;
5631 ata_port_schedule_eh(ap); 5631 ata_port_schedule_eh(ap);
5632 break; 5632 break;
5633
5634 case ATA_CMD_SLEEP:
5635 dev->flags |= ATA_DFLAG_SLEEPING;
5636 break;
5633 } 5637 }
5634 5638
5635 __ata_qc_complete(qc); 5639 __ata_qc_complete(qc);
@@ -5769,6 +5773,14 @@ void ata_qc_issue(struct ata_queued_cmd *qc)
5769 qc->flags &= ~ATA_QCFLAG_DMAMAP; 5773 qc->flags &= ~ATA_QCFLAG_DMAMAP;
5770 } 5774 }
5771 5775
5776 /* if device is sleeping, schedule softreset and abort the link */
5777 if (unlikely(qc->dev->flags & ATA_DFLAG_SLEEPING)) {
5778 link->eh_info.action |= ATA_EH_SOFTRESET;
5779 ata_ehi_push_desc(&link->eh_info, "waking up from sleep");
5780 ata_link_abort(link);
5781 return;
5782 }
5783
5772 ap->ops->qc_prep(qc); 5784 ap->ops->qc_prep(qc);
5773 5785
5774 qc->err_mask |= ap->ops->qc_issue(qc); 5786 qc->err_mask |= ap->ops->qc_issue(qc);
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 8cb35bb87605..496edaff119a 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2208,9 +2208,11 @@ int ata_eh_reset(struct ata_link *link, int classify,
2208 ata_link_for_each_dev(dev, link) { 2208 ata_link_for_each_dev(dev, link) {
2209 /* After the reset, the device state is PIO 0 2209 /* After the reset, the device state is PIO 0
2210 * and the controller state is undefined. 2210 * and the controller state is undefined.
2211 * Record the mode. 2211 * Reset also wakes up drives from sleeping
2212 * mode.
2212 */ 2213 */
2213 dev->pio_mode = XFER_PIO_0; 2214 dev->pio_mode = XFER_PIO_0;
2215 dev->flags &= ~ATA_DFLAG_SLEEPING;
2214 2216
2215 if (ata_link_offline(link)) 2217 if (ata_link_offline(link))
2216 continue; 2218 continue;
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 8263a7b74d34..e21c002c3a4a 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -180,6 +180,7 @@ enum {
180 ATA_CMD_VERIFY_EXT = 0x42, 180 ATA_CMD_VERIFY_EXT = 0x42,
181 ATA_CMD_STANDBYNOW1 = 0xE0, 181 ATA_CMD_STANDBYNOW1 = 0xE0,
182 ATA_CMD_IDLEIMMEDIATE = 0xE1, 182 ATA_CMD_IDLEIMMEDIATE = 0xE1,
183 ATA_CMD_SLEEP = 0xE6,
183 ATA_CMD_INIT_DEV_PARAMS = 0x91, 184 ATA_CMD_INIT_DEV_PARAMS = 0x91,
184 ATA_CMD_READ_NATIVE_MAX = 0xF8, 185 ATA_CMD_READ_NATIVE_MAX = 0xF8,
185 ATA_CMD_READ_NATIVE_MAX_EXT = 0x27, 186 ATA_CMD_READ_NATIVE_MAX_EXT = 0x27,
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 6fd24e03622e..2f0fc636b4b6 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -138,6 +138,7 @@ enum {
138 ATA_DFLAG_PIO = (1 << 12), /* device limited to PIO mode */ 138 ATA_DFLAG_PIO = (1 << 12), /* device limited to PIO mode */
139 ATA_DFLAG_NCQ_OFF = (1 << 13), /* device limited to non-NCQ mode */ 139 ATA_DFLAG_NCQ_OFF = (1 << 13), /* device limited to non-NCQ mode */
140 ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */ 140 ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */
141 ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */
141 ATA_DFLAG_INIT_MASK = (1 << 16) - 1, 142 ATA_DFLAG_INIT_MASK = (1 << 16) - 1,
142 143
143 ATA_DFLAG_DETACH = (1 << 16), 144 ATA_DFLAG_DETACH = (1 << 16),