Date: Tue, 31 Oct 2006 08:20:46 GMT From: Scott Long <scottl@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 108806 for review Message-ID: <200610310820.k9V8KkIp027625@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=108806 Change 108806 by scottl@scottl-x64 on 2006/10/31 08:20:31 Refine the macros in the case of locking not being enabled. Add some extra assertions. Affected files ... .. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpt.c#13 edit .. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpt.h#14 edit .. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpt_cam.c#14 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/dev/mpt/mpt.c#13 (text+ko) ==== @@ -700,6 +700,8 @@ mpt = (struct mpt_softc *)arg; mpt_lprt(mpt, MPT_PRT_DEBUG2, "enter mpt_intr\n"); + MPT_LOCK_ASSERT(mpt); + while ((reply_desc = mpt_pop_reply_queue(mpt)) != MPT_REPLY_EMPTY) { request_t *req; MSG_DEFAULT_REPLY *reply_frame; @@ -1167,7 +1169,7 @@ } KASSERT(req->state != REQ_STATE_FREE, ("freeing free request")); KASSERT(!(req->state & REQ_STATE_LOCKED), ("freeing locked request")); - mtx_assert(&mpt->mpt_lock, MA_OWNED); + MPT_LOCK_ASSERT(mpt); KASSERT(mpt_req_on_free_list(mpt, req) == 0, ("mpt_free_request: req %p:%u func %x already on freelist", req, req->serno, ((MSG_REQUEST_HEADER *)req->req_vbuf)->Function)); @@ -1216,7 +1218,7 @@ request_t *req; retry: - mtx_assert(&mpt->mpt_lock, MA_OWNED); + MPT_LOCK_ASSERT(mpt); req = TAILQ_FIRST(&mpt->request_free_list); if (req != NULL) { KASSERT(req == &mpt->request_pool[req->index], ==== //depot/projects/scottl-camlock/src/sys/dev/mpt/mpt.h#14 (text+ko) ==== @@ -713,6 +713,7 @@ #define MPT_LOCK(mpt) mpt_lockspl(mpt) #define MPT_UNLOCK(mpt) mpt_unlockspl(mpt) #define MPT_OWNED(mpt) mpt->mpt_islocked +#define MPT_LOCK_ASSERT(mpt) #define MPTLOCK_2_CAMLOCK MPT_UNLOCK #define CAMLOCK_2_MPTLOCK MPT_LOCK #define MPT_LOCK_SETUP(mpt) @@ -780,6 +781,7 @@ #define MPT_LOCK(mpt) mtx_lock(&(mpt)->mpt_lock) #define MPT_UNLOCK(mpt) mtx_unlock(&(mpt)->mpt_lock) #define MPT_OWNED(mpt) mtx_owned(&(mpt)->mpt_lock) +#define MPT_LOCK_ASSERT(mpt) mtx_assert(&(mpt)->mpt_lock, MA_OWNED) #define MPTLOCK_2_CAMLOCK(mpt) #define CAMLOCK_2_MPTLOCK(mpt) #define mpt_sleep(mpt, ident, priority, wmesg, timo) \ @@ -796,30 +798,11 @@ #define MPT_IFLAGS INTR_TYPE_CAM | INTR_ENTROPY #define MPT_LOCK_SETUP(mpt) do { } while (0) #define MPT_LOCK_DESTROY(mpt) do { } while (0) -#if 0 -#define MPT_LOCK(mpt) \ - device_printf(mpt->dev, "LOCK %s:%d\n", __FILE__, __LINE__); \ - KASSERT(mpt->mpt_locksetup == 0, \ - ("recursive lock acquire at %s:%d", __FILE__, __LINE__)); \ - mpt->mpt_locksetup = 1 -#define MPT_UNLOCK(mpt) \ - device_printf(mpt->dev, "UNLK %s:%d\n", __FILE__, __LINE__); \ - KASSERT(mpt->mpt_locksetup == 1, \ - ("release unowned lock at %s:%d", __FILE__, __LINE__)); \ - mpt->mpt_locksetup = 0 -#else -#define MPT_LOCK(mpt) \ - KASSERT(mpt->mpt_locksetup == 0, \ - ("recursive lock acquire at %s:%d", __FILE__, __LINE__)); \ - mpt->mpt_locksetup = 1 -#define MPT_UNLOCK(mpt) \ - KASSERT(mpt->mpt_locksetup == 1, \ - ("release unowned lock at %s:%d", __FILE__, __LINE__)); \ - mpt->mpt_locksetup = 0 -#endif -#define MPT_OWNED(mpt) mpt->mpt_locksetup -#define MPTLOCK_2_CAMLOCK(mpt) MPT_UNLOCK(mpt) -#define CAMLOCK_2_MPTLOCK(mpt) MPT_LOCK(mpt) +#define MPT_LOCK_ASSERT(mpt) mtx_assert(&Giant, MA_OWNED) +#define MPT_LOCK(mpt) mtx_lock(&Giant) +#define MPT_UNLOCK(mpt) mtx_unlock(&Giant) +#define MPTLOCK_2_CAMLOCK(mpt) +#define CAMLOCK_2_MPTLOCK(mpt) static __inline int mpt_sleep(struct mpt_softc *, void *, int, const char *, int); @@ -837,9 +820,7 @@ mpt_sleep(struct mpt_softc *mpt, void *i, int p, const char *w, int t) { int r; - MPT_UNLOCK(mpt); r = tsleep(i, p, w, t); - MPT_LOCK(mpt); return (r); } #endif ==== //depot/projects/scottl-camlock/src/sys/dev/mpt/mpt_cam.c#14 (text+ko) ==== @@ -2856,6 +2856,7 @@ mpt = (struct mpt_softc *)cam_sim_softc(sim); raid_passthru = (sim == mpt->phydisk_sim); + MPT_LOCK_ASSERT(mpt); tgt = ccb->ccb_h.target_id; lun = ccb->ccb_h.target_lun;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200610310820.k9V8KkIp027625>