Deleted Added
full compact
xhci_pci.c (275785) xhci_pci.c (276965)
1/*-
2 * Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 10 unchanged lines hidden (view full) ---

19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 10 unchanged lines hidden (view full) ---

19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
27__FBSDID("$FreeBSD: stable/10/sys/dev/usb/controller/xhci_pci.c 275785 2014-12-15 08:26:36Z hselasky $");
27__FBSDID("$FreeBSD: stable/10/sys/dev/usb/controller/xhci_pci.c 276965 2015-01-11 11:28:03Z hselasky $");
28
29#include <sys/stdint.h>
30#include <sys/stddef.h>
31#include <sys/param.h>
32#include <sys/queue.h>
33#include <sys/types.h>
34#include <sys/systm.h>
35#include <sys/kernel.h>

--- 160 unchanged lines hidden (view full) ---

196 goto error;
197 }
198 sc->sc_io_tag = rman_get_bustag(sc->sc_io_res);
199 sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res);
200 sc->sc_io_size = rman_get_size(sc->sc_io_res);
201
202 usb_callout_init_mtx(&sc->sc_callout, &sc->sc_bus.bus_mtx, 0);
203
28
29#include <sys/stdint.h>
30#include <sys/stddef.h>
31#include <sys/param.h>
32#include <sys/queue.h>
33#include <sys/types.h>
34#include <sys/systm.h>
35#include <sys/kernel.h>

--- 160 unchanged lines hidden (view full) ---

196 goto error;
197 }
198 sc->sc_io_tag = rman_get_bustag(sc->sc_io_res);
199 sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res);
200 sc->sc_io_size = rman_get_size(sc->sc_io_res);
201
202 usb_callout_init_mtx(&sc->sc_callout, &sc->sc_bus.bus_mtx, 0);
203
204 sc->sc_irq_rid = 0;
204 rid = 0;
205 if (xhci_use_msi) {
205 if (xhci_use_msi) {
206 count = pci_msi_count(self);
207 if (count >= 1) {
208 count = 1;
209 if (pci_alloc_msi(self, &count) == 0) {
210 if (bootverbose)
211 device_printf(self, "MSI enabled\n");
212 sc->sc_irq_rid = 1;
213 }
206 count = 1;
207 if (pci_alloc_msi(self, &count) == 0) {
208 if (bootverbose)
209 device_printf(self, "MSI enabled\n");
210 rid = 1;
214 }
215 }
211 }
212 }
216 sc->sc_irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ,
217 &sc->sc_irq_rid, RF_SHAREABLE | RF_ACTIVE);
213 sc->sc_irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid,
214 RF_ACTIVE | (rid != 0 ? 0 : RF_SHAREABLE));
218 if (sc->sc_irq_res == NULL) {
215 if (sc->sc_irq_res == NULL) {
216 pci_release_msi(self);
219 device_printf(self, "Could not allocate IRQ\n");
220 /* goto error; FALLTHROUGH - use polling */
221 }
222 sc->sc_bus.bdev = device_add_child(self, "usbus", -1);
223 if (sc->sc_bus.bdev == NULL) {
224 device_printf(self, "Could not add USB device\n");
225 goto error;
226 }
227 device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus);
228
229 sprintf(sc->sc_vendor, "0x%04x", pci_get_vendor(self));
230
231 if (sc->sc_irq_res != NULL) {
232 err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
233 NULL, (driver_intr_t *)xhci_interrupt, sc, &sc->sc_intr_hdl);
234 if (err != 0) {
217 device_printf(self, "Could not allocate IRQ\n");
218 /* goto error; FALLTHROUGH - use polling */
219 }
220 sc->sc_bus.bdev = device_add_child(self, "usbus", -1);
221 if (sc->sc_bus.bdev == NULL) {
222 device_printf(self, "Could not add USB device\n");
223 goto error;
224 }
225 device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus);
226
227 sprintf(sc->sc_vendor, "0x%04x", pci_get_vendor(self));
228
229 if (sc->sc_irq_res != NULL) {
230 err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
231 NULL, (driver_intr_t *)xhci_interrupt, sc, &sc->sc_intr_hdl);
232 if (err != 0) {
233 bus_release_resource(self, SYS_RES_IRQ,
234 rman_get_rid(sc->sc_irq_res), sc->sc_irq_res);
235 sc->sc_irq_res = NULL;
236 pci_release_msi(self);
235 device_printf(self, "Could not setup IRQ, err=%d\n", err);
236 sc->sc_intr_hdl = NULL;
237 }
238 }
237 device_printf(self, "Could not setup IRQ, err=%d\n", err);
238 sc->sc_intr_hdl = NULL;
239 }
240 }
239 if (sc->sc_irq_res == NULL || sc->sc_intr_hdl == NULL ||
240 xhci_use_polling() != 0) {
241 device_printf(self, "Interrupt polling at %dHz\n", hz);
242 USB_BUS_LOCK(&sc->sc_bus);
243 xhci_interrupt_poll(sc);
244 USB_BUS_UNLOCK(&sc->sc_bus);
241 if (sc->sc_irq_res == NULL || sc->sc_intr_hdl == NULL) {
242 if (xhci_use_polling() != 0) {
243 device_printf(self, "Interrupt polling at %dHz\n", hz);
244 USB_BUS_LOCK(&sc->sc_bus);
245 xhci_interrupt_poll(sc);
246 USB_BUS_UNLOCK(&sc->sc_bus);
247 } else
248 goto error;
245 }
246
247 /* On Intel chipsets reroute ports from EHCI to XHCI controller. */
248 switch (pci_get_devid(self)) {
249 case 0x9c318086: /* Panther Point */
250 case 0x1e318086: /* Panther Point */
251 case 0x8c318086: /* Lynx Point */
252 case 0x8cb18086: /* Wildcat Point */

--- 46 unchanged lines hidden (view full) ---

299
300 pci_disable_busmaster(self);
301
302 if (sc->sc_irq_res && sc->sc_intr_hdl) {
303 bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl);
304 sc->sc_intr_hdl = NULL;
305 }
306 if (sc->sc_irq_res) {
249 }
250
251 /* On Intel chipsets reroute ports from EHCI to XHCI controller. */
252 switch (pci_get_devid(self)) {
253 case 0x9c318086: /* Panther Point */
254 case 0x1e318086: /* Panther Point */
255 case 0x8c318086: /* Lynx Point */
256 case 0x8cb18086: /* Wildcat Point */

--- 46 unchanged lines hidden (view full) ---

303
304 pci_disable_busmaster(self);
305
306 if (sc->sc_irq_res && sc->sc_intr_hdl) {
307 bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl);
308 sc->sc_intr_hdl = NULL;
309 }
310 if (sc->sc_irq_res) {
307 if (sc->sc_irq_rid == 1)
308 pci_release_msi(self);
309 bus_release_resource(self, SYS_RES_IRQ, sc->sc_irq_rid,
310 sc->sc_irq_res);
311 bus_release_resource(self, SYS_RES_IRQ,
312 rman_get_rid(sc->sc_irq_res), sc->sc_irq_res);
311 sc->sc_irq_res = NULL;
313 sc->sc_irq_res = NULL;
314 pci_release_msi(self);
312 }
313 if (sc->sc_io_res) {
314 bus_release_resource(self, SYS_RES_MEMORY, PCI_XHCI_CBMEM,
315 sc->sc_io_res);
316 sc->sc_io_res = NULL;
317 }
318
319 xhci_uninit(sc);

--- 50 unchanged lines hidden ---
315 }
316 if (sc->sc_io_res) {
317 bus_release_resource(self, SYS_RES_MEMORY, PCI_XHCI_CBMEM,
318 sc->sc_io_res);
319 sc->sc_io_res = NULL;
320 }
321
322 xhci_uninit(sc);

--- 50 unchanged lines hidden ---