Skip to content

Commit a0ace72

Browse files
xiaoguangwuwenlingz
authored andcommitted
DM USB: xHCI: fix process logic of TRB which has zero data length
Accoring to xHCI spec, there are some TRBs with zero data length which used to pass command to xHCI. In the DM, those TRBs should not be sent to native device through libusb. The logic in the current implentation fails to process some corner cases, this patch is used to fix it. Tracked-On: #1639 Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com> Reviewed-by: Liang Yang <liang3.yang@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
1 parent 6266dd0 commit a0ace72

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

devicemodel/hw/platform/usb_pmapper.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,18 @@ usb_dev_comp_req(struct libusb_transfer *libusb_xfer)
245245
}
246246

247247
/* handle the blocks belong to this request */
248+
i = 0;
248249
buf_idx = 0;
249250
idx = req->blk_start;
250-
for (i = 0; i < req->blk_count; i++) {
251+
while (i < req->blk_count) {
251252
done = 0;
252253
block = &xfer->data[idx % USB_MAX_XFER_BLOCKS];
253254

254255
/* Link TRB need to be skipped */
255256
if (!block->buf || !block->blen) {
257+
/* FIXME: should change hard coded USB_MAX_XFER_BLOCKS
258+
* to dynamically mechanism to avoid dead loop.
259+
*/
256260
idx = (idx + 1) % USB_MAX_XFER_BLOCKS;
257261
continue;
258262
}
@@ -285,6 +289,7 @@ usb_dev_comp_req(struct libusb_transfer *libusb_xfer)
285289
block->blen = 0;
286290
}
287291
}
292+
i++;
288293
}
289294

290295
stall_out:

0 commit comments

Comments
 (0)