diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2008-02-17 18:35:27 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2008-02-17 18:35:27 +0000 |
commit | 9eec03faa59345b7b16236805cb17d2f0cd82709 (patch) | |
tree | 5ffb77f23ed108b69ec0ca9b9852f404483568b9 /apps/tagcache.c | |
parent | 8140705e99f04c044aec139d845e3c3fd311bede (diff) | |
download | rockbox-9eec03faa59345b7b16236805cb17d2f0cd82709.tar.gz rockbox-9eec03faa59345b7b16236805cb17d2f0cd82709.zip |
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
Diffstat (limited to 'apps/tagcache.c')
-rw-r--r-- | apps/tagcache.c | 39 |
1 files changed, 21 insertions, 18 deletions
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 @@ | |||
57 | #include <stdlib.h> | 57 | #include <stdlib.h> |
58 | #include <ctype.h> | 58 | #include <ctype.h> |
59 | #include "config.h" | 59 | #include "config.h" |
60 | #include "ata_idle_notify.h" | ||
60 | #include "thread.h" | 61 | #include "thread.h" |
61 | #include "kernel.h" | 62 | #include "kernel.h" |
62 | #include "system.h" | 63 | #include "system.h" |
@@ -154,9 +155,6 @@ static struct tagcache_command_entry command_queue[TAGCACHE_COMMAND_QUEUE_LENGTH | |||
154 | static volatile int command_queue_widx = 0; | 155 | static volatile int command_queue_widx = 0; |
155 | static volatile int command_queue_ridx = 0; | 156 | static volatile int command_queue_ridx = 0; |
156 | static struct mutex command_queue_mutex; | 157 | static struct mutex command_queue_mutex; |
157 | /* Timestamp of the last added event, so we can wait a bit before committing the | ||
158 | * whole queue at once. */ | ||
159 | static long command_queue_timestamp = 0; | ||
160 | 158 | ||
161 | /* Tag database structures. */ | 159 | /* Tag database structures. */ |
162 | 160 | ||
@@ -3030,26 +3028,16 @@ static bool command_queue_is_full(void) | |||
3030 | 3028 | ||
3031 | return (next == command_queue_ridx); | 3029 | return (next == command_queue_ridx); |
3032 | } | 3030 | } |
3033 | 3031 | bool command_queue_sync_callback(void) | |
3034 | void run_command_queue(bool force) | ||
3035 | { | 3032 | { |
3033 | |||
3036 | struct master_header myhdr; | 3034 | struct master_header myhdr; |
3037 | int masterfd; | 3035 | int masterfd; |
3038 | |||
3039 | if (COMMAND_QUEUE_IS_EMPTY) | ||
3040 | return; | ||
3041 | |||
3042 | if (!force && !command_queue_is_full() | ||
3043 | && current_tick - TAGCACHE_COMMAND_QUEUE_COMMIT_DELAY | ||
3044 | < command_queue_timestamp) | ||
3045 | { | ||
3046 | return; | ||
3047 | } | ||
3048 | 3036 | ||
3049 | mutex_lock(&command_queue_mutex); | 3037 | mutex_lock(&command_queue_mutex); |
3050 | 3038 | ||
3051 | if ( (masterfd = open_master_fd(&myhdr, true)) < 0) | 3039 | if ( (masterfd = open_master_fd(&myhdr, true)) < 0) |
3052 | return; | 3040 | return false; |
3053 | 3041 | ||
3054 | while (command_queue_ridx != command_queue_widx) | 3042 | while (command_queue_ridx != command_queue_widx) |
3055 | { | 3043 | { |
@@ -3064,7 +3052,7 @@ void run_command_queue(bool force) | |||
3064 | 3052 | ||
3065 | /* Re-open the masterfd. */ | 3053 | /* Re-open the masterfd. */ |
3066 | if ( (masterfd = open_master_fd(&myhdr, true)) < 0) | 3054 | if ( (masterfd = open_master_fd(&myhdr, true)) < 0) |
3067 | return; | 3055 | return true; |
3068 | 3056 | ||
3069 | break; | 3057 | break; |
3070 | } | 3058 | } |
@@ -3081,7 +3069,20 @@ void run_command_queue(bool force) | |||
3081 | 3069 | ||
3082 | close(masterfd); | 3070 | close(masterfd); |
3083 | 3071 | ||
3072 | tc_stat.queue_length = 0; | ||
3084 | mutex_unlock(&command_queue_mutex); | 3073 | mutex_unlock(&command_queue_mutex); |
3074 | return true; | ||
3075 | } | ||
3076 | |||
3077 | void run_command_queue(bool force) | ||
3078 | { | ||
3079 | if (COMMAND_QUEUE_IS_EMPTY) | ||
3080 | return; | ||
3081 | |||
3082 | if (force || command_queue_is_full()) | ||
3083 | command_queue_sync_callback(); | ||
3084 | else | ||
3085 | register_ata_idle_func(command_queue_sync_callback); | ||
3085 | } | 3086 | } |
3086 | 3087 | ||
3087 | static void queue_command(int cmd, long idx_id, int tag, long data) | 3088 | 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) | |||
3106 | ce->data = data; | 3107 | ce->data = data; |
3107 | 3108 | ||
3108 | command_queue_widx = next; | 3109 | command_queue_widx = next; |
3109 | command_queue_timestamp = current_tick; | 3110 | |
3111 | tc_stat.queue_length++; | ||
3112 | |||
3110 | mutex_unlock(&command_queue_mutex); | 3113 | mutex_unlock(&command_queue_mutex); |
3111 | break; | 3114 | break; |
3112 | } | 3115 | } |