Inline cam_periph_lock|unlock to make debugging easier. Use more

CAM_SIM_LOCK() more uniformly.
This commit is contained in:
Scott Long 2007-04-19 22:46:26 +00:00
parent 919c80dfc7
commit 11e4face2d
3 changed files with 21 additions and 30 deletions

View File

@ -549,26 +549,6 @@ camperiphfree(struct cam_periph *periph)
xpt_lock_buses();
}
/*
* 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

View File

@ -32,6 +32,7 @@
#define _CAM_CAM_PERIPH_H 1
#include <sys/queue.h>
#include <cam/cam_sim.h>
#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 */

View File

@ -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);
}
}