diff options
author | jhb <jhb@FreeBSD.org> | 2012-10-15 16:09:59 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2012-10-15 16:09:59 +0000 |
commit | fcf1c6db5250deb9191312a95f978e557d091b14 (patch) | |
tree | 5829ecb29696b68ee5df08cafc2d610e3430d0bd /sys/dev/aic/aic_cbus.c | |
parent | 9ffe91c4a4d92a29e7f417b0cf3c9fb449aa5e0f (diff) | |
download | FreeBSD-src-fcf1c6db5250deb9191312a95f978e557d091b14.zip FreeBSD-src-fcf1c6db5250deb9191312a95f978e557d091b14.tar.gz |
Add locking to the aic(4) driver and mark it MPSAFE.
- Move 'free_scbs' into the softc rather than having it be a global list
and convert it to an SLIST instead of a hand-rolled linked-list.
- Use device_printf() and device_get_unit() instead of storing the unit
number in the softc.
- Remove use of explicit bus space handles and tags.
- Don't call device_set_desc() in the pccard attach routine, instead
set a default description during the pccard probe if the matching
product doesn't have a name.
Tested by: no one
Diffstat (limited to 'sys/dev/aic/aic_cbus.c')
-rw-r--r-- | sys/dev/aic/aic_cbus.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/sys/dev/aic/aic_cbus.c b/sys/dev/aic/aic_cbus.c index c641989..d2d2bc3 100644 --- a/sys/dev/aic/aic_cbus.c +++ b/sys/dev/aic/aic_cbus.c @@ -28,8 +28,11 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> +#include <sys/callout.h> #include <sys/kernel.h> +#include <sys/lock.h> #include <sys/module.h> +#include <sys/mutex.h> #include <sys/bus.h> #include <machine/bus.h> @@ -92,7 +95,7 @@ aic_isa_alloc_resources(device_t dev) else bs_iat = aicport_generic; - sc->sc_port = sc->sc_irq = sc->sc_drq = 0; + sc->sc_port = sc->sc_irq = sc->sc_drq = NULL; rid = 0; sc->sc_port = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid, @@ -102,6 +105,7 @@ aic_isa_alloc_resources(device_t dev) return (ENOMEM); } isa_load_resourcev(sc->sc_port, bs_iat, AIC_ISA_PORTSIZE); + mtx_init(&sc->sc_aic.lock, "aic", NULL, MTX_DEF); if (isa_get_irq(dev) != -1) { rid = 0; @@ -126,9 +130,7 @@ aic_isa_alloc_resources(device_t dev) } sc->sc_aic.dev = dev; - sc->sc_aic.unit = device_get_unit(dev); - sc->sc_aic.tag = rman_get_bustag(sc->sc_port); - sc->sc_aic.bsh = rman_get_bushandle(sc->sc_port); + sc->sc_aic.res = sc->sc_port; return (0); } @@ -143,7 +145,8 @@ aic_isa_release_resources(device_t dev) bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq); if (sc->sc_drq) bus_release_resource(dev, SYS_RES_DRQ, 0, sc->sc_drq); - sc->sc_port = sc->sc_irq = sc->sc_drq = 0; + sc->sc_port = sc->sc_irq = sc->sc_drq = NULL; + mtx_destroy(&sc->sc_aic.lock); } static int @@ -172,10 +175,8 @@ aic_isa_probe(device_t dev) continue; if (aic_isa_alloc_resources(dev)) continue; - if (!aic_probe(aic)) { - aic_isa_release_resources(dev); + if (aic_probe(aic) == 0) break; - } aic_isa_release_resources(dev); } @@ -183,6 +184,7 @@ aic_isa_probe(device_t dev) return (ENXIO); porta = aic_inb(aic, PORTA); + aic_isa_release_resources(dev); if (isa_get_irq(dev) == -1) bus_set_resource(dev, SYS_RES_IRQ, 0, PORTA_IRQ(porta), 1); if ((aic->flags & AIC_DMA_ENABLE) && isa_get_drq(dev) == -1) @@ -211,8 +213,8 @@ aic_isa_attach(device_t dev) return (error); } - error = bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_CAM|INTR_ENTROPY, - NULL, aic_intr, aic, &sc->sc_ih); + error = bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_CAM | INTR_ENTROPY | + INTR_MPSAFE, NULL, aic_intr, aic, &sc->sc_ih); if (error) { device_printf(dev, "failed to register interrupt handler\n"); aic_isa_release_resources(dev); |