Deleted Added
full compact
ehci.c (198151) ehci.c (199058)
1/*-
2 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
3 * Copyright (c) 2004 The NetBSD Foundation, Inc. All rights reserved.
4 * Copyright (c) 2004 Lennart Augustsson. All rights reserved.
5 * Copyright (c) 2004 Charles M. Hannum. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

39 */
40
41/*
42 * TODO:
43 * 1) command failures are not recovered correctly
44 */
45
46#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
3 * Copyright (c) 2004 The NetBSD Foundation, Inc. All rights reserved.
4 * Copyright (c) 2004 Lennart Augustsson. All rights reserved.
5 * Copyright (c) 2004 Charles M. Hannum. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

39 */
40
41/*
42 * TODO:
43 * 1) command failures are not recovered correctly
44 */
45
46#include <sys/cdefs.h>
47__FBSDID("$FreeBSD: head/sys/dev/usb/controller/ehci.c 198151 2009-10-15 20:07:08Z thompsa $");
47__FBSDID("$FreeBSD: head/sys/dev/usb/controller/ehci.c 199058 2009-11-08 20:51:15Z thompsa $");
48
49#include <sys/stdint.h>
50#include <sys/stddef.h>
51#include <sys/param.h>
52#include <sys/queue.h>
53#include <sys/types.h>
54#include <sys/systm.h>
55#include <sys/kernel.h>

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

108
109extern struct usb_bus_methods ehci_bus_methods;
110extern struct usb_pipe_methods ehci_device_bulk_methods;
111extern struct usb_pipe_methods ehci_device_ctrl_methods;
112extern struct usb_pipe_methods ehci_device_intr_methods;
113extern struct usb_pipe_methods ehci_device_isoc_fs_methods;
114extern struct usb_pipe_methods ehci_device_isoc_hs_methods;
115
48
49#include <sys/stdint.h>
50#include <sys/stddef.h>
51#include <sys/param.h>
52#include <sys/queue.h>
53#include <sys/types.h>
54#include <sys/systm.h>
55#include <sys/kernel.h>

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

