summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-12-05 09:35:01 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-12-05 09:35:01 +0000
commitba0438e78de14bcb8c62050d0459b686f96df13d (patch)
treeabc0a6aac17dde66036965c9460cae37a370c7fa
parentacbf7e7539aa250f13446857a53417d5b7e92e7a (diff)
downloadrockbox-ba0438e78de14bcb8c62050d0459b686f96df13d.zip
rockbox-ba0438e78de14bcb8c62050d0459b686f96df13d.tar.gz
rockbox-ba0438e78de14bcb8c62050d0459b686f96df13d.tar.bz2
rockbox-ba0438e78de14bcb8c62050d0459b686f96df13d.tar.xz
Fixed spinup clocking. Also updating last_disk_activity more frequently, to avoid shutdown race condition.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2935 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/ata.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 8f70714..9b092e1 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -165,11 +165,12 @@ int ata_read_sectors(unsigned long start,
int timeout;
int count;
void* buf;
-
- last_disk_activity = current_tick;
+ bool spinup = false;
mutex_lock(&ata_mtx);
+ last_disk_activity = current_tick;
+
led(true);
if ( sleeping ) {
@@ -187,7 +188,7 @@ int ata_read_sectors(unsigned long start,
}
sleeping = false;
poweroff = false;
- ata_spinup_time = current_tick - last_disk_activity;
+ spinup = true;
}
ATA_SELECT = ata_device;
@@ -225,6 +226,11 @@ int ata_read_sectors(unsigned long start,
goto retry;
}
+ if (spinup) {
+ ata_spinup_time = current_tick - last_disk_activity;
+ spinup = false;
+ }
+
if ( ATA_ALT_STATUS & (STATUS_ERR | STATUS_DF) ) {
ret = -5;
goto retry;
@@ -258,6 +264,8 @@ int ata_read_sectors(unsigned long start,
#endif
buf += sectors * SECTOR_SIZE; /* Advance one chunk of sectors */
count -= sectors;
+
+ last_disk_activity = current_tick;
}
if(!wait_for_end_of_transfer()) {
@@ -275,8 +283,6 @@ int ata_read_sectors(unsigned long start,
if ( delayed_write )
ata_flush();
- last_disk_activity = current_tick;
-
return ret;
}
@@ -286,14 +292,15 @@ int ata_write_sectors(unsigned long start,
{
int i;
int ret = 0;
-
- last_disk_activity = current_tick;
+ bool spinup = false;
if (start == 0)
panicf("Writing on sector 0\n");
mutex_lock(&ata_mtx);
+ last_disk_activity = current_tick;
+
if ( sleeping ) {
if (poweroff) {
if (ata_power_on()) {
@@ -309,7 +316,7 @@ int ata_write_sectors(unsigned long start,
}
sleeping = false;
poweroff = false;
- ata_spinup_time = current_tick - last_disk_activity;
+ spinup = true;
}
ATA_SELECT = ata_device;
@@ -339,6 +346,11 @@ int ata_write_sectors(unsigned long start,
return 0;
}
+ if (spinup) {
+ ata_spinup_time = current_tick - last_disk_activity;
+ spinup = false;
+ }
+
for (j=0; j<SECTOR_SIZE/2; j++)
ATA_DATA = SWAB16(((unsigned short*)buf)[j]);
@@ -347,6 +359,8 @@ int ata_write_sectors(unsigned long start,
j = ATA_STATUS;
#endif
buf += SECTOR_SIZE;
+
+ last_disk_activity = current_tick;
}
if(!wait_for_end_of_transfer())
@@ -359,8 +373,6 @@ int ata_write_sectors(unsigned long start,
if ( delayed_write )
ata_flush();
- last_disk_activity = current_tick;
-
return ret;
}