Skip to content

Commit 784bfa2

Browse files
xiaoguangwuwenlingz
authored andcommitted
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 <conghui.chen@intel.com> Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
1 parent e30cd45 commit 784bfa2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

devicemodel/hw/platform/usb_pmapper.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ usb_dev_data(void *pdata, struct usb_data_xfer *xfer, int dir, int epctx)
755755
int rc = 0, epid;
756756
uint8_t type;
757757
int blk_start, data_size, blk_count;
758-
int retries = 3, i, buf_idx;
758+
int retries = 3, i, j, buf_idx;
759759
struct usb_data_xfer_block *b;
760760
static const char * const type_str[] = {"CTRL", "ISO", "BULK", "INT"};
761761
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)
810810
data_size, dir_str[dir], type_str[type]);
811811

812812
if (!dir) {
813-
for (i = 0, buf_idx = 0; i < blk_count; i++) {
813+
for (i = 0, j = 0, buf_idx = 0; j < blk_count; ++i) {
814814
b = &xfer->data[(blk_start + i) % USB_MAX_XFER_BLOCKS];
815815
if (b->buf) {
816816
memcpy(&req->buffer[buf_idx], b->buf, b->blen);
817817
buf_idx += b->blen;
818+
j++;
818819
}
819820
}
820821
}

0 commit comments

Comments
 (0)