aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/mpt
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2013-02-12 16:57:20 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2013-02-12 16:57:20 +0000
commitdd0b4fb6d50631c140e800bdfac48d02e7e4c875 (patch)
treee550f2c754f1edf951a8b93963ebcfc4fa0d20ce /sys/dev/mpt
parent44c169253de5caec5de2a397c522ad3e359f86e6 (diff)
Notes
Diffstat (limited to 'sys/dev/mpt')
-rw-r--r--sys/dev/mpt/mpt_cam.c120
1 files changed, 20 insertions, 100 deletions
diff --git a/sys/dev/mpt/mpt_cam.c b/sys/dev/mpt/mpt_cam.c
index d435f77e8a40..119dd5038898 100644
--- a/sys/dev/mpt/mpt_cam.c
+++ b/sys/dev/mpt/mpt_cam.c
@@ -1382,7 +1382,7 @@ bad:
}
}
- if (!(ccb->ccb_h.flags & (CAM_SG_LIST_PHYS|CAM_DATA_PHYS))) {
+ if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
bus_dmasync_op_t op;
if (istgt == 0) {
if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
@@ -1623,7 +1623,7 @@ out:
mpt_prt(mpt,
"mpt_execute_req_a64: I/O cancelled (status 0x%x)\n",
ccb->ccb_h.status & CAM_STATUS_MASK);
- if (nseg && (ccb->ccb_h.flags & CAM_SG_LIST_PHYS) == 0) {
+ if (nseg) {
bus_dmamap_unload(mpt->buffer_dmat, req->dmap);
}
ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
@@ -1785,7 +1785,7 @@ bad:
}
}
- if (!(ccb->ccb_h.flags & (CAM_SG_LIST_PHYS|CAM_DATA_PHYS))) {
+ if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
bus_dmasync_op_t op;
if (istgt) {
if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
@@ -2010,7 +2010,7 @@ out:
mpt_prt(mpt,
"mpt_execute_req: I/O cancelled (status 0x%x)\n",
ccb->ccb_h.status & CAM_STATUS_MASK);
- if (nseg && (ccb->ccb_h.flags & CAM_SG_LIST_PHYS) == 0) {
+ if (nseg) {
bus_dmamap_unload(mpt->buffer_dmat, req->dmap);
}
ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
@@ -2062,6 +2062,7 @@ mpt_start(struct cam_sim *sim, union ccb *ccb)
bus_dmamap_callback_t *cb;
target_id_t tgt;
int raid_passthru;
+ int error;
/* Get the pointer for the physical addapter */
mpt = ccb->ccb_h.ccb_mpt_ptr;
@@ -2206,64 +2207,15 @@ mpt_start(struct cam_sim *sim, union ccb *ccb)
ccb->ccb_h.target_lun, req, req->serno);
}
- /*
- * If we have any data to send with this command map it into bus space.
- */
- if ((ccbh->flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- if ((ccbh->flags & CAM_SCATTER_VALID) == 0) {
- /*
- * We've been given a pointer to a single buffer.
- */
- if ((ccbh->flags & CAM_DATA_PHYS) == 0) {
- /*
- * Virtual address that needs to translated into
- * one or more physical address ranges.
- */
- int error;
- int s = splsoftvm();
- error = bus_dmamap_load(mpt->buffer_dmat,
- req->dmap, csio->data_ptr, csio->dxfer_len,
- cb, req, 0);
- splx(s);
- if (error == EINPROGRESS) {
- /*
- * So as to maintain ordering,
- * freeze the controller queue
- * until our mapping is
- * returned.
- */
- xpt_freeze_simq(mpt->sim, 1);
- ccbh->status |= CAM_RELEASE_SIMQ;
- }
- } else {
- /*
- * We have been given a pointer to single
- * physical buffer.
- */
- struct bus_dma_segment seg;
- seg.ds_addr =
- (bus_addr_t)(vm_offset_t)csio->data_ptr;
- seg.ds_len = csio->dxfer_len;
- (*cb)(req, &seg, 1, 0);
- }
- } else {
- /*
- * We have been given a list of addresses.
- * This case could be easily supported but they are not
- * currently generated by the CAM subsystem so there
- * is no point in wasting the time right now.
- */
- struct bus_dma_segment *segs;
- if ((ccbh->flags & CAM_SG_LIST_PHYS) == 0) {
- (*cb)(req, NULL, 0, EFAULT);
- } else {
- /* Just use the segments provided */
- segs = (struct bus_dma_segment *)csio->data_ptr;
- (*cb)(req, segs, csio->sglist_cnt, 0);
- }
- }
- } else {
- (*cb)(req, NULL, 0, 0);
+ error = bus_dmamap_load_ccb(mpt->buffer_dmat, req->dmap, ccb, cb,
+ req, 0);
+ if (error == EINPROGRESS) {
+ /*
+ * So as to maintain ordering, freeze the controller queue
+ * until our mapping is returned.
+ */
+ xpt_freeze_simq(mpt->sim, 1);
+ ccbh->status |= CAM_RELEASE_SIMQ;
}
}
@@ -4458,6 +4410,7 @@ mpt_target_start_io(struct mpt_softc *mpt, union ccb *ccb)
bus_dmamap_callback_t *cb;
PTR_MSG_TARGET_ASSIST_REQUEST ta;
request_t *req;
+ int error;
KASSERT((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE,
("dxfer_len %u but direction is NONE", csio->dxfer_len));
@@ -4544,44 +4497,11 @@ mpt_target_start_io(struct mpt_softc *mpt, union ccb *ccb)
"nxtstate=%d\n", csio, csio->tag_id, csio->dxfer_len,
tgt->resid, ccb->ccb_h.flags, req, req->serno, tgt->state);
- if ((ccb->ccb_h.flags & CAM_SCATTER_VALID) == 0) {
- if ((ccb->ccb_h.flags & CAM_DATA_PHYS) == 0) {
- int error;
- int s = splsoftvm();
- error = bus_dmamap_load(mpt->buffer_dmat,
- req->dmap, csio->data_ptr, csio->dxfer_len,
- cb, req, 0);
- splx(s);
- if (error == EINPROGRESS) {
- xpt_freeze_simq(mpt->sim, 1);
- ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
- }
- } else {
- /*
- * We have been given a pointer to single
- * physical buffer.
- */
- struct bus_dma_segment seg;
- seg.ds_addr = (bus_addr_t)
- (vm_offset_t)csio->data_ptr;
- seg.ds_len = csio->dxfer_len;
- (*cb)(req, &seg, 1, 0);
- }
- } else {
- /*
- * We have been given a list of addresses.
- * This case could be easily supported but they are not
- * currently generated by the CAM subsystem so there
- * is no point in wasting the time right now.
- */
- struct bus_dma_segment *sgs;
- if ((ccb->ccb_h.flags & CAM_SG_LIST_PHYS) == 0) {
- (*cb)(req, NULL, 0, EFAULT);
- } else {
- /* Just use the segments provided */
- sgs = (struct bus_dma_segment *)csio->data_ptr;
- (*cb)(req, sgs, csio->sglist_cnt, 0);
- }
+ error = bus_dmamap_load_ccb(mpt->buffer_dmat, req->dmap, ccb,
+ cb, req, 0);
+ if (error == EINPROGRESS) {
+ xpt_freeze_simq(mpt->sim, 1);
+ ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
}
} else {
uint8_t *sp = NULL, sense[MPT_SENSE_SIZE];