108
109extern struct usb_bus_methods ehci_bus_methods;
110extern struct usb_pipe_methods ehci_device_bulk_methods;
111extern struct usb_pipe_methods ehci_device_ctrl_methods;
112extern struct usb_pipe_methods ehci_device_intr_methods;
113extern struct usb_pipe_methods ehci_device_isoc_fs_methods;
114extern struct usb_pipe_methods ehci_device_isoc_hs_methods;
115
116static void ehci_do_poll(struct usb_bus *bus);
117static void ehci_device_done(struct usb_xfer *xfer, usb_error_t error);
118static uint8_t ehci_check_transfer(struct usb_xfer *xfer);
119static void ehci_timeout(void *arg);
116static void ehci_do_poll(struct usb_bus *);
117static void ehci_device_done(struct usb_xfer *, usb_error_t);
118static uint8_t ehci_check_transfer(struct usb_xfer *);
119static void ehci_timeout(void *);
120static void ehci_poll_timeout(void *);
121
120static void ehci_root_intr(ehci_softc_t *sc);
121
122struct ehci_std_temp {
123 ehci_softc_t *sc;
124 struct usb_page_cache *pc;
125 ehci_qtd_t *td;
126 ehci_qtd_t *td_next;
127 uint32_t average;

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

238 uint16_t x;
239 uint16_t y;
240 uint16_t bit;
241 usb_error_t err = 0;
242
243 DPRINTF("start\n");
244
245 usb_callout_init_mtx(&sc->sc_tmo_pcd, &sc->sc_bus.bus_mtx, 0);
122static void ehci_root_intr(ehci_softc_t *sc);
123
124struct ehci_std_temp {
125 ehci_softc_t *sc;
126 struct usb_page_cache *pc;
127 ehci_qtd_t *td;
128 ehci_qtd_t *td_next;
129 uint32_t average;

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

240 uint16_t x;
241 uint16_t y;
242 uint16_t bit;
243 usb_error_t err = 0;
244
245 DPRINTF("start\n");
246
247 usb_callout_init_mtx(&sc->sc_tmo_pcd, &sc->sc_bus.bus_mtx, 0);
248 usb_callout_init_mtx(&sc->sc_tmo_poll, &sc->sc_bus.bus_mtx, 0);
246
247#if USB_DEBUG
248 if (ehcidebug > 2) {
249 ehci_dump_regs(sc);
250 }
251#endif
252
253 sc->sc_offs = EREAD1(sc, EHCI_CAPLENGTH);

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

515 * shut down the controller when the system is going down
516 */
517void
518ehci_detach(ehci_softc_t *sc)
519{
520 USB_BUS_LOCK(&sc->sc_bus);
521
522 usb_callout_stop(&sc->sc_tmo_pcd);
249
250#if USB_DEBUG
251 if (ehcidebug > 2) {
252 ehci_dump_regs(sc);
253 }
254#endif
255
256 sc->sc_offs = EREAD1(sc, EHCI_CAPLENGTH);

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

518 * shut down the controller when the system is going down
519 */
520void
521ehci_detach(ehci_softc_t *sc)
522{
523 USB_BUS_LOCK(&sc->sc_bus);
524
525 usb_callout_stop(&sc->sc_tmo_pcd);
526 usb_callout_stop(&sc->sc_tmo_poll);
523
524 EOWRITE4(sc, EHCI_USBINTR, sc->sc_eintrs);
525 USB_BUS_UNLOCK(&sc->sc_bus);
526
527 if (ehci_hcreset(sc)) {
528 DPRINTF("reset failed!\n");
529 }
530
531 /* XXX let stray task complete */
532 usb_pause_mtx(NULL, hz / 20);
533
534 usb_callout_drain(&sc->sc_tmo_pcd);
527
528 EOWRITE4(sc, EHCI_USBINTR, sc->sc_eintrs);
529 USB_BUS_UNLOCK(&sc->sc_bus);
530
531 if (ehci_hcreset(sc)) {
532 DPRINTF("reset failed!\n");
533 }
534
535 /* XXX let stray task complete */
536 usb_pause_mtx(NULL, hz / 20);
537
538 usb_callout_drain(&sc->sc_tmo_pcd);
539 usb_callout_drain(&sc->sc_tmo_poll);
535}
536
537void
538ehci_suspend(ehci_softc_t *sc)
539{
540 uint32_t cmd;
541 uint32_t hcr;
542 uint8_t i;

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

1467 */
1468 if (ehci_check_transfer(xfer)) {
1469 /* queue has been modified */
1470 goto repeat;
1471 }
1472 }
1473}
1474
540}
541
542void
543ehci_suspend(ehci_softc_t *sc)
544{
545 uint32_t cmd;
546 uint32_t hcr;
547 uint8_t i;

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

1472 */
1473 if (ehci_check_transfer(xfer)) {
1474 /* queue has been modified */
1475 goto repeat;
1476 }
1477 }
1478}
1479
1480/*
1481 * Some EHCI chips from VIA / ATI seem to trigger interrupts before
1482 * writing back the qTD status, or miss signalling occasionally under
1483 * heavy load. If the host machine is too fast, we can miss
1484 * transaction completion - when we scan the active list the
1485 * transaction still seems to be active. This generally exhibits
1486 * itself as a umass stall that never recovers.
1487 *
1488 * We work around this behaviour by setting up this callback after any
1489 * softintr that completes with transactions still pending, giving us
1490 * another chance to check for completion after the writeback has
1491 * taken place.
1492 */
1493static void
1494ehci_poll_timeout(void *arg)
1495{
1496 ehci_softc_t *sc = arg;
1497
1498 DPRINTFN(3, "\n");
1499 ehci_interrupt_poll(sc);
1500}
1501
1475/*------------------------------------------------------------------------*
1476 * ehci_interrupt - EHCI interrupt handler
1477 *
1478 * NOTE: Do not access "sc->sc_bus.bdev" inside the interrupt handler,
1479 * hence the interrupt handler will be setup before "sc->sc_bus.bdev"
1480 * is present !
1481 *------------------------------------------------------------------------*/
1482void

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

1534 /* block unprocessed interrupts */
1535 sc->sc_eintrs &= ~status;
1536 EOWRITE4(sc, EHCI_USBINTR, sc->sc_eintrs);
1537 printf("%s: blocking interrupts 0x%x\n", __FUNCTION__, status);
1538 }
1539 /* poll all the USB transfers */
1540 ehci_interrupt_poll(sc);
1541
1502/*------------------------------------------------------------------------*
1503 * ehci_interrupt - EHCI interrupt handler
1504 *
1505 * NOTE: Do not access "sc->sc_bus.bdev" inside the interrupt handler,
1506 * hence the interrupt handler will be setup before "sc->sc_bus.bdev"
1507 * is present !
1508 *------------------------------------------------------------------------*/
1509void

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

1561 /* block unprocessed interrupts */
1562 sc->sc_eintrs &= ~status;
1563 EOWRITE4(sc, EHCI_USBINTR, sc->sc_eintrs);
1564 printf("%s: blocking interrupts 0x%x\n", __FUNCTION__, status);
1565 }
1566 /* poll all the USB transfers */
1567 ehci_interrupt_poll(sc);
1568
1569 if (sc->sc_flags & EHCI_SCFLG_LOSTINTRBUG) {
1570 usb_callout_reset(&sc->sc_tmo_poll, hz / 128,
1571 (void *)&ehci_poll_timeout, sc);
1572 }
1573
1542done:
1543 USB_BUS_UNLOCK(&sc->sc_bus);
1544}
1545
1546/*
1547 * called when a request does not complete
1548 */
1549static void

--- 2316 unchanged lines hidden ---
1574done:
1575 USB_BUS_UNLOCK(&sc->sc_bus);
1576}
1577
1578/*
1579 * called when a request does not complete
1580 */
1581static void

--- 2316 unchanged lines hidden ---