Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Sep 2014 20:38:02 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r272000 - head/sys/dev/tws
Message-ID:  <201409222038.s8MKc2If006244@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Mon Sep 22 20:38:01 2014
New Revision: 272000
URL: http://svnweb.freebsd.org/changeset/base/272000

Log:
  Switch from timeout(9) to callout(9).  In addition, do not teardown the
  IRQ handler while resetting the controller and add some missing teardown
  actions in detach.
  
  Reviewed by:	delphij

Modified:
  head/sys/dev/tws/tws.c
  head/sys/dev/tws/tws.h
  head/sys/dev/tws/tws_cam.c
  head/sys/dev/tws/tws_hdm.c
  head/sys/dev/tws/tws_hdm.h
  head/sys/dev/tws/tws_services.c

Modified: head/sys/dev/tws/tws.c
==============================================================================
--- head/sys/dev/tws/tws.c	Mon Sep 22 20:34:36 2014	(r271999)
+++ head/sys/dev/tws/tws.c	Mon Sep 22 20:38:01 2014	(r272000)
@@ -198,6 +198,7 @@ tws_attach(device_t dev)
     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_detach(device_t dev)
             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 @@ tws_init_reqs(struct tws_softc *sc, u_in
 
         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 @@ tws_get_request(struct tws_softc *sc, u_
         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);

Modified: head/sys/dev/tws/tws.h
==============================================================================
--- head/sys/dev/tws/tws.h	Mon Sep 22 20:34:36 2014	(r271999)
+++ head/sys/dev/tws/tws.h	Mon Sep 22 20:38:01 2014	(r272000)
@@ -268,4 +268,5 @@ struct tws_softc {
     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;
 };

Modified: head/sys/dev/tws/tws_cam.c
==============================================================================
--- head/sys/dev/tws/tws_cam.c	Mon Sep 22 20:34:36 2014	(r271999)
+++ head/sys/dev/tws/tws_cam.c	Mon Sep 22 20:38:01 2014	(r272000)
@@ -341,7 +341,7 @@ tws_scsi_complete(struct tws_request *re
     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_getset_param_complete(struct tws_req
 
     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_aen_complete(struct tws_request *req
 
     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 @@ tws_cmd_complete(struct tws_request *req
 {
     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 @@ tws_scsi_err_complete(struct tws_request
     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 @@ tws_drain_busy_queue(struct tws_softc *s
     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 @@ tws_drain_reserved_reqs(struct tws_softc
     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 @@ tws_drain_reserved_reqs(struct tws_softc
     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 @@ tws_execute_scsi(struct tws_softc *sc, u
      * 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 @@ tws_send_scsi_cmd(struct tws_softc *sc, 
     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 @@ tws_set_param(struct tws_softc *sc, u_in
     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 @@ tws_timeout(void *arg)
         return;
     }
 
-    tws_teardown_intr(sc);
     xpt_freeze_simq(sc->sim, 1);
 
     tws_send_event(sc, TWS_RESET_START);
@@ -1191,7 +1190,6 @@ tws_timeout(void *arg)
     mtx_unlock(&sc->gen_lock);
 
     xpt_release_simq(sc->sim, 1);
-    tws_setup_intr(sc, sc->irqs);
 }
 
 void
@@ -1205,7 +1203,6 @@ tws_reset(void *arg)
         return;
     }
 
-    tws_teardown_intr(sc);
     xpt_freeze_simq(sc->sim, 1);
 
     tws_send_event(sc, TWS_RESET_START);
@@ -1222,7 +1219,6 @@ tws_reset(void *arg)
     mtx_unlock(&sc->gen_lock);
 
     xpt_release_simq(sc->sim, 1);
-    tws_setup_intr(sc, sc->irqs);
 }
 
 static void

Modified: head/sys/dev/tws/tws_hdm.c
==============================================================================
--- head/sys/dev/tws/tws_hdm.c	Mon Sep 22 20:34:36 2014	(r271999)
+++ head/sys/dev/tws/tws_hdm.c	Mon Sep 22 20:38:01 2014	(r272000)
@@ -161,7 +161,7 @@ tws_init_connect(struct tws_softc *sc, u
     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

Modified: head/sys/dev/tws/tws_hdm.h
==============================================================================
--- head/sys/dev/tws/tws_hdm.h	Mon Sep 22 20:34:36 2014	(r271999)
+++ head/sys/dev/tws/tws_hdm.h	Mon Sep 22 20:38:01 2014	(r272000)
@@ -410,7 +410,7 @@ struct tws_request {
     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 */

Modified: head/sys/dev/tws/tws_services.c
==============================================================================
--- head/sys/dev/tws/tws_services.c	Mon Sep 22 20:34:36 2014	(r271999)
+++ head/sys/dev/tws/tws_services.c	Mon Sep 22 20:38:01 2014	(r272000)
@@ -395,7 +395,6 @@ tws_print_stats(void *arg)
                                       , 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 --------------------- */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409222038.s8MKc2If006244>