Skip to content

Commit cb93887

Browse files
xiaoguangwulijinxia
authored andcommitted
DM USB: modify some logs to help debug
Mainly change the logs for transfer submission and completion, which are very important parts in USB emulation code. Change-Id: I4e04f1426e164ca3693e70946ed51380201e49ee 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 aecb67b commit cb93887

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

devicemodel/hw/pci/xhci.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -497,27 +497,27 @@ pci_xhci_native_usb_dev_conn_cb(void *hci_data, void *dev_data)
497497
ue->ue_info(ud, USB_INFO_PORT, &native_port, sizeof(native_port));
498498
ue->ue_info(ud, USB_INFO_VID, &native_vid, sizeof(native_vid));
499499
ue->ue_info(ud, USB_INFO_PID, &native_pid, sizeof(native_pid));
500-
UPRINTF(LDBG, "%X:%X %d-%d connecting.\r\n",
500+
UPRINTF(LDBG, "%04x:%04x %d-%d connecting.\r\n",
501501
native_vid, native_pid, native_bus, native_port);
502502

503503
/* FIXME: will support usb3 in future */
504504
if (xdev->native_assign_ports[native_bus] &&
505505
usb_native_is_ss_port(native_bus)) {
506-
UPRINTF(LDBG, "%X:%X %d-%d not support usb3 device, exit.\r\n",
507-
native_vid, native_pid, native_bus,
508-
native_port);
506+
UPRINTF(LDBG, "%04x:%04x %d-%d be ignored due to superspeed"
507+
" device hasn't support yet\r\n", native_vid,
508+
native_pid, native_bus, native_port);
509509
goto errout;
510510
}
511511

512512
if (!xdev->native_assign_ports[native_bus] ||
513513
!xdev->native_assign_ports[native_bus][native_port]) {
514-
UPRINTF(LDBG, "%X:%X %d-%d doesn't belong to this vm, bye.\r\n",
515-
native_vid, native_pid, native_bus,
514+
UPRINTF(LDBG, "%04x:%04x %d-%d doesn't belong to this vm, bye."
515+
"\r\n", native_vid, native_pid, native_bus,
516516
native_port);
517517
goto errout;
518518
}
519519

520-
UPRINTF(LDBG, "%X:%X %d-%d belong to this vm.\r\n", native_vid,
520+
UPRINTF(LDBG, "%04x:%04x %d-%d belong to this vm.\r\n", native_vid,
521521
native_pid, native_bus, native_port);
522522

523523
if (ue->ue_usbver == 2)

devicemodel/hw/platform/usb_pmapper.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ usb_dev_comp_req(struct libusb_transfer *libusb_xfer)
2727
struct usb_data_xfer_block *block;
2828
int len, do_intr = 0, short_data = 0;
2929
int i, idx, buf_idx, done;
30+
int bstart, bcount;
3031

3132
assert(libusb_xfer);
3233
assert(libusb_xfer->user_data);
@@ -37,9 +38,15 @@ usb_dev_comp_req(struct libusb_transfer *libusb_xfer)
3738

3839
assert(xfer);
3940
assert(xfer->dev);
40-
UPRINTF(LDBG, "xfer_comp: ep %d with %d bytes. status %d,%d\n",
41-
req->xfer->epid, len, libusb_xfer->status,
42-
xfer->ndata);
41+
42+
bstart = req->blk_start;
43+
bcount = req->blk_count;
44+
UPRINTF(LDBG, "%s: actual_length %d ep%d-transfer (%d-%d %d) request-%d"
45+
" (%d-%d %d) status %d\r\n", __func__, len, xfer->epid,
46+
xfer->head, (xfer->tail - 1) % USB_MAX_XFER_BLOCKS,
47+
xfer->ndata, req->seq, bstart, (bstart + bcount - 1) %
48+
USB_MAX_XFER_BLOCKS, req->buf_length,
49+
libusb_xfer->status);
4350

4451
/* lock for protecting the transfer */
4552
USB_DATA_XFER_LOCK(xfer);
@@ -511,11 +518,6 @@ usb_dev_data(void *pdata, struct usb_data_xfer *xfer, int dir, int epctx)
511518
if (data_size <= 0)
512519
goto done;
513520

514-
UPRINTF(LDBG, "%s: DIR=%s|EP=%x|*%s*, data %d %d-%d\n", __func__,
515-
dir ? "IN" : "OUT", epid, type == USB_ENDPOINT_BULK ?
516-
"BULK" : "INT", data_size,
517-
blk_start, blk_start + blk_count - 1);
518-
519521
req = usb_dev_alloc_req(udev, xfer, dir, data_size);
520522
if (!req) {
521523
xfer->status = USB_ERR_IOERROR;
@@ -691,10 +693,10 @@ usb_dev_init(void *pdata, char *opt)
691693
port = libusb_get_port_number(ldev);
692694
bus = libusb_get_bus_number(ldev);
693695
libusb_get_device_descriptor(ldev, &desc);
694-
UPRINTF(LINF, "Found USB device: %d-%d\r\nPID(0x%X), VID(0x%X) "
695-
"CLASS(0x%X) SUBCLASS(0x%x) BCD(0x%x)\r\n", bus, port,
696-
desc.idProduct, desc.idVendor,
697-
desc.bDeviceClass, desc.bDeviceSubClass, desc.bcdUSB);
696+
UPRINTF(LINF, "Found USB device: %d-%d\r\nPID(0x%X), VID(0x%X) CLASS"
697+
"(0x%X) SUBCLASS(0x%X) BCD(0x%X) SPEED(%d)\r\n", bus,
698+
port, desc.idProduct, desc.idVendor, desc.bDeviceClass,
699+
desc.bDeviceSubClass, desc.bcdUSB, speed);
698700

699701
/* allocate and populate udev */
700702
udev = calloc(1, sizeof(struct usb_dev));

0 commit comments

Comments
 (0)