summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2007-11-28 13:47:10 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2007-11-28 13:47:10 +0000
commitc084749f5c95ba0440adc6c76932ac3277c3f860 (patch)
tree813f43685081cdda061de6678c286af42d4da777 /sys/dev/pci
parentcab9e4984ef886485a179deef66ebafa436ba779 (diff)
make ata controllers protect their own command lists so atascsi doesnt have
to continually go to splbio to ensure its safe to work on them. shrinks code a little.
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/ahci.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/dev/pci/ahci.c b/sys/dev/pci/ahci.c
index c9aef7bd030..aaebba7f7b0 100644
--- a/sys/dev/pci/ahci.c
+++ b/sys/dev/pci/ahci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ahci.c,v 1.134 2007/11/26 15:59:53 dlg Exp $ */
+/* $OpenBSD: ahci.c,v 1.135 2007/11/28 13:47:09 dlg Exp $ */
/*
* Copyright (c) 2006 David Gwynne <dlg@openbsd.org>
@@ -24,6 +24,7 @@
#include <sys/device.h>
#include <sys/proc.h>
#include <sys/queue.h>
+#include <sys/mutex.h>
#include <machine/bus.h>
@@ -354,6 +355,7 @@ struct ahci_port {
TAILQ_HEAD(, ahci_ccb) ap_ccb_free;
TAILQ_HEAD(, ahci_ccb) ap_ccb_pending;
+ struct mutex ap_ccb_mtx;
u_int32_t ap_state;
#define AP_S_NORMAL 0
@@ -890,6 +892,7 @@ ahci_port_alloc(struct ahci_softc *sc, u_int port)
#endif
TAILQ_INIT(&ap->ap_ccb_free);
TAILQ_INIT(&ap->ap_ccb_pending);
+ mtx_init(&ap->ap_ccb_mtx, IPL_BIO);
/* Disable port interrupts */
ahci_pwrite(ap, AHCI_PREG_IE, 0);
@@ -1873,12 +1876,14 @@ ahci_get_ccb(struct ahci_port *ap)
{
struct ahci_ccb *ccb;
+ mtx_enter(&ap->ap_ccb_mtx);
ccb = TAILQ_FIRST(&ap->ap_ccb_free);
if (ccb != NULL) {
KASSERT(ccb->ccb_xa.state == ATA_S_PUT);
TAILQ_REMOVE(&ap->ap_ccb_free, ccb, ccb_entry);
ccb->ccb_xa.state = ATA_S_SETUP;
}
+ mtx_leave(&ap->ap_ccb_mtx);
return (ccb);
}
@@ -1899,7 +1904,9 @@ ahci_put_ccb(struct ahci_ccb *ccb)
#endif
ccb->ccb_xa.state = ATA_S_PUT;
+ mtx_enter(&ap->ap_ccb_mtx);
TAILQ_INSERT_TAIL(&ap->ap_ccb_free, ccb, ccb_entry);
+ mtx_leave(&ap->ap_ccb_mtx);
}
struct ahci_ccb *