svn commit: r235460 - in projects/altix2/sys: dev/mpt kern sys
Marcel Moolenaar
marcel at FreeBSD.org
Tue May 15 03:21:37 UTC 2012
Author: marcel
Date: Tue May 15 03:21:36 2012
New Revision: 235460
URL: http://svn.freebsd.org/changeset/base/235460
Log:
Bring in sync with wiki:
o rename busdma_mem_t to busdma_md_t.
o functions to create, destroy and access field of a MD are renamed
as well.
o keep the argument ordering for functions on tags the same as with
bus_dma. This eases conversion.
Modified:
projects/altix2/sys/dev/mpt/mpt.c
projects/altix2/sys/dev/mpt/mpt.h
projects/altix2/sys/dev/mpt/mpt_cam.c
projects/altix2/sys/dev/mpt/mpt_pci.c
projects/altix2/sys/dev/mpt/mpt_user.c
projects/altix2/sys/kern/subr_busdma.c
projects/altix2/sys/sys/busdma.h
Modified: projects/altix2/sys/dev/mpt/mpt.c
==============================================================================
--- projects/altix2/sys/dev/mpt/mpt.c Tue May 15 01:30:25 2012 (r235459)
+++ projects/altix2/sys/dev/mpt/mpt.c Tue May 15 03:21:36 2012 (r235460)
@@ -392,17 +392,6 @@ mpt_postattach(void *unused)
}
SYSINIT(mptdev, SI_SUB_CONFIGURE, SI_ORDER_MIDDLE, mpt_postattach, NULL);
-/******************************* Bus DMA Support ******************************/
-void
-mpt_map_rquest(void *arg, bus_dma_segment_t *segs, int nseg, int error)
-{
- struct mpt_map_info *map_info;
-
- map_info = (struct mpt_map_info *)arg;
- map_info->error = error;
- map_info->phys = segs->ds_addr;
-}
-
/**************************** Reply/Event Handling ****************************/
int
mpt_register_handler(struct mpt_softc *mpt, mpt_handler_type type,
@@ -742,12 +731,8 @@ mpt_intr(void *arg)
*/
reply_baddr = MPT_REPLY_BADDR(reply_desc);
offset = reply_baddr - (mpt->reply_phys & 0xFFFFFFFF);
-#ifdef MPT_USE_BUSDMA
-#else
- bus_dmamap_sync_range(mpt->reply_dmat,
- mpt->reply_dmap, offset, MPT_REPLY_SIZE,
- BUS_DMASYNC_POSTREAD);
-#endif
+ busdma_sync_range(mpt->reply_md, reply_baddr,
+ MPT_REPLY_SIZE, BUS_DMASYNC_POSTREAD);
reply_frame = MPT_REPLY_OTOV(mpt, offset);
ctxt_idx = le32toh(reply_frame->MsgContext);
} else {
@@ -823,21 +808,14 @@ mpt_intr(void *arg)
" 0x%x)\n", req_index, reply_desc);
}
-#ifdef MPT_USE_BUSDMA
-#else
- bus_dmamap_sync(mpt->request_dmat, mpt->request_dmap,
+ busdma_sync(mpt->request_md,
BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
-#endif
free_rf = mpt_reply_handlers[cb_index](mpt, req,
reply_desc, reply_frame);
if (reply_frame != NULL && free_rf) {
-#ifdef MPT_USE_BUSDMA
-#else
- bus_dmamap_sync_range(mpt->reply_dmat,
- mpt->reply_dmap, offset, MPT_REPLY_SIZE,
- BUS_DMASYNC_PREREAD);
-#endif
+ busdma_sync_range(mpt->reply_md, reply_baddr,
+ MPT_REPLY_SIZE, BUS_DMASYNC_PREREAD);
mpt_free_reply(mpt, reply_baddr);
}
@@ -870,11 +848,8 @@ mpt_complete_request_chain(struct mpt_so
MSG_REQUEST_HEADER *msg_hdr;
u_int cb_index;
-#ifdef MPT_USE_BUSDMA
-#else
- bus_dmamap_sync(mpt->request_dmat, mpt->request_dmap,
+ busdma_sync(mpt->request_md,
BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
-#endif
msg_hdr = (MSG_REQUEST_HEADER *)req->req_vbuf;
ioc_status_frame.Function = msg_hdr->Function;
ioc_status_frame.MsgContext = msg_hdr->MsgContext;
@@ -1262,11 +1237,8 @@ mpt_free_request(struct mpt_softc *mpt,
mpt_send_event_ack(mpt, req, &record->reply, record->context);
offset = (uint32_t)((uint8_t *)record - mpt->reply);
reply_baddr = offset + (mpt->reply_phys & 0xFFFFFFFF);
-#ifdef MPT_USE_BUSDMA
-#else
- bus_dmamap_sync_range(mpt->reply_dmat, mpt->reply_dmap, offset,
- MPT_REPLY_SIZE, BUS_DMASYNC_PREREAD);
-#endif
+ busdma_sync_range(mpt->reply_md, offset, MPT_REPLY_SIZE,
+ BUS_DMASYNC_PREREAD);
mpt_free_reply(mpt, reply_baddr);
}
@@ -1306,11 +1278,8 @@ mpt_send_cmd(struct mpt_softc *mpt, requ
if (mpt->verbose > MPT_PRT_DEBUG2) {
mpt_dump_request(mpt, req);
}
-#ifdef MPT_USE_BUSDMA
-#else
- bus_dmamap_sync(mpt->request_dmat, mpt->request_dmap,
+ busdma_sync(mpt->request_md,
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
-#endif
req->state |= REQ_STATE_QUEUED;
KASSERT(mpt_req_on_free_list(mpt, req) == 0,
("req %p:%u func %x on freelist list in mpt_send_cmd",
@@ -2437,12 +2406,12 @@ mpt_upload_fw(struct mpt_softc *mpt)
flags <<= MPI_SGE_FLAGS_SHIFT;
sge->FlagsLength = htole32(flags | mpt->fw_image_size);
sge->Address = htole32(mpt->fw_phys);
- bus_dmamap_sync(mpt->fw_dmat, mpt->fw_dmap, BUS_DMASYNC_PREREAD);
+ busdma_sync(mpt->fw_md, BUS_DMASYNC_PREREAD);
error = mpt_send_handshake_cmd(mpt, sizeof(fw_req_buf), &fw_req_buf);
if (error)
return(error);
error = mpt_recv_handshake_reply(mpt, sizeof(fw_reply), &fw_reply);
- bus_dmamap_sync(mpt->fw_dmat, mpt->fw_dmap, BUS_DMASYNC_POSTREAD);
+ busdma_sync(mpt->fw_md, BUS_DMASYNC_POSTREAD);
return (error);
}
@@ -2492,10 +2461,10 @@ mpt_download_fw(struct mpt_softc *mpt)
MPI_DIAG_RW_ENABLE|MPI_DIAG_DISABLE_ARM);
fw_hdr = (MpiFwHeader_t *)mpt->fw_image;
- bus_dmamap_sync(mpt->fw_dmat, mpt->fw_dmap, BUS_DMASYNC_PREWRITE);
+ busdma_sync(mpt->fw_md, BUS_DMASYNC_PREWRITE);
mpt_diag_outsl(mpt, fw_hdr->LoadStartAddress, (uint32_t*)fw_hdr,
fw_hdr->ImageSize);
- bus_dmamap_sync(mpt->fw_dmat, mpt->fw_dmap, BUS_DMASYNC_POSTWRITE);
+ busdma_sync(mpt->fw_md, BUS_DMASYNC_POSTWRITE);
ext_offset = fw_hdr->NextImageHeaderOffset;
while (ext_offset != 0) {
@@ -2503,12 +2472,10 @@ mpt_download_fw(struct mpt_softc *mpt)
ext = (MpiExtImageHeader_t *)((uintptr_t)fw_hdr + ext_offset);
ext_offset = ext->NextImageHeaderOffset;
- bus_dmamap_sync(mpt->fw_dmat, mpt->fw_dmap,
- BUS_DMASYNC_PREWRITE);
+ busdma_sync(mpt->fw_md, BUS_DMASYNC_PREWRITE);
mpt_diag_outsl(mpt, ext->LoadStartAddress, (uint32_t*)ext,
ext->ImageSize);
- bus_dmamap_sync(mpt->fw_dmat, mpt->fw_dmap,
- BUS_DMASYNC_POSTWRITE);
+ busdma_sync(mpt->fw_md, BUS_DMASYNC_POSTWRITE);
}
if (mpt->is_sas) {
@@ -2546,64 +2513,35 @@ mpt_download_fw(struct mpt_softc *mpt)
static int
mpt_dma_buf_alloc(struct mpt_softc *mpt)
{
-#ifndef MPT_USE_BUSDMA
- struct mpt_map_info mi;
-#endif
uint8_t *vptr;
uint32_t pptr, end;
int i, error;
/* Create a child tag for data buffers */
- if (mpt_dma_tag_derive(mpt, mpt->parent_dmat, 1,
- 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
- NULL, NULL, (mpt->max_cam_seg_cnt - 1) * PAGE_SIZE,
- mpt->max_cam_seg_cnt, BUS_SPACE_MAXSIZE_32BIT, 0,
- &mpt->buffer_dmat) != 0) {
+ error = busdma_tag_derive(mpt->parent_dmat, 1, 0, BUS_SPACE_MAXADDR,
+ (mpt->max_cam_seg_cnt - 1) * PAGE_SIZE, mpt->max_cam_seg_cnt,
+ BUS_SPACE_MAXSIZE_32BIT, 0, &mpt->buffer_dmat);
+ if (error != 0) {
mpt_prt(mpt, "cannot create a dma tag for data buffers\n");
- return (1);
+ return (error);
}
/* Create a child tag for request buffers */
- if (mpt_dma_tag_derive(mpt, mpt->parent_dmat, PAGE_SIZE, 0,
- BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
- NULL, NULL, MPT_REQ_MEM_SIZE(mpt), 1, BUS_SPACE_MAXSIZE_32BIT, 0,
- &mpt->request_dmat) != 0) {
+ error = busdma_tag_derive(mpt->parent_dmat, PAGE_SIZE, 0,
+ BUS_SPACE_MAXADDR_32BIT, MPT_REQ_MEM_SIZE(mpt), 1,
+ BUS_SPACE_MAXSIZE_32BIT, 0, &mpt->request_dmat);
+ if (error != 0) {
mpt_prt(mpt, "cannot create a dma tag for requests\n");
- return (1);
+ return (error);
}
-#ifdef MPT_USE_BUSDMA
- error = busdma_mem_alloc((busdma_tag_t)mpt->request_dmat, 0,
- &mpt->request_dmam);
+ error = busdma_mem_alloc(mpt->request_dmat, 0, &mpt->request_md);
if (error != 0) {
mpt_prt(mpt, "cannot allocate DMA memory for requests\n");
return (error);
}
- mpt->request = (void *)busdma_mem_get_seg_addr(mpt->request_dmam, 0);
- mpt->request_phys = busdma_mem_get_seg_busaddr(mpt->request_dmam, 0);
-#else
- /* Allocate some DMA accessible memory for requests */
- if (bus_dmamem_alloc(mpt->request_dmat, (void **)&mpt->request,
- BUS_DMA_NOWAIT | BUS_DMA_COHERENT, &mpt->request_dmap) != 0) {
- mpt_prt(mpt, "cannot allocate %d bytes of request memory\n",
- MPT_REQ_MEM_SIZE(mpt));
- return (1);
- }
-
- mi.mpt = mpt;
- mi.error = 0;
-
- /* Load and lock it into "bus space" */
- bus_dmamap_load(mpt->request_dmat, mpt->request_dmap, mpt->request,
- MPT_REQ_MEM_SIZE(mpt), mpt_map_rquest, &mi, 0);
-
- if (mi.error) {
- mpt_prt(mpt, "error %d loading dma map for DMA request queue\n",
- mi.error);
- return (1);
- }
- mpt->request_phys = mi.phys;
-#endif
+ mpt->request = busdma_md_get_pointer(mpt->request_md, 0);
+ mpt->request_phys = busdma_md_get_busaddr(mpt->request_md, 0);
/*
* Now create per-request dma maps
@@ -2626,11 +2564,11 @@ mpt_dma_buf_alloc(struct mpt_softc *mpt)
req->sense_pbuf = (pptr - MPT_SENSE_SIZE);
req->sense_vbuf = (vptr - MPT_SENSE_SIZE);
- error = bus_dmamap_create(mpt->buffer_dmat, 0, &req->dmap);
+ error = busdma_md_create(mpt->buffer_dmat, 0, &req->md);
if (error) {
mpt_prt(mpt, "error %d creating per-cmd DMA maps\n",
error);
- return (1);
+ return (error);
}
}
@@ -2647,16 +2585,12 @@ mpt_dma_buf_free(struct mpt_softc *mpt)
return;
}
for (i = 0; i < MPT_MAX_REQUESTS(mpt); i++) {
- bus_dmamap_destroy(mpt->buffer_dmat, mpt->request_pool[i].dmap);
+ busdma_md_destroy(mpt->request_pool[i].md);
}
-#ifdef MPT_USE_BUSDMA
-#else
- bus_dmamap_unload(mpt->request_dmat, mpt->request_dmap);
- bus_dmamem_free(mpt->request_dmat, mpt->request, mpt->request_dmap);
- bus_dma_tag_destroy(mpt->request_dmat);
+ busdma_mem_free(mpt->request_md);
+ busdma_tag_destroy(mpt->request_dmat);
mpt->request_dmat = 0;
- bus_dma_tag_destroy(mpt->buffer_dmat);
-#endif
+ busdma_tag_destroy(mpt->buffer_dmat);
}
/*
@@ -2780,7 +2714,6 @@ mpt_configure_ioc(struct mpt_softc *mpt,
if ((mpt->ioc_facts.Flags & MPI_IOCFACTS_FLAGS_FW_DOWNLOAD_BOOT) &&
(mpt->fw_uploaded == 0)) {
- struct mpt_map_info mi;
/*
* In some configurations, the IOC's firmware is
@@ -2792,35 +2725,28 @@ mpt_configure_ioc(struct mpt_softc *mpt,
* the firmware after any hard-reset.
*/
mpt->fw_image_size = mpt->ioc_facts.FWImageSize;
- error = mpt_dma_tag_derive(mpt, mpt->parent_dmat, 1, 0,
- BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
- mpt->fw_image_size, 1, mpt->fw_image_size, 0,
- &mpt->fw_dmat);
+ error = busdma_tag_derive(mpt->parent_dmat, 1, 0,
+ BUS_SPACE_MAXADDR_32BIT, mpt->fw_image_size, 1,
+ mpt->fw_image_size, 0, &mpt->fw_dmat);
if (error != 0) {
mpt_prt(mpt, "cannot create firmware dma tag\n");
return (ENOMEM);
}
- error = bus_dmamem_alloc(mpt->fw_dmat,
- (void **)&mpt->fw_image, BUS_DMA_NOWAIT |
- BUS_DMA_COHERENT, &mpt->fw_dmap);
+ error = busdma_mem_alloc(mpt->fw_dmat,
+ BUS_DMA_NOWAIT | BUS_DMA_COHERENT, &mpt->fw_md);
if (error != 0) {
mpt_prt(mpt, "cannot allocate firmware memory\n");
- bus_dma_tag_destroy(mpt->fw_dmat);
+ busdma_tag_destroy(mpt->fw_dmat);
return (ENOMEM);
}
- mi.mpt = mpt;
- mi.error = 0;
- bus_dmamap_load(mpt->fw_dmat, mpt->fw_dmap,
- mpt->fw_image, mpt->fw_image_size, mpt_map_rquest, &mi, 0);
- mpt->fw_phys = mi.phys;
+ mpt->fw_image = busdma_md_get_pointer(mpt->fw_md, 0);
+ mpt->fw_phys = busdma_md_get_busaddr(mpt->fw_md, 0);
error = mpt_upload_fw(mpt);
if (error != 0) {
mpt_prt(mpt, "firmware upload failed.\n");
- bus_dmamap_unload(mpt->fw_dmat, mpt->fw_dmap);
- bus_dmamem_free(mpt->fw_dmat, mpt->fw_image,
- mpt->fw_dmap);
- bus_dma_tag_destroy(mpt->fw_dmat);
+ busdma_mem_free(mpt->fw_md);
+ busdma_tag_destroy(mpt->fw_dmat);
mpt->fw_image = NULL;
return (EIO);
}
Modified: projects/altix2/sys/dev/mpt/mpt.h
==============================================================================
--- projects/altix2/sys/dev/mpt/mpt.h Tue May 15 01:30:25 2012 (r235459)
+++ projects/altix2/sys/dev/mpt/mpt.h Tue May 15 03:21:36 2012 (r235460)
@@ -234,60 +234,15 @@ int mpt_modevent(module_t, int, void *);
MPT_PERSONALITY_DEPEND(name, mpt_core, 1, 1, 1)
/******************************* Bus DMA Support ******************************/
-/* XXX Need to update bus_dmamap_sync to take a range argument. */
-#define bus_dmamap_sync_range(dma_tag, dmamap, offset, len, op) \
- bus_dmamap_sync(dma_tag, dmamap, op)
-#ifdef MPT_USE_BUSDMA
#include <sys/busdma.h>
-#define mpt_dma_tag_create(mpt, parent_tag, alignment, boundary, \
- lowaddr, highaddr, filter, filterarg, maxsize, \
- nsegments, maxsegsz, flags, dma_tagp) \
- busdma_tag_create((mpt)->dev, lowaddr, alignment, boundary, \
- maxsize, nsegments, maxsegsz, flags, \
- (busdma_tag_t *)dma_tagp)
-
-#define mpt_dma_tag_derive(mpt, parent_tag, alignment, boundary, \
- lowaddr, highaddr, filter, filterarg, maxsize, \
- nsegments, maxsegsz, flags, dma_tagp) \
- busdma_tag_derive((busdma_tag_t)parent_tag, lowaddr, alignment, \
- boundary, maxsize, nsegments, maxsegsz, flags, \
- (busdma_tag_t *)dma_tagp)
-#else
-#if __FreeBSD_version < 600000
-#define bus_get_dma_tag(x) NULL
-#endif
-#if __FreeBSD_version >= 501102
-#define mpt_dma_tag_create(mpt, parent_tag, alignment, boundary, \
- lowaddr, highaddr, filter, filterarg, \
- maxsize, nsegments, maxsegsz, flags, \
- dma_tagp) \
- bus_dma_tag_create(parent_tag, alignment, boundary, \
- lowaddr, highaddr, filter, filterarg, \
- maxsize, nsegments, maxsegsz, flags, \
- busdma_lock_mutex, &(mpt)->mpt_lock, \
- dma_tagp)
-#else
-#define mpt_dma_tag_create(mpt, parent_tag, alignment, boundary, \
- lowaddr, highaddr, filter, filterarg, \
- maxsize, nsegments, maxsegsz, flags, \
- dma_tagp) \
- bus_dma_tag_create(parent_tag, alignment, boundary, \
- lowaddr, highaddr, filter, filterarg, \
- maxsize, nsegments, maxsegsz, flags, \
- dma_tagp)
-#endif
-#define mpt_dma_tag_derive mpt_dma_tag_create
-#endif /* MPT_USE_BUSDMA */
-
struct mpt_map_info {
struct mpt_softc *mpt;
int error;
uint32_t phys;
};
-void mpt_map_rquest(void *, bus_dma_segment_t *, int, int);
/* **************************** NewBUS interrupt Crock ************************/
#if __FreeBSD_version < 700031
#define mpt_setup_intr(d, i, f, U, if, ifa, hp) \
@@ -397,7 +352,7 @@ struct req_entry {
void *sense_vbuf; /* Virtual Address of sense data */
bus_addr_t req_pbuf; /* Physical Address of Entry */
bus_addr_t sense_pbuf; /* Physical Address of sense data */
- bus_dmamap_t dmap; /* DMA map for data buffers */
+ busdma_md_t md; /* DMA map for data buffers */
struct req_entry *chain; /* for SGE overallocations */
struct callout callout; /* Timeout for the request */
};
@@ -750,23 +705,15 @@ struct mpt_softc {
bus_space_tag_t pci_pio_st;
bus_space_handle_t pci_pio_sh;
- bus_dma_tag_t parent_dmat; /* DMA tag for parent PCI bus */
- bus_dma_tag_t reply_dmat; /* DMA tag for reply memory */
-#ifdef MPT_USE_BUSDMA
- busdma_mem_t reply_dmam;
-#else
- bus_dmamap_t reply_dmap; /* DMA map for reply memory */
-#endif
+ busdma_tag_t parent_dmat; /* DMA tag for parent PCI bus */
+ busdma_tag_t reply_dmat; /* DMA tag for reply memory */
+ busdma_md_t reply_md;
uint8_t *reply; /* KVA of reply memory */
bus_addr_t reply_phys; /* BusAddr of reply memory */
- bus_dma_tag_t buffer_dmat; /* DMA tag for buffers */
- bus_dma_tag_t request_dmat; /* DMA tag for request memroy */
-#ifdef MPT_USE_BUSDMA
- busdma_mem_t request_dmam;
-#else
- bus_dmamap_t request_dmap; /* DMA map for request memroy */
-#endif
+ busdma_tag_t buffer_dmat; /* DMA tag for buffers */
+ busdma_tag_t request_dmat; /* DMA tag for request memroy */
+ busdma_md_t request_md;
uint8_t *request; /* KVA of Request memory */
bus_addr_t request_phys; /* BusAddr of request memory */
@@ -830,8 +777,8 @@ struct mpt_softc {
/* FW Image management */
uint32_t fw_image_size;
uint8_t *fw_image;
- bus_dma_tag_t fw_dmat; /* DMA tag for firmware image */
- bus_dmamap_t fw_dmap; /* DMA map for firmware image */
+ busdma_tag_t fw_dmat; /* DMA tag for firmware image */
+ busdma_md_t fw_md; /* DMA map for firmware image */
bus_addr_t fw_phys; /* BusAddr of firmware image */
/* SAS Topology */
Modified: projects/altix2/sys/dev/mpt/mpt_cam.c
==============================================================================
--- projects/altix2/sys/dev/mpt/mpt_cam.c Tue May 15 01:30:25 2012 (r235459)
+++ projects/altix2/sys/dev/mpt/mpt_cam.c Tue May 15 03:21:36 2012 (r235460)
@@ -1266,14 +1266,14 @@ mpt_timeout(void *arg)
}
/*
- * Callback routine from "bus_dmamap_load" or, in simple cases, called directly.
+ * Callback routine for "busdma_md_load" or, in simple cases, called directly.
*
* Takes a list of physical segments and builds the SGL for SCSI IO command
* and forwards the commard to the IOC after one last check that CAM has not
* aborted the transaction.
*/
static void
-mpt_execute_req_a64(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
+mpt_execute_req_a64(void *arg, busdma_md_t md, int error)
{
request_t *req, *trq;
char *mpt_off;
@@ -1281,12 +1281,13 @@ mpt_execute_req_a64(void *arg, bus_dma_s
struct mpt_softc *mpt;
bus_addr_t chain_list_addr;
int first_lim, seg, this_seg_lim;
- uint32_t addr, cur_off, flags, nxt_off, tf;
+ uint32_t cur_off, flags, nxt_off, tf;
void *sglp = NULL;
MSG_REQUEST_HEADER *hdrp;
SGE_SIMPLE64 *se;
SGE_CHAIN64 *ce;
int istgt = 0;
+ u_int nseg;
req = (request_t *)arg;
ccb = req->ccb;
@@ -1297,10 +1298,6 @@ mpt_execute_req_a64(void *arg, bus_dma_s
hdrp = req->req_vbuf;
mpt_off = req->req_vbuf;
- if (error == 0 && ((uint32_t)nseg) >= mpt->max_seg_cnt) {
- error = EFBIG;
- }
-
if (error == 0) {
switch (hdrp->Function) {
case MPI_FUNCTION_SCSI_IO_REQUEST:
@@ -1320,12 +1317,6 @@ mpt_execute_req_a64(void *arg, bus_dma_s
}
}
- if (error == 0 && ((uint32_t)nseg) >= mpt->max_seg_cnt) {
- error = EFBIG;
- mpt_prt(mpt, "segment count %d too large (max %u)\n",
- nseg, mpt->max_seg_cnt);
- }
-
bad:
if (error != 0) {
if (error != EFBIG && error != ENOMEM) {
@@ -1375,6 +1366,8 @@ bad:
memset(&mpt_off[tidx], 0xff, MPT_REQUEST_AREA - tidx);
}
+ nseg = busdma_md_get_nsegs(md);
+
if (nseg == 0) {
SGE_SIMPLE32 *se1 = (SGE_SIMPLE32 *) sglp;
MPI_pSGE_SET_FLAGS(se1,
@@ -1397,21 +1390,21 @@ bad:
}
if (!(ccb->ccb_h.flags & (CAM_SG_LIST_PHYS|CAM_DATA_PHYS))) {
- bus_dmasync_op_t op;
+ u_int op;
if (istgt == 0) {
if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
- op = BUS_DMASYNC_PREREAD;
+ op = BUSDMA_SYNC_PREREAD;
} else {
- op = BUS_DMASYNC_PREWRITE;
+ op = BUSDMA_SYNC_PREWRITE;
}
} else {
if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
- op = BUS_DMASYNC_PREWRITE;
+ op = BUSDMA_SYNC_PREWRITE;
} else {
- op = BUS_DMASYNC_PREREAD;
+ op = BUSDMA_SYNC_PREREAD;
}
}
- bus_dmamap_sync(mpt->buffer_dmat, req->dmap, op);
+ busdma_sync(req->md, op);
}
/*
@@ -1434,19 +1427,22 @@ bad:
}
se = (SGE_SIMPLE64 *) sglp;
- for (seg = 0; seg < first_lim; seg++, se++, dm_segs++) {
+ for (seg = 0; seg < first_lim; seg++, se++) {
+ bus_addr_t addr;
+
tf = flags;
memset(se, 0, sizeof (*se));
- MPI_pSGE_SET_LENGTH(se, dm_segs->ds_len);
- se->Address.Low = htole32(dm_segs->ds_addr & 0xffffffff);
+ MPI_pSGE_SET_LENGTH(se, busdma_md_get_size(md, seg));
+ addr = busdma_md_get_busaddr(md, seg);
+ se->Address.Low = htole32(addr & 0xffffffff);
if (sizeof(bus_addr_t) > 4) {
- addr = ((uint64_t)dm_segs->ds_addr) >> 32;
/* SAS1078 36GB limitation WAR */
- if (mpt->is_1078 && (((uint64_t)dm_segs->ds_addr +
+ if (mpt->is_1078 && ((addr +
MPI_SGE_LENGTH(se->FlagsLength)) >> 32) == 9) {
- addr |= (1 << 31);
+ addr = (addr >> 32) | (1 << 31);
tf |= MPI_SGE_FLAGS_LOCAL_ADDRESS;
- }
+ } else
+ addr >>= 32;
se->Address.High = htole32(addr);
}
if (seg == first_lim - 1) {
@@ -1555,21 +1551,21 @@ bad:
* set the end of list and end of buffer flags.
*/
while (seg < this_seg_lim) {
+ bus_addr_t addr;
tf = flags;
memset(se, 0, sizeof (*se));
- MPI_pSGE_SET_LENGTH(se, dm_segs->ds_len);
- se->Address.Low = htole32(dm_segs->ds_addr &
- 0xffffffff);
+ MPI_pSGE_SET_LENGTH(se, busdma_md_get_size(md, seg));
+ addr = busdma_md_get_busaddr(md, seg);
+ se->Address.Low = htole32(addr & 0xffffffff);
if (sizeof (bus_addr_t) > 4) {
- addr = ((uint64_t)dm_segs->ds_addr) >> 32;
/* SAS1078 36GB limitation WAR */
- if (mpt->is_1078 &&
- (((uint64_t)dm_segs->ds_addr +
+ if (mpt->is_1078 && ((addr +
MPI_SGE_LENGTH(se->FlagsLength)) >>
32) == 9) {
- addr |= (1 << 31);
+ addr = (addr >> 32) | (1 << 31);
tf |= MPI_SGE_FLAGS_LOCAL_ADDRESS;
- }
+ } else
+ addr >>= 32;
se->Address.High = htole32(addr);
}
if (seg == this_seg_lim - 1) {
@@ -1583,7 +1579,6 @@ bad:
se->FlagsLength = htole32(se->FlagsLength);
se++;
seg++;
- dm_segs++;
}
next_chain:
@@ -1640,7 +1635,7 @@ out:
"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) {
- bus_dmamap_unload(mpt->buffer_dmat, req->dmap);
+ busdma_md_unload(req->md);
}
ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d", __LINE__));
@@ -1685,7 +1680,7 @@ out:
}
static void
-mpt_execute_req(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
+mpt_execute_req(void *arg, busdma_md_t md, int error)
{
request_t *req, *trq;
char *mpt_off;
@@ -1698,6 +1693,7 @@ mpt_execute_req(void *arg, bus_dma_segme
SGE_SIMPLE32 *se;
SGE_CHAIN32 *ce;
int istgt = 0;
+ u_int nseg;
req = (request_t *)arg;
ccb = req->ccb;
@@ -1708,11 +1704,6 @@ mpt_execute_req(void *arg, bus_dma_segme
hdrp = req->req_vbuf;
mpt_off = req->req_vbuf;
-
- if (error == 0 && ((uint32_t)nseg) >= mpt->max_seg_cnt) {
- error = EFBIG;
- }
-
if (error == 0) {
switch (hdrp->Function) {
case MPI_FUNCTION_SCSI_IO_REQUEST:
@@ -1731,12 +1722,6 @@ mpt_execute_req(void *arg, bus_dma_segme
}
}
- if (error == 0 && ((uint32_t)nseg) >= mpt->max_seg_cnt) {
- error = EFBIG;
- mpt_prt(mpt, "segment count %d too large (max %u)\n",
- nseg, mpt->max_seg_cnt);
- }
-
bad:
if (error != 0) {
if (error != EFBIG && error != ENOMEM) {
@@ -1786,6 +1771,8 @@ bad:
memset(&mpt_off[tidx], 0xff, MPT_REQUEST_AREA - tidx);
}
+ nseg = busdma_md_get_nsegs(md);
+
if (nseg == 0) {
SGE_SIMPLE32 *se1 = (SGE_SIMPLE32 *) sglp;
MPI_pSGE_SET_FLAGS(se1,
@@ -1808,21 +1795,21 @@ bad:
}
if (!(ccb->ccb_h.flags & (CAM_SG_LIST_PHYS|CAM_DATA_PHYS))) {
- bus_dmasync_op_t op;
+ u_int op;
if (istgt) {
if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
- op = BUS_DMASYNC_PREREAD;
+ op = BUSDMA_SYNC_PREREAD;
} else {
- op = BUS_DMASYNC_PREWRITE;
+ op = BUSDMA_SYNC_PREWRITE;
}
} else {
if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
- op = BUS_DMASYNC_PREWRITE;
+ op = BUSDMA_SYNC_PREWRITE;
} else {
- op = BUS_DMASYNC_PREREAD;
+ op = BUSDMA_SYNC_PREREAD;
}
}
- bus_dmamap_sync(mpt->buffer_dmat, req->dmap, op);
+ busdma_sync(req->md, op);
}
/*
@@ -1845,13 +1832,13 @@ bad:
}
se = (SGE_SIMPLE32 *) sglp;
- for (seg = 0; seg < first_lim; seg++, se++, dm_segs++) {
+ for (seg = 0; seg < first_lim; seg++, se++) {
uint32_t tf;
memset(se, 0,sizeof (*se));
- se->Address = htole32(dm_segs->ds_addr);
+ se->Address = htole32(busdma_md_get_busaddr(md, seg));
- MPI_pSGE_SET_LENGTH(se, dm_segs->ds_len);
+ MPI_pSGE_SET_LENGTH(se, busdma_md_get_size(md, seg));
tf = flags;
if (seg == first_lim - 1) {
tf |= MPI_SGE_FLAGS_LAST_ELEMENT;
@@ -1963,9 +1950,9 @@ bad:
*/
while (seg < this_seg_lim) {
memset(se, 0, sizeof (*se));
- se->Address = htole32(dm_segs->ds_addr);
+ se->Address = htole32(busdma_md_get_busaddr(md, seg));
- MPI_pSGE_SET_LENGTH(se, dm_segs->ds_len);
+ MPI_pSGE_SET_LENGTH(se, busdma_md_get_size(md, seg));
tf = flags;
if (seg == this_seg_lim - 1) {
tf |= MPI_SGE_FLAGS_LAST_ELEMENT;
@@ -1978,7 +1965,6 @@ bad:
se->FlagsLength = htole32(se->FlagsLength);
se++;
seg++;
- dm_segs++;
}
next_chain:
@@ -2035,7 +2021,7 @@ out:
"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) {
- bus_dmamap_unload(mpt->buffer_dmat, req->dmap);
+ busdma_md_unload(req->md);
}
ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d", __LINE__));
@@ -2087,7 +2073,7 @@ mpt_start(struct cam_sim *sim, union ccb
MSG_SCSI_IO_REQUEST *mpt_req;
struct ccb_scsiio *csio = &ccb->csio;
struct ccb_hdr *ccbh = &ccb->ccb_h;
- bus_dmamap_callback_t *cb;
+ busdma_callback_f cb;
target_id_t tgt;
int raid_passthru;
@@ -2255,9 +2241,9 @@ mpt_start(struct cam_sim *sim, union ccb
*/
int error;
int s = splsoftvm();
- error = bus_dmamap_load(mpt->buffer_dmat,
- req->dmap, csio->data_ptr, csio->dxfer_len,
- cb, req, 0);
+ error = busdma_md_load_linear(req->md,
+ csio->data_ptr, csio->dxfer_len, cb, req,
+ 0);
splx(s);
if (error == EINPROGRESS) {
/*
@@ -2270,6 +2256,7 @@ mpt_start(struct cam_sim *sim, union ccb
ccbh->status |= CAM_RELEASE_SIMQ;
}
} else {
+#if 0
/*
* We have been given a pointer to single
* physical buffer.
@@ -2279,8 +2266,10 @@ mpt_start(struct cam_sim *sim, union ccb
(bus_addr_t)(vm_offset_t)csio->data_ptr;
seg.ds_len = csio->dxfer_len;
(*cb)(req, &seg, 1, 0);
+#endif
}
} else {
+#if 0
/*
* We have been given a list of addresses.
* This case could be easily supported but they are not
@@ -2295,9 +2284,12 @@ mpt_start(struct cam_sim *sim, union ccb
segs = (struct bus_dma_segment *)csio->data_ptr;
(*cb)(req, segs, csio->sglist_cnt, 0);
}
+#endif
}
} else {
+#if 0
(*cb)(req, NULL, 0, 0);
+#endif
}
}
@@ -2703,14 +2695,14 @@ mpt_scsi_reply_handler(struct mpt_softc
ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- bus_dmasync_op_t op;
+ u_int op;
if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)
- op = BUS_DMASYNC_POSTREAD;
+ op = BUSDMA_SYNC_POSTREAD;
else
- op = BUS_DMASYNC_POSTWRITE;
- bus_dmamap_sync(mpt->buffer_dmat, req->dmap, op);
- bus_dmamap_unload(mpt->buffer_dmat, req->dmap);
+ op = BUSDMA_SYNC_POSTWRITE;
+ busdma_sync(req->md, op);
+ busdma_md_unload(req->md);
}
if (reply_frame == NULL) {
@@ -4555,7 +4547,7 @@ mpt_target_start_io(struct mpt_softc *mp
}
if (csio->dxfer_len) {
- bus_dmamap_callback_t *cb;
+ busdma_callback_f cb;
PTR_MSG_TARGET_ASSIST_REQUEST ta;
request_t *req;
@@ -4651,15 +4643,16 @@ mpt_target_start_io(struct mpt_softc *mp
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);
+ error = busdma_md_load_linear(req->md,
+ 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 {
+#if 0
/*
* We have been given a pointer to single
* physical buffer.
@@ -4669,8 +4662,10 @@ mpt_target_start_io(struct mpt_softc *mp
(vm_offset_t)csio->data_ptr;
seg.ds_len = csio->dxfer_len;
(*cb)(req, &seg, 1, 0);
+#endif
}
} else {
+#if 0
/*
* We have been given a list of addresses.
* This case could be easily supported but they are not
@@ -4685,6 +4680,7 @@ mpt_target_start_io(struct mpt_softc *mp
sgs = (struct bus_dma_segment *)csio->data_ptr;
(*cb)(req, sgs, csio->sglist_cnt, 0);
}
+#endif
}
CAMLOCK_2_MPTLOCK(mpt);
} else {
Modified: projects/altix2/sys/dev/mpt/mpt_pci.c
==============================================================================
--- projects/altix2/sys/dev/mpt/mpt_pci.c Tue May 15 01:30:25 2012 (r235459)
+++ projects/altix2/sys/dev/mpt/mpt_pci.c Tue May 15 03:21:36 2012 (r235460)
@@ -734,9 +734,6 @@ static int
mpt_dma_mem_alloc(struct mpt_softc *mpt)
{
size_t len;
-#ifndef MPT_USE_BUSDMA
- struct mpt_map_info mi;
-#endif
int error;
/* Check if we alreay have allocated the reply memory */
@@ -766,62 +763,30 @@ mpt_dma_mem_alloc(struct mpt_softc *mpt)
* Align at byte boundaries,
* Limit to 32-bit addressing for request/reply queues.
*/
- error = mpt_dma_tag_create(mpt, /*parent*/bus_get_dma_tag(mpt->dev),
- /*alignment*/1, /*boundary*/0, /*lowaddr*/BUS_SPACE_MAXADDR,
- /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL,
- /*maxsize*/BUS_SPACE_MAXSIZE_32BIT,
- /*nsegments*/BUS_SPACE_UNRESTRICTED,
- /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT, /*flags*/0,
- &mpt->parent_dmat);
+ error = busdma_tag_create(mpt->dev, 1, 0, BUS_SPACE_MAXADDR,
+ BUS_SPACE_MAXSIZE_32BIT, BUS_SPACE_UNRESTRICTED,
+ BUS_SPACE_MAXSIZE_32BIT, 0, &mpt->parent_dmat);
if (error != 0) {
mpt_prt(mpt, "cannot create parent dma tag\n");
return (error);
}
/* Create a child tag for reply buffers */
- error = mpt_dma_tag_derive(mpt, mpt->parent_dmat, PAGE_SIZE, 0,
- BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
- NULL, NULL, 2 * PAGE_SIZE, 1, BUS_SPACE_MAXSIZE_32BIT, 0,
- &mpt->reply_dmat);
+ error = busdma_tag_derive(mpt->parent_dmat, PAGE_SIZE, 0,
+ BUS_SPACE_MAXADDR_32BIT, 2 * PAGE_SIZE, 1, BUS_SPACE_MAXSIZE_32BIT,
+ 0, &mpt->reply_dmat);
if (error != 0) {
mpt_prt(mpt, "cannot create a dma tag for replies\n");
return (error);
}
-#ifdef MPT_USE_BUSDMA
- error = busdma_mem_alloc((busdma_tag_t)mpt->reply_dmat, 0,
- &mpt->reply_dmam);
+ error = busdma_mem_alloc(mpt->reply_dmat, 0, &mpt->reply_md);
if (error != 0) {
mpt_prt(mpt, "cannot allocate DMA memory for replies\n");
return (error);
}
- mpt->reply = (void *)busdma_mem_get_seg_addr(mpt->reply_dmam, 0);
- mpt->reply_phys = busdma_mem_get_seg_busaddr(mpt->reply_dmam, 0);
-#else
- /* Allocate some DMA accessible memory for replies */
- error = bus_dmamem_alloc(mpt->reply_dmat, (void **)&mpt->reply,
- BUS_DMA_NOWAIT, &mpt->reply_dmap);
- if (error != 0) {
- mpt_prt(mpt, "cannot allocate %lu bytes of reply memory\n",
- (u_long) (2 * PAGE_SIZE));
- return (error);
- }
-
- mi.mpt = mpt;
- mi.error = 0;
-
- /* Load and lock it into "bus space" */
- bus_dmamap_load(mpt->reply_dmat, mpt->reply_dmap, mpt->reply,
- 2 * PAGE_SIZE, mpt_map_rquest, &mi, 0);
-
- if (mi.error) {
- mpt_prt(mpt, "error %d loading dma map for DMA reply queue\n",
- mi.error);
- return (mi.error);
- }
- mpt->reply_phys = mi.phys;
-#endif /* MPT_USE_BUSDMA */
-
+ mpt->reply = busdma_md_get_pointer(mpt->reply_md, 0);
+ mpt->reply_phys = busdma_md_get_busaddr(mpt->reply_md, 0);
return (0);
}
@@ -836,13 +801,9 @@ mpt_dma_mem_free(struct mpt_softc *mpt)
mpt_lprt(mpt, MPT_PRT_DEBUG, "already released dma memory\n");
return;
}
-#ifdef MPT_USE_BUSDMA
-#else
- bus_dmamap_unload(mpt->reply_dmat, mpt->reply_dmap);
- bus_dmamem_free(mpt->reply_dmat, mpt->reply, mpt->reply_dmap);
- bus_dma_tag_destroy(mpt->reply_dmat);
- bus_dma_tag_destroy(mpt->parent_dmat);
-#endif
+ busdma_mem_free(mpt->reply_md);
+ busdma_tag_destroy(mpt->reply_dmat);
+ busdma_tag_destroy(mpt->parent_dmat);
mpt->reply_dmat = NULL;
free(mpt->request_pool, M_DEVBUF);
mpt->request_pool = NULL;
Modified: projects/altix2/sys/dev/mpt/mpt_user.c
==============================================================================
--- projects/altix2/sys/dev/mpt/mpt_user.c Tue May 15 01:30:25 2012 (r235459)
+++ projects/altix2/sys/dev/mpt/mpt_user.c Tue May 15 03:21:36 2012 (r235460)
@@ -48,8 +48,8 @@ struct mpt_user_raid_action_result {
};
struct mpt_page_memory {
- bus_dma_tag_t tag;
- bus_dmamap_t map;
+ busdma_tag_t tag;
+ busdma_md_t map;
bus_addr_t paddr;
void *vaddr;
};
@@ -192,7 +192,6 @@ static int
mpt_alloc_buffer(struct mpt_softc *mpt, struct mpt_page_memory *page_mem,
size_t len)
{
- struct mpt_map_info mi;
int error;
page_mem->vaddr = NULL;
@@ -200,29 +199,18 @@ mpt_alloc_buffer(struct mpt_softc *mpt,
/* Limit requests to 16M. */
if (len > 16 * 1024 * 1024)
return (ENOSPC);
- error = mpt_dma_tag_derive(mpt, mpt->parent_dmat, 1, 0,
- BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
- len, 1, len, 0, &page_mem->tag);
+ error = busdma_tag_derive(mpt->parent_dmat, 1, 0,
+ BUS_SPACE_MAXADDR_32BIT, len, 1, len, 0, &page_mem->tag);
if (error)
return (error);
- error = bus_dmamem_alloc(page_mem->tag, &page_mem->vaddr,
+ error = busdma_mem_alloc(page_mem->tag,
BUS_DMA_NOWAIT | BUS_DMA_COHERENT, &page_mem->map);
if (error) {
- bus_dma_tag_destroy(page_mem->tag);
+ busdma_tag_destroy(page_mem->tag);
return (error);
}
- mi.mpt = mpt;
- error = bus_dmamap_load(page_mem->tag, page_mem->map, page_mem->vaddr,
- len, mpt_map_rquest, &mi, BUS_DMA_NOWAIT);
- if (error == 0)
- error = mi.error;
- if (error) {
- bus_dmamem_free(page_mem->tag, page_mem->vaddr, page_mem->map);
- bus_dma_tag_destroy(page_mem->tag);
- page_mem->vaddr = NULL;
- return (error);
- }
- page_mem->paddr = mi.phys;
+ page_mem->vaddr = busdma_md_get_pointer(page_mem->map, 0);
+ page_mem->paddr = busdma_md_get_busaddr(page_mem->map, 0);
return (0);
}
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-projects
mailing list