From 9eec03faa59345b7b16236805cb17d2f0cd82709 Mon Sep 17 00:00:00 2001 From: Miika Pekkarinen Date: Sun, 17 Feb 2008 18:35:27 +0000 Subject: FS#8565 - fix for runtime data causing extra spin ups. Included a debug menu update also. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16330 a1c6a512-1295-4272-9138-f99709370657 --- apps/tagcache.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'apps/tagcache.c') diff --git a/apps/tagcache.c b/apps/tagcache.c index a53bdc7f84..926ba7b3c7 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -57,6 +57,7 @@ #include #include #include "config.h" +#include "ata_idle_notify.h" #include "thread.h" #include "kernel.h" #include "system.h" @@ -154,9 +155,6 @@ static struct tagcache_command_entry command_queue[TAGCACHE_COMMAND_QUEUE_LENGTH static volatile int command_queue_widx = 0; static volatile int command_queue_ridx = 0; static struct mutex command_queue_mutex; -/* Timestamp of the last added event, so we can wait a bit before committing the - * whole queue at once. */ -static long command_queue_timestamp = 0; /* Tag database structures. */ @@ -3030,26 +3028,16 @@ static bool command_queue_is_full(void) return (next == command_queue_ridx); } - -void run_command_queue(bool force) +bool command_queue_sync_callback(void) { + struct master_header myhdr; int masterfd; - - if (COMMAND_QUEUE_IS_EMPTY) - return; - - if (!force && !command_queue_is_full() - && current_tick - TAGCACHE_COMMAND_QUEUE_COMMIT_DELAY - < command_queue_timestamp) - { - return; - } mutex_lock(&command_queue_mutex); if ( (masterfd = open_master_fd(&myhdr, true)) < 0) - return; + return false; while (command_queue_ridx != command_queue_widx) { @@ -3064,7 +3052,7 @@ void run_command_queue(bool force) /* Re-open the masterfd. */ if ( (masterfd = open_master_fd(&myhdr, true)) < 0) - return; + return true; break; } @@ -3081,7 +3069,20 @@ void run_command_queue(bool force) close(masterfd); + tc_stat.queue_length = 0; mutex_unlock(&command_queue_mutex); + return true; +} + +void run_command_queue(bool force) +{ + if (COMMAND_QUEUE_IS_EMPTY) + return; + + if (force || command_queue_is_full()) + command_queue_sync_callback(); + else + register_ata_idle_func(command_queue_sync_callback); } static void queue_command(int cmd, long idx_id, int tag, long data) @@ -3106,7 +3107,9 @@ static void queue_command(int cmd, long idx_id, int tag, long data) ce->data = data; command_queue_widx = next; - command_queue_timestamp = current_tick; + + tc_stat.queue_length++; + mutex_unlock(&command_queue_mutex); break; } -- cgit v1.2.3