--- //depot/vendor/freebsd/src/sys/dev/tws/tws.c +++ //depot/user/jhb/cleanup/sys/dev/tws/tws.c @@ -198,6 +198,7 @@ mtx_init( &sc->sim_lock, "tws_sim_lock", NULL, MTX_DEF); mtx_init( &sc->gen_lock, "tws_gen_lock", NULL, MTX_DEF); mtx_init( &sc->io_lock, "tws_io_lock", NULL, MTX_DEF | MTX_RECURSE); + callout_init(&sc->stats_timer, CALLOUT_MPSAFE); if ( tws_init_trace_q(sc) == FAILURE ) printf("trace init failure\n"); @@ -408,11 +409,20 @@ TWS_TRACE(sc, "bus release mem resource", 0, sc->reg_res_id); } + for ( i=0; i< tws_queue_depth; i++) { + if (sc->reqs[i].dma_map) + bus_dmamap_destroy(sc->data_tag, sc->reqs[i].dma_map); + callout_drain(&sc->reqs[i].timeout); + } + + callout_drain(&sc->stats_timer); free(sc->reqs, M_TWS); free(sc->sense_bufs, M_TWS); free(sc->scan_ccb, M_TWS); if (sc->ioctl_data_mem) bus_dmamem_free(sc->data_tag, sc->ioctl_data_mem, sc->ioctl_data_map); + if (sc->data_tag) + bus_dma_tag_destroy(sc->data_tag); free(sc->aen_q.q, M_TWS); free(sc->trace_q.q, M_TWS); mtx_destroy(&sc->q_lock); @@ -709,7 +719,7 @@ sc->reqs[i].cmd_pkt->hdr.header_desc.size_header = 128; - callout_handle_init(&sc->reqs[i].thandle); + callout_init(&sc->reqs[i].timeout, CALLOUT_MPSAFE); sc->reqs[i].state = TWS_REQ_STATE_FREE; if ( i >= TWS_RESERVED_REQS ) tws_q_insert_tail(sc, &sc->reqs[i], TWS_FREE_Q); @@ -859,7 +869,7 @@ r->error_code = TWS_REQ_RET_INVALID; r->cb = NULL; r->ccb_ptr = NULL; - r->thandle.callout = NULL; + callout_stop(&r->timeout); r->next = r->prev = NULL; r->state = ((type == TWS_REQ_TYPE_SCSI_IO) ? TWS_REQ_STATE_TRAN : TWS_REQ_STATE_BUSY); --- //depot/vendor/freebsd/src/sys/dev/tws/tws.h +++ //depot/user/jhb/cleanup/sys/dev/tws/tws.h @@ -268,4 +268,5 @@ union ccb *scan_ccb; /* pointer to a ccb */ struct tws_request *q_head[TWS_MAX_QS]; /* head pointers to q's */ struct tws_request *q_tail[TWS_MAX_QS]; /* tail pointers to q's */ + struct callout stats_timer; }; --- //depot/vendor/freebsd/src/sys/dev/tws/tws_cam.c +++ //depot/user/jhb/cleanup/sys/dev/tws/tws_cam.c @@ -341,7 +341,7 @@ tws_q_remove_request(sc, req, TWS_BUSY_Q); mtx_unlock(&sc->q_lock); - untimeout(tws_timeout, req, req->thandle); + callout_stop(&req->timeout); tws_unmap_request(req->sc, req); @@ -362,7 +362,7 @@ TWS_TRACE_DEBUG(sc, "getset complete", req, req->request_id); - untimeout(tws_timeout, req, req->thandle); + callout_stop(&req->timeout); tws_unmap_request(sc, req); free(req->data, M_TWS); @@ -380,7 +380,7 @@ TWS_TRACE_DEBUG(sc, "aen complete", 0, req->request_id); - untimeout(tws_timeout, req, req->thandle); + callout_stop(&req->timeout); tws_unmap_request(sc, req); sense = (struct tws_command_header *)req->data; @@ -454,7 +454,7 @@ { struct tws_softc *sc = req->sc; - untimeout(tws_timeout, req, req->thandle); + callout_stop(&req->timeout); tws_unmap_request(sc, req); } @@ -561,7 +561,7 @@ xpt_done(ccb); mtx_unlock(&sc->sim_lock); - untimeout(tws_timeout, req, req->thandle); + callout_stop(&req->timeout); tws_unmap_request(req->sc, req); mtx_lock(&sc->q_lock); tws_q_remove_request(sc, req, TWS_BUSY_Q); @@ -591,7 +591,7 @@ 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->thandle); + callout_stop(&req->timeout); req->error_code = TWS_REQ_RET_RESET; ccb = (union ccb *)(req->ccb_ptr); @@ -622,7 +622,7 @@ r = &sc->reqs[TWS_REQ_TYPE_AEN_FETCH]; if ( r->state != TWS_REQ_STATE_FREE ) { TWS_TRACE_DEBUG(sc, "reset aen req", 0, 0); - untimeout(tws_timeout, r, r->thandle); + callout_stop(&r->timeout); tws_unmap_request(sc, r); free(r->data, M_TWS); r->state = TWS_REQ_STATE_FREE; @@ -638,7 +638,7 @@ r = &sc->reqs[TWS_REQ_TYPE_GETSET_PARAM]; if ( r->state != TWS_REQ_STATE_FREE ) { TWS_TRACE_DEBUG(sc, "reset setparam req", 0, 0); - untimeout(tws_timeout, r, r->thandle); + callout_stop(&r->timeout); tws_unmap_request(sc, r); free(r->data, M_TWS); r->state = TWS_REQ_STATE_FREE; @@ -747,7 +747,7 @@ * and submit the I/O. */ sc->stats.scsi_ios++; - req->thandle = timeout(tws_timeout, req, (ccb_h->timeout * hz)/1000); + callout_reset(&req->timeout, (ccb_h->timeout * hz) / 1000, tws_timeout, req); error = tws_map_request(sc, req); return(error); } @@ -785,7 +785,7 @@ bzero(req->data, TWS_SECTOR_SIZE); req->flags = TWS_DIR_IN; - req->thandle = timeout(tws_timeout, req, (TWS_IO_TIMEOUT * hz)); + callout_reset(&req->timeout, (TWS_IO_TIMEOUT * hz), tws_timeout, req); error = tws_map_request(sc, req); return(error); @@ -832,7 +832,7 @@ param->parameter_size_bytes = (u_int16_t)param_size; memcpy(param->data, data, param_size); - req->thandle = timeout(tws_timeout, req, (TWS_IOCTL_TIMEOUT * hz)); + callout_reset(&req->timeout, (TWS_IOCTL_TIMEOUT * hz), tws_timeout, req); error = tws_map_request(sc, req); return(error); @@ -1168,7 +1168,6 @@ return; } - tws_teardown_intr(sc); xpt_freeze_simq(sc->sim, 1); tws_send_event(sc, TWS_RESET_START); @@ -1191,7 +1190,6 @@ mtx_unlock(&sc->gen_lock); xpt_release_simq(sc->sim, 1); - tws_setup_intr(sc, sc->irqs); } void @@ -1205,7 +1203,6 @@ return; } - tws_teardown_intr(sc); xpt_freeze_simq(sc->sim, 1); tws_send_event(sc, TWS_RESET_START); @@ -1222,7 +1219,6 @@ mtx_unlock(&sc->gen_lock); xpt_release_simq(sc->sim, 1); - tws_setup_intr(sc, sc->irqs); } static void --- //depot/vendor/freebsd/src/sys/dev/tws/tws_hdm.c +++ //depot/user/jhb/cleanup/sys/dev/tws/tws_hdm.c @@ -161,7 +161,7 @@ req->error_code = TWS_REQ_RET_INVALID; req->cb = NULL; req->ccb_ptr = NULL; - req->thandle.callout = NULL; + callout_stop(&req->timeout); req->next = req->prev = NULL; req->state = TWS_REQ_STATE_BUSY; #endif // 0 --- //depot/vendor/freebsd/src/sys/dev/tws/tws_hdm.h +++ //depot/user/jhb/cleanup/sys/dev/tws/tws_hdm.h @@ -410,7 +410,7 @@ void (*cb)(struct tws_request *); /* callback func */ bus_dmamap_t dma_map; /* dma map */ union ccb *ccb_ptr; /* pointer to ccb */ - struct callout_handle thandle; /* handle to req timeout */ + struct callout timeout; /* request timeout timer */ struct tws_softc *sc; /* pointer back to ctlr softc */ struct tws_request *next; /* pointer to next request */ --- //depot/vendor/freebsd/src/sys/dev/tws/tws_services.c +++ //depot/user/jhb/cleanup/sys/dev/tws/tws_services.c @@ -395,7 +395,6 @@ , sc->stats.num_intrs); TWS_TRACE(sc, "reqs(ioctls, scsi)", sc->stats.ioctls , sc->stats.scsi_ios); - timeout(tws_print_stats, sc, 300*hz); - + callout_reset(&sc->stats_timer, 300 * hz, tws_print_stats, sc); } /* --------------------- misc service end --------------------- */