host: libbladeRF/sync: extend transfer timeout to match stream timeout
In a case where we have a long stream timeout, e.g. when using
triggered receive, the long stream timeout is being rendered
ineffective by the per-transfer timeout, which defaults to
1000 ms.
This adds two functions to async, for setting and getting the
transfer timeout:
int async_set_transfer_timeout(struct bladerf_stream *stream,
unsigned int transfer_timeout_ms);
int async_get_transfer_timeout(struct bladerf_stream *stream,
unsigned int *transfer_timeout_ms);
This also calls async_set_transfer_timeout in sync_worker_init,
setting it to either the BULK_TIMEOUT_MS from usb.h (1000 ms)
or the timeout_ms for the stream (user-specified), whichever is
longer.
This commit is contained in:
parent
ecf2f711dd
commit
d73fd39ac7
3 changed files with 38 additions and 0 deletions
|
|
@ -143,6 +143,26 @@ int async_init_stream(struct bladerf_stream **stream,
|
|||
return status;
|
||||
}
|
||||
|
||||
int async_set_transfer_timeout(struct bladerf_stream *stream,
|
||||
unsigned int transfer_timeout_ms)
|
||||
{
|
||||
MUTEX_LOCK(&stream->lock);
|
||||
stream->transfer_timeout = transfer_timeout_ms;
|
||||
MUTEX_UNLOCK(&stream->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int async_get_transfer_timeout(struct bladerf_stream *stream,
|
||||
unsigned int *transfer_timeout_ms)
|
||||
{
|
||||
MUTEX_LOCK(&stream->lock);
|
||||
*transfer_timeout_ms = stream->transfer_timeout;
|
||||
MUTEX_UNLOCK(&stream->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int async_run_stream(struct bladerf_stream *stream, bladerf_channel_layout layout)
|
||||
{
|
||||
int status;
|
||||
|
|
|
|||
|
|
@ -79,6 +79,14 @@ int async_init_stream(struct bladerf_stream **stream,
|
|||
size_t num_transfers,
|
||||
void *user_data);
|
||||
|
||||
/* Set the transfer timeout. This acquires stream->lock. */
|
||||
int async_set_transfer_timeout(struct bladerf_stream *stream,
|
||||
unsigned int transfer_timeout_ms);
|
||||
|
||||
/* Get the transfer timeout. This acquires stream->lock. */
|
||||
int async_get_transfer_timeout(struct bladerf_stream *stream,
|
||||
unsigned int *transfer_timeout_ms);
|
||||
|
||||
/* Backend code is responsible for acquiring stream->lock in their callbacks */
|
||||
int async_run_stream(struct bladerf_stream *stream,
|
||||
bladerf_channel_layout layout);
|
||||
|
|
|
|||
|
|
@ -30,12 +30,14 @@
|
|||
#endif
|
||||
#include "rel_assert.h"
|
||||
#include "conversions.h"
|
||||
#include "minmax.h"
|
||||
|
||||
#include "async.h"
|
||||
#include "sync.h"
|
||||
#include "sync_worker.h"
|
||||
|
||||
#include "board/board.h"
|
||||
#include "backend/usb/usb.h"
|
||||
|
||||
#define worker2str(s) (direction2str(s->stream_config.layout & BLADERF_DIRECTION_MASK))
|
||||
|
||||
|
|
@ -213,6 +215,14 @@ int sync_worker_init(struct bladerf_sync *s)
|
|||
goto worker_init_out;
|
||||
}
|
||||
|
||||
status = async_set_transfer_timeout(
|
||||
s->worker->stream,
|
||||
uint_max(s->stream_config.timeout_ms, BULK_TIMEOUT_MS));
|
||||
if (status != 0) {
|
||||
log_debug("%s worker: Failed to set transfer timeout: %s\n",
|
||||
worker2str(s), bladerf_strerror(status));
|
||||
goto worker_init_out;
|
||||
}
|
||||
|
||||
MUTEX_INIT(&s->worker->state_lock);
|
||||
MUTEX_INIT(&s->worker->request_lock);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue