...
mtx_unlock(periph->sim->mtx);
...
mtx_lock(periph->sim->mtx);
softc->dev->si_drv1 = periph;
/*
* Add an async callback so that we get
* notified if this device goes away.
*/
xpt_register_async(AC_LOST_DEVICE, passasync, periph, periph->path);
....
the device can go away prior to xpt_register_async being called I think.