From owner-freebsd-usb@FreeBSD.ORG Fri Jul 22 08:24:25 2011 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3BC74106566C for ; Fri, 22 Jul 2011 08:24:25 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe08.c2i.net [212.247.154.226]) by mx1.freebsd.org (Postfix) with ESMTP id 9E4268FC0C for ; Fri, 22 Jul 2011 08:24:24 +0000 (UTC) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.1 cv=0STrgBBJ/IeSzGUncdVPgrlXwYQACyAaeTEJnWJdz8Q= c=1 sm=1 a=B37yEVmeHOAA:10 a=WQU8e4WWZSUA:10 a=CL8lFSKtTFcA:10 a=i9M/sDlu2rpZ9XS819oYzg==:17 a=jhyeloKOAAAA:8 a=B-G0EbpaNDZIYBYEuo0A:9 a=wPNLvfGTeEIA:10 a=eJg08dc81Si69qdiwlIA:9 a=l3uftYnR-8fSCb2oghUA:7 a=i9M/sDlu2rpZ9XS819oYzg==:117 Received: from [188.126.198.129] (account mc467741@c2i.net HELO laptop002.hselasky.homeunix.org) by mailfe08.swip.net (CommuniGate Pro SMTP 5.2.19) with ESMTPA id 155814927; Fri, 22 Jul 2011 10:24:22 +0200 To: freebsd-usb@freebsd.org From: Hans Petter Selasky X-Face: *nPdTl_}RuAI6^PVpA02T?$%Xa^>@hE0uyUIoiha$pC:9TVgl.Oq,NwSZ4V" =?iso-8859-15?q?=7CLR=2E+tj=7Dg5=0A=09=25V?=,x^qOs~mnU3]Gn; cQLv&.N>TrxmSFf+p6(30a/{)KUU!s}w\IhQBj}[g}bj0I3^glmC( =?iso-8859-15?q?=0A=09=3AAuzV9=3A=2EhESm-x4h240C=609=3Dw?= Date: Fri, 22 Jul 2011 10:22:09 +0200 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_xMTKOKq+mHA7yQN" Message-Id: <201107221022.09811.hselasky@c2i.net> Cc: Subject: Re: boot hang without xhci [updated patch] X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2011 08:24:25 -0000 --Boundary-00=_xMTKOKq+mHA7yQN Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit On Friday 22 July 2011 01:38:33 Mike Tancsa wrote: > More for the archives in case anyone else runs into this. > > We got a new desktop board in that we were testing out netbooting and > noticed that without xhci loaded in the kernel the box hangs with the > last thing being initialized em0 (full dmesg etc at > http://www.tancsa.com/xhci.txt) > > Its an Intel DQ67SW > > > ata2: [ITHREAD] > ata3: on atapci0 > ata3: [ITHREAD] > pci0: at device 22.3 (no driver attached) > em0: port 0xf080-0xf09f mem > 0xfe600000-0xfe61ffff,0xfe628000-0xfe628fff irq 20 at device 25.0 on pci0 > em0: Using an MSI interrupt > em0: [FILTER] > em0: Ethernet address: 00:22:4d:52:04:46 > > with usb 3 disabled in the BIOS, or with xhci loaded, all boots fine as > shown below. Please try the attached patch for /sys/dev/pci: --HPS --Boundary-00=_xMTKOKq+mHA7yQN Content-Type: text/x-patch; charset="iso-8859-1"; name="xhci_early_takeover.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="xhci_early_takeover.patch" === pci.c ================================================================== --- pci.c (revision 224243) +++ pci.c (local) @@ -62,6 +62,7 @@ #include #include +#include #include #include #include @@ -2956,6 +2957,68 @@ bus_release_resource(self, SYS_RES_MEMORY, rid, res); } +/* Perform early XHCI takeover from SMM. */ +static void +xhci_early_takeover(device_t self) +{ + struct resource *res; + uint32_t cparams; + uint32_t eec; + uint8_t eecp; + uint8_t bios_sem; + uint8_t offs; + int rid; + int i; + + rid = PCIR_BAR(0); + res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, RF_ACTIVE); + if (res == NULL) + return; + + cparams = bus_read_4(res, XHCI_HCSPARAMS0); + + eec = -1; + + /* Synchronise with the BIOS if it owns the controller. */ + for (eecp = XHCI_HCS0_XECP(cparams) << 2; eecp != 0 && XHCI_XECP_NEXT(eec); + eecp += XHCI_XECP_NEXT(eec) << 2) { + eec = bus_read_4(res, eecp); + + if (XHCI_XECP_ID(eec) != XHCI_ID_USB_LEGACY) + continue; + + bios_sem = bus_read_1(res, eecp + XHCI_XECP_BIOS_SEM); + if (bios_sem == 0) + continue; + + if (bootverbose) + printf("xhci early: " + "SMM active, request owner change\n"); + + bus_write_1(res, eecp + XHCI_XECP_OS_SEM, 1); + + /* wait a maximum of 5 second */ + + for (i = 0; (i < 5000) && (bios_sem != 0); i++) { + DELAY(1000); + bios_sem = bus_read_1(res, eecp + + XHCI_XECP_BIOS_SEM); + } + + if (bios_sem != 0) { + if (bootverbose) + printf("xhci early: " + "SMM does not respond\n"); + } + + /* Disable interrupts */ + offs = bus_read_1(res, XHCI_CAPLENGTH); + bus_write_4(res, offs + XHCI_USBCMD, 0); + bus_read_4(res, offs + XHCI_USBSTS); + } + bus_release_resource(self, SYS_RES_MEMORY, rid, res); +} + void pci_add_resources(device_t bus, device_t dev, int force, uint32_t prefetchmask) { @@ -3002,7 +3065,9 @@ if (pci_usb_takeover && pci_get_class(dev) == PCIC_SERIALBUS && pci_get_subclass(dev) == PCIS_SERIALBUS_USB) { - if (pci_get_progif(dev) == PCIP_SERIALBUS_USB_EHCI) + if (pci_get_progif(dev) == PCIP_SERIALBUS_USB_XHCI) + xhci_early_takeover(dev); + else if (pci_get_progif(dev) == PCIP_SERIALBUS_USB_EHCI) ehci_early_takeover(dev); else if (pci_get_progif(dev) == PCIP_SERIALBUS_USB_OHCI) ohci_early_takeover(dev); --Boundary-00=_xMTKOKq+mHA7yQN--