summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVikram Hegde <Vikram.Hegde@Sun.COM>2009-07-30 11:09:45 -0700
committerVikram Hegde <Vikram.Hegde@Sun.COM>2009-07-30 11:09:45 -0700
commitb51bbbf59a7a1941f5e9531370c2f87d8cd7f621 (patch)
treedcd3144b874c19fcdf4a11a1d29b9e2eed9bf0b5
parent46129c212ab4570ca5c6f845fe853f7e18789976 (diff)
downloadillumos-joyent-b51bbbf59a7a1941f5e9531370c2f87d8cd7f621.tar.gz
6859941 fix for 6855752 is incorrect
-rw-r--r--usr/src/uts/common/os/sunddi.c103
-rw-r--r--usr/src/uts/i86pc/io/rootnex.c59
-rw-r--r--usr/src/uts/intel/io/iommulib.c2
-rw-r--r--usr/src/uts/intel/sys/iommulib.h11
4 files changed, 73 insertions, 102 deletions
diff --git a/usr/src/uts/common/os/sunddi.c b/usr/src/uts/common/os/sunddi.c
index 827ee186ee..5934f01a37 100644
--- a/usr/src/uts/common/os/sunddi.c
+++ b/usr/src/uts/common/os/sunddi.c
@@ -884,7 +884,8 @@ ddi_dma_mctl(dev_info_t *dip, dev_info_t *rdip,
{
int (*fp)();
- dip = (dev_info_t *)DEVI(dip)->devi_bus_dma_ctl;
+ if (dip != ddi_root_node())
+ dip = (dev_info_t *)DEVI(dip)->devi_bus_dma_ctl;
fp = DEVI(dip)->devi_ops->devo_bus_ops->bus_dma_ctl;
return ((*fp) (dip, rdip, handle, request, offp, lenp, objp, flags));
}
@@ -988,40 +989,40 @@ int
ddi_dma_map(dev_info_t *dip, dev_info_t *rdip,
struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep)
{
- dev_info_t *hdip;
int (*funcp)(dev_info_t *, dev_info_t *, struct ddi_dma_req *,
ddi_dma_handle_t *);
- hdip = (dev_info_t *)DEVI(dip)->devi_bus_dma_map;
+ if (dip != ddi_root_node())
+ dip = (dev_info_t *)DEVI(dip)->devi_bus_dma_map;
- funcp = DEVI(hdip)->devi_ops->devo_bus_ops->bus_dma_map;
- return ((*funcp)(hdip, rdip, dmareqp, handlep));
+ funcp = DEVI(dip)->devi_ops->devo_bus_ops->bus_dma_map;
+ return ((*funcp)(dip, rdip, dmareqp, handlep));
}
int
ddi_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep)
{
- dev_info_t *hdip;
int (*funcp)(dev_info_t *, dev_info_t *, ddi_dma_attr_t *,
int (*)(caddr_t), caddr_t, ddi_dma_handle_t *);
- hdip = (dev_info_t *)DEVI(dip)->devi_bus_dma_allochdl;
+ if (dip != ddi_root_node())
+ dip = (dev_info_t *)DEVI(dip)->devi_bus_dma_allochdl;
- funcp = DEVI(hdip)->devi_ops->devo_bus_ops->bus_dma_allochdl;
- return ((*funcp)(hdip, rdip, attr, waitfp, arg, handlep));
+ funcp = DEVI(dip)->devi_ops->devo_bus_ops->bus_dma_allochdl;
+ return ((*funcp)(dip, rdip, attr, waitfp, arg, handlep));
}
int
ddi_dma_freehdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handlep)
{
- dev_info_t *hdip;
int (*funcp)(dev_info_t *, dev_info_t *, ddi_dma_handle_t);
- hdip = (dev_info_t *)DEVI(dip)->devi_bus_dma_allochdl;
+ if (dip != ddi_root_node())
+ dip = (dev_info_t *)DEVI(dip)->devi_bus_dma_allochdl;
- funcp = DEVI(hdip)->devi_ops->devo_bus_ops->bus_dma_freehdl;
- return ((*funcp)(hdip, rdip, handlep));
+ funcp = DEVI(dip)->devi_ops->devo_bus_ops->bus_dma_freehdl;
+ return ((*funcp)(dip, rdip, handlep));
}
int
@@ -1029,27 +1030,27 @@ ddi_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
ddi_dma_cookie_t *cp, uint_t *ccountp)
{
- dev_info_t *hdip;
int (*funcp)(dev_info_t *, dev_info_t *, ddi_dma_handle_t,
struct ddi_dma_req *, ddi_dma_cookie_t *, uint_t *);
- hdip = (dev_info_t *)DEVI(dip)->devi_bus_dma_bindhdl;
+ if (dip != ddi_root_node())
+ dip = (dev_info_t *)DEVI(dip)->devi_bus_dma_bindhdl;
- funcp = DEVI(hdip)->devi_ops->devo_bus_ops->bus_dma_bindhdl;
- return ((*funcp)(hdip, rdip, handle, dmareq, cp, ccountp));
+ funcp = DEVI(dip)->devi_ops->devo_bus_ops->bus_dma_bindhdl;
+ return ((*funcp)(dip, rdip, handle, dmareq, cp, ccountp));
}
int
ddi_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle)
{
- dev_info_t *hdip;
int (*funcp)(dev_info_t *, dev_info_t *, ddi_dma_handle_t);
- hdip = (dev_info_t *)DEVI(dip)->devi_bus_dma_unbindhdl;
+ if (dip != ddi_root_node())
+ dip = (dev_info_t *)DEVI(dip)->devi_bus_dma_unbindhdl;
- funcp = DEVI(hdip)->devi_ops->devo_bus_ops->bus_dma_unbindhdl;
- return ((*funcp)(hdip, rdip, handle));
+ funcp = DEVI(dip)->devi_ops->devo_bus_ops->bus_dma_unbindhdl;
+ return ((*funcp)(dip, rdip, handle));
}
@@ -1058,14 +1059,14 @@ ddi_dma_flush(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle, off_t off, size_t len,
uint_t cache_flags)
{
- dev_info_t *hdip;
int (*funcp)(dev_info_t *, dev_info_t *, ddi_dma_handle_t,
off_t, size_t, uint_t);
- hdip = (dev_info_t *)DEVI(dip)->devi_bus_dma_flush;
+ if (dip != ddi_root_node())
+ dip = (dev_info_t *)DEVI(dip)->devi_bus_dma_flush;
- funcp = DEVI(hdip)->devi_ops->devo_bus_ops->bus_dma_flush;
- return ((*funcp)(hdip, rdip, handle, off, len, cache_flags));
+ funcp = DEVI(dip)->devi_ops->devo_bus_ops->bus_dma_flush;
+ return ((*funcp)(dip, rdip, handle, off, len, cache_flags));
}
int
@@ -1073,14 +1074,14 @@ ddi_dma_win(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle, uint_t win, off_t *offp,
size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp)
{
- dev_info_t *hdip;
int (*funcp)(dev_info_t *, dev_info_t *, ddi_dma_handle_t,
uint_t, off_t *, size_t *, ddi_dma_cookie_t *, uint_t *);
- hdip = (dev_info_t *)DEVI(dip)->devi_bus_dma_win;
+ if (dip != ddi_root_node())
+ dip = (dev_info_t *)DEVI(dip)->devi_bus_dma_win;
- funcp = DEVI(hdip)->devi_ops->devo_bus_ops->bus_dma_win;
- return ((*funcp)(hdip, rdip, handle, win, offp, lenp,
+ funcp = DEVI(dip)->devi_ops->devo_bus_ops->bus_dma_win;
+ return ((*funcp)(dip, rdip, handle, win, offp, lenp,
cookiep, ccountp));
}
@@ -1088,7 +1089,7 @@ int
ddi_dma_sync(ddi_dma_handle_t h, off_t o, size_t l, uint_t whom)
{
ddi_dma_impl_t *hp = (ddi_dma_impl_t *)h;
- dev_info_t *hdip, *dip;
+ dev_info_t *dip, *rdip;
int (*funcp)(dev_info_t *, dev_info_t *, ddi_dma_handle_t, off_t,
size_t, uint_t);
@@ -1101,23 +1102,25 @@ ddi_dma_sync(ddi_dma_handle_t h, off_t o, size_t l, uint_t whom)
if ((hp->dmai_rflags & DMP_NOSYNC) == DMP_NOSYNC)
return (DDI_SUCCESS);
- dip = hp->dmai_rdip;
- hdip = (dev_info_t *)DEVI(dip)->devi_bus_dma_flush;
- funcp = DEVI(hdip)->devi_ops->devo_bus_ops->bus_dma_flush;
- return ((*funcp)(hdip, dip, h, o, l, whom));
+ dip = rdip = hp->dmai_rdip;
+ if (dip != ddi_root_node())
+ dip = (dev_info_t *)DEVI(dip)->devi_bus_dma_flush;
+ funcp = DEVI(dip)->devi_ops->devo_bus_ops->bus_dma_flush;
+ return ((*funcp)(dip, rdip, h, o, l, whom));
}
int
ddi_dma_unbind_handle(ddi_dma_handle_t h)
{
ddi_dma_impl_t *hp = (ddi_dma_impl_t *)h;
- dev_info_t *hdip, *dip;
+ dev_info_t *dip, *rdip;
int (*funcp)(dev_info_t *, dev_info_t *, ddi_dma_handle_t);
- dip = hp->dmai_rdip;
- hdip = (dev_info_t *)DEVI(dip)->devi_bus_dma_unbindhdl;
- funcp = DEVI(dip)->devi_bus_dma_unbindfunc;
- return ((*funcp)(hdip, dip, h));
+ dip = rdip = hp->dmai_rdip;
+ if (dip != ddi_root_node())
+ dip = (dev_info_t *)DEVI(dip)->devi_bus_dma_unbindhdl;
+ funcp = DEVI(rdip)->devi_bus_dma_unbindfunc;
+ return ((*funcp)(dip, rdip, h));
}
#endif /* !__sparc */
@@ -7114,7 +7117,7 @@ ddi_dma_buf_bind_handle(ddi_dma_handle_t handle, struct buf *bp,
ddi_dma_cookie_t *cookiep, uint_t *ccountp)
{
ddi_dma_impl_t *hp = (ddi_dma_impl_t *)handle;
- dev_info_t *hdip, *dip;
+ dev_info_t *dip, *rdip;
struct ddi_dma_req dmareq;
int (*funcp)();
@@ -7157,10 +7160,11 @@ ddi_dma_buf_bind_handle(ddi_dma_handle_t handle, struct buf *bp,
}
}
- dip = hp->dmai_rdip;
- hdip = (dev_info_t *)DEVI(dip)->devi_bus_dma_bindhdl;
- funcp = DEVI(dip)->devi_bus_dma_bindfunc;
- return ((*funcp)(hdip, dip, handle, &dmareq, cookiep, ccountp));
+ dip = rdip = hp->dmai_rdip;
+ if (dip != ddi_root_node())
+ dip = (dev_info_t *)DEVI(dip)->devi_bus_dma_bindhdl;
+ funcp = DEVI(rdip)->devi_bus_dma_bindfunc;
+ return ((*funcp)(dip, rdip, handle, &dmareq, cookiep, ccountp));
}
int
@@ -7169,7 +7173,7 @@ ddi_dma_addr_bind_handle(ddi_dma_handle_t handle, struct as *as,
caddr_t arg, ddi_dma_cookie_t *cookiep, uint_t *ccountp)
{
ddi_dma_impl_t *hp = (ddi_dma_impl_t *)handle;
- dev_info_t *hdip, *dip;
+ dev_info_t *dip, *rdip;
struct ddi_dma_req dmareq;
int (*funcp)();
@@ -7185,10 +7189,11 @@ ddi_dma_addr_bind_handle(ddi_dma_handle_t handle, struct as *as,
dmareq.dmar_object.dmao_obj.virt_obj.v_addr = addr;
dmareq.dmar_object.dmao_obj.virt_obj.v_priv = NULL;
- dip = hp->dmai_rdip;
- hdip = (dev_info_t *)DEVI(dip)->devi_bus_dma_bindhdl;
- funcp = DEVI(dip)->devi_bus_dma_bindfunc;
- return ((*funcp)(hdip, dip, handle, &dmareq, cookiep, ccountp));
+ dip = rdip = hp->dmai_rdip;
+ if (dip != ddi_root_node())
+ dip = (dev_info_t *)DEVI(dip)->devi_bus_dma_bindhdl;
+ funcp = DEVI(rdip)->devi_bus_dma_bindfunc;
+ return ((*funcp)(dip, rdip, handle, &dmareq, cookiep, ccountp));
}
void
diff --git a/usr/src/uts/i86pc/io/rootnex.c b/usr/src/uts/i86pc/io/rootnex.c
index b4ae6eba8e..f2f55a7bd4 100644
--- a/usr/src/uts/i86pc/io/rootnex.c
+++ b/usr/src/uts/i86pc/io/rootnex.c
@@ -236,11 +236,6 @@ static int rootnex_coredma_sync(dev_info_t *dip, dev_info_t *rdip,
static int rootnex_coredma_win(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle, uint_t win, off_t *offp, size_t *lenp,
ddi_dma_cookie_t *cookiep, uint_t *ccountp);
-static int rootnex_coredma_map(dev_info_t *dip, dev_info_t *rdip,
- struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep);
-static int rootnex_coredma_mctl(dev_info_t *dip, dev_info_t *rdip,
- ddi_dma_handle_t handle, enum ddi_dma_ctlops request, off_t *offp,
- size_t *lenp, caddr_t *objpp, uint_t cache_flags);
static struct bus_ops rootnex_bus_ops = {
BUSO_REV,
@@ -320,8 +315,8 @@ static iommulib_nexops_t iommulib_nexops = {
rootnex_coredma_get_sleep_flags,
rootnex_coredma_sync,
rootnex_coredma_win,
- rootnex_coredma_map,
- rootnex_coredma_mctl
+ rootnex_dma_map,
+ rootnex_dma_mctl
};
#endif
@@ -1764,7 +1759,7 @@ rootnex_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
return (DDI_FAILURE);
}
- ASSERT(IOMMULIB_HDL(rdip));
+ ASSERT(IOMMU_USED(rdip));
/* has an IOMMU */
return (iommulib_nexdma_allochdl(dip, rdip, attr,
@@ -1811,7 +1806,7 @@ static int
rootnex_dma_freehdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle)
{
#if !defined(__xpv)
- if (IOMMU_USED(handle)) {
+ if (IOMMU_USED(rdip)) {
return (iommulib_nexdma_freehdl(dip, rdip, handle));
}
#endif
@@ -2085,7 +2080,7 @@ rootnex_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_cookie_t *cookiep, uint_t *ccountp)
{
#if !defined(__xpv)
- if (IOMMU_USED(handle)) {
+ if (IOMMU_USED(rdip)) {
return (iommulib_nexdma_bindhdl(dip, rdip, handle, dmareq,
cookiep, ccountp));
}
@@ -2183,7 +2178,7 @@ rootnex_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
ddi_dma_handle_t handle)
{
#if !defined(__xpv)
- if (IOMMU_USED(handle)) {
+ if (IOMMU_USED(rdip)) {
return (iommulib_nexdma_unbindhdl(dip, rdip, handle));
}
#endif
@@ -4239,7 +4234,7 @@ rootnex_dma_sync(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle,
off_t off, size_t len, uint_t cache_flags)
{
#if !defined(__xpv)
- if (IOMMU_USED(handle)) {
+ if (IOMMU_USED(rdip)) {
return (iommulib_nexdma_sync(dip, rdip, handle, off, len,
cache_flags));
}
@@ -4526,7 +4521,7 @@ rootnex_dma_win(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle,
uint_t *ccountp)
{
#if !defined(__xpv)
- if (IOMMU_USED(handle)) {
+ if (IOMMU_USED(rdip)) {
return (iommulib_nexdma_win(dip, rdip, handle, win, offp, lenp,
cookiep, ccountp));
}
@@ -4542,9 +4537,14 @@ rootnex_dma_win(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle,
* ************************
*/
+/*
+ * rootnex_dma_map()
+ * called from ddi_dma_setup()
+ * NO IOMMU in 32 bit mode. The below routines doesn't work in 64 bit mode.
+ */
/* ARGSUSED */
static int
-rootnex_coredma_map(dev_info_t *dip, dev_info_t *rdip,
+rootnex_dma_map(dev_info_t *dip, dev_info_t *rdip,
struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep)
{
#if defined(__amd64)
@@ -4620,25 +4620,13 @@ rootnex_coredma_map(dev_info_t *dip, dev_info_t *rdip,
}
/*
- * rootnex_dma_map()
- * called from ddi_dma_setup()
- */
-/* ARGSUSED */
-static int
-rootnex_dma_map(dev_info_t *dip, dev_info_t *rdip,
- struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep)
-{
- /* NO IOMMU in 32 bit mode */
- return (rootnex_coredma_map(dip, rdip, dmareq, handlep));
-}
-
-/*
* rootnex_dma_mctl()
*
+ * No IOMMU in 32 bit mode. The below routine doesn't work in 64 bit mode.
*/
/* ARGSUSED */
static int
-rootnex_coredma_mctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle,
+rootnex_dma_mctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle,
enum ddi_dma_ctlops request, off_t *offp, size_t *lenp, caddr_t *objpp,
uint_t cache_flags)
{
@@ -4824,21 +4812,6 @@ rootnex_coredma_mctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle,
}
/*
- * rootnex_dma_mctl()
- *
- */
-/* ARGSUSED */
-static int
-rootnex_dma_mctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle,
- enum ddi_dma_ctlops request, off_t *offp, size_t *lenp, caddr_t *objpp,
- uint_t cache_flags)
-{
- /* NO IOMMU in 32 bit mode */
- return (rootnex_coredma_mctl(dip, rdip, handle, request, offp,
- lenp, objpp, cache_flags));
-}
-
-/*
* *********
* FMA Code
* *********
diff --git a/usr/src/uts/intel/io/iommulib.c b/usr/src/uts/intel/io/iommulib.c
index 2a7482e1d8..173e03de0d 100644
--- a/usr/src/uts/intel/io/iommulib.c
+++ b/usr/src/uts/intel/io/iommulib.c
@@ -576,7 +576,7 @@ iommulib_nex_open(dev_info_t *rdip, uint_t *errorp)
*errorp = 0;
- if (IOMMULIB_HDL(rdip))
+ if (IOMMU_USED(rdip))
return (DDI_SUCCESS);
ASSERT(DEVI(rdip)->devi_iommulib_handle == NULL);
diff --git a/usr/src/uts/intel/sys/iommulib.h b/usr/src/uts/intel/sys/iommulib.h
index a13864f5f7..a765179c3f 100644
--- a/usr/src/uts/intel/sys/iommulib.h
+++ b/usr/src/uts/intel/sys/iommulib.h
@@ -98,16 +98,9 @@ typedef struct iommulib_ops {
/*
- * IOMMULIB_HDL() checks if there is an IOMMU controlling the dip's DMA
- * IOMMU_USED() checks if the dip associated with the DMA handle has DMA
- * controlled by an IOMMU.
- * This ensures that we use the right dip associated with the
- * DMA handle irrespective of which dip's context we call
- * ddi_dma_* routines in.
+ * IOMMU_USED() checks if there is an IOMMU controlling the dip's DMA
*/
-#define IOMMULIB_HDL(dip) (DEVI(dip)->devi_iommulib_handle)
-#define IOMMU_USED(dmahdl) \
-(DEVI(((struct ddi_dma_impl *)(dmahdl))->dmai_rdip)->devi_iommulib_handle)
+#define IOMMU_USED(dip) (DEVI(dip)->devi_iommulib_handle)
typedef enum {
IOMMU_NEXOPS_VERSION_INVALID = 0,