Changeset View
Changeset View
Standalone View
Standalone View
head/sys/cam/nvme/nvme_da.c
Show First 20 Lines • Show All 330 Lines • ▼ Show 20 Lines | if ((softc->flags & NDA_FLAG_DIRTY) != 0 && | ||||
xpt_release_ccb(ccb); | xpt_release_ccb(ccb); | ||||
cam_periph_unhold(periph); | cam_periph_unhold(periph); | ||||
} | } | ||||
softc->flags &= ~NDA_FLAG_OPEN; | softc->flags &= ~NDA_FLAG_OPEN; | ||||
while (softc->refcount != 0) | while (softc->refcount != 0) | ||||
cam_periph_sleep(periph, &softc->refcount, PRIBIO, "ndaclose", 1); | cam_periph_sleep(periph, &softc->refcount, PRIBIO, "ndaclose", 1); | ||||
KASSERT(softc->outstanding_cmds == 0, | |||||
("nda %d outstanding commands", softc->outstanding_cmds)); | |||||
cam_periph_unlock(periph); | cam_periph_unlock(periph); | ||||
cam_periph_release(periph); | cam_periph_release(periph); | ||||
return (0); | return (0); | ||||
} | } | ||||
static void | static void | ||||
ndaschedule(struct cam_periph *periph) | ndaschedule(struct cam_periph *periph) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 634 Lines • ▼ Show 20 Lines | case BIO_FLUSH: | ||||
nda_nvme_flush(softc, nvmeio); | nda_nvme_flush(softc, nvmeio); | ||||
break; | break; | ||||
} | } | ||||
start_ccb->ccb_state = NDA_CCB_BUFFER_IO; | start_ccb->ccb_state = NDA_CCB_BUFFER_IO; | ||||
start_ccb->ccb_bp = bp; | start_ccb->ccb_bp = bp; | ||||
out: | out: | ||||
start_ccb->ccb_h.flags |= CAM_UNLOCKED; | start_ccb->ccb_h.flags |= CAM_UNLOCKED; | ||||
softc->outstanding_cmds++; | softc->outstanding_cmds++; | ||||
softc->refcount++; | softc->refcount++; /* For submission only */ | ||||
cam_periph_unlock(periph); | cam_periph_unlock(periph); | ||||
xpt_action(start_ccb); | xpt_action(start_ccb); | ||||
cam_periph_lock(periph); | cam_periph_lock(periph); | ||||
softc->refcount--; /* Submission done */ | |||||
/* May have more work to do, so ensure we stay scheduled */ | /* May have more work to do, so ensure we stay scheduled */ | ||||
ndaschedule(periph); | ndaschedule(periph); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | if (state == NDA_CCB_BUFFER_IO) { | ||||
* The the I/O scheduler that we're finishing the I/O | * The the I/O scheduler that we're finishing the I/O | ||||
* so we can keep book. The first one we pass in the CCB | * so we can keep book. The first one we pass in the CCB | ||||
* which has the timing information. The rest we pass in NULL | * which has the timing information. The rest we pass in NULL | ||||
* so we can keep proper counts. | * so we can keep proper counts. | ||||
*/ | */ | ||||
bp1 = TAILQ_FIRST(&queue); | bp1 = TAILQ_FIRST(&queue); | ||||
cam_iosched_bio_complete(softc->cam_iosched, bp1, done_ccb); | cam_iosched_bio_complete(softc->cam_iosched, bp1, done_ccb); | ||||
xpt_release_ccb(done_ccb); | xpt_release_ccb(done_ccb); | ||||
softc->outstanding_cmds--; | |||||
ndaschedule(periph); | ndaschedule(periph); | ||||
cam_periph_unlock(periph); | cam_periph_unlock(periph); | ||||
while ((bp2 = TAILQ_FIRST(&queue)) != NULL) { | while ((bp2 = TAILQ_FIRST(&queue)) != NULL) { | ||||
TAILQ_REMOVE(&queue, bp2, bio_queue); | TAILQ_REMOVE(&queue, bp2, bio_queue); | ||||
bp2->bio_error = error; | bp2->bio_error = error; | ||||
if (error != 0) { | if (error != 0) { | ||||
bp2->bio_flags |= BIO_ERROR; | bp2->bio_flags |= BIO_ERROR; | ||||
bp2->bio_resid = bp1->bio_bcount; | bp2->bio_resid = bp1->bio_bcount; | ||||
} else | } else | ||||
bp2->bio_resid = 0; | bp2->bio_resid = 0; | ||||
if (bp1 != bp2) | if (bp1 != bp2) | ||||
cam_iosched_bio_complete(softc->cam_iosched, bp2, NULL); | cam_iosched_bio_complete(softc->cam_iosched, bp2, NULL); | ||||
biodone(bp2); | biodone(bp2); | ||||
} | } | ||||
} | } | ||||
/* | |||||
* Release the periph refcount taken in mdastart() for each CCB. | |||||
*/ | |||||
KASSERT(softc->refcount >= 1, ("ndadone softc %p refcount %d", softc, softc->refcount)); | |||||
softc->refcount--; | |||||
return; | return; | ||||
} | } | ||||
case NDA_CCB_DUMP: | case NDA_CCB_DUMP: | ||||
/* No-op. We're polling */ | /* No-op. We're polling */ | ||||
return; | return; | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines |