From: Oleksij Rempel Date: Thu, 18 Apr 2013 10:00:14 +0000 (+0200) Subject: do not wait forever on ejtag_dma_dstrt_poll X-Git-Tag: v0.8.0-rc1~348 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=21dfb6ee1a238beb7b6e7c1874768c8a9b996e0b;p=openocd do not wait forever on ejtag_dma_dstrt_poll Change-Id: I26adab09839795ecf363b7db912392bd5314cec5 Signed-off-by: Oleksij Rempel Reviewed-on: http://openocd.zylin.com/1344 Tested-by: jenkins Reviewed-by: Spencer Oliver --- diff --git a/src/target/mips32_dmaacc.c b/src/target/mips32_dmaacc.c index 733f96cf..eb6cd8ce 100644 --- a/src/target/mips32_dmaacc.c +++ b/src/target/mips32_dmaacc.c @@ -28,6 +28,7 @@ #endif #include "mips32_dmaacc.h" +#include static int mips32_dmaacc_read_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int count, uint8_t *buf); @@ -53,13 +54,20 @@ static int mips32_dmaacc_write_mem32(struct mips_ejtag *ejtag_info, * displaying/modifying memory and memory mapped registers. */ -static void ejtag_dma_dstrt_poll(struct mips_ejtag *ejtag_info) +static int ejtag_dma_dstrt_poll(struct mips_ejtag *ejtag_info) { uint32_t ejtag_ctrl; + int64_t start = timeval_ms(); + do { + if (timeval_ms() - start > 1000) { + LOG_ERROR("DMA time out"); + return -ETIMEDOUT; + } ejtag_ctrl = EJTAG_CTRL_DMAACC | ejtag_info->ejtag_ctrl; mips_ejtag_drscan_32(ejtag_info, &ejtag_ctrl); } while (ejtag_ctrl & EJTAG_CTRL_DSTRT); + return 0; } static int ejtag_dma_read(struct mips_ejtag *ejtag_info, uint32_t addr, uint32_t *data)