summaryrefslogtreecommitdiffstats
path: root/sys/dev/hpt27xx
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/hpt27xx
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/hpt27xx')
-rw-r--r--sys/dev/hpt27xx/osm_bsd.c100
1 files changed, 28 insertions, 72 deletions
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;
}
OpenPOWER on IntegriCloud