From owner-svn-src-stable-8@freebsd.org Wed Jun 29 10:25:34 2016 Return-Path: Delivered-To: svn-src-stable-8@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 552DBB84493; Wed, 29 Jun 2016 10:25:34 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2C6F221B7; Wed, 29 Jun 2016 10:25:34 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TAPXv6053908; Wed, 29 Jun 2016 10:25:33 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TAPXaT053905; Wed, 29 Jun 2016 10:25:33 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201606291025.u5TAPXaT053905@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 29 Jun 2016 10:25:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r302268 - stable/8/sys/dev/usb/controller X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jun 2016 10:25:34 -0000 Author: hselasky Date: Wed Jun 29 10:25:32 2016 New Revision: 302268 URL: https://svnweb.freebsd.org/changeset/base/302268 Log: MFC r302076: Update the definition for number of scratch pages to match the latest version of the XHCI specification. Make sure the code can handle the maximum number of allowed scratch pages. Submitted by: Shichun_Ma@Dell.com Modified: stable/8/sys/dev/usb/controller/xhci.c stable/8/sys/dev/usb/controller/xhci.h stable/8/sys/dev/usb/controller/xhcireg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/dev/ (props changed) stable/8/sys/dev/usb/ (props changed) Modified: stable/8/sys/dev/usb/controller/xhci.c ============================================================================== --- stable/8/sys/dev/usb/controller/xhci.c Wed Jun 29 10:23:19 2016 (r302267) +++ stable/8/sys/dev/usb/controller/xhci.c Wed Jun 29 10:25:32 2016 (r302268) @@ -199,7 +199,7 @@ static void xhci_iterate_hw_softc(struct usb_bus *bus, usb_bus_mem_sub_cb_t *cb) { struct xhci_softc *sc = XHCI_BUS2SC(bus); - uint8_t i; + uint16_t i; cb(bus, &sc->sc_hw.root_pc, &sc->sc_hw.root_pg, sizeof(struct xhci_hw_root), XHCI_PAGE_SIZE); @@ -207,7 +207,7 @@ xhci_iterate_hw_softc(struct usb_bus *bu cb(bus, &sc->sc_hw.ctx_pc, &sc->sc_hw.ctx_pg, sizeof(struct xhci_dev_ctx_addr), XHCI_PAGE_SIZE); - for (i = 0; i != XHCI_MAX_SCRATCHPADS; i++) { + for (i = 0; i != sc->sc_noscratch; i++) { cb(bus, &sc->sc_hw.scratch_pc[i], &sc->sc_hw.scratch_pg[i], XHCI_PAGE_SIZE, XHCI_PAGE_SIZE); } Modified: stable/8/sys/dev/usb/controller/xhci.h ============================================================================== --- stable/8/sys/dev/usb/controller/xhci.h Wed Jun 29 10:23:19 2016 (r302267) +++ stable/8/sys/dev/usb/controller/xhci.h Wed Jun 29 10:25:32 2016 (r302268) @@ -30,7 +30,7 @@ #define XHCI_MAX_DEVICES MIN(USB_MAX_DEVICES, 128) #define XHCI_MAX_ENDPOINTS 32 /* hardcoded - do not change */ -#define XHCI_MAX_SCRATCHPADS 32 +#define XHCI_MAX_SCRATCHPADS 1024 #define XHCI_MAX_EVENTS (16 * 13) #define XHCI_MAX_COMMANDS (16 * 1) #define XHCI_MAX_RSEG 1 @@ -486,14 +486,15 @@ struct xhci_softc { uint16_t sc_command_idx; uint16_t sc_imod_default; + /* number of scratch pages */ + uint16_t sc_noscratch; + uint8_t sc_event_ccs; uint8_t sc_command_ccs; /* number of XHCI device slots */ uint8_t sc_noslot; /* number of ports on root HUB */ uint8_t sc_noport; - /* number of scratch pages */ - uint8_t sc_noscratch; /* root HUB device configuration */ uint8_t sc_conf; /* root HUB port event bitmap, max 256 ports */ Modified: stable/8/sys/dev/usb/controller/xhcireg.h ============================================================================== --- stable/8/sys/dev/usb/controller/xhcireg.h Wed Jun 29 10:23:19 2016 (r302267) +++ stable/8/sys/dev/usb/controller/xhcireg.h Wed Jun 29 10:25:32 2016 (r302268) @@ -52,8 +52,8 @@ #define XHCI_HCSPARAMS2 0x08 /* RO structual parameters 2 */ #define XHCI_HCS2_IST(x) ((x) & 0xF) #define XHCI_HCS2_ERST_MAX(x) (((x) >> 4) & 0xF) -#define XHCI_HCS2_SPR(x) (((x) >> 24) & 0x1) -#define XHCI_HCS2_SPB_MAX(x) (((x) >> 27) & 0x7F) +#define XHCI_HCS2_SPR(x) (((x) >> 26) & 0x1) +#define XHCI_HCS2_SPB_MAX(x) ((((x) >> 16) & 0x3E0) | (((x) >> 27) & 0x1F)) #define XHCI_HCSPARAMS3 0x0C /* RO structual parameters 3 */ #define XHCI_HCS3_U1_DEL(x) ((x) & 0xFF) #define XHCI_HCS3_U2_DEL(x) (((x) >> 16) & 0xFFFF) From owner-svn-src-stable-8@freebsd.org Wed Jun 29 10:47:46 2016 Return-Path: Delivered-To: svn-src-stable-8@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 28CECB84C1C; Wed, 29 Jun 2016 10:47:46 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ED455221C; Wed, 29 Jun 2016 10:47:45 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5TAlj0N061516; Wed, 29 Jun 2016 10:47:45 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5TAlj5J061515; Wed, 29 Jun 2016 10:47:45 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201606291047.u5TAlj5J061515@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 29 Jun 2016 10:47:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r302274 - stable/8/lib/libusb X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jun 2016 10:47:46 -0000 Author: hselasky Date: Wed Jun 29 10:47:44 2016 New Revision: 302274 URL: https://svnweb.freebsd.org/changeset/base/302274 Log: MFC r301842: Implement code to stop all USB endpoints before executing a USB device reset command, alternate setting command or set configuration command. Else LibUSB v1.0 will not re-open the endpoints which the kernel closes and the USB application might wait infinitely for transfers to complete. Modified: stable/8/lib/libusb/libusb10.c Directory Properties: stable/8/lib/ (props changed) stable/8/lib/libusb/ (props changed) Modified: stable/8/lib/libusb/libusb10.c ============================================================================== --- stable/8/lib/libusb/libusb10.c Wed Jun 29 10:46:10 2016 (r302273) +++ stable/8/lib/libusb/libusb10.c Wed Jun 29 10:47:44 2016 (r302274) @@ -45,6 +45,8 @@ #include "libusb.h" #include "libusb10.h" +#define LIBUSB_NUM_SW_ENDPOINTS (16 * 4) + static pthread_mutex_t default_context_lock = PTHREAD_MUTEX_INITIALIZER; struct libusb_context *usbi_default_context = NULL; @@ -423,7 +425,7 @@ libusb_open(libusb_device *dev, libusb_d if (dev == NULL) return (LIBUSB_ERROR_INVALID_PARAM); - err = libusb20_dev_open(pdev, 16 * 4 /* number of endpoints */ ); + err = libusb20_dev_open(pdev, LIBUSB_NUM_SW_ENDPOINTS); if (err) { libusb_unref_device(dev); return (LIBUSB_ERROR_NO_MEM); @@ -1476,7 +1478,17 @@ libusb_cancel_transfer(struct libusb_tra UNEXPORTED void libusb10_cancel_all_transfer(libusb_device *dev) { - /* TODO */ + struct libusb20_device *pdev = dev->os_priv; + unsigned x; + + for (x = 0; x != LIBUSB_NUM_SW_ENDPOINTS; x++) { + struct libusb20_transfer *xfer; + + xfer = libusb20_tr_get_pointer(pdev, x); + if (xfer == NULL) + continue; + libusb20_tr_close(xfer); + } } uint16_t