Module Name: src Committed By: skrll Date: Wed Dec 20 08:21:11 UTC 2017
Modified Files: src/sys/dev/usb: xhci.c Log Message: Fix the logic around TT Hub Slot ID, TT Port Number and Multi-TT in xhci_setup_tthub. TT Hub/Port need to reference the upstream HS hub and Multi-TT needs to reflect the capabilities of a HS hub itself or the same upstream HS hub. To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/sys/dev/usb/xhci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/usb/xhci.c diff -u src/sys/dev/usb/xhci.c:1.82 src/sys/dev/usb/xhci.c:1.83 --- src/sys/dev/usb/xhci.c:1.82 Tue Dec 19 16:04:27 2017 +++ src/sys/dev/usb/xhci.c Wed Dec 20 08:21:11 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: xhci.c,v 1.82 2017/12/19 16:04:27 skrll Exp $ */ +/* $NetBSD: xhci.c,v 1.83 2017/12/20 08:21:11 skrll Exp $ */ /* * Copyright (c) 2013 Jonathan A. Kollasch @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.82 2017/12/19 16:04:27 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.83 2017/12/20 08:21:11 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -3134,10 +3134,10 @@ static void xhci_setup_tthub(struct usbd_pipe *pipe, uint32_t *cp) { struct usbd_device *dev = pipe->up_dev; - struct usbd_device *myhub = dev->ud_myhub; struct usbd_port *myhsport = dev->ud_myhsport; usb_device_descriptor_t * const dd = &dev->ud_ddesc; uint32_t speed = dev->ud_speed; + uint8_t rhaddr = dev->ud_bus->ub_rhaddr; uint8_t tthubslot, ttportnum; bool ishub; bool usemtt; @@ -3159,8 +3159,8 @@ xhci_setup_tthub(struct usbd_pipe *pipe, * parent hub is not HS hub || * attached to root hub. */ - if (myhsport && myhub && myhub->ud_depth && - myhub->ud_speed == USB_SPEED_HIGH && + if (myhsport && + myhsport->up_parent->ud_addr != rhaddr && (speed == USB_SPEED_LOW || speed == USB_SPEED_FULL)) { ttportnum = myhsport->up_portno; tthubslot = myhsport->up_parent->ud_addr; @@ -3185,29 +3185,30 @@ xhci_setup_tthub(struct usbd_pipe *pipe, DPRINTFN(4, "nports=%jd ttt=%jd", hd->bNbrPorts, ttt, 0, 0); } -#define IS_TTHUB(dd) \ - ((dd)->bDeviceProtocol == UDPROTO_HSHUBSTT || \ - (dd)->bDeviceProtocol == UDPROTO_HSHUBMTT) +#define IS_MTTHUB(dd) \ + ((dd)->bDeviceProtocol == UDPROTO_HSHUBMTT) /* * MTT flag is set if - * 1. this is HS hub && MTT is enabled - * or - * 2. this is not hub && this is LS or FS device && - * MTT of parent HS hub (and its parent, too) is enabled + * 1. this is HS hub && MTTs are supported and enabled; or + * 2. this is LS or FS device && there is a parent HS hub where MTTs + * are supported and enabled. + * + * XXX enabled is not tested yet */ - if (ishub && speed == USB_SPEED_HIGH && IS_TTHUB(dd)) + if (ishub && speed == USB_SPEED_HIGH && IS_MTTHUB(dd)) usemtt = true; - else if (!ishub && (speed == USB_SPEED_LOW || speed == USB_SPEED_FULL) && - myhub && myhub->ud_depth && myhub->ud_speed == USB_SPEED_HIGH && - myhsport && IS_TTHUB(&myhsport->up_parent->ud_ddesc)) + else if ((speed == USB_SPEED_LOW || speed == USB_SPEED_FULL) && + myhsport && + myhsport->up_parent->ud_addr != rhaddr && + IS_MTTHUB(&myhsport->up_parent->ud_ddesc)) usemtt = true; else usemtt = false; DPRINTFN(4, "class %ju proto %ju ishub %jd usemtt %jd", dd->bDeviceClass, dd->bDeviceProtocol, ishub, usemtt); -#undef IS_TTHUB +#undef IS_MTTHUB cp[0] |= XHCI_SCTX_0_HUB_SET(ishub ? 1 : 0) |