Index: sys/cam/cam_periph.c =================================================================== --- sys/cam/cam_periph.c (revision 205349) +++ sys/cam/cam_periph.c (working copy) @@ -204,6 +204,7 @@ if (status != CAM_REQ_CMP) goto failure; + xpt_lock_buses(); cur_periph = TAILQ_FIRST(&(*p_drv)->units); while (cur_periph != NULL && cur_periph->unit_number < periph->unit_number) @@ -215,6 +216,7 @@ TAILQ_INSERT_TAIL(&(*p_drv)->units, periph, unit_links); (*p_drv)->generation++; } + xpt_unlock_buses(); init_level++; @@ -229,7 +231,9 @@ /* Initialized successfully */ break; case 3: + xpt_lock_buses(); TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links); + xpt_unlock_buses(); xpt_remove_periph(periph); /* FALLTHROUGH */ case 2: @@ -391,11 +395,15 @@ periph_name = p_drv->driver_name; for (;;newunit++) { + xpt_lock_buses(); for (periph = TAILQ_FIRST(&p_drv->units); periph != NULL && periph->unit_number != newunit; periph = TAILQ_NEXT(periph, unit_links)) ; + /* XXX: Maybe the periph might be refcounted here? */ + xpt_unlock_buses(); + if (periph != NULL && periph->unit_number == newunit) { if (wired != 0) { xpt_print(periph->path, "Duplicate Wired " Index: sys/cam/scsi/scsi_da.c =================================================================== --- sys/cam/scsi/scsi_da.c (revision 205349) +++ sys/cam/scsi/scsi_da.c (working copy) @@ -2020,6 +2020,7 @@ struct cam_periph *periph; struct da_softc *softc; + xpt_lock_buses(); TAILQ_FOREACH(periph, &dadriver.units, unit_links) { union ccb ccb; @@ -2078,6 +2079,7 @@ /*getcount_only*/0); cam_periph_unlock(periph); } + xpt_unlock_buses(); } #else /* !_KERNEL */ Index: sys/cam/cam_xpt.c =================================================================== --- sys/cam/cam_xpt.c (revision 205349) +++ sys/cam/cam_xpt.c (working copy) @@ -2784,6 +2784,7 @@ retval = 1; + xpt_lock_buses(); for (periph = (start_periph ? start_periph : TAILQ_FIRST(&(*pdrv)->units)); periph != NULL; periph = next_periph) { @@ -2791,9 +2792,12 @@ next_periph = TAILQ_NEXT(periph, unit_links); retval = tr_func(periph, arg); - if (retval == 0) + if (retval == 0) { + xpt_unlock_buses(); return(retval); + } } + xpt_unlock_buses(); return(retval); }