From 8bda0e10975b476a77a17777a733b783a4d718b4 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Fri, 19 Mar 2004 13:26:43 +0000 Subject: A hip shot trying to make the Red LED Death situation a little better git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4409 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/ata.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 7641be7..d12dfbe 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -117,7 +117,7 @@ static int set_features(void); static int wait_for_bsy(void) __attribute__ ((section (".icode"))); static int wait_for_bsy(void) { - int timeout = current_tick + HZ*10; + int timeout = current_tick + HZ*30; while (TIME_BEFORE(current_tick, timeout) && (ATA_STATUS & STATUS_BSY)) { last_disk_activity = current_tick; yield(); @@ -375,6 +375,15 @@ int ata_read_sectors(unsigned long start, int status; if (!wait_for_start_of_transfer()) { + /* We have timed out waiting for RDY and/or DRQ, possibly + because the hard drive is shaking and has problems reading + the data. We have two options: + 1) Wait some more + 2) Perform a soft reset and try again. + + We choose alternative 2. + */ + ata_soft_reset(); ret = -4; goto retry; } @@ -409,6 +418,7 @@ int ata_read_sectors(unsigned long start, -- ATA specification */ if ( status & (STATUS_BSY | STATUS_ERR | STATUS_DF) ) { + ata_soft_reset(); ret = -5; goto retry; } @@ -420,6 +430,7 @@ int ata_read_sectors(unsigned long start, } if(!ret && !wait_for_end_of_transfer()) { + ata_soft_reset(); ret = -3; goto retry; } -- cgit v1.1