[OpenOCD-devel] [PATCH]: 17203a8 [RFC] mips: Enable bulk write optimization for all writes
This is an automated email from Gerrit. Andreas Fritiofson (andreas.fritiof...@gmail.com) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/1215 -- gerrit commit 17203a85b85cd5e1d0dd0d385de043975e05a363 Author: Andreas Fritiofson Date: Sat Mar 9 10:41:16 2013 +0100 [RFC] mips: Enable bulk write optimization for all writes mips_m4k_bulk_write_memory was only called from target_write_buffer as an optimization when the word count was large enough. Remove mips_m4k_bulk_write_memory from the target type, causing the default implementation to call the regular mips_m4k_write_memory instead. Perform the dispatch to bulk write in mips_m4k_write_memory, enabling the optimization for target_write_memory() writes with size 4, in addition to target_write_buffer() writes. It also enables making the choice of bulk write vs regular write specifically for the architecture and not relying on the generic target code to make a sensible decision. Change-Id: I295f21a67ceaa195802403f2518ea2e0a025c1c7 Signed-off-by: Andreas Fritiofson diff --git a/src/target/mips_m4k.c b/src/target/mips_m4k.c index fb4c376..9c78f2e 100644 --- a/src/target/mips_m4k.c +++ b/src/target/mips_m4k.c @@ -978,6 +978,13 @@ static int mips_m4k_write_memory(struct target *target, uint32_t address, return ERROR_TARGET_NOT_HALTED; } + if (size == 4 && count > 128) { + int retval = mips_m4k_bulk_write_memory(target, address, count, buffer); + if (retval == ERROR_OK) + return ERROR_OK; + LOG_WARNING("Falling back to non-bulk write"); + } + /* sanitize arguments */ if (((size != 4) && (size != 2) && (size != 1)) || (count == 0) || !(buffer)) return ERROR_COMMAND_SYNTAX_ERROR; @@ -1098,11 +1105,6 @@ static int mips_m4k_bulk_write_memory(struct target *target, uint32_t address, LOG_DEBUG("address: 0x%8.8" PRIx32 ", count: 0x%8.8" PRIx32 "", address, count); - if (target->state != TARGET_HALTED) { - LOG_WARNING("target not halted"); - return ERROR_TARGET_NOT_HALTED; - } - /* check alignment */ if (address & 0x3u) return ERROR_TARGET_UNALIGNED_ACCESS; @@ -1116,8 +1118,8 @@ static int mips_m4k_bulk_write_memory(struct target *target, uint32_t address, MIPS32_FASTDATA_HANDLER_SIZE, &mips32->fast_data_area); if (retval != ERROR_OK) { - LOG_WARNING("No working area available, falling back to non-bulk write"); - return mips_m4k_write_memory(target, address, 4, count, buffer); + LOG_ERROR("No working area available"); + return retval; } /* reset fastadata state so the algo get reloaded */ @@ -1141,11 +1143,8 @@ static int mips_m4k_bulk_write_memory(struct target *target, uint32_t address, if (t != NULL) free(t); - if (retval != ERROR_OK) { - /* FASTDATA access failed, try normal memory write */ - LOG_DEBUG("Fastdata access Failed, falling back to non-bulk write"); - retval = mips_m4k_write_memory(target, address, 4, count, buffer); - } + if (retval != ERROR_OK) + LOG_ERROR("Fastdata access Failed"); return retval; } @@ -1342,7 +1341,6 @@ struct target_type mips_m4k_target = { .read_memory = mips_m4k_read_memory, .write_memory = mips_m4k_write_memory, - .bulk_write_memory = mips_m4k_bulk_write_memory, .checksum_memory = mips32_checksum_memory, .blank_check_memory = mips32_blank_check_memory, -- -- Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the endpoint security space. For insight on selecting the right partner to tackle endpoint security challenges, access the full report. http://p.sf.net/sfu/symantec-dev2dev ___ OpenOCD-devel mailing list OpenOCD-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openocd-devel
Re: [OpenOCD-devel] [PATCH]: 17203a8 [RFC] mips: Enable bulk write optimization for all writes
On Sat, Mar 9, 2013 at 10:42 AM, wrote: > This is an automated email from Gerrit. > > Andreas Fritiofson (andreas.fritiof...@gmail.com) just uploaded a new > patch set to Gerrit, which you can find at http://openocd.zylin.com/1215 > > -- gerrit > > commit 17203a85b85cd5e1d0dd0d385de043975e05a363 > Author: Andreas Fritiofson > Date: Sat Mar 9 10:41:16 2013 +0100 > > [RFC] mips: Enable bulk write optimization for all writes > > mips_m4k_bulk_write_memory was only called from target_write_buffer as > an > optimization when the word count was large enough. > > Remove mips_m4k_bulk_write_memory from the target type, causing the > default > implementation to call the regular mips_m4k_write_memory instead. > > Perform the dispatch to bulk write in mips_m4k_write_memory, enabling > the > optimization for target_write_memory() writes with size 4, in addition > to > target_write_buffer() writes. > > It also enables making the choice of bulk write vs regular write > specifically for the architecture and not relying on the generic target > code to make a sensible decision. > > Change-Id: I295f21a67ceaa195802403f2518ea2e0a025c1c7 > Signed-off-by: Andreas Fritiofson > If this works, I'd like to do the same for the arm7_9 targets. So we could remove the ugly bulk_write_memory field from the target API entirely. Problem is, there are several targets that use arm7_9_bulk_write_memory directly for bulk writes, but have their own wrapper around the regular arm7_9_write_memory, with additional mmu/cache handling. My guess is that these are bugs, because it will depend on an arbitrary word count limit whether target_write_buffer() will go through or bypass the mmu/cache handling. But I have too little knowledge about these targets or the details of the respective memory write method, so I can't really say what's right or wrong here. Can anyone help out? Also, the arm7_9_write_memory is called in other ways too, specifically through the armv4_5_mmu struct. I don't know if it's a problem to allow the bulk write code to be run in those cases instead of the regular writes. Example targets are arm926ejs, arm946e and fa526 (arm920t). /Andreas -- Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the endpoint security space. For insight on selecting the right partner to tackle endpoint security challenges, access the full report. http://p.sf.net/sfu/symantec-dev2dev___ OpenOCD-devel mailing list OpenOCD-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openocd-devel
[OpenOCD-devel] [PATCH]: 426d90e jtag: opendous: fix tap buffer overflow
This is an automated email from Gerrit. Stefan Mahr (stefan.m...@sphairon.com) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/1216 -- gerrit commit 426d90ecfc725bda0ca8858762e8b59cdb686bbc Author: Stefan Mahr Date: Sat Mar 9 17:50:54 2013 +0100 jtag: opendous: fix tap buffer overflow Appending bits to TAP buffer doesn't check if there's enough space left. This patch adds this check to fix TAP overflow error. Change-Id: If80d5ab4a24983ad24f3cab31f9676d1590ebf5d Signed-off-by: Stefan Mahr diff --git a/src/jtag/drivers/opendous.c b/src/jtag/drivers/opendous.c index b13cbe0..efb6cf2 100644 --- a/src/jtag/drivers/opendous.c +++ b/src/jtag/drivers/opendous.c @@ -482,8 +482,9 @@ void opendous_tap_init(void) void opendous_tap_ensure_space(int scans, int bits) { int available_scans = MAX_PENDING_SCAN_RESULTS - pending_scan_results_length; + int available_bits = OPENDOUS_TAP_BUFFER_SIZE / 2 - tap_length; - if (scans > available_scans) + if ((scans > available_scans) || (bits > available_bits)) opendous_tap_execute(); } @@ -493,6 +494,8 @@ void opendous_tap_append_step(int tms, int tdi) unsigned char _tms = tms ? 1 : 0; unsigned char _tdi = tdi ? 1 : 0; + opendous_tap_ensure_space(0, 1); + int tap_index = tap_length / 4; int bits = (tap_length % 4) * 2; -- -- Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the endpoint security space. For insight on selecting the right partner to tackle endpoint security challenges, access the full report. http://p.sf.net/sfu/symantec-dev2dev ___ OpenOCD-devel mailing list OpenOCD-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openocd-devel