PERFORCE change 134823 for review

Kip Macy kmacy at FreeBSD.org
Mon Feb 4 22:53:29 PST 2008


http://perforce.freebsd.org/chv.cgi?CH=134823

Change 134823 by kmacy at kmacy:storage:toehead on 2008/02/05 06:52:57

	fix shutdown so that module unload works

Affected files ...

.. //depot/projects/toehead/sys/dev/cxgb/cxgb_main.c#6 edit

Differences ...

==== //depot/projects/toehead/sys/dev/cxgb/cxgb_main.c#6 (text+ko) ====

@@ -654,11 +654,7 @@
 		bus_release_resource(sc->dev, SYS_RES_MEMORY, sc->msix_regs_rid,
 		    sc->msix_regs_res);
 	}
-	
-	if (sc->tq != NULL) {
-		taskqueue_drain(sc->tq, &sc->ext_intr_task);
-		taskqueue_drain(sc->tq, &sc->tick_task);	
-	}	
+
 	t3_sge_deinit_sw(sc);
 	/*
 	 * Wait for last callout
@@ -672,8 +668,11 @@
 	}
 		
 	bus_generic_detach(sc->dev);
-	if (sc->tq != NULL) 
+	if (sc->tq != NULL) {
 		taskqueue_free(sc->tq);
+		sc->tq = NULL;
+	}
+	
 	if (is_offload(sc)) {
 		cxgb_adapter_unofld(sc);
 		if (isset(&sc->open_device_map,	OFFLOAD_DEVMAP_BIT))
@@ -682,6 +681,8 @@
 			printf("cxgb_free: DEVMAP_BIT not set\n");
 	} else
 		printf("not offloading set\n");	
+
+	cxgb_offload_deactivate(sc);
 	free(sc->filters, M_DEVBUF);
 	t3_sge_free(sc);
 	
@@ -1526,7 +1527,6 @@
 static void
 cxgb_down_locked(struct adapter *sc)
 {
-	int i;
 	
 	t3_sge_stop(sc);
 	t3_intr_disable(sc);
@@ -1543,20 +1543,24 @@
 		sc->irq_res = NULL;
 	}
 	
-	if (sc->flags & USING_MSIX)
+	if (sc->flags & USING_MSIX) 
 		cxgb_teardown_msix(sc);
-	ADAPTER_UNLOCK(sc);
-
+	
 	callout_stop(&sc->cxgb_tick_ch);
 	callout_stop(&sc->sge_timer_ch);
 	callout_drain(&sc->cxgb_tick_ch);
 	callout_drain(&sc->sge_timer_ch);
 	
 	if (sc->tq != NULL) {
+		printf("draining slow intr\n");
+		
 		taskqueue_drain(sc->tq, &sc->slow_intr_task);
-		for (i = 0; i < sc->params.nports; i++) 
-			taskqueue_drain(sc->tq, &sc->port[i].timer_reclaim_task);
+			printf("draining ext intr\n");	
+		taskqueue_drain(sc->tq, &sc->ext_intr_task);
+		printf("draining tick task\n");
+		taskqueue_drain(sc->tq, &sc->tick_task);
 	}
+	ADAPTER_UNLOCK(sc);
 }
 
 static int
@@ -1635,7 +1639,6 @@
 		cxgb_down_locked(adapter);
 	else
 		ADAPTER_UNLOCK(adapter);
-	cxgb_offload_deactivate(adapter);
 	return (0);
 }
 
@@ -1983,20 +1986,21 @@
 		
 		struct port_info *p = &sc->port[i];
 		struct ifnet *ifp = p->ifp;
-		PORT_LOCK(p);
 
-		if ((ifp->if_drv_flags & IFF_DRV_RUNNING)) 
+		if ((ifp->if_drv_flags & IFF_DRV_RUNNING) &&
+		    (ifp->if_flags & IFF_UP))
 			running = 1;
-		PORT_UNLOCK(p);
 	}	
 
 	if (running == 0)
 		return;
 		
-	taskqueue_enqueue(sc->tq, &sc->tick_task);
+
 	
-	if (sc->open_device_map != 0) 
+	if (sc->open_device_map != 0) {
+		taskqueue_enqueue(sc->tq, &sc->tick_task);
 		callout_reset(&sc->cxgb_tick_ch, hz, cxgb_tick, sc);
+	}
 }
 
 static void


More information about the p4-projects mailing list