From owner-svn-src-projects@FreeBSD.ORG Wed Dec 5 04:52:03 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8BCC7C99; Wed, 5 Dec 2012 04:52:03 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 709FB8FC17; Wed, 5 Dec 2012 04:52:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qB54q3et065388; Wed, 5 Dec 2012 04:52:03 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qB54px6O065330; Wed, 5 Dec 2012 04:51:59 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201212050451.qB54px6O065330@svn.freebsd.org> From: Jeff Roberson Date: Wed, 5 Dec 2012 04:51:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r243876 - in projects/physbio/sys: cam cam/ctl cam/scsi dev/aac dev/ahci dev/aic dev/arcmsr dev/ciss dev/hpt27xx dev/hptmv dev/hptrr dev/iir dev/isci dev/mly dev/mps dev/mpt kern X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Dec 2012 04:52:03 -0000 Author: jeff Date: Wed Dec 5 04:51:59 2012 New Revision: 243876 URL: http://svnweb.freebsd.org/changeset/base/243876 Log: - Arrange the cam ccb data flags into a 3 bit data type field so that it can easily be parsed with a switch statement. Define all physical formats with the low bit set so drivers that don't support any physical formats may easily reject them. - Audit callbacks to make sure they work properly when no segments are passed to them if the command does not have data. Sponsored by: EMC / Isilon Storage Division Modified: projects/physbio/sys/cam/cam_ccb.h projects/physbio/sys/cam/cam_xpt.c projects/physbio/sys/cam/ctl/ctl_frontend_cam_sim.c projects/physbio/sys/cam/ctl/scsi_ctl.c projects/physbio/sys/cam/scsi/scsi_pass.c projects/physbio/sys/dev/aac/aac_cam.c projects/physbio/sys/dev/ahci/ahci.c projects/physbio/sys/dev/aic/aic.c projects/physbio/sys/dev/arcmsr/arcmsr.c projects/physbio/sys/dev/ciss/ciss.c projects/physbio/sys/dev/hpt27xx/osm_bsd.c projects/physbio/sys/dev/hptmv/entry.c projects/physbio/sys/dev/hptrr/hptrr_osm_bsd.c projects/physbio/sys/dev/iir/iir.c projects/physbio/sys/dev/isci/isci_io_request.c projects/physbio/sys/dev/mly/mly.c projects/physbio/sys/dev/mps/mps_sas.c projects/physbio/sys/dev/mpt/mpt_cam.c projects/physbio/sys/kern/subr_busdma.c Modified: projects/physbio/sys/cam/cam_ccb.h ============================================================================== --- projects/physbio/sys/cam/cam_ccb.h Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/cam/cam_ccb.h Wed Dec 5 04:51:59 2012 (r243876) @@ -64,27 +64,33 @@ typedef enum { * Perform transport negotiation * with this command. */ - CAM_SCATTER_VALID = 0x00000010,/* Scatter/gather list is valid */ - CAM_DIS_AUTOSENSE = 0x00000020,/* Disable autosense feature */ + CAM_DIS_AUTOSENSE = 0x00000010,/* Disable autosense feature */ CAM_DIR_BOTH = 0x00000000,/* Data direction (00:IN/OUT) */ - CAM_DIR_IN = 0x00000040,/* Data direction (01:DATA IN) */ - CAM_DIR_OUT = 0x00000080,/* Data direction (10:DATA OUT) */ - CAM_DIR_NONE = 0x000000C0,/* Data direction (11:no data) */ - CAM_DIR_MASK = 0x000000C0,/* Data direction Mask */ - CAM_SOFT_RST_OP = 0x00000100,/* Use Soft reset alternative */ - CAM_ENG_SYNC = 0x00000200,/* Flush resid bytes on complete */ - CAM_DEV_QFRZDIS = 0x00000400,/* Disable DEV Q freezing */ - CAM_DEV_QFREEZE = 0x00000800,/* Freeze DEV Q on execution */ - CAM_HIGH_POWER = 0x00001000,/* Command takes a lot of power */ - CAM_SENSE_PTR = 0x00002000,/* Sense data is a pointer */ - CAM_SENSE_PHYS = 0x00004000,/* Sense pointer is physical addr*/ - CAM_TAG_ACTION_VALID = 0x00008000,/* Use the tag action in this ccb*/ - CAM_PASS_ERR_RECOVER = 0x00010000,/* Pass driver does err. recovery*/ - CAM_DIS_DISCONNECT = 0x00020000,/* Disable disconnect */ - CAM_SG_LIST_PHYS = 0x00040000,/* SG list has physical addrs. */ - CAM_MSG_BUF_PHYS = 0x00080000,/* Message buffer ptr is physical*/ - CAM_SNS_BUF_PHYS = 0x00100000,/* Autosense data ptr is physical*/ - CAM_DATA_PHYS = 0x00200000,/* SG/Buffer data ptrs are phys. */ + CAM_DIR_IN = 0x00000020,/* Data direction (01:DATA IN) */ + CAM_DIR_OUT = 0x00000040,/* Data direction (10:DATA OUT) */ + CAM_DIR_NONE = 0x00000060,/* Data direction (11:no data) */ + CAM_DIR_MASK = 0x00000060,/* Data direction Mask */ + CAM_DATA_ISPHYS = 0x00000080,/* Data type with physical addrs */ + CAM_DATA_VADDR = 0x00000000,/* Data type (000:Virtual) */ + CAM_DATA_PADDR = 0x00000080,/* Data type (001:Physical) */ + CAM_DATA_SG = 0x00000100,/* Data type (010:sglist) */ + CAM_DATA_SG_PADDR = 0x00000180,/* Data type (011:sglist phys) */ + CAM_DATA_BIO = 0x00000200,/* Data type (100:bio) */ + CAM_DATA_MASK = 0x00000380,/* Data type mask. */ + CAM_SOFT_RST_OP = 0x00000400,/* Use Soft reset alternative */ + CAM_ENG_SYNC = 0x00000800,/* Flush resid bytes on complete */ + CAM_DEV_QFRZDIS = 0x00001000,/* Disable DEV Q freezing */ + CAM_DEV_QFREEZE = 0x00002000,/* Freeze DEV Q on execution */ + CAM_HIGH_POWER = 0x00004000,/* Command takes a lot of power */ + CAM_SENSE_PTR = 0x00008000,/* Sense data is a pointer */ + CAM_SENSE_PHYS = 0x00010000,/* Sense pointer is physical addr*/ + CAM_TAG_ACTION_VALID = 0x00020000,/* Use the tag action in this ccb*/ + CAM_PASS_ERR_RECOVER = 0x00040000,/* Pass driver does err. recovery*/ + CAM_DIS_DISCONNECT = 0x00080000,/* Disable disconnect */ + CAM_MSG_BUF_PHYS = 0x00100000,/* Message buffer ptr is physical*/ + CAM_SNS_BUF_PHYS = 0x00200000,/* Autosense data ptr is physical*/ + + CAM_CDB_PHYS = 0x00400000,/* CDB poiner is physical */ CAM_ENG_SGLIST = 0x00800000,/* SG list is for the HBA engine */ Modified: projects/physbio/sys/cam/cam_xpt.c ============================================================================== --- projects/physbio/sys/cam/cam_xpt.c Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/cam/cam_xpt.c Wed Dec 5 04:51:59 2012 (r243876) @@ -547,7 +547,8 @@ xptioctl(struct cdev *dev, u_long cmd, c * We can't deal with physical addresses for this * type of transaction. */ - if (inccb->ccb_h.flags & CAM_DATA_PHYS) { + if ((inccb->ccb_h.flags & CAM_DATA_MASK) != + CAM_DATA_VADDR) { error = EINVAL; break; } Modified: projects/physbio/sys/cam/ctl/ctl_frontend_cam_sim.c ============================================================================== --- projects/physbio/sys/cam/ctl/ctl_frontend_cam_sim.c Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/cam/ctl/ctl_frontend_cam_sim.c Wed Dec 5 04:51:59 2012 (r243876) @@ -93,8 +93,8 @@ struct cfcs_softc { * handle physical addresses yet. That would require mapping things in * order to do the copy. */ -#define CFCS_BAD_CCB_FLAGS (CAM_DATA_PHYS | CAM_SG_LIST_PHYS | \ - CAM_MSG_BUF_PHYS | CAM_SNS_BUF_PHYS | CAM_CDB_PHYS | CAM_SENSE_PTR |\ +#define CFCS_BAD_CCB_FLAGS (CAM_DATA_ISPHYS | CAM_MSG_BUF_PHYS | \ + CAM_SNS_BUF_PHYS | CAM_CDB_PHYS | CAM_SENSE_PTR | \ CAM_SENSE_PHYS) int cfcs_init(void); @@ -393,36 +393,35 @@ cfcs_datamove(union ctl_io *io) * Simplify things on both sides by putting single buffers into a * single entry S/G list. */ - if (ccb->ccb_h.flags & CAM_SCATTER_VALID) { - if (ccb->ccb_h.flags & CAM_SG_LIST_PHYS) { - /* We should filter this out on entry */ - panic("%s: physical S/G list, should not get here", - __func__); - } else { - int len_seen; - - cam_sglist = (bus_dma_segment_t *)ccb->csio.data_ptr; - cam_sg_count = ccb->csio.sglist_cnt; - - for (i = 0, len_seen = 0; i < cam_sg_count; i++) { - if ((len_seen + cam_sglist[i].ds_len) >= - io->scsiio.kern_rel_offset) { - cam_sg_start = i; - cam_sg_offset = - io->scsiio.kern_rel_offset - - len_seen; - break; - } - len_seen += cam_sglist[i].ds_len; + switch ((ccb->ccb_h.flags & CAM_DATA_MASK)) { + case CAM_DATA_SG: { + int len_seen; + + cam_sglist = (bus_dma_segment_t *)ccb->csio.data_ptr; + cam_sg_count = ccb->csio.sglist_cnt; + + for (i = 0, len_seen = 0; i < cam_sg_count; i++) { + if ((len_seen + cam_sglist[i].ds_len) >= + io->scsiio.kern_rel_offset) { + cam_sg_start = i; + cam_sg_offset = io->scsiio.kern_rel_offset - + len_seen; + break; } + len_seen += cam_sglist[i].ds_len; } - } else { + break; + } + case CAM_DATA_VADDR: cam_sglist = &cam_sg_entry; cam_sglist[0].ds_len = ccb->csio.dxfer_len; cam_sglist[0].ds_addr = (bus_addr_t)ccb->csio.data_ptr; cam_sg_count = 1; cam_sg_start = 0; cam_sg_offset = io->scsiio.kern_rel_offset; + break; + default: + panic("Invalid CAM flags %#x", ccb->ccb_h.flags); } if (io->scsiio.kern_sg_entries > 0) { Modified: projects/physbio/sys/cam/ctl/scsi_ctl.c ============================================================================== --- projects/physbio/sys/cam/ctl/scsi_ctl.c Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/cam/ctl/scsi_ctl.c Wed Dec 5 04:51:59 2012 (r243876) @@ -889,6 +889,7 @@ ctlfestart(struct cam_periph *periph, un csio->cdb_len = atio->cdb_len; + flags &= ~CAM_DATA_MASK; if (io->scsiio.kern_sg_entries == 0) { /* No S/G list */ data_ptr = io->scsiio.kern_data_ptr; @@ -896,7 +897,9 @@ ctlfestart(struct cam_periph *periph, un csio->sglist_cnt = 0; if (io->io_hdr.flags & CTL_FLAG_BUS_ADDR) - flags |= CAM_DATA_PHYS; + flags |= CAM_DATA_PADDR; + else + flags |= CAM_DATA_VADDR; } else if (io->scsiio.kern_sg_entries <= (sizeof(cmd_info->cam_sglist)/ sizeof(cmd_info->cam_sglist[0]))) { @@ -920,11 +923,10 @@ ctlfestart(struct cam_periph *periph, un ctl_sglist[i].len; } csio->sglist_cnt = io->scsiio.kern_sg_entries; - flags |= CAM_SCATTER_VALID; if (io->io_hdr.flags & CTL_FLAG_BUS_ADDR) - flags |= CAM_SG_LIST_PHYS; + flags |= CAM_DATA_SG_PADDR; else - flags &= ~CAM_SG_LIST_PHYS; + flags &= ~CAM_DATA_SG; data_ptr = (uint8_t *)cam_sglist; dxfer_len = io->scsiio.kern_data_len; } else { Modified: projects/physbio/sys/cam/scsi/scsi_pass.c ============================================================================== --- projects/physbio/sys/cam/scsi/scsi_pass.c Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/cam/scsi/scsi_pass.c Wed Dec 5 04:51:59 2012 (r243876) @@ -639,8 +639,11 @@ passsendccb(struct cam_periph *periph, u * do the right thing, even if there isn't data to map, but since CCBs * without data are a reasonably common occurance (e.g. test unit * ready), it will save a few cycles if we check for it here. + * + * XXX What happens if a sg list is supplied? We don't filter that + * out. */ - if (((ccb->ccb_h.flags & CAM_DATA_PHYS) == 0) + if (((ccb->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_VADDR) && (((ccb->ccb_h.func_code == XPT_SCSI_IO || ccb->ccb_h.func_code == XPT_ATA_IO) && ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE)) Modified: projects/physbio/sys/dev/aac/aac_cam.c ============================================================================== --- projects/physbio/sys/dev/aac/aac_cam.c Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/dev/aac/aac_cam.c Wed Dec 5 04:51:59 2012 (r243876) @@ -448,26 +448,28 @@ aac_cam_action(struct cam_sim *sim, unio /* 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"); } Modified: projects/physbio/sys/dev/ahci/ahci.c ============================================================================== --- projects/physbio/sys/dev/ahci/ahci.c Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/dev/ahci/ahci.c Wed Dec 5 04:51:59 2012 (r243876) @@ -1667,8 +1667,11 @@ ahci_begin_transaction(device_t dev, uni (ccb->ataio.cmd.flags & (CAM_ATAIO_CONTROL | CAM_ATAIO_NEEDRESULT))) ch->aslots |= (1 << slot->slot); slot->dma.nsegs = 0; - bus_dmamap_load_ccb(ch->dma.data_tag, slot->dma.data_map, ccb, - ahci_dmasetprd, slot, 0); + if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) { + bus_dmamap_load_ccb(ch->dma.data_tag, slot->dma.data_map, ccb, + ahci_dmasetprd, slot, 0); + } else + ahci_execute_transaction(slot); } /* Locked by busdma engine. */ Modified: projects/physbio/sys/dev/aic/aic.c ============================================================================== --- projects/physbio/sys/dev/aic/aic.c Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/dev/aic/aic.c Wed Dec 5 04:51:59 2012 (r243876) @@ -146,8 +146,8 @@ aic_action(struct cam_sim *sim, union cc 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); Modified: projects/physbio/sys/dev/arcmsr/arcmsr.c ============================================================================== --- projects/physbio/sys/dev/arcmsr/arcmsr.c Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/dev/arcmsr/arcmsr.c Wed Dec 5 04:51:59 2012 (r243876) @@ -2100,7 +2100,7 @@ static int arcmsr_iop_message_xfer(struc (u_int32_t ) pccb->csio.cdb_io.cdb_bytes[8]; /* 4 bytes: Areca io control code */ /* XXX Does not handle alternate data formats. */ - 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 { Modified: projects/physbio/sys/dev/ciss/ciss.c ============================================================================== --- projects/physbio/sys/dev/ciss/ciss.c Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/dev/ciss/ciss.c Wed Dec 5 04:51:59 2012 (r243876) @@ -3049,18 +3049,6 @@ ciss_cam_action_io(struct cam_sim *sim, 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"); @@ -3111,6 +3099,7 @@ ciss_cam_action_io(struct cam_sim *sim, cr->cr_flags = CISS_REQ_DATAIN; cc->cdb.direction = CISS_CDB_DIRECTION_READ; } else { + cr->cr_data = NULL; cr->cr_flags = 0; cc->cdb.direction = CISS_CDB_DIRECTION_NONE; } Modified: projects/physbio/sys/dev/hpt27xx/osm_bsd.c ============================================================================== --- projects/physbio/sys/dev/hpt27xx/osm_bsd.c Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/dev/hpt27xx/osm_bsd.c Wed Dec 5 04:51:59 2012 (r243876) @@ -473,33 +473,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; @@ -514,7 +487,7 @@ static void hpt_io_dmamap_callback(void HPT_ASSERT(pCmd->flags.physical_sg); - if (error || nsegs == 0) + if (error) panic("busdma error"); HPT_ASSERT(nsegs<=os_max_sg_descriptors); @@ -524,7 +497,8 @@ static void hpt_io_dmamap_callback(void psg->size = segs[idx].ds_len; psg->eot = 0; } - psg[-1].eot = 1; + if (nsegs) + psg[-1].eot = 1; if (pCmd->flags.data_in) { bus_dmamap_sync(ext->vbus_ext->io_dmat, ext->dma_map, BUS_DMASYNC_PREREAD); Modified: projects/physbio/sys/dev/hptmv/entry.c ============================================================================== --- projects/physbio/sys/dev/hptmv/entry.c Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/dev/hptmv/entry.c Wed Dec 5 04:51:59 2012 (r243876) @@ -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,7 +2732,7 @@ hpt_io_dmamap_callback(void *arg, bus_dm HPT_ASSERT(pCmd->cf_physical_sg); - if (error || nsegs == 0) + if (error) panic("busdma error"); HPT_ASSERT(nsegs<= MAX_SG_DESCRIPTORS); @@ -2768,7 +2743,9 @@ hpt_io_dmamap_callback(void *arg, bus_dm 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 (nsegs) { + /* psg[-1].wSgFlag = SG_FLAG_EOT; */ + } if (pCmd->cf_data_in) { bus_dmamap_sync(pAdapter->io_dma_parent, pmap->dma_map, BUS_DMASYNC_PREREAD); Modified: projects/physbio/sys/dev/hptrr/hptrr_osm_bsd.c ============================================================================== --- projects/physbio/sys/dev/hptrr/hptrr_osm_bsd.c Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/dev/hptrr/hptrr_osm_bsd.c Wed Dec 5 04:51:59 2012 (r243876) @@ -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,7 +496,7 @@ static void hpt_io_dmamap_callback(void HPT_ASSERT(pCmd->flags.physical_sg); - if (error || nsegs == 0) + if (error) panic("busdma error"); HPT_ASSERT(nsegs<=os_max_sg_descriptors); @@ -532,7 +506,8 @@ static void hpt_io_dmamap_callback(void psg->size = segs[idx].ds_len; psg->eot = 0; } - psg[-1].eot = 1; + if (nsegs) + psg[-1].eot = 1; if (pCmd->flags.data_in) { bus_dmamap_sync(ext->vbus_ext->io_dmat, ext->dma_map, BUS_DMASYNC_PREREAD); @@ -724,7 +699,6 @@ static void hpt_scsi_io(PVBUS_EXT vbus_e pCmd->target = vd; pCmd->done = os_cmddone; pCmd->buildsgl = os_buildsgl; - pCmd->psg = ext->psg; pCmd->flags.physical_sg = 1; error = bus_dmamap_load_ccb(vbus_ext->io_dmat, Modified: projects/physbio/sys/dev/iir/iir.c ============================================================================== --- projects/physbio/sys/dev/iir/iir.c Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/dev/iir/iir.c Wed Dec 5 04:51:59 2012 (r243876) @@ -867,6 +867,7 @@ gdt_cache_cmd(struct gdt_softc *gdt, uni 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)); @@ -917,49 +918,15 @@ gdt_cache_cmd(struct gdt_softc *gdt, uni 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); } Modified: projects/physbio/sys/dev/isci/isci_io_request.c ============================================================================== --- projects/physbio/sys/dev/isci/isci_io_request.c Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/dev/isci/isci_io_request.c Wed Dec 5 04:51:59 2012 (r243876) @@ -748,12 +748,8 @@ isci_io_request_execute_scsi_io(union cc 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", - ccb->ccb_h.flags); - - if ((ccb->ccb_h.flags & CAM_DATA_PHYS) != 0) - panic("Unexpected CAM_DATA_PHYS 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); error = bus_dmamap_load_ccb(io_request->parent.dma_tag, Modified: projects/physbio/sys/dev/mly/mly.c ============================================================================== --- projects/physbio/sys/dev/mly/mly.c Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/dev/mly/mly.c Wed Dec 5 04:51:59 2012 (r243876) @@ -2224,18 +2224,6 @@ mly_cam_action_io(struct cam_sim *sim, s 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"); Modified: projects/physbio/sys/dev/mps/mps_sas.c ============================================================================== --- projects/physbio/sys/dev/mps/mps_sas.c Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/dev/mps/mps_sas.c Wed Dec 5 04:51:59 2012 (r243876) @@ -1755,9 +1755,13 @@ mpssas_action_scsiio(struct mpssas_softc } } - cm->cm_data = ccb; - cm->cm_flags |= MPS_CM_FLAGS_USE_CCB; 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; @@ -2692,19 +2696,15 @@ mpssas_send_smpcmd(struct mpssas_softc * /* * 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. @@ -2742,9 +2742,15 @@ mpssas_send_smpcmd(struct mpssas_softc * 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); Modified: projects/physbio/sys/dev/mpt/mpt_cam.c ============================================================================== --- projects/physbio/sys/dev/mpt/mpt_cam.c Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/dev/mpt/mpt_cam.c Wed Dec 5 04:51:59 2012 (r243876) @@ -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; Modified: projects/physbio/sys/kern/subr_busdma.c ============================================================================== --- projects/physbio/sys/kern/subr_busdma.c Wed Dec 5 04:22:53 2012 (r243875) +++ projects/physbio/sys/kern/subr_busdma.c Wed Dec 5 04:51:59 2012 (r243876) @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -76,27 +77,8 @@ bus_dmamap_load_ccb(bus_dma_tag_t dmat, ccb_h->func_code); } - if ((ccb_h->flags & CAM_SCATTER_VALID) != 0) { - struct bus_dma_segment *segs; - - if ((ccb_h->flags & CAM_DATA_PHYS) != 0) - panic("bus_dmamap_load_ccb - Physical segment " - "pointers unsupported"); - - if ((ccb_h->flags & CAM_SG_LIST_PHYS) == 0) - panic("bus_dmamap_load_ccb - Virtual segment " - "addresses unsupported"); - - /* Just use the segments provided */ - segs = (struct bus_dma_segment *)data_ptr; - callback(callback_arg, segs, sglist_cnt, 0); - } else if ((ccb_h->flags & CAM_DATA_PHYS) != 0) { - struct bus_dma_segment seg; - - seg.ds_addr = (bus_addr_t)(vm_offset_t)data_ptr; - seg.ds_len = dxfer_len; - callback(callback_arg, &seg, 1, 0); - } else { + switch ((ccb_h->flags & CAM_DATA_MASK)) { + case CAM_DATA_VADDR: return bus_dmamap_load(dmat, map, data_ptr, @@ -104,6 +86,43 @@ bus_dmamap_load_ccb(bus_dma_tag_t dmat, callback, callback_arg, /*flags*/0); + case CAM_DATA_PADDR: { + struct bus_dma_segment seg; + + seg.ds_addr = (bus_addr_t)(vm_offset_t)data_ptr; + seg.ds_len = dxfer_len; + callback(callback_arg, &seg, 1, 0); + break; + } + case CAM_DATA_SG: { +#if 0 + struct uio sguio; + KASSERT((sizeof (sguio.uio_iov) == sizeof (data_ptr) && + sizeof (sguio.uio_iovcnt) >= sizeof (sglist_cnt) && + sizeof (sguio.uio_resid) >= sizeof (dxfer_len)), + ("uio won't fit csio data")); + sguio.uio_iov = (struct iovec *)data_ptr; + sguio.uio_iovcnt = csio->sglist_cnt; + sguio.uio_resid = csio->dxfer_len; + sguio.uio_segflg = UIO_SYSSPACE; + return bus_dmamap_load_uio(dmat, map, &sguio, callback, + callback_arg, 0); +#else + panic("bus_dmamap_load_ccb: flags 0x%X unimplemented", + ccb_h->flags); +#endif + } + case CAM_DATA_SG_PADDR: { + struct bus_dma_segment *segs; + /* Just use the segments provided */ + segs = (struct bus_dma_segment *)data_ptr; + callback(callback_arg, segs, sglist_cnt, 0); + break; + } + case CAM_DATA_BIO: + default: + panic("bus_dmamap_load_ccb: flags 0x%X unimplemented", + ccb_h->flags); } return (0); }