Index: sys/kern/kern_conf.c =================================================================== --- sys/kern/kern_conf.c +++ sys/kern/kern_conf.c @@ -1437,6 +1437,7 @@ struct cdev *dev; void (*cb)(void *); void *cb_arg; + bool need_giant; dev_lock(); while (!TAILQ_EMPTY(&dev_ddtr)) { @@ -1447,11 +1448,17 @@ TAILQ_REMOVE(&dev_ddtr, cp, cdp_dtr_list); cb = cp->cdp_dtr_cb; cb_arg = cp->cdp_dtr_cb_arg; + need_giant = (dev->si_devsw->d_flags & D_NEEDGIANT) != 0; destroy_devl(dev); dev_unlock_and_free(); dev_rel(dev); - if (cb != NULL) + if (cb != NULL) { + if (need_giant) + mtx_lock(&Giant); cb(cb_arg); + if (need_giant) + mtx_unlock(&Giant); + } dev_lock(); } dev_unlock(); @@ -1478,7 +1485,7 @@ cp->cdp_dtr_cb_arg = arg; TAILQ_INSERT_TAIL(&dev_ddtr, cp, cdp_dtr_list); dev_unlock(); - taskqueue_enqueue(taskqueue_swi_giant, &dev_dtr_task); + taskqueue_enqueue(taskqueue_thread, &dev_dtr_task); return (1); }