summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-12-06 13:08:42 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-12-06 13:08:42 +0000
commitbd0da0e822e4f15d1234ae63a94131a77d3414a0 (patch)
treefb3c53fe4624fcb75b79c0b9c080bc70a37f2428
parent30df1a38e7de45cc3ff62d9f7d6c65ff33aaeaf7 (diff)
downloadrockbox-bd0da0e822e4f15d1234ae63a94131a77d3414a0.zip
rockbox-bd0da0e822e4f15d1234ae63a94131a77d3414a0.tar.gz
rockbox-bd0da0e822e4f15d1234ae63a94131a77d3414a0.tar.bz2
rockbox-bd0da0e822e4f15d1234ae63a94131a77d3414a0.tar.xz
Fixed a race condition between sleep thread and spinup code.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2958 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/ata.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 9b092e1..9e67ea4 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -186,8 +186,6 @@ int ata_read_sectors(unsigned long start,
return -1;
}
}
- sleeping = false;
- poweroff = false;
spinup = true;
}
@@ -226,16 +224,18 @@ 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;
}
+ if (spinup) {
+ ata_spinup_time = current_tick - last_disk_activity;
+ spinup = false;
+ sleeping = false;
+ poweroff = false;
+ }
+
/* if destination address is odd, use byte copying,
otherwise use word copying */
@@ -314,8 +314,6 @@ int ata_write_sectors(unsigned long start,
return -1;
}
}
- sleeping = false;
- poweroff = false;
spinup = true;
}
@@ -349,6 +347,8 @@ int ata_write_sectors(unsigned long start,
if (spinup) {
ata_spinup_time = current_tick - last_disk_activity;
spinup = false;
+ sleeping = false;
+ poweroff = false;
}
for (j=0; j<SECTOR_SIZE/2; j++)
@@ -563,7 +563,6 @@ int ata_hard_reset(void)
/* Massage the return code so it is 0 on success and -1 on failure */
ret = ret?0:-1;
- sleeping = false;
return ret;
}
@@ -589,7 +588,6 @@ static int perform_soft_reset(void)
/* Massage the return code so it is 0 on success and -1 on failure */
ret = ret?0:-1;
- sleeping = false;
return ret;
}
@@ -617,8 +615,6 @@ static int ata_power_on(void)
if (freeze_lock())
return -3;
- sleeping = false;
- poweroff = false;
return 0;
}