From 4fc5076a7d9d61396b2037b5b15b9b762e3f1501 Mon Sep 17 00:00:00 2001 From: scottl Date: Thu, 19 Apr 2007 22:46:26 +0000 Subject: Inline cam_periph_lock|unlock to make debugging easier. Use more CAM_SIM_LOCK() more uniformly. --- sys/cam/cam_periph.c | 20 -------------------- sys/cam/cam_periph.h | 15 +++++++++++++-- sys/cam/cam_xpt.c | 16 ++++++++-------- 3 files changed, 21 insertions(+), 30 deletions(-) (limited to 'sys/cam') diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c index e2e5303..172bc7e 100644 --- a/sys/cam/cam_periph.c +++ b/sys/cam/cam_periph.c @@ -550,26 +550,6 @@ camperiphfree(struct cam_periph *periph) } /* - * Wait interruptibly for an exclusive lock. - */ -void -cam_periph_lock(struct cam_periph *periph) -{ - - mtx_lock(periph->sim->mtx); -} - -/* - * Unlock and wake up any waiters. - */ -void -cam_periph_unlock(struct cam_periph *periph) -{ - - mtx_unlock(periph->sim->mtx); -} - -/* * Map user virtual pointers into kernel virtual address space, so we can * access the memory. This won't work on physical pointers, for now it's * up to the caller to check for that. (XXX KDM -- should we do that here diff --git a/sys/cam/cam_periph.h b/sys/cam/cam_periph.h index 8a6c1eb..e6073d9 100644 --- a/sys/cam/cam_periph.h +++ b/sys/cam/cam_periph.h @@ -32,6 +32,7 @@ #define _CAM_CAM_PERIPH_H 1 #include +#include #ifdef _KERNEL @@ -138,8 +139,6 @@ cam_status cam_periph_alloc(periph_ctor_t *periph_ctor, char *name, cam_periph_type type, struct cam_path *, ac_callback_t *, ac_code, void *arg); struct cam_periph *cam_periph_find(struct cam_path *path, char *name); -void cam_periph_lock(struct cam_periph *periph); -void cam_periph_unlock(struct cam_periph *periph); cam_status cam_periph_acquire(struct cam_periph *periph); void cam_periph_release(struct cam_periph *periph); int cam_periph_hold(struct cam_periph *periph, int priority); @@ -177,5 +176,17 @@ void cam_periph_freeze_after_event(struct cam_periph *periph, int cam_periph_error(union ccb *ccb, cam_flags camflags, u_int32_t sense_flags, union ccb *save_ccb); +static __inline void +cam_periph_lock(struct cam_periph *periph) +{ + mtx_lock(periph->sim->mtx); +} + +static __inline void +cam_periph_unlock(struct cam_periph *periph) +{ + mtx_unlock(periph->sim->mtx); +} + #endif /* _KERNEL */ #endif /* _CAM_CAM_PERIPH_H */ diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index c211711..a0001e1 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -1428,7 +1428,7 @@ xpt_scanner_thread(void *dummy) TAILQ_REMOVE(&queue, &ccb->ccb_h, sim_links.tqe); sim = ccb->ccb_h.path->bus->sim; - mtx_lock(sim->mtx); + CAM_SIM_LOCK(sim); ccb->ccb_h.func_code = XPT_SCAN_BUS; ccb->ccb_h.cbfcnp = xptdone; @@ -1436,7 +1436,7 @@ xpt_scanner_thread(void *dummy) cam_periph_runccb(ccb, NULL, 0, 0, NULL); xpt_free_path(ccb->ccb_h.path); xpt_free_ccb(ccb); - mtx_unlock(sim->mtx); + CAM_SIM_UNLOCK(sim); } } } @@ -2661,9 +2661,9 @@ xptbustraverse(struct cam_eb *start_bus, xpt_busfunc_t *tr_func, void *arg) next_bus = TAILQ_NEXT(bus, links); mtx_unlock(&xsoftc.xpt_topo_lock); - mtx_lock(bus->sim->mtx); + CAM_SIM_LOCK(bus->sim); retval = tr_func(bus, arg); - mtx_unlock(bus->sim->mtx); + CAM_SIM_UNLOCK(bus->sim); if (retval == 0) return(retval); mtx_lock(&xsoftc.xpt_topo_lock); @@ -4068,12 +4068,12 @@ xpt_create_path_unlocked(struct cam_path **new_path_ptr, bus = xpt_find_bus(path_id); if (bus != NULL) { need_unlock = 1; - mtx_lock(bus->sim->mtx); + CAM_SIM_LOCK(bus->sim); } } status = xpt_compile_path(path, periph, path_id, target_id, lun_id); if (need_unlock) - mtx_unlock(bus->sim->mtx); + CAM_SIM_UNLOCK(bus->sim); if (status != CAM_REQ_CMP) { free(path, M_CAMXPT); path = NULL; @@ -7248,10 +7248,10 @@ camisr(void *dummy) while ((sim = TAILQ_FIRST(&queue)) != NULL) { TAILQ_REMOVE(&queue, sim, links); - mtx_lock(sim->mtx); + CAM_SIM_LOCK(sim); sim->flags &= ~CAM_SIM_ON_DONEQ; camisr_runqueue(&sim->sim_doneq); - mtx_unlock(sim->mtx); + CAM_SIM_UNLOCK(sim); } } -- cgit v1.1