diff options
Diffstat (limited to 'sys/cam/cam_sim.c')
-rw-r--r-- | sys/cam/cam_sim.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/sys/cam/cam_sim.c b/sys/cam/cam_sim.c index 530e160..9a8c666 100644 --- a/sys/cam/cam_sim.c +++ b/sys/cam/cam_sim.c @@ -87,7 +87,6 @@ cam_sim_alloc(sim_action_func sim_action, sim_poll_func sim_poll, sim->flags = 0; sim->refcount = 1; sim->devq = queue; - sim->max_ccbs = 8; /* Reserve for management purposes. */ sim->mtx = mtx; if (mtx == &Giant) { sim->flags |= 0; @@ -96,17 +95,12 @@ cam_sim_alloc(sim_action_func sim_action, sim_poll_func sim_poll, sim->flags |= CAM_SIM_MPSAFE; callout_init(&sim->callout, 1); } - - SLIST_INIT(&sim->ccb_freeq); - TAILQ_INIT(&sim->sim_doneq); - return (sim); } void cam_sim_free(struct cam_sim *sim, int free_devq) { - union ccb *ccb; int error; mtx_assert(sim->mtx, MA_OWNED); @@ -118,10 +112,6 @@ cam_sim_free(struct cam_sim *sim, int free_devq) KASSERT(sim->refcount == 0, ("sim->refcount == 0")); - while ((ccb = (union ccb *)SLIST_FIRST(&sim->ccb_freeq)) != NULL) { - SLIST_REMOVE_HEAD(&sim->ccb_freeq, xpt_links.sle); - xpt_free_ccb(ccb); - } if (free_devq) cam_simq_free(sim->devq); free(sim, M_CAMSIM); @@ -130,21 +120,31 @@ cam_sim_free(struct cam_sim *sim, int free_devq) void cam_sim_release(struct cam_sim *sim) { - KASSERT(sim->refcount >= 1, ("sim->refcount >= 1")); - mtx_assert(sim->mtx, MA_OWNED); + int lock; + lock = (mtx_owned(sim->mtx) == 0); + if (lock) + CAM_SIM_LOCK(sim); + KASSERT(sim->refcount >= 1, ("sim->refcount >= 1")); sim->refcount--; if (sim->refcount == 0) wakeup(sim); + if (lock) + CAM_SIM_UNLOCK(sim); } void cam_sim_hold(struct cam_sim *sim) { - KASSERT(sim->refcount >= 1, ("sim->refcount >= 1")); - mtx_assert(sim->mtx, MA_OWNED); + int lock; + lock = (mtx_owned(sim->mtx) == 0); + if (lock) + CAM_SIM_LOCK(sim); + KASSERT(sim->refcount >= 1, ("sim->refcount >= 1")); sim->refcount++; + if (lock) + CAM_SIM_UNLOCK(sim); } void |