static void tws_drain_busy_queue(struct tws_softc *sc) { struct tws_request *req; union ccb *ccb; TWS_TRACE_DEBUG(sc, "entry", 0, 0); mtx_lock(&sc->q_lock); req = tws_q_remove_tail(sc, TWS_BUSY_Q); mtx_unlock(&sc->q_lock); while ( req ) { TWS_TRACE_DEBUG(sc, "moved to TWS_COMPLETE_Q", 0, req->request_id); untimeout(tws_timeout, req, req->ccb_ptr->ccb_h.timeout_ch); req->error_code = TWS_REQ_RET_RESET; ccb = (union ccb *)(req->ccb_ptr); ccb->ccb_h.status &= ~CAM_SIM_QUEUED; ccb->ccb_h.status |= CAM_REQUEUE_REQ; ccb->ccb_h.status |= CAM_SCSI_BUS_RESET; tws_unmap_request(req->sc, req); mtx_lock(&sc->sim_lock); xpt_done(req->ccb_ptr); mtx_unlock(&sc->sim_lock); mtx_lock(&sc->q_lock); tws_q_insert_tail(sc, req, TWS_FREE_Q); req = tws_q_remove_tail(sc, TWS_BUSY_Q); mtx_unlock(&sc->q_lock); } }
static void tws_drain_busy_queue(struct tws_softc *sc) { struct tws_request *req; TWS_TRACE_DEBUG(sc, "entry", 0, 0); lockmgr(&sc->q_lock, LK_EXCLUSIVE); req = tws_q_remove_tail(sc, TWS_BUSY_Q); lockmgr(&sc->q_lock, LK_RELEASE); while ( req ) { callout_stop(req->ccb_ptr->ccb_h.timeout_ch); tws_unmap_request(req->sc, req); TWS_TRACE_DEBUG(sc, "drained", 0, req->request_id); lockmgr(&sc->sim_lock, LK_EXCLUSIVE); req->ccb_ptr->ccb_h.status = CAM_REQUEUE_REQ; xpt_done(req->ccb_ptr); lockmgr(&sc->sim_lock, LK_RELEASE); lockmgr(&sc->q_lock, LK_EXCLUSIVE); tws_q_insert_tail(sc, req, TWS_FREE_Q); req = tws_q_remove_tail(sc, TWS_BUSY_Q); lockmgr(&sc->q_lock, LK_RELEASE); } }