This is an automated email from Gerrit.

Matthias Welwarsky (matth...@welwarsky.de) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/3167

-- gerrit

commit 10d2491a27ef6538825290290b830416ff0e696a
Author: Matthias Welwarsky <matth...@welwarsky.de>
Date:   Sat Dec 12 21:14:19 2015 +0100

    arm_debug: optimize DP and AP reads over JTAG
    
    On JTAG, all reads are pipelined. If you read a register, the result is not
    delivered inside the request that issued the read, it is delivered in the
    following request. The current code therefore issues a read of the RDBUFF
    register after each read. This adds a superfluous read access after each 
read.
    
    This patch follows the same strategy the SWD transport already implements.
    For consecutive reads, the result of each read is collected with the next
    read access. When the next access is a "write", a RDBUFF read is queued
    before. The result of the final read is captured in dap_run().
    
    This should double the throughput on memory reads.
    
    Change-Id: Ie40b1fef3203f0cdcb503f40dcbd2a68b0f9776c
    Signed-off-by: Matthias Welwarsky <matth...@welwarsky.de>

diff --git a/src/target/adi_v5_jtag.c b/src/target/adi_v5_jtag.c
index eeec7c8..687785b 100644
--- a/src/target/adi_v5_jtag.c
+++ b/src/target/adi_v5_jtag.c
@@ -299,14 +299,13 @@ static int adi_jtag_dp_scan_u32(struct adiv5_dap *dap,
        return retval;
 }
 
-/**
- * Utility to write AP registers.
- */
-static inline int adi_jtag_ap_write_check(struct adiv5_ap *ap,
-               uint8_t reg_addr, uint8_t *outvalue)
+static void adi_jtag_finish_read(struct adiv5_dap *dap)
 {
-       return adi_jtag_dp_scan(ap->dap, JTAG_DP_APACC, reg_addr, DPAP_WRITE,
-                       outvalue, NULL, ap->memaccess_tck);
+       if (dap->last_read != NULL) {
+               adi_jtag_dp_scan_u32(dap, JTAG_DP_DPACC,
+                               DP_RDBUFF, DPAP_READ, 0, dap->last_read, 0);
+               dap->last_read = NULL;
+       }
 }
 
 static int adi_jtag_scan_inout_check_u32(struct adiv5_dap *dap,
@@ -448,13 +447,16 @@ static int jtagdp_transaction_endcheck(struct adiv5_dap 
*dap)
 static int jtag_dp_q_read(struct adiv5_dap *dap, unsigned reg,
                uint32_t *data)
 {
-       return adi_jtag_scan_inout_check_u32(dap, JTAG_DP_DPACC,
-                       reg, DPAP_READ, 0, data, 0);
+       int retval =  adi_jtag_dp_scan_u32(dap, JTAG_DP_DPACC, reg,
+                       DPAP_READ, 0, dap->last_read, 0);
+       dap->last_read = data;
+       return retval;
 }
 
 static int jtag_dp_q_write(struct adiv5_dap *dap, unsigned reg,
                uint32_t data)
 {
+       adi_jtag_finish_read(dap);
        return adi_jtag_scan_inout_check_u32(dap, JTAG_DP_DPACC,
                        reg, DPAP_WRITE, data, NULL, 0);
 }
@@ -477,26 +479,25 @@ static int jtag_ap_q_read(struct adiv5_ap *ap, unsigned 
reg,
                uint32_t *data)
 {
        int retval = jtag_ap_q_bankselect(ap, reg);
-
        if (retval != ERROR_OK)
                return retval;
 
-       return adi_jtag_scan_inout_check_u32(ap->dap, JTAG_DP_APACC, reg,
-                       DPAP_READ, 0, data, ap->memaccess_tck);
+       retval =  adi_jtag_dp_scan_u32(ap->dap, JTAG_DP_APACC, reg,
+                       DPAP_READ, 0, ap->dap->last_read, ap->memaccess_tck);
+       ap->dap->last_read = data;
+
+       return retval;
 }
 
 static int jtag_ap_q_write(struct adiv5_ap *ap, unsigned reg,
                uint32_t data)
 {
-       uint8_t out_value_buf[4];
-
        int retval = jtag_ap_q_bankselect(ap, reg);
        if (retval != ERROR_OK)
                return retval;
 
-       buf_set_u32(out_value_buf, 0, 32, data);
-
-       return adi_jtag_ap_write_check(ap, reg, out_value_buf);
+       return adi_jtag_dp_scan_u32(ap->dap, JTAG_DP_APACC, reg,
+                       DPAP_WRITE, data, NULL, ap->memaccess_tck);
 }
 
 static int jtag_ap_q_abort(struct adiv5_dap *dap, uint8_t *ack)
@@ -508,6 +509,7 @@ static int jtag_ap_q_abort(struct adiv5_dap *dap, uint8_t 
*ack)
 
 static int jtag_dp_run(struct adiv5_dap *dap)
 {
+       adi_jtag_finish_read(dap);
        return jtagdp_transaction_endcheck(dap);
 }
 

-- 

------------------------------------------------------------------------------
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to