diff options
author | Tim Newsome <tim@sifive.com> | 2018-09-12 09:08:19 -0700 |
---|---|---|
committer | Tim Newsome <tim@sifive.com> | 2018-09-12 09:08:19 -0700 |
commit | af501f4905ec0118cf66faa39ac98d9f81313cae (patch) | |
tree | 187663d1d2b9ebef4874573e7b6e54b0bfaa1c85 /src | |
parent | 933cb875a8fb6243df52208c725b1c6ebc9662e3 (diff) | |
download | riscv-openocd-af501f4905ec0118cf66faa39ac98d9f81313cae.zip riscv-openocd-af501f4905ec0118cf66faa39ac98d9f81313cae.tar.gz riscv-openocd-af501f4905ec0118cf66faa39ac98d9f81313cae.tar.bz2 |
Add wall clock timeout to mpsse_flush()
I think that libusb_handle_events_timeout_completed is supposed to make
progress or time out, but sometimes we hit a case where it makes no
progress, and mpsse_flush() loops forever. This wall clock timeout kicks
it out of that loop. OpenOCD appears to die afterwards, but that's still
an improvement.
Change-Id: Id9220557625834fb5b7dccf65251651a11a887f0
Diffstat (limited to 'src')
-rw-r--r-- | src/jtag/drivers/mpsse.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/jtag/drivers/mpsse.c b/src/jtag/drivers/mpsse.c index 06d008b..c9c19d0 100644 --- a/src/jtag/drivers/mpsse.c +++ b/src/jtag/drivers/mpsse.c @@ -892,6 +892,7 @@ int mpsse_flush(struct mpsse_ctx *ctx) } /* Polling loop, more or less taken from libftdi */ + int64_t start = timeval_ms(); while (!write_result.done || !read_result.done) { struct timeval timeout_usb; @@ -914,6 +915,11 @@ int mpsse_flush(struct mpsse_ctx *ctx) break; } } + + if (timeval_ms() - start > 2000) { + LOG_ERROR("Timed out handling USB events in mpsse_flush()."); + break; + } } error_check: |