Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions firehose.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ static int firehose_write(struct qdl_device *qdl, xmlDoc *doc)
for (;;) {
ux_debug("FIREHOSE WRITE: %s\n", s);
vip_gen_chunk_update(qdl, s, len);
ret = qdl_write(qdl, s, len);
ret = qdl_write(qdl, s, len, 1000);
saved_errno = errno;

/*
Expand Down Expand Up @@ -560,7 +560,7 @@ static int firehose_program(struct qdl_device *qdl, struct program *program, int

vip_transfer_clear_status(qdl);
}
n = qdl_write(qdl, buf, chunk_size * sector_size);
n = qdl_write(qdl, buf, chunk_size * sector_size, 10000);
if (n < 0) {
ux_err("USB write failed for data chunk\n");
ret = firehose_read(qdl, 30000, firehose_generic_parser, NULL);
Expand Down
5 changes: 3 additions & 2 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ int qdl_read(struct qdl_device *qdl, void *buf, size_t len, unsigned int timeout
* @qdl: device handle
* @buf: buffer with data to be written
* @len: length of data to be written
* @timeout: timeout for write, in milliseconds
*
* Returns: number of bytes read
* negative errno on failure (notably -ETIMEDOUT)
*/
int qdl_write(struct qdl_device *qdl, const void *buf, size_t len)
int qdl_write(struct qdl_device *qdl, const void *buf, size_t len, unsigned int timeout)
{
return qdl->write(qdl, buf, len);
return qdl->write(qdl, buf, len, timeout);
}
2 changes: 1 addition & 1 deletion ks.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int qdl_read(struct qdl_device *qdl, void *buf, size_t len, unsigned int timeout
return read(qdl->fd, buf, len);
}

int qdl_write(struct qdl_device *qdl, const void *buf, size_t len)
int qdl_write(struct qdl_device *qdl, const void *buf, size_t len, unsigned int timeout)
{
return write(qdl->fd, buf, len);
}
Expand Down
4 changes: 2 additions & 2 deletions qdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct qdl_device {

int (*open)(struct qdl_device *qdl, const char *serial);
int (*read)(struct qdl_device *qdl, void *buf, size_t len, unsigned int timeout);
int (*write)(struct qdl_device *qdl, const void *buf, size_t nbytes);
int (*write)(struct qdl_device *qdl, const void *buf, size_t nbytes, unsigned int timeout);
void (*close)(struct qdl_device *qdl);
void (*set_out_chunk_size)(struct qdl_device *qdl, long size);
void (*set_vip_transfer)(struct qdl_device *qdl, const char *signed_table,
Expand All @@ -61,7 +61,7 @@ void qdl_deinit(struct qdl_device *qdl);
int qdl_open(struct qdl_device *qdl, const char *serial);
void qdl_close(struct qdl_device *qdl);
int qdl_read(struct qdl_device *qdl, void *buf, size_t len, unsigned int timeout);
int qdl_write(struct qdl_device *qdl, const void *buf, size_t len);
int qdl_write(struct qdl_device *qdl, const void *buf, size_t len, unsigned int timeout);
void qdl_set_out_chunk_size(struct qdl_device *qdl, long size);
int qdl_vip_transfer_enable(struct qdl_device *qdl, const char *vip_table_path);

Expand Down
18 changes: 10 additions & 8 deletions sahara.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@

#define DEBUG_BLOCK_SIZE (512 * 1024)

#define SAHARA_CMD_TIMEOUT_MS 1000

struct sahara_pkt {
uint32_t cmd;
uint32_t length;
Expand Down Expand Up @@ -120,7 +122,7 @@ static void sahara_send_reset(struct qdl_device *qdl)
resp.cmd = SAHARA_RESET_CMD;
resp.length = SAHARA_RESET_LENGTH;

qdl_write(qdl, &resp, resp.length);
qdl_write(qdl, &resp, resp.length, SAHARA_CMD_TIMEOUT_MS);
}

static void sahara_hello(struct qdl_device *qdl, struct sahara_pkt *pkt)
Expand All @@ -139,7 +141,7 @@ static void sahara_hello(struct qdl_device *qdl, struct sahara_pkt *pkt)
resp.hello_resp.status = SAHARA_SUCCESS;
resp.hello_resp.mode = pkt->hello_req.mode;

qdl_write(qdl, &resp, resp.length);
qdl_write(qdl, &resp, resp.length, SAHARA_CMD_TIMEOUT_MS);
}

static int sahara_read_common(struct qdl_device *qdl, int progfd, off_t offset, size_t len)
Expand All @@ -159,7 +161,7 @@ static int sahara_read_common(struct qdl_device *qdl, int progfd, off_t offset,
goto out;
}

n = qdl_write(qdl, buf, n);
n = qdl_write(qdl, buf, n, SAHARA_CMD_TIMEOUT_MS);
if (n != len)
err(1, "failed to write %zu bytes to sahara", len);

Expand Down Expand Up @@ -259,7 +261,7 @@ static void sahara_eoi(struct qdl_device *qdl, struct sahara_pkt *pkt)

done.cmd = SAHARA_DONE_CMD;
done.length = SAHARA_DONE_LENGTH;
qdl_write(qdl, &done, done.length);
qdl_write(qdl, &done, done.length, SAHARA_CMD_TIMEOUT_MS);
}

static int sahara_done(struct qdl_device *qdl, struct sahara_pkt *pkt)
Expand Down Expand Up @@ -309,7 +311,7 @@ static ssize_t sahara_debug64_one(struct qdl_device *qdl,
read_req.length = SAHARA_MEM_READ64_LENGTH;
read_req.debug64_req.addr = region.addr + chunk;
read_req.debug64_req.length = remain;
n = qdl_write(qdl, &read_req, read_req.length);
n = qdl_write(qdl, &read_req, read_req.length, SAHARA_CMD_TIMEOUT_MS);
if (n < 0)
break;

Expand Down Expand Up @@ -405,13 +407,13 @@ static void sahara_debug64(struct qdl_device *qdl, struct sahara_pkt *pkt,
read_req.debug64_req.addr = pkt->debug64_req.addr;
read_req.debug64_req.length = pkt->debug64_req.length;

n = qdl_write(qdl, &read_req, read_req.length);
n = qdl_write(qdl, &read_req, read_req.length, SAHARA_CMD_TIMEOUT_MS);
if (n < 0)
return;

table = malloc(read_req.debug64_req.length);

n = qdl_read(qdl, table, pkt->debug64_req.length, 1000);
n = qdl_read(qdl, table, pkt->debug64_req.length, SAHARA_CMD_TIMEOUT_MS);
if (n < 0)
return;

Expand Down Expand Up @@ -451,7 +453,7 @@ int sahara_run(struct qdl_device *qdl, char *img_arr[], bool single_image,
return 0;

while (!done) {
n = qdl_read(qdl, buf, sizeof(buf), 1000);
n = qdl_read(qdl, buf, sizeof(buf), SAHARA_CMD_TIMEOUT_MS);
if (n < 0) {
ux_err("failed to read sahara request from device\n");
break;
Expand Down
2 changes: 1 addition & 1 deletion sim.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static int sim_read(struct qdl_device *qdl, void *buf, size_t len, unsigned int
return len;
}

static int sim_write(struct qdl_device *qdl, const void *buf, size_t len)
static int sim_write(struct qdl_device *qdl, const void *buf, size_t len, unsigned int timeout)
{
return len;
}
Expand Down
6 changes: 3 additions & 3 deletions usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ static int usb_read(struct qdl_device *qdl, void *buf, size_t len, unsigned int
return actual;
}

static int usb_write(struct qdl_device *qdl, const void *buf, size_t len)
static int usb_write(struct qdl_device *qdl, const void *buf, size_t len, unsigned int timeout)
{
unsigned char *data = (unsigned char *)buf;
struct qdl_device_usb *qdl_usb = container_of(qdl, struct qdl_device_usb, base);
Expand All @@ -261,7 +261,7 @@ static int usb_write(struct qdl_device *qdl, const void *buf, size_t len)
xfer = (len > qdl_usb->out_chunk_size) ? qdl_usb->out_chunk_size : len;

ret = libusb_bulk_transfer(qdl_usb->usb_handle, qdl_usb->out_ep, data,
xfer, &actual, 1000);
xfer, &actual, timeout);
if (ret != 0 && ret != LIBUSB_ERROR_TIMEOUT) {
warnx("bulk write failed: %s", libusb_strerror(ret));
return -EIO;
Expand All @@ -276,7 +276,7 @@ static int usb_write(struct qdl_device *qdl, const void *buf, size_t len)

if (len_orig % qdl_usb->out_maxpktsize == 0) {
ret = libusb_bulk_transfer(qdl_usb->usb_handle, qdl_usb->out_ep, NULL,
0, &actual, 1000);
0, &actual, timeout);
if (ret < 0)
return -EIO;
}
Expand Down
2 changes: 1 addition & 1 deletion vip.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ static int vip_transfer_send_raw(struct qdl_device *qdl, int table_fd)
goto out;
}

n = qdl_write(qdl, buf, sb.st_size);
n = qdl_write(qdl, buf, sb.st_size, 1000);
if (n < 0) {
ux_err("USB write failed for data chunk\n");
ret = -1;
Expand Down