From: mpi Date: Sun, 10 Aug 2014 11:18:57 +0000 (+0000) Subject: Since USB xfer pools are accessed in interrupt context, initialize them X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=4269b561f733eb5c2874706889a2a2dad4d46b59;p=openbsd Since USB xfer pools are accessed in interrupt context, initialize them with the correct ipl to prevent your CPU from locking against itself. --- diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c index e6efccd425c..4a6caaf9f07 100644 --- a/sys/dev/usb/ehci.c +++ b/sys/dev/usb/ehci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ehci.c,v 1.165 2014/08/10 11:00:35 mpi Exp $ */ +/* $OpenBSD: ehci.c,v 1.166 2014/08/10 11:18:57 mpi Exp $ */ /* $NetBSD: ehci.c,v 1.66 2004/06/30 03:11:56 mycroft Exp $ */ /* @@ -334,6 +334,7 @@ ehci_init(struct ehci_softc *sc) } pool_init(ehcixfer, sizeof(struct ehci_xfer), 0, 0, 0, "ehcixfer", NULL); + pool_setipl(ehcixfer, IPL_SOFTUSB); } /* frame list size at default, read back what we got and use that */ diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c index 18637bc1f04..76c7aebd60c 100644 --- a/sys/dev/usb/ohci.c +++ b/sys/dev/usb/ohci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ohci.c,v 1.138 2014/08/10 11:00:36 mpi Exp $ */ +/* $OpenBSD: ohci.c,v 1.139 2014/08/10 11:18:57 mpi 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 $ */ @@ -726,6 +726,7 @@ ohci_init(struct ohci_softc *sc) } pool_init(ohcixfer, sizeof(struct ohci_xfer), 0, 0, 0, "ohcixfer", NULL); + pool_setipl(ohcixfer, IPL_SOFTUSB); } /* XXX determine alignment by R/W */ diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c index f52c07d7707..583689d9dcd 100644 --- a/sys/dev/usb/uhci.c +++ b/sys/dev/usb/uhci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhci.c,v 1.130 2014/08/10 11:00:36 mpi Exp $ */ +/* $OpenBSD: uhci.c,v 1.131 2014/08/10 11:18:57 mpi 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 $ */ @@ -373,6 +373,7 @@ uhci_init(struct uhci_softc *sc) } pool_init(uhcixfer, sizeof(struct uhci_xfer), 0, 0, 0, "uhcixfer", NULL); + pool_setipl(uhcixfer, IPL_SOFTUSB); } /* Restore saved SOF. */ diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c index 5cd6b3cff37..ef99af42c9e 100644 --- a/sys/dev/usb/usb.c +++ b/sys/dev/usb/usb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usb.c,v 1.101 2014/08/09 09:45:14 mpi Exp $ */ +/* $OpenBSD: usb.c,v 1.102 2014/08/10 11:18:57 mpi Exp $ */ /* $NetBSD: usb.c,v 1.77 2003/01/01 00:10:26 thorpej Exp $ */ /* @@ -195,8 +195,7 @@ usb_attach(struct device *parent, struct device *self, void *aux) usb_init_task(&sc->sc_explore_task, usb_explore, sc, USB_TASK_TYPE_EXPLORE); - /* XXX we should have our own level */ - sc->sc_bus->soft = softintr_establish(IPL_SOFTNET, + sc->sc_bus->soft = softintr_establish(IPL_SOFTUSB, sc->sc_bus->methods->soft_intr, sc->sc_bus); if (sc->sc_bus->soft == NULL) { printf("%s: can't register softintr\n", sc->sc_dev.dv_xname); diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h index 819bb291c32..a4c15393f76 100644 --- a/sys/dev/usb/usbdi.h +++ b/sys/dev/usb/usbdi.h @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdi.h,v 1.62 2014/03/07 09:38:14 mpi Exp $ */ +/* $OpenBSD: usbdi.h,v 1.63 2014/08/10 11:18:57 mpi Exp $ */ /* $NetBSD: usbdi.h,v 1.62 2002/07/11 21:14:35 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $ */ @@ -255,11 +255,13 @@ struct usb_attach_arg { /* XXX Perhaps USB should have its own levels? */ #define splusb splsoftnet #if 0 -#define SPLUSBCHECK splsoftassert(IPL_SOFTNET) +#define SPLUSBCHECK splsoftassert(IPL_SOFTUSB) #else #define SPLUSBCHECK do { /* nothing */ } while (0) #endif #define splhardusb splbio -#define IPL_USB IPL_BIO + +#define IPL_USB IPL_BIO +#define IPL_SOFTUSB IPL_SOFTNET #endif /* _USBDI_H_ */ diff --git a/sys/dev/usb/usbf_subr.c b/sys/dev/usb/usbf_subr.c index e27e76ebc90..9cbf2385f8a 100644 --- a/sys/dev/usb/usbf_subr.c +++ b/sys/dev/usb/usbf_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usbf_subr.c,v 1.19 2014/07/12 18:48:53 tedu Exp $ */ +/* $OpenBSD: usbf_subr.c,v 1.20 2014/08/10 11:18:57 mpi Exp $ */ /* * Copyright (c) 2006 Uwe Stuehler @@ -1067,8 +1067,7 @@ usbf_softintr_establish(struct usbf_bus *bus) { KASSERT(bus->soft == NULL); - /* XXX we should have our own level */ - bus->soft = softintr_establish(IPL_SOFTNET, + bus->soft = softintr_establish(IPL_SOFTUSB, bus->methods->soft_intr, bus); if (bus->soft == NULL) return USBF_INVAL; diff --git a/sys/dev/usb/xhci.c b/sys/dev/usb/xhci.c index a799818a8ea..1f209ab0350 100644 --- a/sys/dev/usb/xhci.c +++ b/sys/dev/usb/xhci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xhci.c,v 1.22 2014/08/10 11:00:36 mpi Exp $ */ +/* $OpenBSD: xhci.c,v 1.23 2014/08/10 11:18:57 mpi Exp $ */ /* * Copyright (c) 2014 Martin Pieuchot @@ -245,6 +245,7 @@ xhci_init(struct xhci_softc *sc) } pool_init(xhcixfer, sizeof(struct xhci_xfer), 0, 0, 0, "xhcixfer", NULL); + pool_setipl(xhcixfer, IPL_SOFTUSB); } hcr = XREAD4(sc, XHCI_HCCPARAMS);