dmaga.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* SBus DMA gate array 'driver'
*/
#include <sys/ddi_impldefs.h>
#include <sys/ddi_subrdefs.h>
typedef struct dma_softc {
int dma_use; /* use count */
} dma_softc_t;
static dma_softc_t *dma_softc;
/*
* Configuration data structures
*/
static struct cb_ops dma_cb_ops = {
nodev, /* open */
nodev, /* close */
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
nodev, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
nochpoll, /* poll */
ddi_prop_op, /* cb_prop_op */
0, /* streamtab */
CB_REV, /* rev */
nodev, /* int (*cb_aread)() */
nodev /* int (*cb_awrite)() */
};
static struct bus_ops dma_bus_ops = {
0,
0,
0,
0, /* (*bus_get_eventcookie)(); */
0, /* (*bus_add_eventcall)(); */
0, /* (*bus_remove_eventcall)(); */
0, /* (*bus_post_event)(); */
0, /* bus_intr_ctl */
0, /* bus_config */
0, /* bus_unconfig */
0, /* bus_fm_init */
0, /* bus_fm_fini */
0, /* bus_fm_access_enter */
0, /* bus_fm_access_exit */
0, /* bus_power */
i_ddi_intr_ops /* bus_intr_op */
};
DEVO_REV, /* devo_rev, */
0, /* refcnt */
ddi_no_info, /* info */
nulldev, /* identify */
nulldev, /* probe */
dmaattach, /* attach */
dmadetach, /* detach */
nodev, /* reset */
&dma_cb_ops, /* driver operations */
&dma_bus_ops, /* bus operations */
nulldev /* power */
};
&mod_driverops, /* Type of module. This one is a driver */
"Direct Memory Access driver %I%", /* Name and version */
&dma_ops, /* driver ops */
};
static struct modlinkage modlinkage = {
};
static kmutex_t dmaautolock;
int
_init(void)
{
int status;
if (status != 0) {
}
return (status);
}
int
_fini(void)
{
int status;
if (status == 0) {
}
return (status);
}
int
{
}
/*ARGSUSED1*/
static int
{
switch (cmd) {
case DDI_ATTACH:
break;
case DDI_RESUME:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
/*
* map in the device registers
*/
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*ARGSUSED*/
static int
{
switch (cmd) {
case DDI_SUSPEND:
return (DDI_SUCCESS);
case DDI_DETACH:
break;
}
return (DDI_FAILURE);
}
} else {
}
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
/*
* For DMA debugging:
*
* #define DMA_ALLOC_DEBUG
*/
#ifdef DMA_ALLOC_DEBUG
int dma_alloc_debug = 1;
#endif /* DMA_ALLOC_DEBUG */
struct dmaga *
{
/*
* What we need to do is 'find' the dma gate array
* 'associated' with the caller.
*
* We first try to find a dma gate array which is the
* parent of the caller.
*/
#ifdef DMA_ALLOC_DEBUG
if (dma_alloc_debug) {
"?dma_alloc %s esp%d -> %s dma%d (dp %x)",
}
#endif /* DMA_ALLOC_DEBUG */
}
}
/*
* Next we try to find a dma gate array by checking the
* 'reg' property
*/
#ifdef DMA_ALLOC_DEBUG
if (dma_alloc_debug) {
"?dma_alloc %s esp%d -> %s dma%d (dp %x)",
}
#endif /* DMA_ALLOC_DEBUG */
}
}
/*
* Next we try to find a dma gate array which claims 'affinity'
*/
#ifdef DMA_ALLOC_DEBUG
if (dma_alloc_debug) {
"?dma_alloc %s esp%d -> %s dma%d (dp %x)",
}
#endif /* DMA_ALLOC_DEBUG */
}
}
#ifdef DMA_ALLOC_DEBUG
if (dma_alloc_debug)
#endif /* DMA_ALLOC_DEBUG */
return ((struct dmaga *)0);
}
void
{
/*
* We used to lock exclusive access upon the mapped
* in registers for the DMA gate array, but this has
* not been actually ever needed. If we end up needing
* it, then this routine becomes useful for that.
*
* Barring that, this routine is useful for tracking
* who might still be using a dma gate array's registers.
*
* XXX We should probably complain if the dma_use count
* goes negative.
*/
break;
}
}
}
/*
* this is a workaround for 1149413. If multiple scsi cards show
* up in one SBus slot we have a problem. If we can't figure out the
* correct dma engine by looking at the parent and if we don't have
* a nexus driver that handles affinity we 'guess' the right dma
* engine by looking at the 'reg' property of dma engine and scsi
* card. If they have the right 'distance' we assume we got the
* right one. This turns out to be only a problem for third party
* SBus expansion boxes with missing nexus driver and sport8 scsi
* cards where esp and dma are siblings.
*/
/*
* 'distance' between esp and dma reg property if esp and dma
* are siblings in the device tree.
*/
static int restrict_affinity = 1;
int
{
return (DDI_FAILURE);
} else {
}
(restrict_affinity_delta == delta)))
return (DDI_SUCCESS);
}
return (DDI_FAILURE);
}