diff options
author | Marcus Glocker <mglocker@cvs.openbsd.org> | 2007-03-18 20:14:52 +0000 |
---|---|---|
committer | Marcus Glocker <mglocker@cvs.openbsd.org> | 2007-03-18 20:14:52 +0000 |
commit | 2820d116979e135234d1261ada149c763a9c0e8f (patch) | |
tree | 0bf89f6bb84c1a9536807c2a741a63210ccaa24d /sys | |
parent | ac1137b6a847c7588490a81e52944d5a73b778ac (diff) |
Backout pascoe@'s last USB change because it page faults at attachment
time.
Chris; Get your shiz fixed and tested for the next time. We have
better todo then wasting our time by backing out untested stuff.
OK deraadt, OK ckuethe
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/ohci_pci.c | 58 | ||||
-rw-r--r-- | sys/dev/pci/uhci_pci.c | 29 | ||||
-rw-r--r-- | sys/dev/usb/ohci.c | 28 | ||||
-rw-r--r-- | sys/dev/usb/uhci.c | 9 | ||||
-rw-r--r-- | sys/dev/usb/uhub.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/usb.c | 8 |
6 files changed, 32 insertions, 108 deletions
diff --git a/sys/dev/pci/ohci_pci.c b/sys/dev/pci/ohci_pci.c index 7c3f3507b23..9b435a1b80f 100644 --- a/sys/dev/pci/ohci_pci.c +++ b/sys/dev/pci/ohci_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ohci_pci.c,v 1.30 2007/03/18 06:08:24 pascoe Exp $ */ +/* $OpenBSD: ohci_pci.c,v 1.31 2007/03/18 20:14:51 mglocker Exp $ */ /* $NetBSD: ohci_pci.c,v 1.23 2002/10/02 16:51:47 thorpej Exp $ */ /* @@ -64,17 +64,8 @@ #include <dev/usb/ohcireg.h> #include <dev/usb/ohcivar.h> -#ifdef OHCI_DEBUG -#define DPRINTF(x) do { if (ohcidebug) logprintf x; } while (0) -extern int ohcidebug; -#else -#define DPRINTF(x) -#define DPRINTFN(n,x) -#endif - int ohci_pci_match(struct device *, void *, void *); void ohci_pci_attach(struct device *, struct device *, void *); -void ohci_pci_attach_deferred(struct device *); int ohci_pci_detach(struct device *, int); struct ohci_pci_softc { @@ -109,10 +100,10 @@ ohci_pci_attach(struct device *parent, struct device *self, void *aux) pci_chipset_tag_t pc = pa->pa_pc; char const *intrstr; pci_intr_handle_t ih; - int s, i; + usbd_status r; + int s; const char *vendor; char *devname = sc->sc.sc_bus.bdev.dv_xname; - u_int32_t ctl, sts; /* Map I/O registers */ if (pci_mapreg_map(pa, PCI_CBMEM, PCI_MAPREG_TYPE_MEM, 0, @@ -167,49 +158,6 @@ ohci_pci_attach(struct device *parent, struct device *self, void *aux) else snprintf(sc->sc.sc_vendor, sizeof (sc->sc.sc_vendor), "vendor 0x%04x", PCI_VENDOR(pa->pa_id)); - - /* Ignore interrupts for now */ - sc->sc.sc_dying = 1; - - /* Perform legacy handover if required. */ - ctl = bus_space_read_4(sc->sc.iot, sc->sc.ioh, OHCI_CONTROL); - if (ctl & OHCI_IR) { - /* SMM active, request change */ - DPRINTF(("ohci_init: SMM active, request owner change\n")); - if ((sc->sc.sc_intre & (OHCI_OC | OHCI_MIE)) == - (OHCI_OC | OHCI_MIE)) - bus_space_write_4(sc->sc.iot, sc->sc.ioh, - OHCI_INTERRUPT_ENABLE, OHCI_MIE); - sts = bus_space_read_4(sc->sc.iot, sc->sc.ioh, - OHCI_COMMAND_STATUS); - bus_space_write_4(sc->sc.iot, sc->sc.ioh, OHCI_COMMAND_STATUS, - sts | OHCI_OCR); - for (i = 0; i < 100 && (ctl & OHCI_IR); i++) { - usb_delay_ms(&sc->sc.sc_bus, 1); - ctl = bus_space_read_4(sc->sc.iot, sc->sc.ioh, - OHCI_CONTROL); - } - bus_space_write_4(sc->sc.iot, sc->sc.ioh, - OHCI_INTERRUPT_DISABLE, OHCI_MIE); - } - - config_defer(self, ohci_pci_attach_deferred); - - splx(s); - - return; -} - -void -ohci_pci_attach_deferred(struct device *self) -{ - struct ohci_pci_softc *sc = (struct ohci_pci_softc *)self; - usbd_status r; - int s; - - s = splusb(); - - sc->sc.sc_dying = 1; r = ohci_init(&sc->sc); if (r != USBD_NORMAL_COMPLETION) { diff --git a/sys/dev/pci/uhci_pci.c b/sys/dev/pci/uhci_pci.c index f609b453af9..7cdbc61add9 100644 --- a/sys/dev/pci/uhci_pci.c +++ b/sys/dev/pci/uhci_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhci_pci.c,v 1.23 2007/03/18 06:08:24 pascoe Exp $ */ +/* $OpenBSD: uhci_pci.c,v 1.24 2007/03/18 20:14:51 mglocker Exp $ */ /* $NetBSD: uhci_pci.c,v 1.24 2002/10/02 16:51:58 thorpej Exp $ */ /* @@ -59,7 +59,6 @@ int uhci_pci_match(struct device *, void *, void *); void uhci_pci_attach(struct device *, struct device *, void *); -void uhci_pci_attach_deferred(struct device *); int uhci_pci_detach(struct device *, int); struct uhci_pci_softc { @@ -98,6 +97,7 @@ uhci_pci_attach(struct device *parent, struct device *self, void *aux) pci_intr_handle_t ih; const char *vendor; char *devname = sc->sc.sc_bus.bdev.dv_xname; + usbd_status r; int s; #if defined(__NetBSD__) @@ -172,32 +172,7 @@ uhci_pci_attach(struct device *parent, struct device *self, void *aux) else snprintf(sc->sc.sc_vendor, sizeof (sc->sc.sc_vendor), "vendor 0x%04x", PCI_VENDOR(pa->pa_id)); - - config_defer(self, uhci_pci_attach_deferred); - - /* Ignore interrupts for now */ - sc->sc.sc_dying = 1; - - splx(s); - - return; - -unmap_ret: - bus_space_unmap(sc->sc.iot, sc->sc.ioh, sc->sc.sc_size); - splx(s); -} - -void -uhci_pci_attach_deferred(struct device *self) -{ - struct uhci_pci_softc *sc = (struct uhci_pci_softc *)self; - char *devname = sc->sc.sc_bus.bdev.dv_xname; - usbd_status r; - int s; - - s = splhardusb(); - sc->sc.sc_dying = 0; r = uhci_init(&sc->sc); if (r != USBD_NORMAL_COMPLETION) { printf("%s: init failed, error=%d\n", devname, r); diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c index 4e3c6bc2a2f..122a67ee846 100644 --- a/sys/dev/usb/ohci.c +++ b/sys/dev/usb/ohci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ohci.c,v 1.74 2007/03/18 06:08:24 pascoe Exp $ */ +/* $OpenBSD: ohci.c,v 1.75 2007/03/18 20:14:51 mglocker Exp $ */ /* $NetBSD: ohci.c,v 1.139 2003/02/22 05:24:16 tsutsui Exp $ */ /* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */ @@ -616,7 +616,7 @@ ohci_init(ohci_softc_t *sc) ohci_soft_ed_t *sed, *psed; usbd_status err; int i; - u_int32_t ctl, rwc, ival, hcr, fm, per, rev, desca, descb; + u_int32_t s, ctl, rwc, ival, hcr, fm, per, rev, desca, descb; DPRINTF(("ohci_init: start\n")); printf(","); @@ -718,12 +718,26 @@ ohci_init(ohci_softc_t *sc) desca = OREAD4(sc, OHCI_RH_DESCRIPTOR_A); descb = OREAD4(sc, OHCI_RH_DESCRIPTOR_B); - /* SMM handover performed by the PCI code didn't work? */ + /* Determine in what context we are running. */ if (ctl & OHCI_IR) { - printf("%s: SMM does not respond, resetting\n", - USBDEVNAME(sc->sc_bus.bdev)); - OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESET | rwc); - goto reset; + /* SMM active, request change */ + DPRINTF(("ohci_init: SMM active, request owner change\n")); + if ((sc->sc_intre & (OHCI_OC | OHCI_MIE)) == + (OHCI_OC | OHCI_MIE)) + OWRITE4(sc, OHCI_INTERRUPT_ENABLE, OHCI_MIE); + s = OREAD4(sc, OHCI_COMMAND_STATUS); + OWRITE4(sc, OHCI_COMMAND_STATUS, s | OHCI_OCR); + for (i = 0; i < 100 && (ctl & OHCI_IR); i++) { + usb_delay_ms(&sc->sc_bus, 1); + ctl = OREAD4(sc, OHCI_CONTROL); + } + OWRITE4(sc, OHCI_INTERRUPT_DISABLE, OHCI_MIE); + if (ctl & OHCI_IR) { + printf("%s: SMM does not respond, resetting\n", + USBDEVNAME(sc->sc_bus.bdev)); + OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESET | rwc); + goto reset; + } #if 0 /* Don't bother trying to reuse the BIOS init, we'll reset it anyway. */ } else if ((ctl & OHCI_HCFS_MASK) != OHCI_HCFS_RESET) { diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c index e83cecaadb1..50ec3b3e891 100644 --- a/sys/dev/usb/uhci.c +++ b/sys/dev/usb/uhci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhci.c,v 1.49 2007/03/18 05:55:24 pascoe Exp $ */ +/* $OpenBSD: uhci.c,v 1.50 2007/03/18 20:14:51 mglocker Exp $ */ /* $NetBSD: uhci.c,v 1.172 2003/02/23 04:19:26 simonb Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */ @@ -409,16 +409,10 @@ uhci_init(uhci_softc_t *sc) uhci_dumpregs(sc); #endif - /* Save SOF over HC reset. */ - sc->sc_saved_sof = UREAD1(sc, UHCI_SOF); - UWRITE2(sc, UHCI_INTR, 0); /* disable interrupts */ uhci_globalreset(sc); /* reset the controller */ uhci_reset(sc); - /* Restore saved SOF. */ - UWRITE1(sc, UHCI_SOF, sc->sc_saved_sof); - /* Allocate and initialize real frame array. */ err = usb_allocmem(&sc->sc_bus, UHCI_FRAMELIST_COUNT * sizeof(uhci_physaddr_t), @@ -726,6 +720,7 @@ uhci_power(int why, void *v) /* save some state if BIOS doesn't */ sc->sc_saved_frnum = UREAD2(sc, UHCI_FRNUM); + sc->sc_saved_sof = UREAD1(sc, UHCI_SOF); UWRITE2(sc, UHCI_INTR, 0); /* disable intrs */ diff --git a/sys/dev/usb/uhub.c b/sys/dev/usb/uhub.c index 056158408e2..631607cdb14 100644 --- a/sys/dev/usb/uhub.c +++ b/sys/dev/usb/uhub.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhub.c,v 1.35 2007/03/18 06:00:45 pascoe Exp $ */ +/* $OpenBSD: uhub.c,v 1.36 2007/03/18 20:14:51 mglocker Exp $ */ /* $NetBSD: uhub.c,v 1.64 2003/02/08 03:32:51 ichiro Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */ @@ -338,11 +338,9 @@ USB_ATTACH(uhub) USBDEVNAME(sc->sc_dev), port, usbd_errstr(err)); DPRINTF(("usb_init_port: turn on port %d power\n", port)); - } - - /* Wait for stable power. Root hubs delay in their event thread. */ - if (dev->powersrc->parent != NULL) + /* Wait for stable power. */ usbd_delay_ms(dev, pwrdly); + } /* The usual exploration will finish the setup. */ diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c index c8256f255dd..b8012f31e27 100644 --- a/sys/dev/usb/usb.c +++ b/sys/dev/usb/usb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usb.c,v 1.36 2007/03/18 06:00:45 pascoe Exp $ */ +/* $OpenBSD: usb.c,v 1.37 2007/03/18 20:14:51 mglocker Exp $ */ /* $NetBSD: usb.c,v 1.77 2003/01/01 00:10:26 thorpej Exp $ */ /* @@ -304,15 +304,9 @@ void usb_event_thread(void *arg) { struct usb_softc *sc = arg; - int pwrdly; DPRINTF(("usb_event_thread: start\n")); - /* Wait for power to come good. */ - pwrdly = sc->sc_bus->root_hub->hub->hubdesc.bPwrOn2PwrGood * - UHD_PWRON_FACTOR + USB_EXTRA_POWER_UP_TIME; - usb_delay_ms(sc->sc_bus, pwrdly); - /* USB1 threads wait for USB2 threads to finish their first probe. */ while (sc->sc_bus->usbrev != USBREV_2_0 && threads_pending) (void)tsleep((void *)&threads_pending, PWAIT, "config", 0); |