1
0
Fork 0
forked from len0rd/rockbox

Some misc. ATA stuff: Increase threads' priority (important for idle callbacks to get done faster). Use a simpler loop for ata thread. Add a balancing mutex_lock call to ata_init (oops).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16278 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2008-02-11 07:42:11 +00:00
parent 523f88e192
commit 9811fc9abf
2 changed files with 42 additions and 37 deletions

View file

@ -816,7 +816,10 @@ static void ata_thread(void)
static long last_seen_mtx_unlock = 0; static long last_seen_mtx_unlock = 0;
while (1) { while (1) {
while ( queue_empty( &ata_queue ) ) { queue_wait_w_tmo(&ata_queue, &ev, HZ/2);
switch ( ev.id ) {
case SYS_TIMEOUT:
if (!spinup && !sleeping) if (!spinup && !sleeping)
{ {
if (!ata_mtx.locked) if (!ata_mtx.locked)
@ -840,6 +843,7 @@ static void ata_thread(void)
last_sleep = current_tick; last_sleep = current_tick;
} }
} }
#ifdef HAVE_ATA_POWER_OFF #ifdef HAVE_ATA_POWER_OFF
if ( !spinup && sleeping && !poweroff && if ( !spinup && sleeping && !poweroff &&
TIME_AFTER( current_tick, last_sleep + ATA_POWER_OFF_TIMEOUT )) TIME_AFTER( current_tick, last_sleep + ATA_POWER_OFF_TIMEOUT ))
@ -850,11 +854,8 @@ static void ata_thread(void)
poweroff = true; poweroff = true;
} }
#endif #endif
break;
sleep(HZ/4);
}
queue_wait(&ata_queue, &ev);
switch ( ev.id ) {
#ifndef USB_NONE #ifndef USB_NONE
case SYS_USB_CONNECTED: case SYS_USB_CONNECTED:
if (poweroff) { if (poweroff) {
@ -1149,7 +1150,8 @@ int ata_init(void)
#endif #endif
if ( !initialized ) { if ( !initialized ) {
/* First call won't have multiple thread contention */ /* First call won't have multiple thread contention - this
* may return at any point without having to unlock */
mutex_unlock(&ata_mtx); mutex_unlock(&ata_mtx);
if (!ide_powered()) /* somebody has switched it off */ if (!ide_powered()) /* somebody has switched it off */
@ -1211,10 +1213,12 @@ int ata_init(void)
if (rc) if (rc)
return -60 + rc; return -60 + rc;
mutex_lock(&ata_mtx); /* Balance unlock below */
last_disk_activity = current_tick; last_disk_activity = current_tick;
create_thread(ata_thread, ata_stack, create_thread(ata_thread, ata_stack,
sizeof(ata_stack), 0, ata_thread_name sizeof(ata_stack), 0, ata_thread_name
IF_PRIO(, PRIORITY_SYSTEM) IF_PRIO(, PRIORITY_USER_INTERFACE)
IF_COP(, CPU)); IF_COP(, CPU));
initialized = true; initialized = true;

View file

@ -1190,7 +1190,8 @@ int ata_init(void)
queue_init(&sd_queue, true); queue_init(&sd_queue, true);
create_thread(sd_thread, sd_stack, sizeof(sd_stack), 0, create_thread(sd_thread, sd_stack, sizeof(sd_stack), 0,
sd_thread_name IF_PRIO(, PRIORITY_SYSTEM) IF_COP(, CPU)); sd_thread_name IF_PRIO(, PRIORITY_USER_INTERFACE)
IF_COP(, CPU));
/* enable interupt for the mSD card */ /* enable interupt for the mSD card */
sleep(HZ/10); sleep(HZ/10);