From owner-freebsd-usb@FreeBSD.ORG Tue Jun 11 17:48:27 2013 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 44792631; Tue, 11 Jun 2013 17:48:27 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id 918CA116B; Tue, 11 Jun 2013 17:48:26 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.7/8.14.7) with ESMTP id r5BHmMeB042937; Tue, 11 Jun 2013 20:48:22 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.3 kib.kiev.ua r5BHmMeB042937 Received: (from kostik@localhost) by tom.home (8.14.7/8.14.7/Submit) id r5BHmMhC042936; Tue, 11 Jun 2013 20:48:22 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 11 Jun 2013 20:48:22 +0300 From: Konstantin Belousov To: Michal Sviba Subject: Re: amd64/179376: xhci ehci irq storm Message-ID: <20130611174822.GR3047@kib.kiev.ua> References: <201306110920.r5B9K1m4071258@freefall.freebsd.org> <20130611132744.GM3047@kib.kiev.ua> <51B7563D.20807@sviba.cz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ctUw0psqOmtaOScQ" Content-Disposition: inline In-Reply-To: <51B7563D.20807@sviba.cz> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on tom.home Cc: freebsd-usb@freebsd.org, freebsd-amd64@FreeBSD.org X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jun 2013 17:48:27 -0000 --ctUw0psqOmtaOScQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 11, 2013 at 06:54:21PM +0200, Michal Sviba wrote: > xhci0@pci0:0:20:0: class=3D0x0c0330 card=3D0x3397103c chip=3D0x1e318= 086=20 > rev=3D0x04 hdr=3D0x00 > vendor =3D 'Intel Corporation' > device =3D 'Panther Point USB xHCI Host Controller' > class =3D serial bus > subclass =3D USB > cap 01[70] =3D powerspec 2 supports D0 D3 current D0 > cap 05[80] =3D MSI supports 8 messages, 64 bit Please try this. I cannot test since I do not have any usb 3.0 controller, not to mention controllers which support MSI. diff --git a/sys/dev/usb/controller/xhci.h b/sys/dev/usb/controller/xhci.h index 0872f40..3d436fd 100644 --- a/sys/dev/usb/controller/xhci.h +++ b/sys/dev/usb/controller/xhci.h @@ -447,6 +447,7 @@ struct xhci_softc { =20 struct usb_device *sc_devices[XHCI_MAX_DEVICES]; struct resource *sc_io_res; + int sc_irq_rid; struct resource *sc_irq_res; =20 void *sc_intr_hdl; diff --git a/sys/dev/usb/controller/xhci_pci.c b/sys/dev/usb/controller/xhc= i_pci.c index 8695dac..d714e0f 100644 --- a/sys/dev/usb/controller/xhci_pci.c +++ b/sys/dev/usb/controller/xhci_pci.c @@ -146,8 +146,7 @@ static int xhci_pci_attach(device_t self) { struct xhci_softc *sc =3D device_get_softc(self); - int err; - int rid; + int count, err, rid; =20 /* XXX check for 64-bit capability */ =20 @@ -171,11 +170,22 @@ xhci_pci_attach(device_t self) =20 usb_callout_init_mtx(&sc->sc_callout, &sc->sc_bus.bus_mtx, 0); =20 - rid =3D 0; - sc->sc_irq_res =3D bus_alloc_resource_any(self, SYS_RES_IRQ, &rid, - RF_SHAREABLE | RF_ACTIVE); + sc->sc_irq_rid =3D 0; + count =3D pci_msi_count(self); + if (count >=3D 1) { + if (count > 1) + count =3D 1; + if (pci_alloc_msi(self, &count) =3D=3D 0) { + if (bootverbose) + device_printf(self, "MSI enabled\n"); + sc->sc_irq_rid =3D 1; + } + } + sc->sc_irq_res =3D bus_alloc_resource_any(self, SYS_RES_IRQ, + &sc->sc_irq_rid, RF_SHAREABLE | RF_ACTIVE); if (sc->sc_irq_res =3D=3D NULL) { device_printf(self, "Could not allocate IRQ\n"); + goto error; } sc->sc_bus.bdev =3D device_add_child(self, "usbus", -1); if (sc->sc_bus.bdev =3D=3D NULL) { @@ -249,7 +259,10 @@ xhci_pci_detach(device_t self) sc->sc_intr_hdl =3D NULL; } if (sc->sc_irq_res) { - bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res); + if (sc->sc_irq_rid =3D=3D 1) + pci_release_msi(self); + bus_release_resource(self, SYS_RES_IRQ, sc->sc_irq_rid, + sc->sc_irq_res); sc->sc_irq_res =3D NULL; } if (sc->sc_io_res) { --ctUw0psqOmtaOScQ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (FreeBSD) iQIcBAEBAgAGBQJRt2LmAAoJEJDCuSvBvK1B8YsP+QEaSlleCbUMshsPBxSu+DHk IZmj6JnPyAT9IQS8Ivp/3HLIXWAOxDu+D9xaVT2tK4XUXVVm2Xx3RMXxVGuS6vwE YsO9+X4Y3bsrPPqFdt+Z/aSuG9aZeGPCG+Zqo/0f2J0ukGOjl6orNy0zPY5Gfw2k lMrJllWQqajyqanEyuiv/uIFKBk9wzzNwAgiZl65d+NUlnSftXFOl3d9w0N6EOh3 Kc5ROXPyBYJfnOvDz0wYsYwyg7rpiWhdcApSccSLT0D1lZLxgoSLdlg2RGQr/QnG dW4mRfi6j6THB5SQDSMDyld3rSb02bAlJCr/qK1jvmlYzYD5BD4aBklt7+QWBoRo nRslJETZ6hW2CnjVZf1LEVybl/BfBx8dllXZ3s2jtwysbkFEYoc0+7cc0PpBlB9v yifimuknDiwza+RBvBfFh/TctN8eTBrciW8l4XqZTgae1gmy5776hkVZy0SvjClK Ntz3keRMIJE511mGtJxf+Hm13o+6+sR8uhZmlQfP6+w0oeHpYdQldCZ1zn9jrJ25 9kbM5K5smyw5glmPyDo7FGQGC/oUPHEMwHmSJjscgR3FxNyLEO9RE0L+u3rJnDxH IWw7GAVhLKofYVoDQ/P20WV5mW5FBfbRB10OovGvbzqlccCwiMDP0q8GbLkqVSN3 A4SfBm+2Ls+gcPMxTWaE =fm+u -----END PGP SIGNATURE----- --ctUw0psqOmtaOScQ--