libata: implement ata_wait_after_reset()
PATCH 2/4 libata: implement ata_wait_after_reset()
From: Tejun Heo <[email protected]>
On certain device/controller combination, 0xff status is asserted after reset and doesn't get cleared during 150ms post-reset wait. As 0xff status is interpreted as no device (for good reasons), this can lead to misdetection on such cases.
This patch implements ata_wait_after_reset() which replaces the 150ms sleep and waits upto ATA_TMOUT_FF_WAIT if status is 0xff. ATA_TMOUT_FF_WAIT is currently 800ms which is enough for HHD424020F7SV00 to get detected but not enough for Quantum GoVault drive which is known to take upto 2s.
Without parallel probing, spending 2s on 0xff port would incur too much delay on ata_piix's which use 0xff to indicate empty port and doesn't have SCR register, so GoVault needs to wait till parallel probing.
---
drivers/ata/ahci.c | 11 +---- drivers/ata/libata-core.c | 67 +++++++++++++++++++++++++++------- drivers/ata/pata_scc.c | 13 +----- drivers/ata/sata_inic162x.c | 2 - include/linux/libata.h | 8 ++++ 5 files changed, 67 insertions(+), 34 deletions(-)
drivers/ata/ahci.c renamed from drivers/ata/ahci.c~libata-implement-ata_wait_after_reset +2 -9
@@ -1117,15 +1117,8 @@ static int ahci_do_softreset(struct ata_ tf.ctl &= ~ATA_SRST ;ahci_exec_polled_cmd (ap, pmp, &tf,0 ,0 ,0 ); -/* spec mandates ">= 2ms" before checking status. -* We wait 150ms, because that was the magic delay used for -* ATAPI devices in Hale Landis's ATADRVR, for the period of time -* between when the ATA command register is written, and then -* status is checked. Because waiting for "a while" before -* checking status is fine, post SRST, we perform this magic -* delay here as well. -*/ -msleep (150 ); +/* wait a while before checking status */ +ata_wait_after_reset (ap, deadline); rc =ata_wait_ready (ap, deadline);/* link occupied, -ENODEV too is an error */
drivers/ata/libata-core.c renamed from drivers/ata/libata-core.c~libata-implement-ata_wait_after_reset +54 -13
91 lines not on this page · raw message
drivers/ata/pata_scc.c renamed from drivers/ata/pata_scc.c~libata-implement-ata_wait_after_reset +2 -11
@@ -570,17 +570,8 @@ static unsigned int scc_bus_softreset(studelay (20 );out_be32 (ioaddr->ctl_addr, ap->ctl); -/* spec mandates ">= 2ms" before checking status. -* We wait 150ms, because that was the magic delay used for -* ATAPI devices in Hale Landis's ATADRVR, for the period of time -* between when the ATA command register is written, and then -* status is checked. Because waiting for "a while" before -* checking status is fine, post SRST, we perform this magic -* delay here as well. -* -* Old drivers/ide uses the 2mS rule and then waits for ready -*/ -msleep (150 ); +/* wait a while before checking status */ +ata_wait_after_reset (ap, deadline);/* Before we perform post reset processing we want to see if * the bus shows 0xFF because the odd clown forgets the D7
drivers/ata/sata_inic162x.c renamed from drivers/ata/sata_inic162x.c~libata-implement-ata_wait_after_reset +1 -1
@@ -448,7 +448,7 @@ static int inic_hardreset(struct ata_linstruct ata_taskfile tf;/* wait a while before checking status */ -msleep (150 ); +ata_wait_after_reset (ap, deadline); rc =ata_wait_ready (ap, deadline);/* link occupied, -ENODEV too is an error */
include/linux/libata.h renamed from include/linux/libata.h~libata-implement-ata_wait_after_reset +8 -0
@@ -234,6 +234,13 @@ enum {ATA_TMOUT_INTERNAL =30 *HZ ,ATA_TMOUT_INTERNAL_QUICK =5 *HZ , +/* FIXME: GoVault needs 2s but we can't afford that without +* parallel probing. 800ms is enough for iVDR disk +* HHD424020F7SV00. Increase to 2secs when parallel probing +* is in place. +*/ +ATA_TMOUT_FF_WAIT =4 *HZ /5 , +/* ATA bus states */ BUS_UNKNOWN =0 , BUS_DMA = 1,
@@ -799,6 +806,7 @@ extern void ata_host_resume(struct ata_hextern int ata_ratelimit (void );extern int ata_busy_sleep (struct ata_port *ap,unsigned long timeout_pat,unsigned long timeout); +extern void ata_wait_after_reset (struct ata_port *ap,unsigned long deadline);extern int ata_wait_ready (struct ata_port *ap,unsigned long deadline);extern void ata_port_queue_task (struct ata_port *ap,work_func_t fn,void *data,unsigned long delay);
_
Jeff Garzik
AppliedQuoted 20 lines · [email protected] wrote:
From: Tejun Heo <[email protected]>
On certain device/controller combination,
0xffstatus is asserted after reset and doesn't get cleared during 150ms post-reset wait. As0xffstatus is interpreted as no device (for good reasons), this can lead to misdetection on such cases.This patch implements
ata_wait_after_reset()which replaces the 150ms sleep and waits uptoATA_TMOUT_FF_WAITif status is0xff.ATA_TMOUT_FF_WAITis currently 800ms which is enough for HHD424020F7SV00 to get detected but not enough for Quantum GoVault drive which is known to take upto 2s.Without parallel probing, spending 2s on
0xffport would incur too much delay on ata_piix's which use0xffto indicate empty port and doesn't have SCR register, so GoVault needs to wait till parallel probing.Signed-off-by Tejun Heo <[email protected]>Signed-off-by Andrew Morton <[email protected]>
Quoted 8 lines
---
drivers/ata/ahci.c | 11 +---- drivers/ata/libata-core.c | 67 +++++++++++++++++++++++++++------- drivers/ata/pata_scc.c | 13 +----- drivers/ata/sata_inic162x.c | 2 - include/linux/libata.h | 8 ++++ 5 files changed, 67 insertions(+), 34 deletions(-)
applied