From 784bfa28aef31e8640e56ac261d6a1884169b289 Mon Sep 17 00:00:00 2001 From: Xiaoguang Wu Date: Tue, 19 Feb 2019 12:50:18 +0800 Subject: [PATCH] DM USB: xHCI: fix an issue during BULK transfer When LINK type TRB are received among multiple BULK TRBs, the copying logic in DM will miss one or more TRBs. This patch is used to fix it. Tracked-On: #2926 Signed-off-by: Conghui Chen Signed-off-by: Xiaoguang Wu Acked-by: Yu Wang --- devicemodel/hw/platform/usb_pmapper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/devicemodel/hw/platform/usb_pmapper.c b/devicemodel/hw/platform/usb_pmapper.c index 5a4d58a50..58c72ed29 100755 --- a/devicemodel/hw/platform/usb_pmapper.c +++ b/devicemodel/hw/platform/usb_pmapper.c @@ -755,7 +755,7 @@ usb_dev_data(void *pdata, struct usb_data_xfer *xfer, int dir, int epctx) int rc = 0, epid; uint8_t type; int blk_start, data_size, blk_count; - int retries = 3, i, buf_idx; + int retries = 3, i, j, buf_idx; struct usb_data_xfer_block *b; static const char * const type_str[] = {"CTRL", "ISO", "BULK", "INT"}; static const char * const dir_str[] = {"OUT", "IN"}; @@ -810,11 +810,12 @@ usb_dev_data(void *pdata, struct usb_data_xfer *xfer, int dir, int epctx) data_size, dir_str[dir], type_str[type]); if (!dir) { - for (i = 0, buf_idx = 0; i < blk_count; i++) { + for (i = 0, j = 0, buf_idx = 0; j < blk_count; ++i) { b = &xfer->data[(blk_start + i) % USB_MAX_XFER_BLOCKS]; if (b->buf) { memcpy(&req->buffer[buf_idx], b->buf, b->blen); buf_idx += b->blen; + j++; } } }