forked from len0rd/rockbox
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
This commit is contained in:
parent
acbf7e7539
commit
ba0438e78d
1 changed files with 22 additions and 10 deletions
|
@ -165,11 +165,12 @@ int ata_read_sectors(unsigned long start,
|
||||||
int timeout;
|
int timeout;
|
||||||
int count;
|
int count;
|
||||||
void* buf;
|
void* buf;
|
||||||
|
bool spinup = false;
|
||||||
last_disk_activity = current_tick;
|
|
||||||
|
|
||||||
mutex_lock(&ata_mtx);
|
mutex_lock(&ata_mtx);
|
||||||
|
|
||||||
|
last_disk_activity = current_tick;
|
||||||
|
|
||||||
led(true);
|
led(true);
|
||||||
|
|
||||||
if ( sleeping ) {
|
if ( sleeping ) {
|
||||||
|
@ -187,7 +188,7 @@ int ata_read_sectors(unsigned long start,
|
||||||
}
|
}
|
||||||
sleeping = false;
|
sleeping = false;
|
||||||
poweroff = false;
|
poweroff = false;
|
||||||
ata_spinup_time = current_tick - last_disk_activity;
|
spinup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ATA_SELECT = ata_device;
|
ATA_SELECT = ata_device;
|
||||||
|
@ -225,6 +226,11 @@ int ata_read_sectors(unsigned long start,
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (spinup) {
|
||||||
|
ata_spinup_time = current_tick - last_disk_activity;
|
||||||
|
spinup = false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ATA_ALT_STATUS & (STATUS_ERR | STATUS_DF) ) {
|
if ( ATA_ALT_STATUS & (STATUS_ERR | STATUS_DF) ) {
|
||||||
ret = -5;
|
ret = -5;
|
||||||
goto retry;
|
goto retry;
|
||||||
|
@ -258,6 +264,8 @@ int ata_read_sectors(unsigned long start,
|
||||||
#endif
|
#endif
|
||||||
buf += sectors * SECTOR_SIZE; /* Advance one chunk of sectors */
|
buf += sectors * SECTOR_SIZE; /* Advance one chunk of sectors */
|
||||||
count -= sectors;
|
count -= sectors;
|
||||||
|
|
||||||
|
last_disk_activity = current_tick;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!wait_for_end_of_transfer()) {
|
if(!wait_for_end_of_transfer()) {
|
||||||
|
@ -275,8 +283,6 @@ int ata_read_sectors(unsigned long start,
|
||||||
if ( delayed_write )
|
if ( delayed_write )
|
||||||
ata_flush();
|
ata_flush();
|
||||||
|
|
||||||
last_disk_activity = current_tick;
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,14 +292,15 @@ int ata_write_sectors(unsigned long start,
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
bool spinup = false;
|
||||||
last_disk_activity = current_tick;
|
|
||||||
|
|
||||||
if (start == 0)
|
if (start == 0)
|
||||||
panicf("Writing on sector 0\n");
|
panicf("Writing on sector 0\n");
|
||||||
|
|
||||||
mutex_lock(&ata_mtx);
|
mutex_lock(&ata_mtx);
|
||||||
|
|
||||||
|
last_disk_activity = current_tick;
|
||||||
|
|
||||||
if ( sleeping ) {
|
if ( sleeping ) {
|
||||||
if (poweroff) {
|
if (poweroff) {
|
||||||
if (ata_power_on()) {
|
if (ata_power_on()) {
|
||||||
|
@ -309,7 +316,7 @@ int ata_write_sectors(unsigned long start,
|
||||||
}
|
}
|
||||||
sleeping = false;
|
sleeping = false;
|
||||||
poweroff = false;
|
poweroff = false;
|
||||||
ata_spinup_time = current_tick - last_disk_activity;
|
spinup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ATA_SELECT = ata_device;
|
ATA_SELECT = ata_device;
|
||||||
|
@ -339,6 +346,11 @@ int ata_write_sectors(unsigned long start,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (spinup) {
|
||||||
|
ata_spinup_time = current_tick - last_disk_activity;
|
||||||
|
spinup = false;
|
||||||
|
}
|
||||||
|
|
||||||
for (j=0; j<SECTOR_SIZE/2; j++)
|
for (j=0; j<SECTOR_SIZE/2; j++)
|
||||||
ATA_DATA = SWAB16(((unsigned short*)buf)[j]);
|
ATA_DATA = SWAB16(((unsigned short*)buf)[j]);
|
||||||
|
|
||||||
|
@ -347,6 +359,8 @@ int ata_write_sectors(unsigned long start,
|
||||||
j = ATA_STATUS;
|
j = ATA_STATUS;
|
||||||
#endif
|
#endif
|
||||||
buf += SECTOR_SIZE;
|
buf += SECTOR_SIZE;
|
||||||
|
|
||||||
|
last_disk_activity = current_tick;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!wait_for_end_of_transfer())
|
if(!wait_for_end_of_transfer())
|
||||||
|
@ -359,8 +373,6 @@ int ata_write_sectors(unsigned long start,
|
||||||
if ( delayed_write )
|
if ( delayed_write )
|
||||||
ata_flush();
|
ata_flush();
|
||||||
|
|
||||||
last_disk_activity = current_tick;
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue