diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2010-06-02 01:33:58 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2010-06-02 01:33:58 +0000 |
commit | f781d3bcd838d60368133bf54ee4c6771724fd19 (patch) | |
tree | d8505174a0c396b76e02a0d10908bc83d33a5d21 /sys | |
parent | 9432f16eb35bbe9fa8fac3e7af067cb4551114d7 (diff) |
protect the ccb free queue with its own mutex
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ic/ciss.c | 11 | ||||
-rw-r--r-- | sys/dev/ic/cissvar.h | 3 |
2 files changed, 11 insertions, 3 deletions
diff --git a/sys/dev/ic/ciss.c b/sys/dev/ic/ciss.c index 5b0f8418bad..7020040064f 100644 --- a/sys/dev/ic/ciss.c +++ b/sys/dev/ic/ciss.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ciss.c,v 1.46 2010/06/02 01:27:20 dlg Exp $ */ +/* $OpenBSD: ciss.c,v 1.47 2010/06/02 01:33:57 dlg Exp $ */ /* * Copyright (c) 2005,2006 Michael Shalayeff @@ -112,12 +112,15 @@ ciss_get_ccb(struct ciss_softc *sc) { struct ciss_ccb *ccb; + mtx_enter(&sc->sc_free_ccb_mtx); if ((ccb = TAILQ_LAST(&sc->sc_free_ccb, ciss_queue_head))) { TAILQ_REMOVE(&sc->sc_free_ccb, ccb, ccb_link); ccb->ccb_state = CISS_CCB_READY; ccb->ccb_xs = NULL; } - return ccb; + mtx_leave(&sc->sc_free_ccb_mtx); + + return (ccb); } void @@ -133,7 +136,10 @@ ciss_put_ccb(struct ciss_ccb *ccb) ccb->ccb_state = CISS_CCB_FREE; ccb->ccb_xs = NULL; ccb->ccb_data = NULL; + + mtx_enter(&sc->sc_free_ccb_mtx); TAILQ_INSERT_TAIL(&sc->sc_free_ccb, ccb, ccb_link); + mtx_leave(&sc->sc_free_ccb_mtx); } int @@ -255,6 +261,7 @@ ciss_attach(struct ciss_softc *sc) } TAILQ_INIT(&sc->sc_free_ccb); + mtx_init(&sc->sc_free_ccb_mtx, IPL_BIO); maxfer = sc->maxsg * PAGE_SIZE; for (i = 0; total; i++, total -= sc->ccblen) { diff --git a/sys/dev/ic/cissvar.h b/sys/dev/ic/cissvar.h index 459ee0eeebe..049c9ff9983 100644 --- a/sys/dev/ic/cissvar.h +++ b/sys/dev/ic/cissvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cissvar.h,v 1.10 2010/06/02 01:27:20 dlg Exp $ */ +/* $OpenBSD: cissvar.h,v 1.11 2010/06/02 01:33:57 dlg Exp $ */ /* * Copyright (c) 2005,2006 Michael Shalayeff @@ -41,6 +41,7 @@ struct ciss_softc { #define CISS_BIO 0x0001 int ccblen, maxcmd, maxsg, nbus, ndrives, maxunits; ciss_queue_head sc_free_ccb; + struct mutex sc_free_ccb_mtx; bus_space_tag_t iot; bus_space_handle_t ioh, cfg_ioh; |