summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/debug_menu.c10
-rw-r--r--apps/tagcache.c39
2 files changed, 29 insertions, 20 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index b3df043609..61b564820e 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1913,7 +1913,9 @@ static int database_callback(int btn, struct gui_synclist *lists)
1913 simplelist_addline(SIMPLELIST_ADD_LINE, "Commit delayed: %s", 1913 simplelist_addline(SIMPLELIST_ADD_LINE, "Commit delayed: %s",
1914 stat->commit_delayed ? "Yes" : "No"); 1914 stat->commit_delayed ? "Yes" : "No");
1915 1915
1916 1916 simplelist_addline(SIMPLELIST_ADD_LINE, "Queue length: %d",
1917 stat->queue_length);
1918
1917 if (synced) 1919 if (synced)
1918 { 1920 {
1919 synced = false; 1921 synced = false;
@@ -1937,7 +1939,11 @@ static bool dbg_tagcache_info(void)
1937 simplelist_info_init(&info, "Database Info", 8, NULL); 1939 simplelist_info_init(&info, "Database Info", 8, NULL);
1938 info.action_callback = database_callback; 1940 info.action_callback = database_callback;
1939 info.hide_selection = true; 1941 info.hide_selection = true;
1940 info.timeout = TIMEOUT_NOBLOCK; 1942
1943 /* Don't do nonblock here, must give enough processing time
1944 for tagcache thread. */
1945 /* info.timeout = TIMEOUT_NOBLOCK; */
1946 info.timeout = 1;
1941 tagcache_screensync_enable(true); 1947 tagcache_screensync_enable(true);
1942 return simplelist_show_list(&info); 1948 return simplelist_show_list(&info);
1943} 1949}
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
154static volatile int command_queue_widx = 0; 155static volatile int command_queue_widx = 0;
155static volatile int command_queue_ridx = 0; 156static volatile int command_queue_ridx = 0;
156static struct mutex command_queue_mutex; 157static 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. */
159static 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 3031bool command_queue_sync_callback(void)
3034void 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
3077void 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
3087static void queue_command(int cmd, long idx_id, int tag, long data) 3088static 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 }