Avoid possible panic on shutdown: if there are still some devices

attached when shutting down, kill our kthreads, but don't destroy
the mutex pool and uma zone resources since the driver shutdown
routine may need them later.
This commit is contained in:
Bill Paul 2004-01-26 08:36:18 +00:00
parent 09d2d42edd
commit 6c272c0241
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=125006

View File

@ -113,6 +113,7 @@ static STAILQ_HEAD(ndisqhead, ndis_req) ndis_ttodo;
struct ndisqhead ndis_itodo;
struct ndisqhead ndis_free;
static int ndis_jobs = 32;
static int ndis_devs = 0;
static struct ndisproc ndis_tproc;
static struct ndisproc ndis_iproc;
@ -145,10 +146,22 @@ ndis_modevent(module_t mod, int cmd, void *arg)
ndis_create_kthreads();
break;
case MOD_UNLOAD:
case MOD_SHUTDOWN:
/* stop kthreads */
ndis_destroy_kthreads();
if (ndis_devs == 0) {
/* Shut down subsystems */
ndis_libfini();
ntoskrnl_libfini();
/* Remove zones */
uma_zdestroy(ndis_packet_zone);
uma_zdestroy(ndis_buffer_zone);
}
break;
case MOD_UNLOAD:
/* stop kthreads */
ndis_destroy_kthreads();
/* Shut down subsystems */
ndis_libfini();
@ -1191,6 +1204,9 @@ ndis_shutdown_nic(arg)
else
shutdownfunc(sc->ndis_chars.nmc_rsvd0);
ndis_shrink_thrqueue(8);
ndis_devs--;
return(0);
}
@ -1384,6 +1400,7 @@ ndis_unload_driver(arg)
ndis_flush_sysctls(sc);
ndis_shrink_thrqueue(8);
ndis_devs--;
return(0);
}
@ -1493,5 +1510,7 @@ ndis_load_driver(img, arg)
ndis_enlarge_thrqueue(8);
ndis_devs++;
return(0);
}