jtag: commands: save a pointer to list tail
By saving a pointer to the tail of the list, we don't need to traverse the entire command queue before we're able to append an item to it. With this patch, I see a 10% improvement when using the embedded XDS100v2 on AM437x IDK board to load a 4MiB binary (linux zImage) to DDR with load_image. IOW, we went from ~305kB/sec to ~336kb/sec. Change-Id: Idb55d49f0d0106043374ab520b2f3b6b32f2c50f Signed-off-by: Felipe Balbi <balbi@ti.com> Reviewed-on: http://openocd.zylin.com/2709 Tested-by: jenkins Reviewed-by: Stian Skjelstad <stian@nixia.no> Reviewed-by: Daniele Emancipato <daniele12457@hotmail.com> Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de> Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
This commit is contained in:
parent
a652a4ea20
commit
2bb9256c34
|
@ -36,13 +36,14 @@
|
|||
#include "commands.h"
|
||||
|
||||
struct cmd_queue_page {
|
||||
struct cmd_queue_page *next;
|
||||
void *address;
|
||||
size_t used;
|
||||
struct cmd_queue_page *next;
|
||||
};
|
||||
|
||||
#define CMD_QUEUE_PAGE_SIZE (1024 * 1024)
|
||||
static struct cmd_queue_page *cmd_queue_pages;
|
||||
static struct cmd_queue_page *cmd_queue_pages_tail;
|
||||
|
||||
struct jtag_command *jtag_command_queue;
|
||||
static struct jtag_command **next_command_pointer = &jtag_command_queue;
|
||||
|
@ -100,8 +101,7 @@ void *cmd_queue_alloc(size_t size)
|
|||
/* Done... */
|
||||
|
||||
if (*p_page) {
|
||||
while ((*p_page)->next)
|
||||
p_page = &((*p_page)->next);
|
||||
p_page = &cmd_queue_pages_tail;
|
||||
if (CMD_QUEUE_PAGE_SIZE - (*p_page)->used < size)
|
||||
p_page = &((*p_page)->next);
|
||||
}
|
||||
|
@ -113,6 +113,7 @@ void *cmd_queue_alloc(size_t size)
|
|||
CMD_QUEUE_PAGE_SIZE : size;
|
||||
(*p_page)->address = malloc(alloc_size);
|
||||
(*p_page)->next = NULL;
|
||||
cmd_queue_pages_tail = *p_page;
|
||||
}
|
||||
|
||||
offset = (*p_page)->used;
|
||||
|
@ -134,6 +135,7 @@ static void cmd_queue_free(void)
|
|||
}
|
||||
|
||||
cmd_queue_pages = NULL;
|
||||
cmd_queue_pages_tail = NULL;
|
||||
}
|
||||
|
||||
void jtag_command_queue_reset(void)
|
||||
|
|
Loading…
Reference in New Issue