ghd_dma.c revision 507c32411f3f101e90ca2120f042b5ee698ba1d5
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * CDDL HEADER START
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * The contents of this file are subject to the terms of the
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * Common Development and Distribution License (the "License").
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * You may not use this file except in compliance with the License.
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * See the License for the specific language governing permissions
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * and limitations under the License.
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * When distributing Covered Code, include this CDDL HEADER in each
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * If applicable, add the following below this CDDL HEADER, with the
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * fields enclosed by brackets "[]" replaced with your own identifying
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * information: Portions Copyright [yyyy] [name of copyright owner]
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * CDDL HEADER END
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * Use is subject to license terms.
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf#pragma ident "%Z%%M% %I% %E% SMI"
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf "unbind handle failed");
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf GDBG_DMA(("ghd_dma_attr_free: ddi_dma_free 0x%p\n", gcmdp));
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf GDBG_DMA(("ghd_dma_attr_get: start: gcmdp 0x%p sg_attrp 0x%p\n",
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * First time, need to establish the handle.
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf status = ddi_dma_alloc_handle(cccp->ccc_hba_dip, sg_attrp, callback,
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf status = ddi_dma_buf_bind_handle(gcmdp->cmd_dma_handle, bp, dma_flags,
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf GDBG_DMA(("ghd_dma_attr_get: setup: gcmdp 0x%p status %d h 0x%p "
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf /* enable first (and only) call to ddi_dma_getwin */
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf /* enable first call to ddi_dma_getwin */
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf if (ddi_dma_numwin(gcmdp->cmd_dma_handle, &gcmdp->cmd_wcount) !=
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf /* initialize the loop controls for ghd_dmaget_next_attr() */
507c32411f3f101e90ca2120f042b5ee698ba1d5mlfghd_dmaget_next_attr(ccc_t *cccp, gcmd_t *gcmdp, long max_transfer_cnt,
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf GDBG_DMA(("ghd_dma_attr_get: start: gcmdp 0x%p h 0x%p c 0x%x\n",
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * Disable single-segment Scatter/Gather option
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * if can't do this transfer in a single segment,
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf for (;;) {
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * call the controller specific S/G function
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf (*cccp->ccc_sg_func)(gcmdp, &cookie, single_seg, num_segs);
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf /* take care of the loop-bookkeeping */
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * if this was the last cookie in the current window
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * set the loop controls start the next window and
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * exit so the HBA can do this partial transfer
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * reached the end of buffer. This should not happen.
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * start the next window, and get its first cookie
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * get the next cookie in the current window
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * start the Scatter/Gather loop passing in the first
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * cookie obtained above