summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2013-02-12 16:57:20 +0000
committerkib <kib@FreeBSD.org>2013-02-12 16:57:20 +0000
commitbd7f0fa0bb4b7b0f87227e0c4d49a4bd9b113cf0 (patch)
treee550f2c754f1edf951a8b93963ebcfc4fa0d20ce /sys/dev
parente0a463e76c719f11788ec107b5aa3e2da4e57c0b (diff)
downloadFreeBSD-src-bd7f0fa0bb4b7b0f87227e0c4d49a4bd9b113cf0.zip
FreeBSD-src-bd7f0fa0bb4b7b0f87227e0c4d49a4bd9b113cf0.tar.gz
Reform the busdma API so that new types may be added without modifying
every architecture's busdma_machdep.c. It is done by unifying the bus_dmamap_load_buffer() routines so that they may be called from MI code. The MD busdma is then given a chance to do any final processing in the complete() callback. The cam changes unify the bus_dmamap_load* handling in cam drivers. The arm and mips implementations are updated to track virtual addresses for sync(). Previously this was done in a type specific way. Now it is done in a generic way by recording the list of virtuals in the map. Submitted by: jeff (sponsored by EMC/Isilon) Reviewed by: kan (previous version), scottl, mjacob (isp(4), no objections for target mode changes) Discussed with: ian (arm changes) Tested by: marius (sparc64), mips (jmallet), isci(4) on x86 (jharris), amd64 (Fabian Keil <freebsd-listen@fabiankeil.de>)
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/aac/aac_cam.c40
-rw-r--r--sys/dev/advansys/advansys.c64
-rw-r--r--sys/dev/advansys/adwcam.c73
-rw-r--r--sys/dev/aha/aha.c78
-rw-r--r--sys/dev/ahb/ahb.c73
-rw-r--r--sys/dev/ahci/ahci.c15
-rw-r--r--sys/dev/aic/aic.c4
-rw-r--r--sys/dev/aic7xxx/aic79xx_osm.c71
-rw-r--r--sys/dev/aic7xxx/aic7xxx_osm.c74
-rw-r--r--sys/dev/amr/amr_cam.c5
-rw-r--r--sys/dev/arcmsr/arcmsr.c56
-rw-r--r--sys/dev/ata/ata-dma.c15
-rw-r--r--sys/dev/ata/atapi-cam.c6
-rw-r--r--sys/dev/buslogic/bt.c77
-rw-r--r--sys/dev/ciss/ciss.c30
-rw-r--r--sys/dev/ciss/cissvar.h1
-rw-r--r--sys/dev/dpt/dpt_scsi.c62
-rw-r--r--sys/dev/firewire/sbp.c10
-rw-r--r--sys/dev/hpt27xx/osm_bsd.c100
-rw-r--r--sys/dev/hptiop/hptiop.c63
-rw-r--r--sys/dev/hptmv/entry.c107
-rw-r--r--sys/dev/hptrr/hptrr_osm_bsd.c106
-rw-r--r--sys/dev/iir/iir.c99
-rw-r--r--sys/dev/isci/isci_io_request.c35
-rw-r--r--sys/dev/isp/isp_pci.c72
-rw-r--r--sys/dev/isp/isp_sbus.c50
-rw-r--r--sys/dev/mfi/mfi.c10
-rw-r--r--sys/dev/mfi/mfi_cam.c17
-rw-r--r--sys/dev/mfi/mfivar.h1
-rw-r--r--sys/dev/mly/mly.c26
-rw-r--r--sys/dev/mly/mlyvar.h1
-rw-r--r--sys/dev/mps/mps.c3
-rw-r--r--sys/dev/mps/mps_sas.c27
-rw-r--r--sys/dev/mps/mpsvar.h1
-rw-r--r--sys/dev/mpt/mpt_cam.c120
-rw-r--r--sys/dev/mvs/mvs.c14
-rw-r--r--sys/dev/siis/siis.c50
-rw-r--r--sys/dev/sym/sym_hipd.c50
-rw-r--r--sys/dev/trm/trm.c68
-rw-r--r--sys/dev/twa/tw_osl.h1
-rw-r--r--sys/dev/twa/tw_osl_cam.c50
-rw-r--r--sys/dev/twa/tw_osl_freebsd.c4
-rw-r--r--sys/dev/tws/tws.h1
-rw-r--r--sys/dev/tws/tws_cam.c49
-rw-r--r--sys/dev/virtio/scsi/virtio_scsi.c39
-rw-r--r--sys/dev/wds/wd7000.c2
46 files changed, 487 insertions, 1433 deletions
diff --git a/sys/dev/aac/aac_cam.c b/sys/dev/aac/aac_cam.c
index 57e87da..7f0d7ee 100644
--- a/sys/dev/aac/aac_cam.c
+++ b/sys/dev/aac/aac_cam.c
@@ -448,26 +448,28 @@ aac_cam_action(struct cam_sim *sim, union ccb *ccb)
/* Map the s/g list. XXX 32bit addresses only! */
if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- if ((ccb->ccb_h.flags & CAM_SCATTER_VALID) == 0) {
+ switch ((ccb->ccb_h.flags & CAM_DATA_MASK)) {
+ case CAM_DATA_VADDR:
srb->data_len = csio->dxfer_len;
- if (ccb->ccb_h.flags & CAM_DATA_PHYS) {
- /* Send a 32bit command */
- fib->Header.Command = ScsiPortCommand;
- srb->sg_map.SgCount = 1;
- srb->sg_map.SgEntry[0].SgAddress =
- (uint32_t)(uintptr_t)csio->data_ptr;
- srb->sg_map.SgEntry[0].SgByteCount =
- csio->dxfer_len;
- } else {
- /*
- * Arrange things so that the S/G
- * map will get set up automagically
- */
- cm->cm_data = (void *)csio->data_ptr;
- cm->cm_datalen = csio->dxfer_len;
- cm->cm_sgtable = &srb->sg_map;
- }
- } else {
+ /*
+ * Arrange things so that the S/G
+ * map will get set up automagically
+ */
+ cm->cm_data = (void *)csio->data_ptr;
+ cm->cm_datalen = csio->dxfer_len;
+ cm->cm_sgtable = &srb->sg_map;
+ break;
+ case CAM_DATA_PADDR:
+ /* Send a 32bit command */
+ fib->Header.Command = ScsiPortCommand;
+ srb->sg_map.SgCount = 1;
+ srb->sg_map.SgEntry[0].SgAddress =
+ (uint32_t)(uintptr_t)csio->data_ptr;
+ srb->sg_map.SgEntry[0].SgByteCount =
+ csio->dxfer_len;
+ srb->data_len = csio->dxfer_len;
+ break;
+ default:
/* XXX Need to handle multiple s/g elements */
panic("aac_cam: multiple s/g elements");
}
diff --git a/sys/dev/advansys/advansys.c b/sys/dev/advansys/advansys.c
index d804b6d..c9ccb67 100644
--- a/sys/dev/advansys/advansys.c
+++ b/sys/dev/advansys/advansys.c
@@ -207,6 +207,7 @@ adv_action(struct cam_sim *sim, union ccb *ccb)
struct ccb_hdr *ccb_h;
struct ccb_scsiio *csio;
struct adv_ccb_info *cinfo;
+ int error;
ccb_h = &ccb->ccb_h;
csio = &ccb->csio;
@@ -217,58 +218,17 @@ adv_action(struct cam_sim *sim, union ccb *ccb)
ccb_h->ccb_cinfo_ptr = cinfo;
cinfo->ccb = ccb;
- /* Only use S/G if there is a transfer */
- if ((ccb_h->flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- if ((ccb_h->flags & CAM_SCATTER_VALID) == 0) {
- /*
- * We've been given a pointer
- * to a single buffer
- */
- if ((ccb_h->flags & CAM_DATA_PHYS) == 0) {
- int error;
-
- error =
- bus_dmamap_load(adv->buffer_dmat,
- cinfo->dmamap,
- csio->data_ptr,
- csio->dxfer_len,
- adv_execute_ccb,
- csio, /*flags*/0);
- if (error == EINPROGRESS) {
- /*
- * So as to maintain ordering,
- * freeze the controller queue
- * until our mapping is
- * returned.
- */
- adv_set_state(adv,
- ADV_BUSDMA_BLOCK);
- }
- } else {
- struct bus_dma_segment seg;
-
- /* Pointer to physical buffer */
- seg.ds_addr =
- (bus_addr_t)csio->data_ptr;
- seg.ds_len = csio->dxfer_len;
- adv_execute_ccb(csio, &seg, 1, 0);
- }
- } else {
- struct bus_dma_segment *segs;
- if ((ccb_h->flags & CAM_DATA_PHYS) != 0)
- panic("adv_setup_data - Physical "
- "segment pointers unsupported");
-
- if ((ccb_h->flags & CAM_SG_LIST_PHYS) == 0)
- panic("adv_setup_data - Virtual "
- "segment addresses unsupported");
-
- /* Just use the segments provided */
- segs = (struct bus_dma_segment *)csio->data_ptr;
- adv_execute_ccb(ccb, segs, csio->sglist_cnt, 0);
- }
- } else {
- adv_execute_ccb(ccb, NULL, 0, 0);
+ error = bus_dmamap_load_ccb(adv->buffer_dmat,
+ cinfo->dmamap,
+ ccb,
+ adv_execute_ccb,
+ csio, /*flags*/0);
+ if (error == EINPROGRESS) {
+ /*
+ * So as to maintain ordering, freeze the controller
+ * queue until our mapping is returned.
+ */
+ adv_set_state(adv, ADV_BUSDMA_BLOCK);
}
break;
}
diff --git a/sys/dev/advansys/adwcam.c b/sys/dev/advansys/adwcam.c
index defc7c7..de1f413 100644
--- a/sys/dev/advansys/adwcam.c
+++ b/sys/dev/advansys/adwcam.c
@@ -353,6 +353,7 @@ adw_action(struct cam_sim *sim, union ccb *ccb)
struct ccb_scsiio *csio;
struct ccb_hdr *ccbh;
struct acb *acb;
+ int error;
csio = &ccb->csio;
ccbh = &ccb->ccb_h;
@@ -427,66 +428,18 @@ adw_action(struct cam_sim *sim, union ccb *ccb)
acb->queue.cdb, csio->cdb_len);
}
- /*
- * 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) {
- int error;
-
- error =
- bus_dmamap_load(adw->buffer_dmat,
- acb->dmamap,
- csio->data_ptr,
- csio->dxfer_len,
- adwexecuteacb,
- acb, /*flags*/0);
- if (error == EINPROGRESS) {
- /*
- * So as to maintain ordering,
- * freeze the controller queue
- * until our mapping is
- * returned.
- */
- xpt_freeze_simq(sim, 1);
- acb->state |= CAM_RELEASE_SIMQ;
- }
- } else {
- struct bus_dma_segment seg;
-
- /* Pointer to physical buffer */
- seg.ds_addr =
- (bus_addr_t)csio->data_ptr;
- seg.ds_len = csio->dxfer_len;
- adwexecuteacb(acb, &seg, 1, 0);
- }
- } else {
- struct bus_dma_segment *segs;
-
- if ((ccbh->flags & CAM_DATA_PHYS) != 0)
- panic("adw_action - Physical "
- "segment pointers "
- "unsupported");
-
- if ((ccbh->flags&CAM_SG_LIST_PHYS)==0)
- panic("adw_action - Virtual "
- "segment addresses "
- "unsupported");
-
- /* Just use the segments provided */
- segs = (struct bus_dma_segment *)csio->data_ptr;
- adwexecuteacb(acb, segs, csio->sglist_cnt,
- (csio->sglist_cnt < ADW_SGSIZE)
- ? 0 : EFBIG);
- }
- } else {
- adwexecuteacb(acb, NULL, 0, 0);
+ error = bus_dmamap_load_ccb(adw->buffer_dmat,
+ acb->dmamap,
+ ccb,
+ adwexecuteacb,
+ acb, /*flags*/0);
+ if (error == EINPROGRESS) {
+ /*
+ * So as to maintain ordering, freeze the controller
+ * queue until our mapping is returned.
+ */
+ xpt_freeze_simq(sim, 1);
+ acb->state |= CAM_RELEASE_SIMQ;
}
break;
}
diff --git a/sys/dev/aha/aha.c b/sys/dev/aha/aha.c
index 07b0682..ab2a59a 100644
--- a/sys/dev/aha/aha.c
+++ b/sys/dev/aha/aha.c
@@ -778,6 +778,7 @@ ahaaction(struct cam_sim *sim, union ccb *ccb)
if (ccb->ccb_h.func_code == XPT_SCSI_IO) {
struct ccb_scsiio *csio;
struct ccb_hdr *ccbh;
+ int error;
csio = &ccb->csio;
ccbh = &csio->ccb_h;
@@ -811,67 +812,22 @@ ahaaction(struct cam_sim *sim, union ccb *ccb)
* If we have any data to send with this command,
* map it into bus space.
*/
- /* Only use S/G if there is a transfer */
- 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) {
- int error;
-
- error = bus_dmamap_load(
- aha->buffer_dmat,
- accb->dmamap,
- csio->data_ptr,
- csio->dxfer_len,
- ahaexecuteccb,
- accb,
- /*flags*/0);
- if (error == EINPROGRESS) {
- /*
- * So as to maintain
- * ordering, freeze the
- * controller queue
- * until our mapping is
- * returned.
- */
- xpt_freeze_simq(aha->sim,
- 1);
- csio->ccb_h.status |=
- CAM_RELEASE_SIMQ;
- }
- } else {
- struct bus_dma_segment seg;
-
- /* Pointer to physical buffer */
- seg.ds_addr =
- (bus_addr_t)csio->data_ptr;
- seg.ds_len = csio->dxfer_len;
- ahaexecuteccb(accb, &seg, 1, 0);
- }
- } else {
- struct bus_dma_segment *segs;
-
- if ((ccbh->flags & CAM_DATA_PHYS) != 0)
- panic("ahaaction - Physical "
- "segment pointers "
- "unsupported");
-
- if ((ccbh->flags&CAM_SG_LIST_PHYS)==0)
- panic("ahaaction - Virtual "
- "segment addresses "
- "unsupported");
-
- /* Just use the segments provided */
- segs = (struct bus_dma_segment *)
- csio->data_ptr;
- ahaexecuteccb(accb, segs,
- csio->sglist_cnt, 0);
- }
- } else {
- ahaexecuteccb(accb, NULL, 0, 0);
+
+ error = bus_dmamap_load_ccb(
+ aha->buffer_dmat,
+ accb->dmamap,
+ ccb,
+ ahaexecuteccb,
+ accb,
+ /*flags*/0);
+ if (error == EINPROGRESS) {
+ /*
+ * So as to maintain ordering, freeze the
+ * controller queue until our mapping is
+ * returned.
+ */
+ xpt_freeze_simq(aha->sim, 1);
+ csio->ccb_h.status |= CAM_RELEASE_SIMQ;
}
} else {
hccb->opcode = INITIATOR_BUS_DEV_RESET;
diff --git a/sys/dev/ahb/ahb.c b/sys/dev/ahb/ahb.c
index b0b4db2..fd07c44 100644
--- a/sys/dev/ahb/ahb.c
+++ b/sys/dev/ahb/ahb.c
@@ -1006,6 +1006,7 @@ ahbaction(struct cam_sim *sim, union ccb *ccb)
{
struct ecb *ecb;
struct hardware_ecb *hecb;
+ int error;
/*
* get an ecb to use.
@@ -1056,65 +1057,19 @@ ahbaction(struct cam_sim *sim, union ccb *ccb)
hecb->cdb, hecb->cdb_len);
}
- /*
- * If we have any data to send with this command,
- * map it into bus space.
- */
- if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- if ((ccb->ccb_h.flags & CAM_SCATTER_VALID) == 0) {
- /*
- * We've been given a pointer
- * to a single buffer.
- */
- if ((ccb->ccb_h.flags & CAM_DATA_PHYS)==0) {
- int error;
-
- error = bus_dmamap_load(
- ahb->buffer_dmat,
- ecb->dmamap,
- ccb->csio.data_ptr,
- ccb->csio.dxfer_len,
- ahbexecuteecb,
- ecb, /*flags*/0);
- if (error == EINPROGRESS) {
- /*
- * So as to maintain ordering,
- * freeze the controller queue
- * until our mapping is
- * returned.
- */
- xpt_freeze_simq(ahb->sim, 1);
- ccb->ccb_h.status |=
- CAM_RELEASE_SIMQ;
- }
- } else {
- struct bus_dma_segment seg;
-
- /* Pointer to physical buffer */
- seg.ds_addr =
- (bus_addr_t)ccb->csio.data_ptr;
- seg.ds_len = ccb->csio.dxfer_len;
- ahbexecuteecb(ecb, &seg, 1, 0);
- }
- } else {
- struct bus_dma_segment *segs;
-
- if ((ccb->ccb_h.flags & CAM_DATA_PHYS) != 0)
- panic("ahbaction - Physical segment "
- "pointers unsupported");
-
- if ((ccb->ccb_h.flags & CAM_SG_LIST_PHYS) == 0)
- panic("btaction - Virtual segment "
- "addresses unsupported");
-
- /* Just use the segments provided */
- segs = (struct bus_dma_segment *)
- ccb->csio.data_ptr;
- ahbexecuteecb(ecb, segs, ccb->csio.sglist_cnt,
- 0);
- }
- } else {
- ahbexecuteecb(ecb, NULL, 0, 0);
+ error = bus_dmamap_load_ccb(
+ ahb->buffer_dmat,
+ ecb->dmamap,
+ ccb,
+ ahbexecuteecb,
+ ecb, /*flags*/0);
+ if (error == EINPROGRESS) {
+ /*
+ * So as to maintain ordering, freeze the controller
+ * queue until our mapping is returned.
+ */
+ xpt_freeze_simq(ahb->sim, 1);
+ ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
}
break;
}
diff --git a/sys/dev/ahci/ahci.c b/sys/dev/ahci/ahci.c
index b17b9f3..8e692bd 100644
--- a/sys/dev/ahci/ahci.c
+++ b/sys/dev/ahci/ahci.c
@@ -1683,21 +1683,10 @@ ahci_begin_transaction(device_t dev, union ccb *ccb)
(ccb->ataio.cmd.flags & (CAM_ATAIO_CONTROL | CAM_ATAIO_NEEDRESULT)))
ch->aslots |= (1 << slot->slot);
slot->dma.nsegs = 0;
- /* If request moves data, setup and load SG list */
if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- void *buf;
- bus_size_t size;
-
slot->state = AHCI_SLOT_LOADING;
- if (ccb->ccb_h.func_code == XPT_ATA_IO) {
- buf = ccb->ataio.data_ptr;
- size = ccb->ataio.dxfer_len;
- } else {
- buf = ccb->csio.data_ptr;
- size = ccb->csio.dxfer_len;
- }
- bus_dmamap_load(ch->dma.data_tag, slot->dma.data_map,
- buf, size, ahci_dmasetprd, slot, 0);
+ bus_dmamap_load_ccb(ch->dma.data_tag, slot->dma.data_map, ccb,
+ ahci_dmasetprd, slot, 0);
} else
ahci_execute_transaction(slot);
}
diff --git a/sys/dev/aic/aic.c b/sys/dev/aic/aic.c
index d83df32..d751b4d 100644
--- a/sys/dev/aic/aic.c
+++ b/sys/dev/aic/aic.c
@@ -146,8 +146,8 @@ aic_action(struct cam_sim *sim, union ccb *ccb)
scb->cmd_ptr = ccb->csio.cdb_io.cdb_bytes;
}
if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- if ((ccb->ccb_h.flags & CAM_SCATTER_VALID) ||
- (ccb->ccb_h.flags & CAM_DATA_PHYS)) {
+ if ((ccb->ccb_h.flags & CAM_DATA_MASK) !=
+ CAM_DATA_VADDR) {
ccb->ccb_h.status = CAM_REQ_INVALID;
aic_free_scb(aic, scb);
xpt_done(ccb);
diff --git a/sys/dev/aic7xxx/aic79xx_osm.c b/sys/dev/aic7xxx/aic79xx_osm.c
index 3f7b818..6ef0f92 100644
--- a/sys/dev/aic7xxx/aic79xx_osm.c
+++ b/sys/dev/aic7xxx/aic79xx_osm.c
@@ -1071,6 +1071,7 @@ ahd_setup_data(struct ahd_softc *ahd, struct cam_sim *sim,
{
struct hardware_scb *hscb;
struct ccb_hdr *ccb_h;
+ int error;
hscb = scb->hscb;
ccb_h = &csio->ccb_h;
@@ -1120,64 +1121,18 @@ ahd_setup_data(struct ahd_softc *ahd, struct cam_sim *sim,
}
}
- /* Only use S/G if there is a transfer */
- if ((ccb_h->flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- if ((ccb_h->flags & CAM_SCATTER_VALID) == 0) {
- /* We've been given a pointer to a single buffer */
- if ((ccb_h->flags & CAM_DATA_PHYS) == 0) {
- int s;
- int error;
-
- s = splsoftvm();
- error = bus_dmamap_load(ahd->buffer_dmat,
- scb->dmamap,
- csio->data_ptr,
- csio->dxfer_len,
- ahd_execute_scb,
- scb, /*flags*/0);
- if (error == EINPROGRESS) {
- /*
- * So as to maintain ordering,
- * freeze the controller queue
- * until our mapping is
- * returned.
- */
- xpt_freeze_simq(sim,
- /*count*/1);
- scb->io_ctx->ccb_h.status |=
- CAM_RELEASE_SIMQ;
- }
- splx(s);
- } else {
- struct bus_dma_segment seg;
-
- /* Pointer to physical buffer */
- if (csio->dxfer_len > AHD_MAXTRANSFER_SIZE)
- panic("ahd_setup_data - Transfer size "
- "larger than can device max");
-
- seg.ds_addr =
- (bus_addr_t)(vm_offset_t)csio->data_ptr;
- seg.ds_len = csio->dxfer_len;
- ahd_execute_scb(scb, &seg, 1, 0);
- }
- } else {
- struct bus_dma_segment *segs;
-
- if ((ccb_h->flags & CAM_DATA_PHYS) != 0)
- panic("ahd_setup_data - Physical segment "
- "pointers unsupported");
-
- if ((ccb_h->flags & CAM_SG_LIST_PHYS) == 0)
- panic("ahd_setup_data - Virtual segment "
- "addresses unsupported");
-
- /* Just use the segments provided */
- segs = (struct bus_dma_segment *)csio->data_ptr;
- ahd_execute_scb(scb, segs, csio->sglist_cnt, 0);
- }
- } else {
- ahd_execute_scb(scb, NULL, 0, 0);
+ error = bus_dmamap_load_ccb(ahd->buffer_dmat,
+ scb->dmamap,
+ (union ccb *)csio,
+ ahd_execute_scb,
+ scb, /*flags*/0);
+ if (error == EINPROGRESS) {
+ /*
+ * So as to maintain ordering, freeze the controller queue
+ * until our mapping is returned.
+ */
+ xpt_freeze_simq(sim, /*count*/1);
+ scb->io_ctx->ccb_h.status |= CAM_RELEASE_SIMQ;
}
}
diff --git a/sys/dev/aic7xxx/aic7xxx_osm.c b/sys/dev/aic7xxx/aic7xxx_osm.c
index 281b00e..a51177c9 100644
--- a/sys/dev/aic7xxx/aic7xxx_osm.c
+++ b/sys/dev/aic7xxx/aic7xxx_osm.c
@@ -1138,6 +1138,7 @@ ahc_setup_data(struct ahc_softc *ahc, struct cam_sim *sim,
{
struct hardware_scb *hscb;
struct ccb_hdr *ccb_h;
+ int error;
hscb = scb->hscb;
ccb_h = &csio->ccb_h;
@@ -1179,64 +1180,21 @@ ahc_setup_data(struct ahc_softc *ahc, struct cam_sim *sim,
}
}
- /* Only use S/G if there is a transfer */
- if ((ccb_h->flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- if ((ccb_h->flags & CAM_SCATTER_VALID) == 0) {
- /* We've been given a pointer to a single buffer */
- if ((ccb_h->flags & CAM_DATA_PHYS) == 0) {
- int s;
- int error;
-
- s = splsoftvm();
- error = bus_dmamap_load(ahc->buffer_dmat,
- scb->dmamap,
- csio->data_ptr,
- csio->dxfer_len,
- ahc_execute_scb,
- scb, /*flags*/0);
- if (error == EINPROGRESS) {
- /*
- * So as to maintain ordering,
- * freeze the controller queue
- * until our mapping is
- * returned.
- */
- xpt_freeze_simq(sim,
- /*count*/1);
- scb->io_ctx->ccb_h.status |=
- CAM_RELEASE_SIMQ;
- }
- splx(s);
- } else {
- struct bus_dma_segment seg;
-
- /* Pointer to physical buffer */
- if (csio->dxfer_len > AHC_MAXTRANSFER_SIZE)
- panic("ahc_setup_data - Transfer size "
- "larger than can device max");
-
- seg.ds_addr =
- (bus_addr_t)(vm_offset_t)csio->data_ptr;
- seg.ds_len = csio->dxfer_len;
- ahc_execute_scb(scb, &seg, 1, 0);
- }
- } else {
- struct bus_dma_segment *segs;
-
- if ((ccb_h->flags & CAM_DATA_PHYS) != 0)
- panic("ahc_setup_data - Physical segment "
- "pointers unsupported");
-
- if ((ccb_h->flags & CAM_SG_LIST_PHYS) == 0)
- panic("ahc_setup_data - Virtual segment "
- "addresses unsupported");
-
- /* Just use the segments provided */
- segs = (struct bus_dma_segment *)csio->data_ptr;
- ahc_execute_scb(scb, segs, csio->sglist_cnt, 0);
- }
- } else {
- ahc_execute_scb(scb, NULL, 0, 0);
+ error = bus_dmamap_load_ccb(ahc->buffer_dmat,
+ scb->dmamap,
+ (union ccb *)csio,
+ ahc_execute_scb,
+ scb,
+ 0);
+ if (error == EINPROGRESS) {
+ /*
+ * So as to maintain ordering,
+ * freeze the controller queue
+ * until our mapping is
+ * returned.
+ */
+ xpt_freeze_simq(sim, /*count*/1);
+ scb->io_ctx->ccb_h.status |= CAM_RELEASE_SIMQ;
}
}
diff --git a/sys/dev/amr/amr_cam.c b/sys/dev/amr/amr_cam.c
index d03ac6d..a1e0a88 100644
--- a/sys/dev/amr/amr_cam.c
+++ b/sys/dev/amr/amr_cam.c
@@ -274,12 +274,9 @@ amr_cam_action(struct cam_sim *sim, union ccb *ccb)
* address
*/
if ((ccbh->flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- if (ccbh->flags & CAM_DATA_PHYS)
+ if ((ccbh->flags & CAM_DATA_MASK) != CAM_DATA_VADDR)
/* we can't map it */
ccbh->status = CAM_REQ_INVALID;
- if (ccbh->flags & CAM_SCATTER_VALID)
- /* we want to do the s/g setup */
- ccbh->status = CAM_REQ_INVALID;
}
/*
diff --git a/sys/dev/arcmsr/arcmsr.c b/sys/dev/arcmsr/arcmsr.c
index 2096a22..c815d02 100644
--- a/sys/dev/arcmsr/arcmsr.c
+++ b/sys/dev/arcmsr/arcmsr.c
@@ -2341,7 +2341,7 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, union ccb *p
(u_int32_t ) pccb->csio.cdb_io.cdb_bytes[7] << 8 |
(u_int32_t ) pccb->csio.cdb_io.cdb_bytes[8];
/* 4 bytes: Areca io control code */
- if((pccb->ccb_h.flags & CAM_SCATTER_VALID) == 0) {
+ if ((pccb->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_VADDR) {
buffer = pccb->csio.data_ptr;
transfer_len = pccb->csio.dxfer_len;
} else {
@@ -2731,6 +2731,7 @@ static void arcmsr_action(struct cam_sim *psim, union ccb *pccb)
case XPT_SCSI_IO: {
struct CommandControlBlock *srb;
int target = pccb->ccb_h.target_id;
+ int error;
if(target == 16) {
/* virtual device for iop message transfer */
@@ -2745,52 +2746,13 @@ static void arcmsr_action(struct cam_sim *psim, union ccb *pccb)
pccb->ccb_h.arcmsr_ccbsrb_ptr = srb;
pccb->ccb_h.arcmsr_ccbacb_ptr = acb;
srb->pccb = pccb;
- if((pccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- if(!(pccb->ccb_h.flags & CAM_SCATTER_VALID)) {
- /* Single buffer */
- if(!(pccb->ccb_h.flags & CAM_DATA_PHYS)) {
- /* Buffer is virtual */
- u_int32_t error, s;
-
- s = splsoftvm();
- error = bus_dmamap_load(acb->dm_segs_dmat
- , srb->dm_segs_dmamap
- , pccb->csio.data_ptr
- , pccb->csio.dxfer_len
- , arcmsr_execute_srb, srb, /*flags*/0);
- if(error == EINPROGRESS) {
- xpt_freeze_simq(acb->psim, 1);
- pccb->ccb_h.status |= CAM_RELEASE_SIMQ;
- }
- splx(s);
- }
- else { /* Buffer is physical */
-#ifdef PAE
- panic("arcmsr: CAM_DATA_PHYS not supported");
-#else
- struct bus_dma_segment seg;
-
- seg.ds_addr = (bus_addr_t)pccb->csio.data_ptr;
- seg.ds_len = pccb->csio.dxfer_len;
- arcmsr_execute_srb(srb, &seg, 1, 0);
-#endif
- }
- } else {
- /* Scatter/gather list */
- struct bus_dma_segment *segs;
-
- if((pccb->ccb_h.flags & CAM_SG_LIST_PHYS) == 0
- || (pccb->ccb_h.flags & CAM_DATA_PHYS) != 0) {
- pccb->ccb_h.status |= CAM_PROVIDE_FAIL;
- xpt_done(pccb);
- free(srb, M_DEVBUF);
- return;
- }
- segs = (struct bus_dma_segment *)pccb->csio.data_ptr;
- arcmsr_execute_srb(srb, segs, pccb->csio.sglist_cnt, 0);
- }
- } else {
- arcmsr_execute_srb(srb, NULL, 0, 0);
+ error = bus_dmamap_load_ccb(acb->dm_segs_dmat
+ , srb->dm_segs_dmamap
+ , pccb
+ , arcmsr_execute_srb, srb, /*flags*/0);
+ if(error == EINPROGRESS) {
+ xpt_freeze_simq(acb->psim, 1);
+ pccb->ccb_h.status |= CAM_RELEASE_SIMQ;
}
break;
}
diff --git a/sys/dev/ata/ata-dma.c b/sys/dev/ata/ata-dma.c
index ffd2461..9aea845 100644
--- a/sys/dev/ata/ata-dma.c
+++ b/sys/dev/ata/ata-dma.c
@@ -304,10 +304,17 @@ ata_dmaload(struct ata_request *request, void *addr, int *entries)
else
dspa.dmatab = request->dma->sg;
- if ((error = bus_dmamap_load(request->dma->data_tag, request->dma->data_map,
- request->data, request->bytecount,
- ch->dma.setprd, &dspa, BUS_DMA_NOWAIT)) ||
- (error = dspa.error)) {
+#ifdef ATA_CAM
+ if (request->ccb)
+ error = bus_dmamap_load_ccb(request->dma->data_tag,
+ request->dma->data_map, request->ccb,
+ ch->dma.setprd, &dspa, BUS_DMA_NOWAIT);
+ else
+#endif
+ error = bus_dmamap_load(request->dma->data_tag, request->dma->data_map,
+ request->data, request->bytecount,
+ ch->dma.setprd, &dspa, BUS_DMA_NOWAIT);
+ if (error || (error = dspa.error)) {
device_printf(request->parent, "FAILURE - load data\n");
goto error;
}
diff --git a/sys/dev/ata/atapi-cam.c b/sys/dev/ata/atapi-cam.c
index 363aa94..0181785 100644
--- a/sys/dev/ata/atapi-cam.c
+++ b/sys/dev/ata/atapi-cam.c
@@ -514,12 +514,6 @@ atapi_action(struct cam_sim *sim, union ccb *ccb)
("CAM CCB too long for ATAPI"));
goto action_invalid;
}
- if ((ccb_h->flags & CAM_SCATTER_VALID)) {
- /* scatter-gather not supported */
- xpt_print_path(ccb_h->path);
- printf("ATAPI/CAM does not support scatter-gather yet!\n");
- goto action_invalid;
- }
switch (ccb_h->flags & CAM_DIR_MASK) {
case CAM_DIR_IN:
diff --git a/sys/dev/buslogic/bt.c b/sys/dev/buslogic/bt.c
index 51f5fdd..a2c9f4f 100644
--- a/sys/dev/buslogic/bt.c
+++ b/sys/dev/buslogic/bt.c
@@ -1158,6 +1158,7 @@ btaction(struct cam_sim *sim, union ccb *ccb)
if (ccb->ccb_h.func_code == XPT_SCSI_IO) {
struct ccb_scsiio *csio;
struct ccb_hdr *ccbh;
+ int error;
csio = &ccb->csio;
ccbh = &csio->ccb_h;
@@ -1205,67 +1206,21 @@ btaction(struct cam_sim *sim, union ccb *ccb)
* If we have any data to send with this command,
* map it into bus space.
*/
- /* Only use S/G if there is a transfer */
- 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) {
- int error;
-
- error = bus_dmamap_load(
- bt->buffer_dmat,
- bccb->dmamap,
- csio->data_ptr,
- csio->dxfer_len,
- btexecuteccb,
- bccb,
- /*flags*/0);
- if (error == EINPROGRESS) {
- /*
- * So as to maintain
- * ordering, freeze the
- * controller queue
- * until our mapping is
- * returned.
- */
- xpt_freeze_simq(bt->sim,
- 1);
- csio->ccb_h.status |=
- CAM_RELEASE_SIMQ;
- }
- } else {
- struct bus_dma_segment seg;
-
- /* Pointer to physical buffer */
- seg.ds_addr =
- (bus_addr_t)csio->data_ptr;
- seg.ds_len = csio->dxfer_len;
- btexecuteccb(bccb, &seg, 1, 0);
- }
- } else {
- struct bus_dma_segment *segs;
-
- if ((ccbh->flags & CAM_DATA_PHYS) != 0)
- panic("btaction - Physical "
- "segment pointers "
- "unsupported");
-
- if ((ccbh->flags&CAM_SG_LIST_PHYS)==0)
- panic("btaction - Virtual "
- "segment addresses "
- "unsupported");
-
- /* Just use the segments provided */
- segs = (struct bus_dma_segment *)
- csio->data_ptr;
- btexecuteccb(bccb, segs,
- csio->sglist_cnt, 0);
- }
- } else {
- btexecuteccb(bccb, NULL, 0, 0);
+ error = bus_dmamap_load_ccb(
+ bt->buffer_dmat,
+ bccb->dmamap,
+ ccb,
+ btexecuteccb,
+ bccb,
+ /*flags*/0);
+ if (error == EINPROGRESS) {
+ /*
+ * So as to maintain ordering, freeze the
+ * controller queue until our mapping is
+ * returned.
+ */
+ xpt_freeze_simq(bt->sim, 1);
+ csio->ccb_h.status |= CAM_RELEASE_SIMQ;
}
} else {
hccb->opcode = INITIATOR_BUS_DEV_RESET;
diff --git a/sys/dev/ciss/ciss.c b/sys/dev/ciss/ciss.c
index a3f0a4a..9aef998 100644
--- a/sys/dev/ciss/ciss.c
+++ b/sys/dev/ciss/ciss.c
@@ -2688,9 +2688,14 @@ ciss_map_request(struct ciss_request *cr)
BUS_DMASYNC_PREWRITE);
if (cr->cr_data != NULL) {
- error = bus_dmamap_load(sc->ciss_buffer_dmat, cr->cr_datamap,
- cr->cr_data, cr->cr_length,
- ciss_request_map_helper, cr, 0);
+ if (cr->cr_flags & CISS_REQ_CCB)
+ error = bus_dmamap_load_ccb(sc->ciss_buffer_dmat,
+ cr->cr_datamap, cr->cr_data,
+ ciss_request_map_helper, cr, 0);
+ else
+ error = bus_dmamap_load(sc->ciss_buffer_dmat, cr->cr_datamap,
+ cr->cr_data, cr->cr_length,
+ ciss_request_map_helper, cr, 0);
if (error != 0)
return (error);
} else {
@@ -3056,18 +3061,6 @@ ciss_cam_action_io(struct cam_sim *sim, struct ccb_scsiio *csio)
csio->ccb_h.status = CAM_REQ_CMP_ERR;
}
- /* if there is data transfer, it must be to/from a virtual address */
- if ((csio->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- if (csio->ccb_h.flags & CAM_DATA_PHYS) { /* we can't map it */
- debug(3, " data pointer is to physical address");
- csio->ccb_h.status = CAM_REQ_CMP_ERR;
- }
- if (csio->ccb_h.flags & CAM_SCATTER_VALID) { /* we want to do the s/g setup */
- debug(3, " data has premature s/g setup");
- csio->ccb_h.status = CAM_REQ_CMP_ERR;
- }
- }
-
/* abandon aborted ccbs or those that have failed validation */
if ((csio->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_INPROG) {
debug(3, "abandoning CCB due to abort/validation failure");
@@ -3094,7 +3087,7 @@ ciss_cam_action_io(struct cam_sim *sim, struct ccb_scsiio *csio)
* Build the command.
*/
cc = cr->cr_cc;
- cr->cr_data = csio->data_ptr;
+ cr->cr_data = csio;
cr->cr_length = csio->dxfer_len;
cr->cr_complete = ciss_cam_complete;
cr->cr_private = csio;
@@ -3112,12 +3105,13 @@ ciss_cam_action_io(struct cam_sim *sim, struct ccb_scsiio *csio)
cc->cdb.type = CISS_CDB_TYPE_COMMAND;
cc->cdb.attribute = CISS_CDB_ATTRIBUTE_SIMPLE; /* XXX ordered tags? */
if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT) {
- cr->cr_flags = CISS_REQ_DATAOUT;
+ cr->cr_flags = CISS_REQ_DATAOUT | CISS_REQ_CCB;
cc->cdb.direction = CISS_CDB_DIRECTION_WRITE;
} else if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
- cr->cr_flags = CISS_REQ_DATAIN;
+ cr->cr_flags = CISS_REQ_DATAIN | CISS_REQ_CCB;
cc->cdb.direction = CISS_CDB_DIRECTION_READ;
} else {
+ cr->cr_data = NULL;
cr->cr_flags = 0;
cc->cdb.direction = CISS_CDB_DIRECTION_NONE;
}
diff --git a/sys/dev/ciss/cissvar.h b/sys/dev/ciss/cissvar.h
index e89e4e9..b3719cfa 100644
--- a/sys/dev/ciss/cissvar.h
+++ b/sys/dev/ciss/cissvar.h
@@ -116,6 +116,7 @@ struct ciss_request
#define CISS_REQ_DATAOUT (1<<3) /* data host->adapter */
#define CISS_REQ_DATAIN (1<<4) /* data adapter->host */
#define CISS_REQ_BUSY (1<<5) /* controller has req */
+#define CISS_REQ_CCB (1<<6) /* data is ccb */
void (* cr_complete)(struct ciss_request *);
void *cr_private;
diff --git a/sys/dev/dpt/dpt_scsi.c b/sys/dev/dpt/dpt_scsi.c
index b4a73c9..908f0f8 100644
--- a/sys/dev/dpt/dpt_scsi.c
+++ b/sys/dev/dpt/dpt_scsi.c
@@ -910,56 +910,22 @@ dpt_action(struct cam_sim *sim, union ccb *ccb)
*/
/* Only use S/G if there is a transfer */
if ((ccbh->flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- if ((ccbh->flags & CAM_SCATTER_VALID) == 0) {
+ int error;
+
+ error = bus_dmamap_load_ccb(dpt->buffer_dmat,
+ dccb->dmamap,
+ ccb,
+ dptexecuteccb,
+ dccb, /*flags*/0);
+ if (error == EINPROGRESS) {
/*
- * We've been given a pointer
- * to a single buffer.
+ * So as to maintain ordering,
+ * freeze the controller queue
+ * until our mapping is
+ * returned.
*/
- if ((ccbh->flags & CAM_DATA_PHYS) == 0) {
- int error;
-
- error =
- bus_dmamap_load(dpt->buffer_dmat,
- dccb->dmamap,
- csio->data_ptr,
- csio->dxfer_len,
- dptexecuteccb,
- dccb, /*flags*/0);
- if (error == EINPROGRESS) {
- /*
- * So as to maintain ordering,
- * freeze the controller queue
- * until our mapping is
- * returned.
- */
- xpt_freeze_simq(sim, 1);
- dccb->state |= CAM_RELEASE_SIMQ;
- }
- } else {
- struct bus_dma_segment seg;
-
- /* Pointer to physical buffer */
- seg.ds_addr =
- (bus_addr_t)csio->data_ptr;
- seg.ds_len = csio->dxfer_len;
- dptexecuteccb(dccb, &seg, 1, 0);
- }
- } else {
- struct bus_dma_segment *segs;
-
- if ((ccbh->flags & CAM_DATA_PHYS) != 0)
- panic("dpt_action - Physical "
- "segment pointers "
- "unsupported");
-
- if ((ccbh->flags&CAM_SG_LIST_PHYS)==0)
- panic("dpt_action - Virtual "
- "segment addresses "
- "unsupported");
-
- /* Just use the segments provided */
- segs = (struct bus_dma_segment *)csio->data_ptr;
- dptexecuteccb(dccb, segs, csio->sglist_cnt, 0);
+ xpt_freeze_simq(sim, 1);
+ dccb->state |= CAM_RELEASE_SIMQ;
}
} else {
/*
diff --git a/sys/dev/firewire/sbp.c b/sys/dev/firewire/sbp.c
index 9204449..8089d99 100644
--- a/sys/dev/firewire/sbp.c
+++ b/sys/dev/firewire/sbp.c
@@ -2478,11 +2478,6 @@ END_DEBUG
ocb->orb[4] |= htonl(ORB_CMD_IN);
}
- if (csio->ccb_h.flags & CAM_SCATTER_VALID)
- printf("sbp: CAM_SCATTER_VALID\n");
- if (csio->ccb_h.flags & CAM_DATA_PHYS)
- printf("sbp: CAM_DATA_PHYS\n");
-
if (csio->ccb_h.flags & CAM_CDB_POINTER)
cdb = (void *)csio->cdb_io.cdb_ptr;
else
@@ -2496,10 +2491,9 @@ printf("ORB %08x %08x %08x %08x\n", ntohl(ocb->orb[4]), ntohl(ocb->orb[5]), ntoh
int s, error;
s = splsoftvm();
- error = bus_dmamap_load(/*dma tag*/sbp->dmat,
+ error = bus_dmamap_load_ccb(/*dma tag*/sbp->dmat,
/*dma map*/ocb->dmamap,
- ccb->csio.data_ptr,
- ccb->csio.dxfer_len,
+ ccb,
sbp_execute_ocb,
ocb,
/*flags*/0);
diff --git a/sys/dev/hpt27xx/osm_bsd.c b/sys/dev/hpt27xx/osm_bsd.c
index fab1c71d..9f4d1b9 100644
--- a/sys/dev/hpt27xx/osm_bsd.c
+++ b/sys/dev/hpt27xx/osm_bsd.c
@@ -474,33 +474,6 @@ static void os_cmddone(PCOMMAND pCmd)
static int os_buildsgl(PCOMMAND pCmd, PSG pSg, int logical)
{
- POS_CMDEXT ext = (POS_CMDEXT)pCmd->priv;
- union ccb *ccb = ext->ccb;
- bus_dma_segment_t *sgList = (bus_dma_segment_t *)ccb->csio.data_ptr;
- int idx;
-
- if(logical) {
- if (ccb->ccb_h.flags & CAM_DATA_PHYS)
- panic("physical address unsupported");
-
- if (ccb->ccb_h.flags & CAM_SCATTER_VALID) {
- if (ccb->ccb_h.flags & CAM_SG_LIST_PHYS)
- panic("physical address unsupported");
-
- for (idx = 0; idx < ccb->csio.sglist_cnt; idx++) {
- os_set_sgptr(&pSg[idx], (HPT_U8 *)(HPT_UPTR)sgList[idx].ds_addr);
- pSg[idx].size = sgList[idx].ds_len;
- pSg[idx].eot = (idx==ccb->csio.sglist_cnt-1)? 1 : 0;
- }
- }
- else {
- os_set_sgptr(pSg, (HPT_U8 *)ccb->csio.data_ptr);
- pSg->size = ccb->csio.dxfer_len;
- pSg->eot = 1;
- }
- return TRUE;
- }
-
/* since we have provided physical sg, nobody will ask us to build physical sg */
HPT_ASSERT(0);
return FALSE;
@@ -515,23 +488,27 @@ static void hpt_io_dmamap_callback(void *arg, bus_dma_segment_t *segs, int nsegs
HPT_ASSERT(pCmd->flags.physical_sg);
- if (error || nsegs == 0)
+ if (error)
panic("busdma error");
HPT_ASSERT(nsegs<=os_max_sg_descriptors);
- for (idx = 0; idx < nsegs; idx++, psg++) {
- psg->addr.bus = segs[idx].ds_addr;
- psg->size = segs[idx].ds_len;
- psg->eot = 0;
- }
- psg[-1].eot = 1;
+ if (nsegs != 0) {
+ for (idx = 0; idx < nsegs; idx++, psg++) {
+ psg->addr.bus = segs[idx].ds_addr;
+ psg->size = segs[idx].ds_len;
+ psg->eot = 0;
+ }
+ psg[-1].eot = 1;
- if (pCmd->flags.data_in) {
- bus_dmamap_sync(ext->vbus_ext->io_dmat, ext->dma_map, BUS_DMASYNC_PREREAD);
- }
- else if (pCmd->flags.data_out) {
- bus_dmamap_sync(ext->vbus_ext->io_dmat, ext->dma_map, BUS_DMASYNC_PREWRITE);
+ if (pCmd->flags.data_in) {
+ bus_dmamap_sync(ext->vbus_ext->io_dmat, ext->dma_map,
+ BUS_DMASYNC_PREREAD);
+ }
+ else if (pCmd->flags.data_out) {
+ bus_dmamap_sync(ext->vbus_ext->io_dmat, ext->dma_map,
+ BUS_DMASYNC_PREWRITE);
+ }
}
ext->ccb->ccb_h.timeout_ch = timeout(hpt_timeout, pCmd, HPT_OSM_TIMEOUT);
@@ -661,6 +638,7 @@ static void hpt_scsi_io(PVBUS_EXT vbus_ext, union ccb *ccb)
case 0x2f:
case 0x8f: /* VERIFY_16 */
{
+ int error;
pCmd = ldm_alloc_cmds(vbus, vd->cmds_per_request);
if(!pCmd){
KdPrint(("Failed to allocate command!"));
@@ -717,42 +695,20 @@ static void hpt_scsi_io(PVBUS_EXT vbus_ext, union ccb *ccb)
pCmd->target = vd;
pCmd->done = os_cmddone;
pCmd->buildsgl = os_buildsgl;
-
pCmd->psg = ext->psg;
-
- if (ccb->ccb_h.flags & CAM_SCATTER_VALID) {
- int idx;
- bus_dma_segment_t *sgList = (bus_dma_segment_t *)ccb->csio.data_ptr;
-
- if (ccb->ccb_h.flags & CAM_SG_LIST_PHYS)
- pCmd->flags.physical_sg = 1;
-
- for (idx = 0; idx < ccb->csio.sglist_cnt; idx++) {
- pCmd->psg[idx].addr.bus = sgList[idx].ds_addr;
- pCmd->psg[idx].size = sgList[idx].ds_len;
- pCmd->psg[idx].eot = (idx==ccb->csio.sglist_cnt-1)? 1 : 0;
- }
-
- ccb->ccb_h.timeout_ch = timeout(hpt_timeout, pCmd, HPT_OSM_TIMEOUT);
- ldm_queue_cmd(pCmd);
- }
- else {
- int error;
- pCmd->flags.physical_sg = 1;
- error = bus_dmamap_load(vbus_ext->io_dmat,
- ext->dma_map,
- ccb->csio.data_ptr, ccb->csio.dxfer_len,
- hpt_io_dmamap_callback, pCmd,
+ pCmd->flags.physical_sg = 1;
+ error = bus_dmamap_load_ccb(vbus_ext->io_dmat,
+ ext->dma_map, ccb,
+ hpt_io_dmamap_callback, pCmd,
BUS_DMA_WAITOK
);
- KdPrint(("bus_dmamap_load return %d", error));
- if (error && error!=EINPROGRESS) {
- os_printk("bus_dmamap_load error %d", error);
- cmdext_put(ext);
- ldm_free_cmds(pCmd);
- ccb->ccb_h.status = CAM_REQ_CMP_ERR;
- xpt_done(ccb);
- }
+ KdPrint(("bus_dmamap_load return %d", error));
+ if (error && error!=EINPROGRESS) {
+ os_printk("bus_dmamap_load error %d", error);
+ cmdext_put(ext);
+ ldm_free_cmds(pCmd);
+ ccb->ccb_h.status = CAM_REQ_CMP_ERR;
+ xpt_done(ccb);
}
return;
}
diff --git a/sys/dev/hptiop/hptiop.c b/sys/dev/hptiop/hptiop.c
index c4e3d5a..e3190d2 100644
--- a/sys/dev/hptiop/hptiop.c
+++ b/sys/dev/hptiop/hptiop.c
@@ -2358,6 +2358,7 @@ static void hptiop_action(struct cam_sim *sim, union ccb *ccb)
{
struct hpt_iop_hba * hba = (struct hpt_iop_hba *)cam_sim_softc(sim);
struct hpt_iop_srb * srb;
+ int error;
switch (ccb->ccb_h.func_code) {
@@ -2380,52 +2381,22 @@ static void hptiop_action(struct cam_sim *sim, union ccb *ccb)
}
srb->ccb = ccb;
-
- if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE)
- hptiop_post_scsi_command(srb, NULL, 0, 0);
- else if ((ccb->ccb_h.flags & CAM_SCATTER_VALID) == 0) {
- if ((ccb->ccb_h.flags & CAM_DATA_PHYS) == 0) {
- int error;
-
- error = bus_dmamap_load(hba->io_dmat,
- srb->dma_map,
- ccb->csio.data_ptr,
- ccb->csio.dxfer_len,
- hptiop_post_scsi_command,
- srb, 0);
-
- if (error && error != EINPROGRESS) {
- device_printf(hba->pcidev,
- "%d bus_dmamap_load error %d",
- hba->pciunit, error);
- xpt_freeze_simq(hba->sim, 1);
- ccb->ccb_h.status = CAM_REQ_CMP_ERR;
-invalid:
- hptiop_free_srb(hba, srb);
- xpt_done(ccb);
- goto scsi_done;
- }
- }
- else {
- device_printf(hba->pcidev,
- "CAM_DATA_PHYS not supported");
- ccb->ccb_h.status = CAM_REQ_CMP_ERR;
- goto invalid;
- }
- }
- else {
- struct bus_dma_segment *segs;
-
- if ((ccb->ccb_h.flags & CAM_SG_LIST_PHYS) == 0 ||
- (ccb->ccb_h.flags & CAM_DATA_PHYS) != 0) {
- device_printf(hba->pcidev, "SCSI cmd failed");
- ccb->ccb_h.status=CAM_PROVIDE_FAIL;
- goto invalid;
- }
-
- segs = (struct bus_dma_segment *)ccb->csio.data_ptr;
- hptiop_post_scsi_command(srb, segs,
- ccb->csio.sglist_cnt, 0);
+ error = bus_dmamap_load_ccb(hba->io_dmat,
+ srb->dma_map,
+ ccb,
+ hptiop_post_scsi_command,
+ srb,
+ 0);
+
+ if (error && error != EINPROGRESS) {
+ device_printf(hba->pcidev,
+ "%d bus_dmamap_load error %d",
+ hba->pciunit, error);
+ xpt_freeze_simq(hba->sim, 1);
+ ccb->ccb_h.status = CAM_REQ_CMP_ERR;
+ hptiop_free_srb(hba, srb);
+ xpt_done(ccb);
+ goto scsi_done;
}
scsi_done:
diff --git a/sys/dev/hptmv/entry.c b/sys/dev/hptmv/entry.c
index 8dfa7e2..248d655 100644
--- a/sys/dev/hptmv/entry.c
+++ b/sys/dev/hptmv/entry.c
@@ -2620,32 +2620,7 @@ launch_worker_thread(void)
int HPTLIBAPI fOsBuildSgl(_VBUS_ARG PCommand pCmd, FPSCAT_GATH pSg, int logical)
{
- union ccb *ccb = (union ccb *)pCmd->pOrgCommand;
- bus_dma_segment_t *sgList = (bus_dma_segment_t *)ccb->csio.data_ptr;
- int idx;
- if(logical) {
- if (ccb->ccb_h.flags & CAM_DATA_PHYS)
- panic("physical address unsupported");
-
- if (ccb->ccb_h.flags & CAM_SCATTER_VALID) {
- if (ccb->ccb_h.flags & CAM_SG_LIST_PHYS)
- panic("physical address unsupported");
-
- for (idx = 0; idx < ccb->csio.sglist_cnt; idx++) {
- pSg[idx].dSgAddress = (ULONG_PTR)(UCHAR *)sgList[idx].ds_addr;
- pSg[idx].wSgSize = sgList[idx].ds_len;
- pSg[idx].wSgFlag = (idx==ccb->csio.sglist_cnt-1)? SG_FLAG_EOT : 0;
- }
- }
- else {
- pSg->dSgAddress = (ULONG_PTR)(UCHAR *)ccb->csio.data_ptr;
- pSg->wSgSize = ccb->csio.dxfer_len;
- pSg->wSgFlag = SG_FLAG_EOT;
- }
- return TRUE;
- }
-
/* since we have provided physical sg, nobody will ask us to build physical sg */
HPT_ASSERT(0);
return FALSE;
@@ -2757,24 +2732,28 @@ hpt_io_dmamap_callback(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
HPT_ASSERT(pCmd->cf_physical_sg);
- if (error || nsegs == 0)
+ if (error)
panic("busdma error");
HPT_ASSERT(nsegs<= MAX_SG_DESCRIPTORS);
- for (idx = 0; idx < nsegs; idx++, psg++) {
- psg->dSgAddress = (ULONG_PTR)(UCHAR *)segs[idx].ds_addr;
- psg->wSgSize = segs[idx].ds_len;
- psg->wSgFlag = (idx == nsegs-1)? SG_FLAG_EOT: 0;
-/* KdPrint(("psg[%d]:add=%p,size=%x,flag=%x\n", idx, psg->dSgAddress,psg->wSgSize,psg->wSgFlag)); */
- }
-/* psg[-1].wSgFlag = SG_FLAG_EOT; */
-
- if (pCmd->cf_data_in) {
- bus_dmamap_sync(pAdapter->io_dma_parent, pmap->dma_map, BUS_DMASYNC_PREREAD);
- }
- else if (pCmd->cf_data_out) {
- bus_dmamap_sync(pAdapter->io_dma_parent, pmap->dma_map, BUS_DMASYNC_PREWRITE);
+ if (nsegs != 0) {
+ for (idx = 0; idx < nsegs; idx++, psg++) {
+ psg->dSgAddress = (ULONG_PTR)(UCHAR *)segs[idx].ds_addr;
+ psg->wSgSize = segs[idx].ds_len;
+ psg->wSgFlag = (idx == nsegs-1)? SG_FLAG_EOT: 0;
+ /* KdPrint(("psg[%d]:add=%p,size=%x,flag=%x\n", idx, psg->dSgAddress,psg->wSgSize,psg->wSgFlag)); */
+ }
+ /* psg[-1].wSgFlag = SG_FLAG_EOT; */
+
+ if (pCmd->cf_data_in) {
+ bus_dmamap_sync(pAdapter->io_dma_parent, pmap->dma_map,
+ BUS_DMASYNC_PREREAD);
+ }
+ else if (pCmd->cf_data_out) {
+ bus_dmamap_sync(pAdapter->io_dma_parent, pmap->dma_map,
+ BUS_DMASYNC_PREWRITE);
+ }
}
ccb->ccb_h.timeout_ch = timeout(hpt_timeout, (caddr_t)ccb, 20*hz);
@@ -2883,6 +2862,7 @@ OsSendCommand(_VBUS_ARG union ccb *ccb)
UCHAR CdbLength;
_VBUS_INST(pVDev->pVBus)
PCommand pCmd = AllocateCommand(_VBUS_P0);
+ int error;
HPT_ASSERT(pCmd);
CdbLength = csio->cdb_len;
@@ -2960,40 +2940,21 @@ OsSendCommand(_VBUS_ARG union ccb *ccb)
break;
}
/*///////////////////////// */
- if (ccb->ccb_h.flags & CAM_SCATTER_VALID) {
- int idx;
- bus_dma_segment_t *sgList = (bus_dma_segment_t *)ccb->csio.data_ptr;
-
- if (ccb->ccb_h.flags & CAM_SG_LIST_PHYS)
- pCmd->cf_physical_sg = 1;
-
- for (idx = 0; idx < ccb->csio.sglist_cnt; idx++) {
- pCmd->pSgTable[idx].dSgAddress = (ULONG_PTR)(UCHAR *)sgList[idx].ds_addr;
- pCmd->pSgTable[idx].wSgSize = sgList[idx].ds_len;
- pCmd->pSgTable[idx].wSgFlag= (idx==ccb->csio.sglist_cnt-1)?SG_FLAG_EOT: 0;
- }
-
- ccb->ccb_h.timeout_ch = timeout(hpt_timeout, (caddr_t)ccb, 20*hz);
- pVDev->pfnSendCommand(_VBUS_P pCmd);
- }
- else {
- int error;
- pCmd->cf_physical_sg = 1;
- error = bus_dmamap_load(pAdapter->io_dma_parent,
- pmap->dma_map,
- ccb->csio.data_ptr, ccb->csio.dxfer_len,
- hpt_io_dmamap_callback, pCmd,
- BUS_DMA_WAITOK
- );
- KdPrint(("bus_dmamap_load return %d\n", error));
- if (error && error!=EINPROGRESS) {
- hpt_printk(("bus_dmamap_load error %d\n", error));
- FreeCommand(_VBUS_P pCmd);
- ccb->ccb_h.status = CAM_REQ_CMP_ERR;
- dmamap_put(pmap);
- pAdapter->outstandingCommands--;
- xpt_done(ccb);
- }
+ pCmd->cf_physical_sg = 1;
+ error = bus_dmamap_load_ccb(pAdapter->io_dma_parent,
+ pmap->dma_map,
+ ccb,
+ hpt_io_dmamap_callback,
+ pCmd, BUS_DMA_WAITOK
+ );
+ KdPrint(("bus_dmamap_load return %d\n", error));
+ if (error && error!=EINPROGRESS) {
+ hpt_printk(("bus_dmamap_load error %d\n", error));
+ FreeCommand(_VBUS_P pCmd);
+ ccb->ccb_h.status = CAM_REQ_CMP_ERR;
+ dmamap_put(pmap);
+ pAdapter->outstandingCommands--;
+ xpt_done(ccb);
}
goto Command_Complished;
}
diff --git a/sys/dev/hptrr/hptrr_osm_bsd.c b/sys/dev/hptrr/hptrr_osm_bsd.c
index cff4254..3c31f8c 100644
--- a/sys/dev/hptrr/hptrr_osm_bsd.c
+++ b/sys/dev/hptrr/hptrr_osm_bsd.c
@@ -481,32 +481,6 @@ static void os_cmddone(PCOMMAND pCmd)
static int os_buildsgl(PCOMMAND pCmd, PSG pSg, int logical)
{
- POS_CMDEXT ext = (POS_CMDEXT)pCmd->priv;
- union ccb *ccb = ext->ccb;
- bus_dma_segment_t *sgList = (bus_dma_segment_t *)ccb->csio.data_ptr;
- int idx;
-
- if(logical) {
- if (ccb->ccb_h.flags & CAM_DATA_PHYS)
- panic("physical address unsupported");
-
- if (ccb->ccb_h.flags & CAM_SCATTER_VALID) {
- if (ccb->ccb_h.flags & CAM_SG_LIST_PHYS)
- panic("physical address unsupported");
-
- for (idx = 0; idx < ccb->csio.sglist_cnt; idx++) {
- os_set_sgptr(&pSg[idx], (HPT_U8 *)(HPT_UPTR)sgList[idx].ds_addr);
- pSg[idx].size = sgList[idx].ds_len;
- pSg[idx].eot = (idx==ccb->csio.sglist_cnt-1)? 1 : 0;
- }
- }
- else {
- os_set_sgptr(pSg, (HPT_U8 *)ccb->csio.data_ptr);
- pSg->size = ccb->csio.dxfer_len;
- pSg->eot = 1;
- }
- return TRUE;
- }
/* since we have provided physical sg, nobody will ask us to build physical sg */
HPT_ASSERT(0);
@@ -522,25 +496,28 @@ static void hpt_io_dmamap_callback(void *arg, bus_dma_segment_t *segs, int nsegs
HPT_ASSERT(pCmd->flags.physical_sg);
- if (error || nsegs == 0)
+ if (error)
panic("busdma error");
HPT_ASSERT(nsegs<=os_max_sg_descriptors);
- for (idx = 0; idx < nsegs; idx++, psg++) {
- psg->addr.bus = segs[idx].ds_addr;
- psg->size = segs[idx].ds_len;
- psg->eot = 0;
- }
- psg[-1].eot = 1;
-
- if (pCmd->flags.data_in) {
- bus_dmamap_sync(ext->vbus_ext->io_dmat, ext->dma_map, BUS_DMASYNC_PREREAD);
- }
- else if (pCmd->flags.data_out) {
- bus_dmamap_sync(ext->vbus_ext->io_dmat, ext->dma_map, BUS_DMASYNC_PREWRITE);
+ if (nsegs != 0) {
+ for (idx = 0; idx < nsegs; idx++, psg++) {
+ psg->addr.bus = segs[idx].ds_addr;
+ psg->size = segs[idx].ds_len;
+ psg->eot = 0;
+ }
+ psg[-1].eot = 1;
+
+ if (pCmd->flags.data_in) {
+ bus_dmamap_sync(ext->vbus_ext->io_dmat, ext->dma_map,
+ BUS_DMASYNC_PREREAD);
+ }
+ else if (pCmd->flags.data_out) {
+ bus_dmamap_sync(ext->vbus_ext->io_dmat, ext->dma_map,
+ BUS_DMASYNC_PREWRITE);
+ }
}
-
ext->ccb->ccb_h.timeout_ch = timeout(hpt_timeout, pCmd, HPT_OSM_TIMEOUT);
ldm_queue_cmd(pCmd);
}
@@ -667,6 +644,8 @@ static void hpt_scsi_io(PVBUS_EXT vbus_ext, union ccb *ccb)
case 0x13:
case 0x2f:
{
+ int error;
+
pCmd = ldm_alloc_cmds(vbus, vd->cmds_per_request);
if(!pCmd){
KdPrint(("Failed to allocate command!"));
@@ -722,42 +701,21 @@ static void hpt_scsi_io(PVBUS_EXT vbus_ext, union ccb *ccb)
pCmd->target = vd;
pCmd->done = os_cmddone;
pCmd->buildsgl = os_buildsgl;
-
pCmd->psg = ext->psg;
-
- if (ccb->ccb_h.flags & CAM_SCATTER_VALID) {
- int idx;
- bus_dma_segment_t *sgList = (bus_dma_segment_t *)ccb->csio.data_ptr;
-
- if (ccb->ccb_h.flags & CAM_SG_LIST_PHYS)
- pCmd->flags.physical_sg = 1;
-
- for (idx = 0; idx < ccb->csio.sglist_cnt; idx++) {
- pCmd->psg[idx].addr.bus = sgList[idx].ds_addr;
- pCmd->psg[idx].size = sgList[idx].ds_len;
- pCmd->psg[idx].eot = (idx==ccb->csio.sglist_cnt-1)? 1 : 0;
- }
-
- ccb->ccb_h.timeout_ch = timeout(hpt_timeout, pCmd, HPT_OSM_TIMEOUT);
- ldm_queue_cmd(pCmd);
- }
- else {
- int error;
- pCmd->flags.physical_sg = 1;
- error = bus_dmamap_load(vbus_ext->io_dmat,
- ext->dma_map,
- ccb->csio.data_ptr, ccb->csio.dxfer_len,
- hpt_io_dmamap_callback, pCmd,
- BUS_DMA_WAITOK
+ pCmd->flags.physical_sg = 1;
+ error = bus_dmamap_load_ccb(vbus_ext->io_dmat,
+ ext->dma_map,
+ ccb,
+ hpt_io_dmamap_callback, pCmd,
+ BUS_DMA_WAITOK
);
- KdPrint(("bus_dmamap_load return %d", error));
- if (error && error!=EINPROGRESS) {
- os_printk("bus_dmamap_load error %d", error);
- cmdext_put(ext);
- ldm_free_cmds(pCmd);
- ccb->ccb_h.status = CAM_REQ_CMP_ERR;
- xpt_done(ccb);
- }
+ KdPrint(("bus_dmamap_load return %d", error));
+ if (error && error!=EINPROGRESS) {
+ os_printk("bus_dmamap_load error %d", error);
+ cmdext_put(ext);
+ ldm_free_cmds(pCmd);
+ ccb->ccb_h.status = CAM_REQ_CMP_ERR;
+ xpt_done(ccb);
}
return;
}
diff --git a/sys/dev/iir/iir.c b/sys/dev/iir/iir.c
index 057194a..4c907f0 100644
--- a/sys/dev/iir/iir.c
+++ b/sys/dev/iir/iir.c
@@ -794,6 +794,7 @@ gdt_raw_cmd(struct gdt_softc *gdt, union ccb *ccb, int *lock)
{
struct gdt_ccb *gccb;
struct cam_sim *sim;
+ int error;
GDT_DPRINTF(GDT_D_CMD, ("gdt_raw_cmd(%p, %p)\n", gdt, ccb));
@@ -844,51 +845,14 @@ gdt_raw_cmd(struct gdt_softc *gdt, union ccb *ccb, int *lock)
gdt_enc32(gccb->gc_cmd + GDT_CMD_UNION + GDT_RAW_SENSE_DATA,
gccb->gc_scratch_busbase);
- /*
- * If we have any data to send with this command,
- * map it into bus space.
- */
- /* Only use S/G if there is a transfer */
- if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- if ((ccb->ccb_h.flags & CAM_SCATTER_VALID) == 0) {
- if ((ccb->ccb_h.flags & CAM_DATA_PHYS) == 0) {
- int s;
- int error;
-
- /* vorher unlock von splcam() ??? */
- s = splsoftvm();
- error =
- bus_dmamap_load(gdt->sc_buffer_dmat,
- gccb->gc_dmamap,
- ccb->csio.data_ptr,
- ccb->csio.dxfer_len,
- gdtexecuteccb,
- gccb, /*flags*/0);
- if (error == EINPROGRESS) {
- xpt_freeze_simq(sim, 1);
- gccb->gc_ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
- }
- splx(s);
- } else {
- panic("iir: CAM_DATA_PHYS not supported");
- }
- } else {
- struct bus_dma_segment *segs;
-
- if ((ccb->ccb_h.flags & CAM_DATA_PHYS) != 0)
- panic("iir%d: iir_action - Physical "
- "segment pointers unsupported", gdt->sc_hanum);
-
- if ((ccb->ccb_h.flags & CAM_SG_LIST_PHYS)==0)
- panic("iir%d: iir_action - Virtual "
- "segment addresses unsupported", gdt->sc_hanum);
-
- /* Just use the segments provided */
- segs = (struct bus_dma_segment *)ccb->csio.data_ptr;
- gdtexecuteccb(gccb, segs, ccb->csio.sglist_cnt, 0);
- }
- } else {
- gdtexecuteccb(gccb, NULL, 0, 0);
+ error = bus_dmamap_load_ccb(gdt->sc_buffer_dmat,
+ gccb->gc_dmamap,
+ ccb,
+ gdtexecuteccb,
+ gccb, /*flags*/0);
+ if (error == EINPROGRESS) {
+ xpt_freeze_simq(sim, 1);
+ gccb->gc_ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
}
*lock = splcam();
@@ -903,6 +867,7 @@ gdt_cache_cmd(struct gdt_softc *gdt, union ccb *ccb, int *lock)
u_int8_t *cmdp;
u_int16_t opcode;
u_int32_t blockno, blockcnt;
+ int error;
GDT_DPRINTF(GDT_D_CMD, ("gdt_cache_cmd(%p, %p)\n", gdt, ccb));
@@ -953,49 +918,15 @@ gdt_cache_cmd(struct gdt_softc *gdt, union ccb *ccb, int *lock)
gdt_enc32(gccb->gc_cmd + GDT_CMD_UNION + GDT_CACHE_BLOCKCNT,
blockcnt);
- /*
- * If we have any data to send with this command,
- * map it into bus space.
- */
- /* Only use S/G if there is a transfer */
- if ((ccb->ccb_h.flags & CAM_SCATTER_VALID) == 0) {
- if ((ccb->ccb_h.flags & CAM_DATA_PHYS) == 0) {
- int s;
- int error;
-
- /* vorher unlock von splcam() ??? */
- s = splsoftvm();
- error =
- bus_dmamap_load(gdt->sc_buffer_dmat,
+ error = bus_dmamap_load_ccb(gdt->sc_buffer_dmat,
gccb->gc_dmamap,
- ccb->csio.data_ptr,
- ccb->csio.dxfer_len,
+ ccb,
gdtexecuteccb,
gccb, /*flags*/0);
- if (error == EINPROGRESS) {
- xpt_freeze_simq(sim, 1);
- gccb->gc_ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
- }
- splx(s);
- } else {
- panic("iir: CAM_DATA_PHYS not supported");
- }
- } else {
- struct bus_dma_segment *segs;
-
- if ((ccb->ccb_h.flags & CAM_DATA_PHYS) != 0)
- panic("iir%d: iir_action - Physical "
- "segment pointers unsupported", gdt->sc_hanum);
-
- if ((ccb->ccb_h.flags & CAM_SG_LIST_PHYS)==0)
- panic("iir%d: iir_action - Virtual "
- "segment addresses unsupported", gdt->sc_hanum);
-
- /* Just use the segments provided */
- segs = (struct bus_dma_segment *)ccb->csio.data_ptr;
- gdtexecuteccb(gccb, segs, ccb->csio.sglist_cnt, 0);
+ if (error == EINPROGRESS) {
+ xpt_freeze_simq(sim, 1);
+ gccb->gc_ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
}
-
*lock = splcam();
return (gccb);
}
diff --git a/sys/dev/isci/isci_io_request.c b/sys/dev/isci/isci_io_request.c
index 719034e..9778ed0 100644
--- a/sys/dev/isci/isci_io_request.c
+++ b/sys/dev/isci/isci_io_request.c
@@ -713,7 +713,6 @@ void
isci_io_request_execute_scsi_io(union ccb *ccb,
struct ISCI_CONTROLLER *controller)
{
- struct ccb_scsiio *csio = &ccb->csio;
target_id_t target_id = ccb->ccb_h.target_id;
struct ISCI_REQUEST *request;
struct ISCI_IO_REQUEST *io_request;
@@ -748,29 +747,21 @@ isci_io_request_execute_scsi_io(union ccb *ccb,
io_request->current_sge_index = 0;
io_request->parent.remote_device_handle = device->sci_object;
- if ((ccb->ccb_h.flags & CAM_SCATTER_VALID) != 0)
- panic("Unexpected CAM_SCATTER_VALID flag! flags = 0x%x\n",
+ if ((ccb->ccb_h.flags & CAM_DATA_MASK) != CAM_DATA_VADDR)
+ panic("Unexpected cam data format! flags = 0x%x\n",
ccb->ccb_h.flags);
- if ((ccb->ccb_h.flags & CAM_DATA_PHYS) != 0)
- panic("Unexpected CAM_DATA_PHYS flag! flags = 0x%x\n",
- ccb->ccb_h.flags);
-
- if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- error = bus_dmamap_load(io_request->parent.dma_tag,
- io_request->parent.dma_map, csio->data_ptr, csio->dxfer_len,
- isci_io_request_construct, io_request, 0x0);
-
- /* A resource shortage from BUSDMA will be automatically
- * continued at a later point, pushing the CCB processing
- * forward, which will in turn unfreeze the simq.
- */
- if (error == EINPROGRESS) {
- xpt_freeze_simq(controller->sim, 1);
- ccb->ccb_h.flags |= CAM_RELEASE_SIMQ;
- }
- } else
- isci_io_request_construct(io_request, NULL, 0, 0);
+ error = bus_dmamap_load_ccb(io_request->parent.dma_tag,
+ io_request->parent.dma_map, ccb,
+ isci_io_request_construct, io_request, 0x0);
+ /* A resource shortage from BUSDMA will be automatically
+ * continued at a later point, pushing the CCB processing
+ * forward, which will in turn unfreeze the simq.
+ */
+ if (error == EINPROGRESS) {
+ xpt_freeze_simq(controller->sim, 1);
+ ccb->ccb_h.flags |= CAM_RELEASE_SIMQ;
+ }
}
void
diff --git a/sys/dev/isp/isp_pci.c b/sys/dev/isp/isp_pci.c
index e0260d4..795f432 100644
--- a/sys/dev/isp/isp_pci.c
+++ b/sys/dev/isp/isp_pci.c
@@ -1922,6 +1922,7 @@ isp_pci_dmasetup(ispsoftc_t *isp, struct ccb_scsiio *csio, void *ff)
mush_t mush, *mp;
void (*eptr)(void *, bus_dma_segment_t *, int, int);
void (*eptr2)(void *, bus_dma_segment_t *, int, bus_size_t, int);
+ int error;
mp = &mush;
mp->isp = isp;
@@ -1942,70 +1943,17 @@ isp_pci_dmasetup(ispsoftc_t *isp, struct ccb_scsiio *csio, void *ff)
}
- if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE || (csio->dxfer_len == 0)) {
- (*eptr)(mp, NULL, 0, 0);
- } else if ((csio->ccb_h.flags & CAM_SCATTER_VALID) == 0) {
- if ((csio->ccb_h.flags & CAM_DATA_PHYS) == 0) {
- int error;
- error = bus_dmamap_load(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, csio->data_ptr, csio->dxfer_len, eptr, mp, 0);
-#if 0
- xpt_print(csio->ccb_h.path, "%s: bus_dmamap_load " "ptr %p len %d returned %d\n", __func__, csio->data_ptr, csio->dxfer_len, error);
-#endif
-
- if (error == EINPROGRESS) {
- bus_dmamap_unload(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap);
- mp->error = EINVAL;
- isp_prt(isp, ISP_LOGERR, "deferred dma allocation not supported");
- } else if (error && mp->error == 0) {
+ error = bus_dmamap_load_ccb(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap,
+ (union ccb *)csio, eptr, mp, 0);
+ if (error == EINPROGRESS) {
+ bus_dmamap_unload(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap);
+ mp->error = EINVAL;
+ isp_prt(isp, ISP_LOGERR, "deferred dma allocation not supported");
+ } else if (error && mp->error == 0) {
#ifdef DIAGNOSTIC
- isp_prt(isp, ISP_LOGERR, "error %d in dma mapping code", error);
+ isp_prt(isp, ISP_LOGERR, "error %d in dma mapping code", error);
#endif
- mp->error = error;
- }
- } else {
- /* Pointer to 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;
- (*eptr)(mp, &seg, 1, 0);
- }
- } else {
- struct bus_dma_segment *segs;
-
- if ((csio->ccb_h.flags & CAM_DATA_PHYS) != 0) {
- isp_prt(isp, ISP_LOGERR, "Physical segment pointers unsupported");
- mp->error = EINVAL;
- } else if ((csio->ccb_h.flags & CAM_SG_LIST_PHYS) == 0) {
- struct uio sguio;
- int error;
-
- /*
- * We're taking advantage of the fact that
- * the pointer/length sizes and layout of the iovec
- * structure are the same as the bus_dma_segment
- * structure. This might be a little dangerous,
- * but only if they change the structures, which
- * seems unlikely.
- */
- KASSERT((sizeof (sguio.uio_iov) == sizeof (csio->data_ptr) &&
- sizeof (sguio.uio_iovcnt) >= sizeof (csio->sglist_cnt) &&
- sizeof (sguio.uio_resid) >= sizeof (csio->dxfer_len)), ("Ken's assumption failed"));
- sguio.uio_iov = (struct iovec *)csio->data_ptr;
- sguio.uio_iovcnt = csio->sglist_cnt;
- sguio.uio_resid = csio->dxfer_len;
- sguio.uio_segflg = UIO_SYSSPACE;
-
- error = bus_dmamap_load_uio(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, &sguio, eptr2, mp, 0);
-
- if (error != 0 && mp->error == 0) {
- isp_prt(isp, ISP_LOGERR, "error %d in dma mapping code", error);
- mp->error = error;
- }
- } else {
- /* Just use the segments provided */
- segs = (struct bus_dma_segment *) csio->data_ptr;
- (*eptr)(mp, segs, csio->sglist_cnt, 0);
- }
+ mp->error = error;
}
if (mp->error) {
int retval = CMD_COMPLETE;
diff --git a/sys/dev/isp/isp_sbus.c b/sys/dev/isp/isp_sbus.c
index 0b4f63f..9afcc8e 100644
--- a/sys/dev/isp/isp_sbus.c
+++ b/sys/dev/isp/isp_sbus.c
@@ -635,6 +635,7 @@ isp_sbus_dmasetup(ispsoftc_t *isp, struct ccb_scsiio *csio, void *ff)
{
mush_t mush, *mp;
void (*eptr)(void *, bus_dma_segment_t *, int, int);
+ int error;
mp = &mush;
mp->isp = isp;
@@ -645,47 +646,18 @@ isp_sbus_dmasetup(ispsoftc_t *isp, struct ccb_scsiio *csio, void *ff)
eptr = dma2;
- if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE || (csio->dxfer_len == 0)) {
- (*eptr)(mp, NULL, 0, 0);
- } else if ((csio->ccb_h.flags & CAM_SCATTER_VALID) == 0) {
- if ((csio->ccb_h.flags & CAM_DATA_PHYS) == 0) {
- int error;
- error = bus_dmamap_load(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, csio->data_ptr, csio->dxfer_len, eptr, mp, 0);
-#if 0
- xpt_print(csio->ccb_h.path, "%s: bus_dmamap_load " "ptr %p len %d returned %d\n", __func__, csio->data_ptr, csio->dxfer_len, error);
-#endif
-
- if (error == EINPROGRESS) {
- bus_dmamap_unload(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap);
- mp->error = EINVAL;
- isp_prt(isp, ISP_LOGERR, "deferred dma allocation not supported");
- } else if (error && mp->error == 0) {
+ error = bus_dmamap_load_ccb(isp->isp_osinfo.dmat,
+ PISP_PCMD(csio)->dmap, (union ccb *)csio, eptr, mp, 0);
+ if (error == EINPROGRESS) {
+ bus_dmamap_unload(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap);
+ mp->error = EINVAL;
+ isp_prt(isp, ISP_LOGERR,
+ "deferred dma allocation not supported");
+ } else if (error && mp->error == 0) {
#ifdef DIAGNOSTIC
- isp_prt(isp, ISP_LOGERR, "error %d in dma mapping code", error);
+ isp_prt(isp, ISP_LOGERR, "error %d in dma mapping code", error);
#endif
- mp->error = error;
- }
- } else {
- /* Pointer to 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;
- (*eptr)(mp, &seg, 1, 0);
- }
- } else {
- struct bus_dma_segment *segs;
-
- if ((csio->ccb_h.flags & CAM_DATA_PHYS) != 0) {
- isp_prt(isp, ISP_LOGERR, "Physical segment pointers unsupported");
- mp->error = EINVAL;
- } else if ((csio->ccb_h.flags & CAM_SG_LIST_PHYS) == 0) {
- isp_prt(isp, ISP_LOGERR, "Physical SG/LIST Phys segment pointers unsupported");
- mp->error = EINVAL;
- } else {
- /* Just use the segments provided */
- segs = (struct bus_dma_segment *) csio->data_ptr;
- (*eptr)(mp, segs, csio->sglist_cnt, 0);
- }
+ mp->error = error;
}
if (mp->error) {
int retval = CMD_COMPLETE;
diff --git a/sys/dev/mfi/mfi.c b/sys/dev/mfi/mfi.c
index 7cb19d2..ed759fc 100644
--- a/sys/dev/mfi/mfi.c
+++ b/sys/dev/mfi/mfi.c
@@ -2267,8 +2267,14 @@ mfi_mapcmd(struct mfi_softc *sc, struct mfi_command *cm)
if ((cm->cm_data != NULL) && (cm->cm_frame->header.cmd != MFI_CMD_STP )) {
polled = (cm->cm_flags & MFI_CMD_POLLED) ? BUS_DMA_NOWAIT : 0;
- error = bus_dmamap_load(sc->mfi_buffer_dmat, cm->cm_dmamap,
- cm->cm_data, cm->cm_len, mfi_data_cb, cm, polled);
+ if (cm->cm_flags & MFI_CMD_CCB)
+ error = bus_dmamap_load_ccb(sc->mfi_buffer_dmat,
+ cm->cm_dmamap, cm->cm_data, mfi_data_cb, cm,
+ polled);
+ else
+ error = bus_dmamap_load(sc->mfi_buffer_dmat,
+ cm->cm_dmamap, cm->cm_data, cm->cm_len,
+ mfi_data_cb, cm, polled);
if (error == EINPROGRESS) {
sc->mfi_flags |= MFI_FLAGS_QFRZN;
return (0);
diff --git a/sys/dev/mfi/mfi_cam.c b/sys/dev/mfi/mfi_cam.c
index 2bbfafe..325b064 100644
--- a/sys/dev/mfi/mfi_cam.c
+++ b/sys/dev/mfi/mfi_cam.c
@@ -265,17 +265,6 @@ mfip_cam_action(struct cam_sim *sim, union ccb *ccb)
ccbh->status = CAM_REQ_INVALID;
break;
}
- if ((ccbh->flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- if (ccbh->flags & CAM_DATA_PHYS) {
- ccbh->status = CAM_REQ_INVALID;
- break;
- }
- if (ccbh->flags & CAM_SCATTER_VALID) {
- ccbh->status = CAM_REQ_INVALID;
- break;
- }
- }
-
ccbh->ccb_mfip_ptr = sc;
TAILQ_INSERT_TAIL(&mfisc->mfi_cam_ccbq, ccbh, sim_links.tqe);
mfi_startio(mfisc);
@@ -380,14 +369,14 @@ mfip_start(void *data)
cm->cm_private = ccb;
cm->cm_sg = &pt->sgl;
cm->cm_total_frame_size = MFI_PASS_FRAME_SIZE;
- cm->cm_data = csio->data_ptr;
+ cm->cm_data = ccb;
cm->cm_len = csio->dxfer_len;
switch (ccbh->flags & CAM_DIR_MASK) {
case CAM_DIR_IN:
- cm->cm_flags = MFI_CMD_DATAIN;
+ cm->cm_flags = MFI_CMD_DATAIN | MFI_CMD_CCB;
break;
case CAM_DIR_OUT:
- cm->cm_flags = MFI_CMD_DATAOUT;
+ cm->cm_flags = MFI_CMD_DATAOUT | MFI_CMD_CCB;
break;
case CAM_DIR_NONE:
default:
diff --git a/sys/dev/mfi/mfivar.h b/sys/dev/mfi/mfivar.h
index 435ca8d..bb2a324 100644
--- a/sys/dev/mfi/mfivar.h
+++ b/sys/dev/mfi/mfivar.h
@@ -107,6 +107,7 @@ struct mfi_command {
#define MFI_ON_MFIQ_BUSY (1<<7)
#define MFI_ON_MFIQ_MASK ((1<<5)|(1<<6)|(1<<7))
#define MFI_CMD_SCSI (1<<8)
+#define MFI_CMD_CCB (1<<9)
uint8_t retry_for_fw_reset;
void (* cm_complete)(struct mfi_command *cm);
void *cm_private;
diff --git a/sys/dev/mly/mly.c b/sys/dev/mly/mly.c
index 1f0a9e2..9155d60 100644
--- a/sys/dev/mly/mly.c
+++ b/sys/dev/mly/mly.c
@@ -1864,9 +1864,13 @@ mly_map_command(struct mly_command *mc)
/* does the command have a data buffer? */
if (mc->mc_data != NULL) {
- bus_dmamap_load(sc->mly_buffer_dmat, mc->mc_datamap, mc->mc_data, mc->mc_length,
- mly_map_command_sg, mc, 0);
-
+ if (mc->mc_flags & MLY_CMD_CCB)
+ bus_dmamap_load_ccb(sc->mly_buffer_dmat, mc->mc_datamap,
+ mc->mc_data, mly_map_command_sg, mc, 0);
+ else
+ bus_dmamap_load(sc->mly_buffer_dmat, mc->mc_datamap,
+ mc->mc_data, mc->mc_length,
+ mly_map_command_sg, mc, 0);
if (mc->mc_flags & MLY_CMD_DATAIN)
bus_dmamap_sync(sc->mly_buffer_dmat, mc->mc_datamap, BUS_DMASYNC_PREREAD);
if (mc->mc_flags & MLY_CMD_DATAOUT)
@@ -2220,18 +2224,6 @@ mly_cam_action_io(struct cam_sim *sim, struct ccb_scsiio *csio)
csio->ccb_h.status = CAM_REQ_CMP_ERR;
}
- /* if there is data transfer, it must be to/from a virtual address */
- if ((csio->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- if (csio->ccb_h.flags & CAM_DATA_PHYS) { /* we can't map it */
- debug(0, " data pointer is to physical address");
- csio->ccb_h.status = CAM_REQ_CMP_ERR;
- }
- if (csio->ccb_h.flags & CAM_SCATTER_VALID) { /* we want to do the s/g setup */
- debug(0, " data has premature s/g setup");
- csio->ccb_h.status = CAM_REQ_CMP_ERR;
- }
- }
-
/* abandon aborted ccbs or those that have failed validation */
if ((csio->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_INPROG) {
debug(2, "abandoning CCB due to abort/validation failure");
@@ -2251,10 +2243,12 @@ mly_cam_action_io(struct cam_sim *sim, struct ccb_scsiio *csio)
}
/* build the command */
- mc->mc_data = csio->data_ptr;
+ mc->mc_data = csio;
mc->mc_length = csio->dxfer_len;
mc->mc_complete = mly_cam_complete;
mc->mc_private = csio;
+ mc->mc_flags |= MLY_CMD_CCB;
+ /* XXX This code doesn't set the data direction in mc_flags. */
/* save the bus number in the ccb for later recovery XXX should be a better way */
csio->ccb_h.sim_priv.entries[0].field = bus;
diff --git a/sys/dev/mly/mlyvar.h b/sys/dev/mly/mlyvar.h
index 62e674c..7413fa4 100644
--- a/sys/dev/mly/mlyvar.h
+++ b/sys/dev/mly/mlyvar.h
@@ -126,6 +126,7 @@ struct mly_command {
#define MLY_CMD_MAPPED (1<<3) /* command has had its data mapped */
#define MLY_CMD_DATAIN (1<<4) /* data moves controller->system */
#define MLY_CMD_DATAOUT (1<<5) /* data moves system->controller */
+#define MLY_CMD_CCB (1<<6) /* data is ccb. */
u_int16_t mc_status; /* command completion status */
u_int8_t mc_sense; /* sense data length */
int32_t mc_resid; /* I/O residual count */
diff --git a/sys/dev/mps/mps.c b/sys/dev/mps/mps.c
index ce94a06..7a3e4f7 100644
--- a/sys/dev/mps/mps.c
+++ b/sys/dev/mps/mps.c
@@ -2278,6 +2278,9 @@ mps_map_command(struct mps_softc *sc, struct mps_command *cm)
if (cm->cm_flags & MPS_CM_FLAGS_USE_UIO) {
error = bus_dmamap_load_uio(sc->buffer_dmat, cm->cm_dmamap,
&cm->cm_uio, mps_data_cb2, cm, 0);
+ } else if (cm->cm_flags & MPS_CM_FLAGS_USE_CCB) {
+ error = bus_dmamap_load_ccb(sc->buffer_dmat, cm->cm_dmamap,
+ cm->cm_data, mps_data_cb, cm, 0);
} else if ((cm->cm_data != NULL) && (cm->cm_length != 0)) {
error = bus_dmamap_load(sc->buffer_dmat, cm->cm_dmamap,
cm->cm_data, cm->cm_length, mps_data_cb, cm, 0);
diff --git a/sys/dev/mps/mps_sas.c b/sys/dev/mps/mps_sas.c
index a76a0aa..0d8342e 100644
--- a/sys/dev/mps/mps_sas.c
+++ b/sys/dev/mps/mps_sas.c
@@ -1755,8 +1755,13 @@ mpssas_action_scsiio(struct mpssas_softc *sassc, union ccb *ccb)
}
}
- cm->cm_data = csio->data_ptr;
cm->cm_length = csio->dxfer_len;
+ if (cm->cm_length != 0) {
+ cm->cm_data = ccb;
+ cm->cm_flags |= MPS_CM_FLAGS_USE_CCB;
+ } else {
+ cm->cm_data = NULL;
+ }
cm->cm_sge = &req->SGL;
cm->cm_sglsize = (32 - 24) * 4;
cm->cm_desc.SCSIIO.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO;
@@ -2691,19 +2696,15 @@ mpssas_send_smpcmd(struct mpssas_softc *sassc, union ccb *ccb, uint64_t sasaddr)
/*
* XXX We don't yet support physical addresses here.
*/
- if (ccb->ccb_h.flags & (CAM_DATA_PHYS|CAM_SG_LIST_PHYS)) {
+ switch ((ccb->ccb_h.flags & CAM_DATA_MASK)) {
+ case CAM_DATA_PADDR:
+ case CAM_DATA_SG_PADDR:
mps_printf(sc, "%s: physical addresses not supported\n",
__func__);
ccb->ccb_h.status = CAM_REQ_INVALID;
xpt_done(ccb);
return;
- }
-
- /*
- * If the user wants to send an S/G list, check to make sure they
- * have single buffers.
- */
- if (ccb->ccb_h.flags & CAM_SCATTER_VALID) {
+ case CAM_DATA_SG:
/*
* The chip does not support more than one buffer for the
* request or response.
@@ -2741,9 +2742,15 @@ mpssas_send_smpcmd(struct mpssas_softc *sassc, union ccb *ccb, uint64_t sasaddr)
response = (uint8_t *)(uintptr_t)rsp_sg[0].ds_addr;
} else
response = ccb->smpio.smp_response;
- } else {
+ break;
+ case CAM_DATA_VADDR:
request = ccb->smpio.smp_request;
response = ccb->smpio.smp_response;
+ break;
+ default:
+ ccb->ccb_h.status = CAM_REQ_INVALID;
+ xpt_done(ccb);
+ return;
}
cm = mps_alloc_command(sc);
diff --git a/sys/dev/mps/mpsvar.h b/sys/dev/mps/mpsvar.h
index ac0f0da..5d14b5f 100644
--- a/sys/dev/mps/mpsvar.h
+++ b/sys/dev/mps/mpsvar.h
@@ -231,6 +231,7 @@ struct mps_command {
#define MPS_CM_FLAGS_SMP_PASS (1 << 8)
#define MPS_CM_FLAGS_CHAIN_FAILED (1 << 9)
#define MPS_CM_FLAGS_ERROR_MASK MPS_CM_FLAGS_CHAIN_FAILED
+#define MPS_CM_FLAGS_USE_CCB (1 << 10)
u_int cm_state;
#define MPS_CM_STATE_FREE 0
#define MPS_CM_STATE_BUSY 1
diff --git a/sys/dev/mpt/mpt_cam.c b/sys/dev/mpt/mpt_cam.c
index d435f77..119dd50 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];
diff --git a/sys/dev/mvs/mvs.c b/sys/dev/mvs/mvs.c
index 21c9f97..91ca4f0 100644
--- a/sys/dev/mvs/mvs.c
+++ b/sys/dev/mvs/mvs.c
@@ -1260,19 +1260,9 @@ mvs_begin_transaction(device_t dev, union ccb *ccb)
mvs_set_edma_mode(dev, MVS_EDMA_OFF);
}
if (ch->numpslots == 0 || ch->basic_dma) {
- void *buf;
- bus_size_t size;
-
slot->state = MVS_SLOT_LOADING;
- if (ccb->ccb_h.func_code == XPT_ATA_IO) {
- buf = ccb->ataio.data_ptr;
- size = ccb->ataio.dxfer_len;
- } else {
- buf = ccb->csio.data_ptr;
- size = ccb->csio.dxfer_len;
- }
- bus_dmamap_load(ch->dma.data_tag, slot->dma.data_map,
- buf, size, mvs_dmasetprd, slot, 0);
+ bus_dmamap_load_ccb(ch->dma.data_tag, slot->dma.data_map,
+ ccb, mvs_dmasetprd, slot, 0);
} else
mvs_legacy_execute_transaction(slot);
}
diff --git a/sys/dev/siis/siis.c b/sys/dev/siis/siis.c
index a8a1ed2..fb88664 100644
--- a/sys/dev/siis/siis.c
+++ b/sys/dev/siis/siis.c
@@ -996,19 +996,9 @@ siis_begin_transaction(device_t dev, union ccb *ccb)
slot->dma.nsegs = 0;
/* If request moves data, setup and load SG list */
if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- void *buf;
- bus_size_t size;
-
slot->state = SIIS_SLOT_LOADING;
- if (ccb->ccb_h.func_code == XPT_ATA_IO) {
- buf = ccb->ataio.data_ptr;
- size = ccb->ataio.dxfer_len;
- } else {
- buf = ccb->csio.data_ptr;
- size = ccb->csio.dxfer_len;
- }
- bus_dmamap_load(ch->dma.data_tag, slot->dma.data_map,
- buf, size, siis_dmasetprd, slot, 0);
+ bus_dmamap_load_ccb(ch->dma.data_tag, slot->dma.data_map,
+ ccb, siis_dmasetprd, slot, 0);
} else
siis_execute_transaction(slot);
}
@@ -1032,24 +1022,26 @@ siis_dmasetprd(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
return;
}
KASSERT(nsegs <= SIIS_SG_ENTRIES, ("too many DMA segment entries\n"));
- /* Get a piece of the workspace for this request */
- ctp = (struct siis_cmd *)
- (ch->dma.work + SIIS_CT_OFFSET + (SIIS_CT_SIZE * slot->slot));
- /* Fill S/G table */
- if (slot->ccb->ccb_h.func_code == XPT_ATA_IO)
- prd = &ctp->u.ata.prd[0];
- else
- prd = &ctp->u.atapi.prd[0];
- for (i = 0; i < nsegs; i++) {
- prd[i].dba = htole64(segs[i].ds_addr);
- prd[i].dbc = htole32(segs[i].ds_len);
- prd[i].control = 0;
- }
- prd[nsegs - 1].control = htole32(SIIS_PRD_TRM);
slot->dma.nsegs = nsegs;
- bus_dmamap_sync(ch->dma.data_tag, slot->dma.data_map,
- ((slot->ccb->ccb_h.flags & CAM_DIR_IN) ?
- BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE));
+ if (nsegs != 0) {
+ /* Get a piece of the workspace for this request */
+ ctp = (struct siis_cmd *)(ch->dma.work + SIIS_CT_OFFSET +
+ (SIIS_CT_SIZE * slot->slot));
+ /* Fill S/G table */
+ if (slot->ccb->ccb_h.func_code == XPT_ATA_IO)
+ prd = &ctp->u.ata.prd[0];
+ else
+ prd = &ctp->u.atapi.prd[0];
+ for (i = 0; i < nsegs; i++) {
+ prd[i].dba = htole64(segs[i].ds_addr);
+ prd[i].dbc = htole32(segs[i].ds_len);
+ prd[i].control = 0;
+ }
+ prd[nsegs - 1].control = htole32(SIIS_PRD_TRM);
+ bus_dmamap_sync(ch->dma.data_tag, slot->dma.data_map,
+ ((slot->ccb->ccb_h.flags & CAM_DIR_IN) ?
+ BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE));
+ }
siis_execute_transaction(slot);
}
diff --git a/sys/dev/sym/sym_hipd.c b/sys/dev/sym/sym_hipd.c
index 7d0450c..68ad77f 100644
--- a/sys/dev/sym/sym_hipd.c
+++ b/sys/dev/sym/sym_hipd.c
@@ -7877,51 +7877,15 @@ sym_setup_data_and_start(hcb_p np, struct ccb_scsiio *csio, ccb_p cp)
return;
}
- if (!(ccb_h->flags & CAM_SCATTER_VALID)) {
- /* Single buffer */
- if (!(ccb_h->flags & CAM_DATA_PHYS)) {
- /* Buffer is virtual */
- cp->dmamapped = (dir == CAM_DIR_IN) ?
- SYM_DMA_READ : SYM_DMA_WRITE;
- retv = bus_dmamap_load(np->data_dmat, cp->dmamap,
- csio->data_ptr, csio->dxfer_len,
- sym_execute_ccb, cp, 0);
- if (retv == EINPROGRESS) {
- cp->host_status = HS_WAIT;
- xpt_freeze_simq(np->sim, 1);
- csio->ccb_h.status |= CAM_RELEASE_SIMQ;
- }
- } else {
- /* Buffer is physical */
- struct bus_dma_segment seg;
-
- seg.ds_addr = (bus_addr_t) csio->data_ptr;
- sym_execute_ccb(cp, &seg, 1, 0);
- }
- } else {
- /* Scatter/gather list */
- struct bus_dma_segment *segs;
-
- if ((ccb_h->flags & CAM_SG_LIST_PHYS) != 0) {
- /* The SG list pointer is physical */
- sym_set_cam_status(cp->cam_ccb, CAM_REQ_INVALID);
- goto out_abort;
- }
-
- if (!(ccb_h->flags & CAM_DATA_PHYS)) {
- /* SG buffer pointers are virtual */
- sym_set_cam_status(cp->cam_ccb, CAM_REQ_INVALID);
- goto out_abort;
- }
-
- /* SG buffer pointers are physical */
- segs = (struct bus_dma_segment *)csio->data_ptr;
- sym_execute_ccb(cp, segs, csio->sglist_cnt, 0);
+ cp->dmamapped = (dir == CAM_DIR_IN) ? SYM_DMA_READ : SYM_DMA_WRITE;
+ retv = bus_dmamap_load_ccb(np->data_dmat, cp->dmamap,
+ (union ccb *)csio, sym_execute_ccb, cp, 0);
+ if (retv == EINPROGRESS) {
+ cp->host_status = HS_WAIT;
+ xpt_freeze_simq(np->sim, 1);
+ csio->ccb_h.status |= CAM_RELEASE_SIMQ;
}
return;
-out_abort:
- sym_xpt_done(np, (union ccb *) csio, cp);
- sym_free_ccb(np, cp);
}
/*
diff --git a/sys/dev/trm/trm.c b/sys/dev/trm/trm.c
index 765d5ea..6032798 100644
--- a/sys/dev/trm/trm.c
+++ b/sys/dev/trm/trm.c
@@ -559,6 +559,7 @@ trm_action(struct cam_sim *psim, union ccb *pccb)
PDCB pDCB = NULL;
PSRB pSRB;
struct ccb_scsiio *pcsio;
+ int error;
pcsio = &pccb->csio;
TRM_DPRINTF(" XPT_SCSI_IO \n");
@@ -614,71 +615,18 @@ trm_action(struct cam_sim *psim, union ccb *pccb)
} else
bcopy(pcsio->cdb_io.cdb_bytes,
pSRB->CmdBlock, pcsio->cdb_len);
- if ((pccb->ccb_h.flags & CAM_DIR_MASK)
- != CAM_DIR_NONE) {
- if ((pccb->ccb_h.flags &
- CAM_SCATTER_VALID) == 0) {
- if ((pccb->ccb_h.flags
- & CAM_DATA_PHYS) == 0) {
- int vmflags;
- int error;
-
- vmflags = splsoftvm();
- error = bus_dmamap_load(
- pACB->buffer_dmat,
+ error = bus_dmamap_load_ccb(pACB->buffer_dmat,
pSRB->dmamap,
- pcsio->data_ptr,
- pcsio->dxfer_len,
+ pccb,
trm_ExecuteSRB,
pSRB,
0);
- if (error == EINPROGRESS) {
- xpt_freeze_simq(
- pACB->psim,
- 1);
- pccb->ccb_h.status |=
- CAM_RELEASE_SIMQ;
- }
- splx(vmflags);
- } else {
- struct bus_dma_segment seg;
-
- /* Pointer to physical buffer */
- seg.ds_addr =
- (bus_addr_t)pcsio->data_ptr;
- seg.ds_len = pcsio->dxfer_len;
- trm_ExecuteSRB(pSRB, &seg, 1,
- 0);
- }
- } else {
- /* CAM_SCATTER_VALID */
- struct bus_dma_segment *segs;
-
- if ((pccb->ccb_h.flags &
- CAM_SG_LIST_PHYS) == 0 ||
- (pccb->ccb_h.flags
- & CAM_DATA_PHYS) != 0) {
- pSRB->pNextSRB = pACB->pFreeSRB;
- pACB->pFreeSRB = pSRB;
- pccb->ccb_h.status =
- CAM_PROVIDE_FAIL;
- xpt_done(pccb);
- splx(actionflags);
- return;
- }
-
- /* cam SG list is physical,
- * cam data is virtual
- */
- segs = (struct bus_dma_segment *)
- pcsio->data_ptr;
- trm_ExecuteSRB(pSRB, segs,
- pcsio->sglist_cnt, 1);
- } /* CAM_SCATTER_VALID */
- } else
- trm_ExecuteSRB(pSRB, NULL, 0, 0);
- }
+ if (error == EINPROGRESS) {
+ xpt_freeze_simq(pACB->psim, 1);
+ pccb->ccb_h.status |= CAM_RELEASE_SIMQ;
+ }
break;
+ }
case XPT_GDEV_TYPE:
TRM_DPRINTF(" XPT_GDEV_TYPE \n");
pccb->ccb_h.status = CAM_REQ_INVALID;
diff --git a/sys/dev/twa/tw_osl.h b/sys/dev/twa/tw_osl.h
index 50fa722..bed16cd 100644
--- a/sys/dev/twa/tw_osl.h
+++ b/sys/dev/twa/tw_osl.h
@@ -72,6 +72,7 @@
#define TW_OSLI_REQ_FLAGS_PASSTHRU (1<<5) /* pass through request */
#define TW_OSLI_REQ_FLAGS_SLEEPING (1<<6) /* owner sleeping on this cmd */
#define TW_OSLI_REQ_FLAGS_FAILED (1<<7) /* bus_dmamap_load() failed */
+#define TW_OSLI_REQ_FLAGS_CCB (1<<8) /* req is ccb. */
#ifdef TW_OSL_DEBUG
diff --git a/sys/dev/twa/tw_osl_cam.c b/sys/dev/twa/tw_osl_cam.c
index 2c2d5ae..9c4de23 100644
--- a/sys/dev/twa/tw_osl_cam.c
+++ b/sys/dev/twa/tw_osl_cam.c
@@ -261,55 +261,23 @@ tw_osli_execute_scsi(struct tw_osli_req_context *req, union ccb *ccb)
scsi_req->cdb = csio->cdb_io.cdb_bytes;
scsi_req->cdb_len = csio->cdb_len;
- if (!(ccb_h->flags & CAM_DATA_PHYS)) {
- /* Virtual data addresses. Need to convert them... */
- tw_osli_dbg_dprintf(3, sc,
- "XPT_SCSI_IO: Single virtual address!");
- if (!(ccb_h->flags & CAM_SCATTER_VALID)) {
- if (csio->dxfer_len > TW_CL_MAX_IO_SIZE) {
- tw_osli_printf(sc, "size = %d",
- TW_CL_SEVERITY_ERROR_STRING,
- TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER,
- 0x2106,
- "I/O size too big",
- csio->dxfer_len);
- ccb_h->status = CAM_REQ_TOO_BIG;
- ccb_h->status &= ~CAM_SIM_QUEUED;
- xpt_done(ccb);
- return(1);
- }
-
- if ((req->length = csio->dxfer_len)) {
- req->data = csio->data_ptr;
- scsi_req->sgl_entries = 1;
- }
- } else {
- tw_osli_printf(sc, "",
- TW_CL_SEVERITY_ERROR_STRING,
- TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER,
- 0x2107,
- "XPT_SCSI_IO: Got SGList");
- ccb_h->status = CAM_REQ_INVALID;
- ccb_h->status &= ~CAM_SIM_QUEUED;
- xpt_done(ccb);
- return(1);
- }
- } else {
- /* Data addresses are physical. */
- tw_osli_printf(sc, "",
+ if (csio->dxfer_len > TW_CL_MAX_IO_SIZE) {
+ tw_osli_printf(sc, "size = %d",
TW_CL_SEVERITY_ERROR_STRING,
TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER,
- 0x2108,
- "XPT_SCSI_IO: Physical data addresses");
- ccb_h->status = CAM_REQ_INVALID;
+ 0x2106,
+ "I/O size too big",
+ csio->dxfer_len);
+ ccb_h->status = CAM_REQ_TOO_BIG;
ccb_h->status &= ~CAM_SIM_QUEUED;
xpt_done(ccb);
return(1);
}
-
+ req->data = ccb;
+ req->length = csio->dxfer_len;
+ req->flags |= TW_OSLI_REQ_FLAGS_CCB;
req->deadline = tw_osl_get_local_time() + (ccb_h->timeout / 1000);
-
/*
* twa_map_load_data_callback will fill in the SGL,
* and submit the I/O.
diff --git a/sys/dev/twa/tw_osl_freebsd.c b/sys/dev/twa/tw_osl_freebsd.c
index aedcfe8..2956df6 100644
--- a/sys/dev/twa/tw_osl_freebsd.c
+++ b/sys/dev/twa/tw_osl_freebsd.c
@@ -1473,6 +1473,10 @@ tw_osli_map_request(struct tw_osli_req_context *req)
twa_map_load_data_callback, req,
BUS_DMA_WAITOK);
mtx_unlock_spin(sc->io_lock);
+ } else if (req->flags & TW_OSLI_REQ_FLAGS_CCB) {
+ error = bus_dmamap_load_ccb(sc->dma_tag, req->dma_map,
+ req->data, twa_map_load_data_callback, req,
+ BUS_DMA_WAITOK);
} else {
/*
* There's only one CAM I/O thread running at a time.
diff --git a/sys/dev/tws/tws.h b/sys/dev/tws/tws.h
index 5242d9d..e84047d 100644
--- a/sys/dev/tws/tws.h
+++ b/sys/dev/tws/tws.h
@@ -137,6 +137,7 @@ enum tws_req_flags {
TWS_DIR_IN = 0x2,
TWS_DIR_OUT = 0x4,
TWS_DIR_NONE = 0x8,
+ TWS_DATA_CCB = 0x16,
};
enum tws_intrs {
diff --git a/sys/dev/tws/tws_cam.c b/sys/dev/tws/tws_cam.c
index 18ac2be..657777a 100644
--- a/sys/dev/tws/tws_cam.c
+++ b/sys/dev/tws/tws_cam.c
@@ -739,39 +739,8 @@ tws_execute_scsi(struct tws_softc *sc, union ccb *ccb)
else
bcopy(csio->cdb_io.cdb_bytes, cmd_pkt->cmd.pkt_a.cdb, csio->cdb_len);
- if (!(ccb_h->flags & CAM_DATA_PHYS)) {
- /* Virtual data addresses. Need to convert them... */
- if (!(ccb_h->flags & CAM_SCATTER_VALID)) {
- if (csio->dxfer_len > TWS_MAX_IO_SIZE) {
- TWS_TRACE(sc, "I/O is big", csio->dxfer_len, 0);
- tws_release_request(req);
- ccb_h->status = CAM_REQ_TOO_BIG;
- xpt_done(ccb);
- return(0);
- }
-
- req->length = csio->dxfer_len;
- if (req->length) {
- req->data = csio->data_ptr;
- /* there is 1 sgl_entrie */
- /* cmd_pkt->cmd.pkt_a.lun_h4__sgl_entries |= 1; */
- }
- } else {
- TWS_TRACE_DEBUG(sc, "got sglist", ccb_h->target_id, ccb_h->target_lun);
- tws_release_request(req);
- ccb_h->status = CAM_REQ_INVALID;
- xpt_done(ccb);
- return(0);
- }
- } else {
- /* Data addresses are physical. */
- TWS_TRACE_DEBUG(sc, "Phy data addr", ccb_h->target_id, ccb_h->target_lun);
- tws_release_request(req);
- ccb_h->status = CAM_REQ_INVALID;
- ccb_h->status &= ~CAM_SIM_QUEUED;
- xpt_done(ccb);
- return(0);
- }
+ req->data = ccb;
+ req->flags |= TWS_DATA_CCB;
/* save ccb ptr */
req->ccb_ptr = ccb;
/*
@@ -961,10 +930,16 @@ tws_map_request(struct tws_softc *sc, struct tws_request *req)
* Map the data buffer into bus space and build the SG list.
*/
mtx_lock(&sc->io_lock);
- error = bus_dmamap_load(sc->data_tag, req->dma_map,
- req->data, req->length,
- tws_dmamap_data_load_cbfn, req,
- my_flags);
+ if (req->flags & TWS_DATA_CCB)
+ error = bus_dmamap_load_ccb(sc->data_tag, req->dma_map,
+ req->data,
+ tws_dmamap_data_load_cbfn, req,
+ my_flags);
+ else
+ error = bus_dmamap_load(sc->data_tag, req->dma_map,
+ req->data, req->length,
+ tws_dmamap_data_load_cbfn, req,
+ my_flags);
mtx_unlock(&sc->io_lock);
if (error == EINPROGRESS) {
diff --git a/sys/dev/virtio/scsi/virtio_scsi.c b/sys/dev/virtio/scsi/virtio_scsi.c
index 86684ba..7ebce09 100644
--- a/sys/dev/virtio/scsi/virtio_scsi.c
+++ b/sys/dev/virtio/scsi/virtio_scsi.c
@@ -961,28 +961,31 @@ vtscsi_sg_append_scsi_buf(struct vtscsi_softc *sc, struct sglist *sg,
ccbh = &csio->ccb_h;
error = 0;
- if ((ccbh->flags & CAM_SCATTER_VALID) == 0) {
-
- if ((ccbh->flags & CAM_DATA_PHYS) == 0)
+ switch ((ccbh->flags & CAM_DATA_MASK)) {
+ case CAM_DATA_VADDR:
+ error = sglist_append(sg, csio->data_ptr, csio->dxfer_len);
+ break;
+ case CAM_DATA_PADDR:
+ error = sglist_append_phys(sg,
+ (vm_paddr_t)(vm_offset_t) csio->data_ptr, csio->dxfer_len);
+ break;
+ case CAM_DATA_SG:
+ for (i = 0; i < csio->sglist_cnt && error == 0; i++) {
+ dseg = &((struct bus_dma_segment *)csio->data_ptr)[i];
error = sglist_append(sg,
- csio->data_ptr, csio->dxfer_len);
- else
- error = sglist_append_phys(sg,
- (vm_paddr_t)(vm_offset_t) csio->data_ptr,
- csio->dxfer_len);
- } else {
-
+ (void *)(vm_offset_t) dseg->ds_addr, dseg->ds_len);
+ }
+ break;
+ case CAM_DATA_SG_PADDR:
for (i = 0; i < csio->sglist_cnt && error == 0; i++) {
dseg = &((struct bus_dma_segment *)csio->data_ptr)[i];
-
- if ((ccbh->flags & CAM_SG_LIST_PHYS) == 0)
- error = sglist_append(sg,
- (void *)(vm_offset_t) dseg->ds_addr,
- dseg->ds_len);
- else
- error = sglist_append_phys(sg,
- (vm_paddr_t) dseg->ds_addr, dseg->ds_len);
+ error = sglist_append_phys(sg,
+ (vm_paddr_t) dseg->ds_addr, dseg->ds_len);
}
+ break;
+ default:
+ error = EINVAL;
+ break;
}
return (error);
diff --git a/sys/dev/wds/wd7000.c b/sys/dev/wds/wd7000.c
index 3dcd735..194d39e 100644
--- a/sys/dev/wds/wd7000.c
+++ b/sys/dev/wds/wd7000.c
@@ -1066,7 +1066,7 @@ wds_scsi_io(struct cam_sim * sim, struct ccb_scsiio * csio)
xpt_done((union ccb *) csio);
return;
}
- if (ccb_h->flags & (CAM_CDB_PHYS | CAM_SCATTER_VALID | CAM_DATA_PHYS)) {
+ if ((ccb_h->flags & CAM_DATA_MASK) != CAM_DATA_VADDR) {
/* don't support these */
ccb_h->status = CAM_REQ_INVALID;
xpt_done((union ccb *) csio);
OpenPOWER on IntegriCloud