aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/amr/amr_pci.c
diff options
context:
space:
mode:
authorScott Long <scottl@FreeBSD.org>2005-01-16 07:34:26 +0000
committerScott Long <scottl@FreeBSD.org>2005-01-16 07:34:26 +0000
commit5b4a781b96ffc9526a18dd0d5576dbda89bffa8a (patch)
treebfdf6effed4ced3ac3ccec00ef9ddd7f6c13681e /sys/dev/amr/amr_pci.c
parent835e0fa318d85113643e78fceff2f806f6c34fc4 (diff)
downloadsrc-5b4a781b96ffc9526a18dd0d5576dbda89bffa8a.tar.gz
src-5b4a781b96ffc9526a18dd0d5576dbda89bffa8a.zip
Lock the AMR driver:
- Introduce the amr_io_lock to control access to command queues, bio queues, and the hardware. - Eliminate the taskqueue and do all completion processing in the ithread. - Assign a static slot number to each command instead of doing a linear search for free slots each time a command is needed. - Modify the interrupt handler to more closely match what Linux does, for safety.
Notes
Notes: svn path=/head/; revision=140340
Diffstat (limited to 'sys/dev/amr/amr_pci.c')
-rw-r--r--sys/dev/amr/amr_pci.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/dev/amr/amr_pci.c b/sys/dev/amr/amr_pci.c
index 8f3ef11b1b2e..d408eefe3c2d 100644
--- a/sys/dev/amr/amr_pci.c
+++ b/sys/dev/amr/amr_pci.c
@@ -173,6 +173,7 @@ amr_pci_attach(device_t dev)
sc = device_get_softc(dev);
bzero(sc, sizeof(*sc));
sc->amr_dev = dev;
+ mtx_init(&sc->amr_io_lock, "AMR IO Lock", NULL, MTX_DEF);
/* assume failure is 'not configured' */
error = ENXIO;
@@ -233,7 +234,7 @@ amr_pci_attach(device_t dev)
device_printf(sc->amr_dev, "can't allocate interrupt\n");
goto out;
}
- if (bus_setup_intr(sc->amr_dev, sc->amr_irq, INTR_TYPE_BIO | INTR_ENTROPY, amr_pci_intr, sc, &sc->amr_intr)) {
+ if (bus_setup_intr(sc->amr_dev, sc->amr_irq, INTR_TYPE_BIO | INTR_ENTROPY | INTR_MPSAFE, amr_pci_intr, sc, &sc->amr_intr)) {
device_printf(sc->amr_dev, "can't set up interrupt\n");
goto out;
}
@@ -271,7 +272,7 @@ amr_pci_attach(device_t dev)
MAXBSIZE, AMR_NSEG, /* maxsize, nsegments */
MAXBSIZE, /* maxsegsize */
BUS_DMA_ALLOCNOW, /* flags */
- busdma_lock_mutex, &Giant, /* lockfunc, lockarg */
+ busdma_lock_mutex, &sc->amr_io_lock, /* lockfunc, lockarg */
&sc->amr_buffer_dmat)) {
device_printf(sc->amr_dev, "can't allocate buffer DMA tag\n");
goto out;
@@ -423,7 +424,9 @@ amr_pci_intr(void *arg)
debug_called(2);
/* collect finished commands, queue anything waiting */
+ mtx_lock(&sc->amr_io_lock);
amr_done(sc);
+ mtx_unlock(&sc->amr_io_lock);
}
/********************************************************************************