Index: cam/cam_xpt_sim.h =================================================================== --- cam/cam_xpt_sim.h (revision 228936) +++ cam/cam_xpt_sim.h (working copy) @@ -51,6 +51,8 @@ u_int count, int run_queue); int xpt_sim_opened(struct cam_sim *sim); void xpt_done(union ccb *done_ccb); +void xpt_batch_start(struct cam_sim *sim); +void xpt_batch_done(struct cam_sim *sim); #endif #endif /* _CAM_CAM_XPT_SIM_H */ Index: cam/cam_sim.h =================================================================== --- cam/cam_sim.h (revision 228936) +++ cam/cam_sim.h (working copy) @@ -106,6 +106,7 @@ #define CAM_SIM_MPSAFE 0x02 #define CAM_SIM_ON_DONEQ 0x04 #define CAM_SIM_POLLED 0x08 +#define CAM_SIM_BATCH 0x10 struct callout callout; struct cam_devq *devq; /* Device Queue to use for this SIM */ int refcount; /* References to the SIM. */ Index: cam/cam_xpt.c =================================================================== --- cam/cam_xpt.c (revision 228936) +++ cam/cam_xpt.c (working copy) @@ -4232,7 +4232,8 @@ TAILQ_INSERT_TAIL(&sim->sim_doneq, &done_ccb->ccb_h, sim_links.tqe); done_ccb->ccb_h.pinfo.index = CAM_DONEQ_INDEX; - if ((sim->flags & (CAM_SIM_ON_DONEQ | CAM_SIM_POLLED)) == 0) { + if ((sim->flags & (CAM_SIM_ON_DONEQ | CAM_SIM_POLLED | + CAM_SIM_BATCH)) == 0) { mtx_lock(&cam_simq_lock); first = TAILQ_EMPTY(&cam_simq); TAILQ_INSERT_TAIL(&cam_simq, sim, links); @@ -4244,6 +4245,25 @@ } } +void +xpt_batch_start(struct cam_sim *sim) +{ + + KASSERT((sim->flags & CAM_SIM_BATCH) == 0, ("Batch flag already set")); + sim->flags |= CAM_SIM_BATCH; +} + +void +xpt_batch_done(struct cam_sim *sim) +{ + + KASSERT((sim->flags & CAM_SIM_BATCH) != 0, ("Batch flag was not set")); + sim->flags &= ~CAM_SIM_BATCH; + if (!TAILQ_EMPTY(&sim->sim_doneq) && + (sim->flags & CAM_SIM_ON_DONEQ) == 0) + camisr_runqueue(&sim->sim_doneq); +} + union ccb * xpt_alloc_ccb() { Index: dev/siis/siis.c =================================================================== --- dev/siis/siis.c (revision 228936) +++ dev/siis/siis.c (working copy) @@ -830,7 +830,9 @@ struct siis_channel *ch = device_get_softc(dev); mtx_lock(&ch->mtx); + xpt_batch_start(ch->sim); siis_ch_intr(data); + xpt_batch_done(ch->sim); mtx_unlock(&ch->mtx); } Index: dev/ahci/ahci.c =================================================================== --- dev/ahci/ahci.c (revision 228936) +++ dev/ahci/ahci.c (working copy) @@ -1456,7 +1456,9 @@ struct ahci_channel *ch = device_get_softc(dev); mtx_lock(&ch->mtx); + xpt_batch_start(ch->sim); ahci_ch_intr(data); + xpt_batch_done(ch->sim); mtx_unlock(&ch->mtx); } Index: dev/mvs/mvs.c =================================================================== --- dev/mvs/mvs.c (revision 228936) +++ dev/mvs/mvs.c (working copy) @@ -654,7 +654,9 @@ struct mvs_channel *ch = device_get_softc(dev); mtx_lock(&ch->mtx); + xpt_batch_start(ch->sim); mvs_ch_intr(data); + xpt_batch_done(ch->sim); mtx_unlock(&ch->mtx); } Index: dev/ata/ata-all.c =================================================================== --- dev/ata/ata-all.c (revision 228936) +++ dev/ata/ata-all.c (working copy) @@ -532,9 +532,11 @@ struct ata_channel *ch = (struct ata_channel *)data; mtx_lock(&ch->state_mtx); + xpt_batch_start(ch->sim); #endif ata_interrupt_locked(data); #ifdef ATA_CAM + xpt_batch_done(ch->sim); mtx_unlock(&ch->state_mtx); #endif }