diff options
author | Garrett D'Amore <garrett@damore.org> | 2012-03-11 22:00:47 -0700 |
---|---|---|
committer | Garrett D'Amore <garrett@damore.org> | 2012-03-11 22:00:47 -0700 |
commit | cd21e7c548ae2a3b5e522244bf798f2a6b4ba02d (patch) | |
tree | 407cc0857b2bfb1e15ba3dc275938511a9165221 /usr/src/uts | |
parent | b30a53d02d9bc370d76b8125a98e34311c768b5e (diff) | |
download | illumos-gate-cd21e7c548ae2a3b5e522244bf798f2a6b4ba02d.tar.gz |
998 obsolete DMA driver interfaces should be removed
Reviewed by: Igor Khozhukhov <igor.khozhukhov@nexenta.com>
Reviewed by: Albert Lee <trisk@nexenta.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Approved by: Robert Mustacchi <rm@joyent.com>
Diffstat (limited to 'usr/src/uts')
56 files changed, 303 insertions, 2080 deletions
diff --git a/usr/src/uts/common/io/1394/nx1394.c b/usr/src/uts/common/io/1394/nx1394.c index cc710b8417..216b70a319 100644 --- a/usr/src/uts/common/io/1394/nx1394.c +++ b/usr/src/uts/common/io/1394/nx1394.c @@ -23,8 +23,9 @@ * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ - -#pragma ident "%Z%%M% %I% %E% SMI" +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* * nx1394.c @@ -72,7 +73,7 @@ struct bus_ops nx1394_busops = { NULL, /* bus_add_intrspec */ NULL, /* bus_remove_intrspec */ i_ddi_map_fault, /* XXXX bus_map_fault */ - ddi_dma_map, /* bus_dma_map */ + NULL, /* bus_dma_map */ nx1394_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, @@ -391,7 +392,7 @@ nx1394_add_eventcall(dev_info_t *dip, dev_info_t *rdip, #if defined(DEBUG) event_name = ndi_event_cookie_to_name(hal->hal_ndi_event_hdl, cookie); if (event_name == NULL) - event_name = ""; + event_name = ""; #endif TNF_PROBE_4_DEBUG(nx1394_add_eventcall_exit, S1394_TNF_SL_NEXUS_STACK, "", tnf_opaque, parent_dip, (void *)dip, tnf_opaque, requestor_dip, @@ -430,7 +431,7 @@ nx1394_remove_eventcall(dev_info_t *dip, ddi_callback_id_t cb_id) #if defined(DEBUG) event_name = ndi_event_cookie_to_name(hal->hal_ndi_event_hdl, cookie); if (event_name == NULL) - event_name = ""; + event_name = ""; TNF_PROBE_4_DEBUG(nx1394_remove_eventcall_exit, S1394_TNF_SL_NEXUS_STACK, "", tnf_opaque, parent_dip, (void *)dip, diff --git a/usr/src/uts/common/io/blkdev/blkdev.c b/usr/src/uts/common/io/blkdev/blkdev.c index f7d6cff7a1..7b722f126c 100644 --- a/usr/src/uts/common/io/blkdev/blkdev.c +++ b/usr/src/uts/common/io/blkdev/blkdev.c @@ -20,10 +20,8 @@ */ /* * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. - */ - -/* * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. */ #include <sys/types.h> @@ -1680,7 +1678,7 @@ bd_mod_init(struct dev_ops *devops) NULL, /* bus_add_intrspec (OBSOLETE) */ NULL, /* bus_remove_intrspec (OBSOLETE) */ i_ddi_map_fault, /* bus_map_fault */ - ddi_dma_map, /* bus_dma_map */ + NULL, /* bus_dma_map (OBSOLETE) */ ddi_dma_allochdl, /* bus_dma_allochdl */ ddi_dma_freehdl, /* bus_dma_freehdl */ ddi_dma_bindhdl, /* bus_dma_bindhdl */ diff --git a/usr/src/uts/common/io/bofi.c b/usr/src/uts/common/io/bofi.c index 80b69bd07b..6554d29f76 100644 --- a/usr/src/uts/common/io/bofi.c +++ b/usr/src/uts/common/io/bofi.c @@ -22,6 +22,9 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ #include <sys/types.h> @@ -161,8 +164,6 @@ static int bofi_errdef_check_w(struct bofi_errstate *, struct acc_log_elem **); static int bofi_map(dev_info_t *, dev_info_t *, ddi_map_req_t *, off_t, off_t, caddr_t *); -static int bofi_dma_map(dev_info_t *, dev_info_t *, - struct ddi_dma_req *, ddi_dma_handle_t *); static int bofi_dma_allochdl(dev_info_t *, dev_info_t *, ddi_dma_attr_t *, int (*)(caddr_t), caddr_t, ddi_dma_handle_t *); @@ -209,7 +210,7 @@ static struct bus_ops bofi_bus_ops = { NULL, NULL, i_ddi_map_fault, - bofi_dma_map, + NULL, bofi_dma_allochdl, bofi_dma_freehdl, bofi_dma_bindhdl, @@ -3334,174 +3335,6 @@ xbcopy(void *from, void *to, u_longlong_t len) /* - * our ddi_dma_map routine - */ -static int -bofi_dma_map(dev_info_t *dip, dev_info_t *rdip, - struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep) -{ - struct bofi_shadow *hp, *xhp; - int maxrnumber = 0; - int retval = DDI_DMA_NORESOURCES; - auto struct ddi_dma_req dmareq; - int sleep; - struct bofi_shadow *dhashp; - struct bofi_shadow *hhashp; - ddi_dma_impl_t *mp; - unsigned long pagemask = ddi_ptob(rdip, 1) - 1; - - /* - * if driver_list is set, only intercept those drivers - */ - if (handlep == NULL || !driver_under_test(rdip)) - return (save_bus_ops.bus_dma_map(dip, rdip, dmareqp, handlep)); - - sleep = (dmareqp->dmar_fp == DDI_DMA_SLEEP) ? KM_SLEEP : KM_NOSLEEP; - /* - * allocate shadow handle structure and fill it in - */ - hp = kmem_zalloc(sizeof (struct bofi_shadow), sleep); - if (hp == NULL) - goto error; - (void) strncpy(hp->name, ddi_get_name(rdip), NAMESIZE); - hp->instance = ddi_get_instance(rdip); - hp->dip = rdip; - hp->flags = dmareqp->dmar_flags; - if (dmareqp->dmar_object.dmao_type == DMA_OTYP_PAGES) { - hp->map_flags = B_PAGEIO; - hp->map_pp = dmareqp->dmar_object.dmao_obj.pp_obj.pp_pp; - } else if (dmareqp->dmar_object.dmao_obj.virt_obj.v_priv != NULL) { - hp->map_flags = B_SHADOW; - hp->map_pplist = dmareqp->dmar_object.dmao_obj.virt_obj.v_priv; - } else { - hp->map_flags = 0; - } - hp->link = NULL; - hp->type = BOFI_DMA_HDL; - /* - * get a kernel virtual mapping - */ - hp->addr = ddi_dmareq_mapin(dmareqp, &hp->mapaddr, &hp->len); - if (hp->addr == NULL) - goto error; - if (bofi_sync_check) { - /* - * Take a copy and pass pointers to this up to nexus instead. - * Data will be copied from the original on explicit - * and implicit ddi_dma_sync() - * - * - maintain page alignment because some devices assume it. - */ - hp->origaddr = hp->addr; - hp->allocaddr = ddi_umem_alloc( - ((uintptr_t)hp->addr & pagemask) + hp->len, sleep, - &hp->umem_cookie); - if (hp->allocaddr == NULL) - goto error; - hp->addr = hp->allocaddr + ((uintptr_t)hp->addr & pagemask); - if (dmareqp->dmar_flags & DDI_DMA_WRITE) - xbcopy(hp->origaddr, hp->addr, hp->len); - dmareq = *dmareqp; - dmareq.dmar_object.dmao_size = hp->len; - dmareq.dmar_object.dmao_type = DMA_OTYP_VADDR; - dmareq.dmar_object.dmao_obj.virt_obj.v_as = &kas; - dmareq.dmar_object.dmao_obj.virt_obj.v_addr = hp->addr; - dmareq.dmar_object.dmao_obj.virt_obj.v_priv = NULL; - dmareqp = &dmareq; - } - /* - * call nexus to do the real work - */ - retval = save_bus_ops.bus_dma_map(dip, rdip, dmareqp, handlep); - if (retval != DDI_SUCCESS) - goto error2; - /* - * now set dma_handle to point to real handle - */ - hp->hdl.dma_handle = *handlep; - /* - * unset DMP_NOSYNC - */ - mp = (ddi_dma_impl_t *)*handlep; - mp->dmai_rflags &= ~DMP_NOSYNC; - mp->dmai_fault_check = bofi_check_dma_hdl; - /* - * bind and unbind are cached in devinfo - must overwrite them - * - note that our bind and unbind are quite happy dealing with - * any handles for this devinfo that were previously allocated - */ - if (save_bus_ops.bus_dma_bindhdl == DEVI(rdip)->devi_bus_dma_bindfunc) - DEVI(rdip)->devi_bus_dma_bindfunc = bofi_dma_bindhdl; - if (save_bus_ops.bus_dma_unbindhdl == - DEVI(rdip)->devi_bus_dma_unbindfunc) - DEVI(rdip)->devi_bus_dma_unbindfunc = bofi_dma_unbindhdl; - mutex_enter(&bofi_low_mutex); - mutex_enter(&bofi_mutex); - /* - * get an "rnumber" for this handle - really just seeking to - * get a unique number - generally only care for early allocated - * handles - so we get as far as INT_MAX, just stay there - */ - dhashp = HDL_DHASH(hp->dip); - for (xhp = dhashp->dnext; xhp != dhashp; xhp = xhp->dnext) - if (ddi_name_to_major(xhp->name) == - ddi_name_to_major(hp->name) && - xhp->instance == hp->instance && - xhp->type == BOFI_DMA_HDL) - if (xhp->rnumber >= maxrnumber) { - if (xhp->rnumber == INT_MAX) - maxrnumber = INT_MAX; - else - maxrnumber = xhp->rnumber + 1; - } - hp->rnumber = maxrnumber; - /* - * add to dhash, hhash and inuse lists - */ - hp->next = shadow_list.next; - shadow_list.next->prev = hp; - hp->prev = &shadow_list; - shadow_list.next = hp; - hhashp = HDL_HHASH(*handlep); - hp->hnext = hhashp->hnext; - hhashp->hnext->hprev = hp; - hp->hprev = hhashp; - hhashp->hnext = hp; - dhashp = HDL_DHASH(hp->dip); - hp->dnext = dhashp->dnext; - dhashp->dnext->dprev = hp; - hp->dprev = dhashp; - dhashp->dnext = hp; - /* - * chain on any pre-existing errdefs that apply to this - * acc_handle and corrupt if required (as there is an implicit - * ddi_dma_sync() in this call) - */ - chain_on_errdefs(hp); - mutex_exit(&bofi_mutex); - mutex_exit(&bofi_low_mutex); - return (retval); -error: - if (dmareqp->dmar_fp != DDI_DMA_DONTWAIT) { - /* - * what to do here? Wait a bit and try again - */ - (void) timeout((void (*)())dmareqp->dmar_fp, - dmareqp->dmar_arg, 10); - } -error2: - if (hp) { - ddi_dmareq_mapout(hp->mapaddr, hp->len, hp->map_flags, - hp->map_pp, hp->map_pplist); - if (bofi_sync_check && hp->allocaddr) - ddi_umem_free(hp->umem_cookie); - kmem_free(hp, sizeof (struct bofi_shadow)); - } - return (retval); -} - - -/* * our ddi_dma_allochdl routine */ static int @@ -4003,14 +3836,11 @@ bofi_dma_ctl(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 *objp, uint_t flags) { - struct bofi_link *lp, *next_lp; - struct bofi_errent *ep; struct bofi_shadow *hp; struct bofi_shadow *hhashp; int retval; int i; struct bofi_shadow *dummyhp; - ddi_dma_impl_t *mp; /* * get nexus to do real work @@ -4089,58 +3919,6 @@ bofi_dma_ctl(dev_info_t *dip, dev_info_t *rdip, sizeof (struct bofi_shadow *)); kmem_free(dummyhp, sizeof (struct bofi_shadow)); return (retval); - case DDI_DMA_FREE: - /* - * ddi_dma_free case - remove from dhash, hhash and inuse lists - */ - hp->hnext->hprev = hp->hprev; - hp->hprev->hnext = hp->hnext; - hp->dnext->dprev = hp->dprev; - hp->dprev->dnext = hp->dnext; - hp->next->prev = hp->prev; - hp->prev->next = hp->next; - /* - * free any errdef link structures tagged on to this - * shadow handle - */ - for (lp = hp->link; lp != NULL; ) { - next_lp = lp->link; - /* - * there is an implicit sync_for_cpu on free - - * may need to corrupt - */ - ep = lp->errentp; - if ((ep->errdef.access_type & BOFI_DMA_R) && - (hp->flags & DDI_DMA_READ) && - (ep->state & BOFI_DEV_ACTIVE)) { - do_dma_corrupt(hp, ep, DDI_DMA_SYNC_FORCPU, - 0, hp->len); - } - lp->link = bofi_link_freelist; - bofi_link_freelist = lp; - lp = next_lp; - } - hp->link = NULL; - mutex_exit(&bofi_mutex); - mutex_exit(&bofi_low_mutex); - - if (bofi_sync_check && (hp->flags & DDI_DMA_READ)) - if (hp->allocaddr) - xbcopy(hp->addr, hp->origaddr, hp->len); - ddi_dmareq_mapout(hp->mapaddr, hp->len, hp->map_flags, - hp->map_pp, hp->map_pplist); - if (bofi_sync_check && hp->allocaddr) - ddi_umem_free(hp->umem_cookie); - kmem_free(hp, sizeof (struct bofi_shadow)); - return (retval); - case DDI_DMA_MOVWIN: - mp = (ddi_dma_impl_t *)handle; - mp->dmai_rflags &= ~DMP_NOSYNC; - break; - case DDI_DMA_NEXTWIN: - mp = (ddi_dma_impl_t *)handle; - mp->dmai_rflags &= ~DMP_NOSYNC; - break; default: break; } diff --git a/usr/src/uts/common/io/fcoe/fcoe.c b/usr/src/uts/common/io/fcoe/fcoe.c index 5c58dfb01c..f2550c3008 100644 --- a/usr/src/uts/common/io/fcoe/fcoe.c +++ b/usr/src/uts/common/io/fcoe/fcoe.c @@ -22,6 +22,9 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* * The following notice accompanied the original version of this file: @@ -156,7 +159,7 @@ static struct bus_ops fcoe_busops = { NULL, /* bus_add_intrspec */ NULL, /* bus_remove_intrspec */ i_ddi_map_fault, /* bus_map_fault */ - ddi_dma_map, /* bus_dma_map */ + NULL, /* bus_dma_map */ ddi_dma_allochdl, /* bus_dma_allochdl */ ddi_dma_freehdl, /* bus_dma_freehdl */ ddi_dma_bindhdl, /* bus_dma_bindhdl */ diff --git a/usr/src/uts/common/io/fdc.c b/usr/src/uts/common/io/fdc.c index 444b6b46e5..fdfc73a4fa 100644 --- a/usr/src/uts/common/io/fdc.c +++ b/usr/src/uts/common/io/fdc.c @@ -22,6 +22,9 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* @@ -214,7 +217,7 @@ struct bus_ops fdc_bus_ops = { 0, /* int (*bus_add_intrspec)(); */ 0, /* void (*bus_remove_intrspec)(); */ i_ddi_map_fault, - ddi_dma_map, + 0, ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/common/io/fibre-channel/impl/fctl.c b/usr/src/uts/common/io/fibre-channel/impl/fctl.c index 747df29d08..634de6c6dd 100644 --- a/usr/src/uts/common/io/fibre-channel/impl/fctl.c +++ b/usr/src/uts/common/io/fibre-channel/impl/fctl.c @@ -21,7 +21,11 @@ /* * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. - * + */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ +/* * Fibre channel Transport Library (fctl) * * Function naming conventions: @@ -172,7 +176,7 @@ static struct bus_ops fctl_fca_busops = { NULL, /* bus_add_intrspec */ NULL, /* bus_remove_intrspec */ i_ddi_map_fault, /* bus_map_fault */ - ddi_dma_map, /* bus_dma_map */ + NULL, /* bus_dma_map */ ddi_dma_allochdl, /* bus_dma_allochdl */ ddi_dma_freehdl, /* bus_dma_freehdl */ ddi_dma_bindhdl, /* bus_dma_bindhdl */ diff --git a/usr/src/uts/common/io/pci-ide/pci-ide.c b/usr/src/uts/common/io/pci-ide/pci-ide.c index c885fed6a0..7afa702ca4 100644 --- a/usr/src/uts/common/io/pci-ide/pci-ide.c +++ b/usr/src/uts/common/io/pci-ide/pci-ide.c @@ -21,7 +21,9 @@ /* * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. */ - +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* * PCI-IDE bus nexus driver @@ -129,7 +131,7 @@ struct bus_ops pciide_bus_ops = { 0, 0, i_ddi_map_fault, - ddi_dma_map, + 0, ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/common/io/pciex/pcieb.c b/usr/src/uts/common/io/pciex/pcieb.c index 0aba544755..e01f132156 100644 --- a/usr/src/uts/common/io/pciex/pcieb.c +++ b/usr/src/uts/common/io/pciex/pcieb.c @@ -21,6 +21,9 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* * Common x86 and SPARC PCI-E to PCI bus bridge nexus driver @@ -96,7 +99,7 @@ static struct bus_ops pcieb_bus_ops = { 0, 0, i_ddi_map_fault, - ddi_dma_map, + 0, pcieb_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/common/io/pshot.c b/usr/src/uts/common/io/pshot.c index a1d69ea9ae..bc5c328d6b 100644 --- a/usr/src/uts/common/io/pshot.c +++ b/usr/src/uts/common/io/pshot.c @@ -22,6 +22,9 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* * pseudo bus nexus driver @@ -305,7 +308,7 @@ static struct bus_ops pshot_bus_ops = { NULL, /* bus_add_interspec */ NULL, /* bus_remove_interspec */ i_ddi_map_fault, /* bus_map_fault */ - ddi_dma_map, /* bus_dma_map */ + NULL, /* bus_dma_map */ ddi_dma_allochdl, /* bus_dma_allochdl */ ddi_dma_freehdl, /* bus_dma_freehdl */ ddi_dma_bindhdl, /* bus_dma_bindhdl */ diff --git a/usr/src/uts/common/io/scsi/impl/scsi_hba.c b/usr/src/uts/common/io/scsi/impl/scsi_hba.c index 6d9c00840f..252bd5316e 100644 --- a/usr/src/uts/common/io/scsi/impl/scsi_hba.c +++ b/usr/src/uts/common/io/scsi/impl/scsi_hba.c @@ -21,6 +21,7 @@ /* * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. */ #include <sys/note.h> @@ -293,7 +294,7 @@ static struct bus_ops scsi_hba_busops = { NULL, /* bus_add_intrspec */ NULL, /* bus_remove_intrspec */ scsi_hba_map_fault, /* bus_map_fault */ - ddi_dma_map, /* bus_dma_map */ + NULL, /* bus_dma_map */ ddi_dma_allochdl, /* bus_dma_allochdl */ ddi_dma_freehdl, /* bus_dma_freehdl */ ddi_dma_bindhdl, /* bus_dma_bindhdl */ diff --git a/usr/src/uts/common/io/usb/hwa/hwahc/hwahc.c b/usr/src/uts/common/io/usb/hwa/hwahc/hwahc.c index beba53c65f..9ca1fa0f54 100644 --- a/usr/src/uts/common/io/usb/hwa/hwahc/hwahc.c +++ b/usr/src/uts/common/io/usb/hwa/hwahc/hwahc.c @@ -22,6 +22,9 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* * The Data Transfer Interface driver for Host Wire Adapter device @@ -252,7 +255,7 @@ static struct bus_ops hwahc_busops = { NULL, /* bus_add_intrspec */ NULL, /* bus_remove_intrspec */ NULL, /* bus_map_fault */ - ddi_dma_map, /* bus_dma_map */ + NULL, /* bus_dma_map */ ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/common/io/usb/usb_ia/usb_ia.c b/usr/src/uts/common/io/usb/usb_ia/usb_ia.c index 579aae37a7..243b995ed7 100644 --- a/usr/src/uts/common/io/usb/usb_ia/usb_ia.c +++ b/usr/src/uts/common/io/usb/usb_ia/usb_ia.c @@ -22,6 +22,9 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* @@ -130,7 +133,7 @@ static struct bus_ops usb_ia_busops = { NULL, /* bus_add_intrspec */ NULL, /* bus_remove_intrspec */ NULL, /* XXXX bus_map_fault */ - ddi_dma_map, /* bus_dma_map */ + NULL, /* bus_dma_map */ ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/common/io/usb/usb_mid/usb_mid.c b/usr/src/uts/common/io/usb/usb_mid/usb_mid.c index 7c6b507b72..faacf41a79 100644 --- a/usr/src/uts/common/io/usb/usb_mid/usb_mid.c +++ b/usr/src/uts/common/io/usb/usb_mid/usb_mid.c @@ -22,6 +22,9 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* @@ -142,7 +145,7 @@ static struct bus_ops usb_mid_busops = { NULL, /* bus_add_intrspec */ NULL, /* bus_remove_intrspec */ NULL, /* XXXX bus_map_fault */ - ddi_dma_map, /* bus_dma_map */ + NULL, /* bus_dma_map */ ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/common/io/usb/usba/hubdi.c b/usr/src/uts/common/io/usb/usba/hubdi.c index 23ab998f0e..de454de41c 100644 --- a/usr/src/uts/common/io/usb/usba/hubdi.c +++ b/usr/src/uts/common/io/usb/usba/hubdi.c @@ -20,6 +20,7 @@ */ /* * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. */ /* @@ -112,7 +113,7 @@ struct bus_ops usba_hubdi_busops = { NULL, /* bus_add_intrspec */ NULL, /* bus_remove_intrspec */ usba_hubdi_map_fault, /* bus_map_fault */ - ddi_dma_map, /* bus_dma_map */ + NULL, /* bus_dma_map */ ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/common/io/warlock/ddi_dki_comm.inc b/usr/src/uts/common/io/warlock/ddi_dki_comm.inc index 4667eddcb0..75e51bdbbb 100644 --- a/usr/src/uts/common/io/warlock/ddi_dki_comm.inc +++ b/usr/src/uts/common/io/warlock/ddi_dki_comm.inc @@ -23,7 +23,9 @@ * All rights reserved. Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* * ddi_dki_comm.inc - Part of a pseudo-kernel to use when analyzing drivers @@ -188,22 +190,6 @@ ddi_dma_setup( } int -ddi_dma_pp_setup( - dev_info_t *a, - struct page *b, - off_t c, - uint_t d, - uint_t e, - int (*fp)(), - caddr_t f, - ddi_dma_lim_t *g, - ddi_dma_handle_t *h) -{ - struct bus_ops *ops; - (*ops->bus_dma_map)(0, 0, 0, 0); -} - -int ddi_dma_mctl(dev_info_t *a, dev_info_t *b, ddi_dma_handle_t c, enum ddi_dma_ctlops d, off_t *e, size_t *f, caddr_t *g, uint_t h) @@ -234,35 +220,6 @@ ddi_dma_coff(ddi_dma_handle_t h, ddi_dma_cookie_t *c, off_t *o) } int -ddi_dma_movwin(ddi_dma_handle_t h, off_t *o, size_t *l, ddi_dma_cookie_t *c) -{ - struct bus_ops *ops; - (*ops->bus_dma_ctl)(0, 0, 0, 0, 0, 0, 0, 0); -} - -int -ddi_dma_curwin(ddi_dma_handle_t h, off_t *o, size_t *l) -{ - struct bus_ops *ops; - (*ops->bus_dma_ctl)(0, 0, 0, 0, 0, 0, 0, 0); -} - -int -ddi_dma_nextwin(register ddi_dma_handle_t h, ddi_dma_win_t win, - ddi_dma_win_t *nwin) -{ - struct bus_ops *ops; - (*ops->bus_dma_ctl)(0, 0, 0, 0, 0, 0, 0, 0); -} - -int -ddi_dma_nextseg(ddi_dma_win_t win, ddi_dma_seg_t seg, ddi_dma_seg_t *nseg) -{ - struct bus_ops *ops; - (*ops->bus_dma_ctl)(0, 0, 0, 0, 0, 0, 0, 0); -} - -int ddi_dma_get_error(ddi_dma_handle_t h, uint_t len, caddr_t errblk) { struct bus_ops *ops; diff --git a/usr/src/uts/common/os/devcfg.c b/usr/src/uts/common/os/devcfg.c index b2f6db6cdd..d11c6fb7b7 100644 --- a/usr/src/uts/common/os/devcfg.c +++ b/usr/src/uts/common/os/devcfg.c @@ -20,9 +20,8 @@ */ /* * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. - */ -/* * Copyright 2012 Nexenta Systems, Inc. All rights reserved. + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. */ #include <sys/note.h> @@ -3185,7 +3184,6 @@ ddi_optimize_dtree(dev_info_t *devi) * Set the unoptimized values */ DEVI(devi)->devi_bus_map_fault = pdevi; - DEVI(devi)->devi_bus_dma_map = pdevi; DEVI(devi)->devi_bus_dma_allochdl = pdevi; DEVI(devi)->devi_bus_dma_freehdl = pdevi; DEVI(devi)->devi_bus_dma_bindhdl = pdevi; @@ -3212,11 +3210,6 @@ ddi_optimize_dtree(dev_info_t *devi) "bus_map_fault"); } - if (ddi_dma_map == b->bus_dma_map) { - DEVI(devi)->devi_bus_dma_map = pdevi->devi_bus_dma_map; - debug_dtree(devi, DEVI(devi)->devi_bus_dma_map, "bus_dma_map"); - } - if (ddi_dma_allochdl == b->bus_dma_allochdl) { DEVI(devi)->devi_bus_dma_allochdl = pdevi->devi_bus_dma_allochdl; diff --git a/usr/src/uts/common/os/sunddi.c b/usr/src/uts/common/os/sunddi.c index ee3fa51b95..8daea07d18 100644 --- a/usr/src/uts/common/os/sunddi.c +++ b/usr/src/uts/common/os/sunddi.c @@ -21,6 +21,7 @@ /* * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. */ #include <sys/note.h> @@ -736,145 +737,6 @@ static ddi_dma_lim_t standard_limits = { #endif -int -ddi_dma_setup(dev_info_t *dip, struct ddi_dma_req *dmareqp, - ddi_dma_handle_t *handlep) -{ - int (*funcp)() = ddi_dma_map; - struct bus_ops *bop; -#if defined(__sparc) - auto ddi_dma_lim_t dma_lim; - - if (dmareqp->dmar_limits == (ddi_dma_lim_t *)0) { - dma_lim = standard_limits; - } else { - dma_lim = *dmareqp->dmar_limits; - } - dmareqp->dmar_limits = &dma_lim; -#endif -#if defined(__x86) - if (dmareqp->dmar_limits == (ddi_dma_lim_t *)0) - return (DDI_FAILURE); -#endif - - /* - * Handle the case that the requester is both a leaf - * and a nexus driver simultaneously by calling the - * requester's bus_dma_map function directly instead - * of ddi_dma_map. - */ - bop = DEVI(dip)->devi_ops->devo_bus_ops; - if (bop && bop->bus_dma_map) - funcp = bop->bus_dma_map; - return ((*funcp)(dip, dip, dmareqp, handlep)); -} - -int -ddi_dma_addr_setup(dev_info_t *dip, struct as *as, caddr_t addr, size_t len, - uint_t flags, int (*waitfp)(), caddr_t arg, - ddi_dma_lim_t *limits, ddi_dma_handle_t *handlep) -{ - int (*funcp)() = ddi_dma_map; - ddi_dma_lim_t dma_lim; - struct ddi_dma_req dmareq; - struct bus_ops *bop; - - if (len == 0) { - return (DDI_DMA_NOMAPPING); - } - if (limits == (ddi_dma_lim_t *)0) { - dma_lim = standard_limits; - } else { - dma_lim = *limits; - } - dmareq.dmar_limits = &dma_lim; - dmareq.dmar_flags = flags; - dmareq.dmar_fp = waitfp; - dmareq.dmar_arg = arg; - dmareq.dmar_object.dmao_size = len; - dmareq.dmar_object.dmao_type = DMA_OTYP_VADDR; - dmareq.dmar_object.dmao_obj.virt_obj.v_as = as; - dmareq.dmar_object.dmao_obj.virt_obj.v_addr = addr; - dmareq.dmar_object.dmao_obj.virt_obj.v_priv = NULL; - - /* - * Handle the case that the requester is both a leaf - * and a nexus driver simultaneously by calling the - * requester's bus_dma_map function directly instead - * of ddi_dma_map. - */ - bop = DEVI(dip)->devi_ops->devo_bus_ops; - if (bop && bop->bus_dma_map) - funcp = bop->bus_dma_map; - - return ((*funcp)(dip, dip, &dmareq, handlep)); -} - -int -ddi_dma_buf_setup(dev_info_t *dip, struct buf *bp, uint_t flags, - int (*waitfp)(), caddr_t arg, ddi_dma_lim_t *limits, - ddi_dma_handle_t *handlep) -{ - int (*funcp)() = ddi_dma_map; - ddi_dma_lim_t dma_lim; - struct ddi_dma_req dmareq; - struct bus_ops *bop; - - if (limits == (ddi_dma_lim_t *)0) { - dma_lim = standard_limits; - } else { - dma_lim = *limits; - } - dmareq.dmar_limits = &dma_lim; - dmareq.dmar_flags = flags; - dmareq.dmar_fp = waitfp; - dmareq.dmar_arg = arg; - dmareq.dmar_object.dmao_size = (uint_t)bp->b_bcount; - - if (bp->b_flags & B_PAGEIO) { - dmareq.dmar_object.dmao_type = DMA_OTYP_PAGES; - dmareq.dmar_object.dmao_obj.pp_obj.pp_pp = bp->b_pages; - dmareq.dmar_object.dmao_obj.pp_obj.pp_offset = - (uint_t)(((uintptr_t)bp->b_un.b_addr) & MMU_PAGEOFFSET); - } else { - dmareq.dmar_object.dmao_type = DMA_OTYP_BUFVADDR; - dmareq.dmar_object.dmao_obj.virt_obj.v_addr = bp->b_un.b_addr; - if (bp->b_flags & B_SHADOW) { - dmareq.dmar_object.dmao_obj.virt_obj.v_priv = - bp->b_shadow; - } else { - dmareq.dmar_object.dmao_obj.virt_obj.v_priv = NULL; - } - - /* - * If the buffer has no proc pointer, or the proc - * struct has the kernel address space, or the buffer has - * been marked B_REMAPPED (meaning that it is now - * mapped into the kernel's address space), then - * the address space is kas (kernel address space). - */ - if ((bp->b_proc == NULL) || (bp->b_proc->p_as == &kas) || - (bp->b_flags & B_REMAPPED)) { - dmareq.dmar_object.dmao_obj.virt_obj.v_as = 0; - } else { - dmareq.dmar_object.dmao_obj.virt_obj.v_as = - bp->b_proc->p_as; - } - } - - /* - * Handle the case that the requester is both a leaf - * and a nexus driver simultaneously by calling the - * requester's bus_dma_map function directly instead - * of ddi_dma_map. - */ - bop = DEVI(dip)->devi_ops->devo_bus_ops; - if (bop && bop->bus_dma_map) - funcp = bop->bus_dma_map; - - return ((*funcp)(dip, dip, &dmareq, handlep)); -} - #if !defined(__sparc) /* * Request bus_dma_ctl parent to fiddle with a dma request. @@ -908,79 +770,18 @@ ddi_dma_mctl(dev_info_t *dip, dev_info_t *rdip, #define HD ((ddi_dma_impl_t *)h)->dmai_rdip -int -ddi_dma_kvaddrp(ddi_dma_handle_t h, off_t off, size_t len, caddr_t *kp) -{ - return (ddi_dma_mctl(HD, HD, h, DDI_DMA_KVADDR, &off, &len, kp, 0)); -} - -int -ddi_dma_htoc(ddi_dma_handle_t h, off_t o, ddi_dma_cookie_t *c) -{ - return (ddi_dma_mctl(HD, HD, h, DDI_DMA_HTOC, &o, 0, (caddr_t *)c, 0)); -} - -int -ddi_dma_coff(ddi_dma_handle_t h, ddi_dma_cookie_t *c, off_t *o) -{ - return (ddi_dma_mctl(HD, HD, h, DDI_DMA_COFF, - (off_t *)c, 0, (caddr_t *)o, 0)); -} - -int -ddi_dma_movwin(ddi_dma_handle_t h, off_t *o, size_t *l, ddi_dma_cookie_t *c) -{ - return (ddi_dma_mctl(HD, HD, h, DDI_DMA_MOVWIN, o, - l, (caddr_t *)c, 0)); -} - -int -ddi_dma_curwin(ddi_dma_handle_t h, off_t *o, size_t *l) -{ - if ((((ddi_dma_impl_t *)h)->dmai_rflags & DDI_DMA_PARTIAL) == 0) - return (DDI_FAILURE); - return (ddi_dma_mctl(HD, HD, h, DDI_DMA_REPWIN, o, l, 0, 0)); -} - -int -ddi_dma_nextwin(ddi_dma_handle_t h, ddi_dma_win_t win, - ddi_dma_win_t *nwin) -{ - return (ddi_dma_mctl(HD, HD, h, DDI_DMA_NEXTWIN, (off_t *)&win, 0, - (caddr_t *)nwin, 0)); -} - -int -ddi_dma_nextseg(ddi_dma_win_t win, ddi_dma_seg_t seg, ddi_dma_seg_t *nseg) -{ - ddi_dma_handle_t h = (ddi_dma_handle_t)win; - - return (ddi_dma_mctl(HD, HD, h, DDI_DMA_NEXTSEG, (off_t *)&win, - (size_t *)&seg, (caddr_t *)nseg, 0)); -} - -#if (defined(__i386) && !defined(__amd64)) || defined(__sparc) /* - * This routine is Obsolete and should be removed from ALL architectures - * in a future release of Solaris. - * - * It is deliberately NOT ported to amd64; please fix the code that - * depends on this routine to use ddi_dma_nextcookie(9F). - * - * NOTE: even though we fixed the pointer through a 32-bit param issue (the fix - * is a side effect to some other cleanup), we're still not going to support - * this interface on x64. + * This routine is left in place to satisfy link dependencies + * for any 3rd party nexus drivers that rely on it. It is never + * called, though. */ +/*ARGSUSED*/ int -ddi_dma_segtocookie(ddi_dma_seg_t seg, off_t *o, off_t *l, - ddi_dma_cookie_t *cookiep) +ddi_dma_map(dev_info_t *dip, dev_info_t *rdip, + struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep) { - ddi_dma_handle_t h = (ddi_dma_handle_t)seg; - - return (ddi_dma_mctl(HD, HD, h, DDI_DMA_SEGTOC, o, (size_t *)l, - (caddr_t *)cookiep, 0)); + return (DDI_FAILURE); } -#endif /* (__i386 && !__amd64) || __sparc */ #if !defined(__sparc) @@ -990,20 +791,6 @@ ddi_dma_segtocookie(ddi_dma_seg_t seg, off_t *o, off_t *l, */ int -ddi_dma_map(dev_info_t *dip, dev_info_t *rdip, - struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep) -{ - int (*funcp)(dev_info_t *, dev_info_t *, struct ddi_dma_req *, - ddi_dma_handle_t *); - - if (dip != ddi_root_node()) - dip = (dev_info_t *)DEVI(dip)->devi_bus_dma_map; - - 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) { @@ -1129,66 +916,9 @@ ddi_dma_unbind_handle(ddi_dma_handle_t h) #endif /* !__sparc */ -int -ddi_dma_free(ddi_dma_handle_t h) -{ - return (ddi_dma_mctl(HD, HD, h, DDI_DMA_FREE, 0, 0, 0, 0)); -} - -int -ddi_iopb_alloc(dev_info_t *dip, ddi_dma_lim_t *limp, uint_t len, caddr_t *iopbp) -{ - ddi_dma_lim_t defalt; - size_t size = len; - - if (!limp) { - defalt = standard_limits; - limp = &defalt; - } - return (i_ddi_mem_alloc_lim(dip, limp, size, 0, 0, 0, - iopbp, NULL, NULL)); -} - -void -ddi_iopb_free(caddr_t iopb) -{ - i_ddi_mem_free(iopb, NULL); -} - -int -ddi_mem_alloc(dev_info_t *dip, ddi_dma_lim_t *limits, uint_t length, - uint_t flags, caddr_t *kaddrp, uint_t *real_length) -{ - ddi_dma_lim_t defalt; - size_t size = length; - - if (!limits) { - defalt = standard_limits; - limits = &defalt; - } - return (i_ddi_mem_alloc_lim(dip, limits, size, flags & 0x1, - 1, 0, kaddrp, real_length, NULL)); -} - -void -ddi_mem_free(caddr_t kaddr) -{ - i_ddi_mem_free(kaddr, NULL); -} - /* - * DMA attributes, alignment, burst sizes, and transfer minimums + * DMA burst sizes, and transfer minimums */ -int -ddi_dma_get_attr(ddi_dma_handle_t handle, ddi_dma_attr_t *attrp) -{ - ddi_dma_impl_t *dimp = (ddi_dma_impl_t *)handle; - - if (attrp == NULL) - return (DDI_FAILURE); - *attrp = dimp->dmai_attr; - return (DDI_SUCCESS); -} int ddi_dma_burstsizes(ddi_dma_handle_t handle) @@ -1202,26 +932,6 @@ ddi_dma_burstsizes(ddi_dma_handle_t handle) } int -ddi_dma_devalign(ddi_dma_handle_t handle, uint_t *alignment, uint_t *mineffect) -{ - ddi_dma_impl_t *dimp = (ddi_dma_impl_t *)handle; - - if (!dimp || !alignment || !mineffect) - return (DDI_FAILURE); - if (!(dimp->dmai_rflags & DDI_DMA_SBUS_64BIT)) { - *alignment = 1 << ddi_ffs(dimp->dmai_burstsizes); - } else { - if (dimp->dmai_burstsizes & 0xff0000) { - *alignment = 1 << ddi_ffs(dimp->dmai_burstsizes >> 16); - } else { - *alignment = 1 << ddi_ffs(dimp->dmai_burstsizes); - } - } - *mineffect = dimp->dmai_minxfer; - return (DDI_SUCCESS); -} - -int ddi_iomin(dev_info_t *a, int i, int stream) { int r; diff --git a/usr/src/uts/common/sys/ddi_impldefs.h b/usr/src/uts/common/sys/ddi_impldefs.h index 0699d1cbce..bfe2d855b6 100644 --- a/usr/src/uts/common/sys/ddi_impldefs.h +++ b/usr/src/uts/common/sys/ddi_impldefs.h @@ -20,6 +20,7 @@ */ /* * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. */ #ifndef _SYS_DDI_IMPLDEFS_H @@ -160,7 +161,7 @@ struct dev_info { /* logical parents for busop primitives */ struct dev_info *devi_bus_map_fault; /* bus_map_fault parent */ - struct dev_info *devi_bus_dma_map; /* bus_dma_map parent */ + void *devi_obsolete; /* obsolete placeholder */ struct dev_info *devi_bus_dma_allochdl; /* bus_dma_newhdl parent */ struct dev_info *devi_bus_dma_freehdl; /* bus_dma_freehdl parent */ struct dev_info *devi_bus_dma_bindhdl; /* bus_dma_bindhdl parent */ diff --git a/usr/src/uts/common/sys/ddi_implfuncs.h b/usr/src/uts/common/sys/ddi_implfuncs.h index d095aff6f8..23413cffef 100644 --- a/usr/src/uts/common/sys/ddi_implfuncs.h +++ b/usr/src/uts/common/sys/ddi_implfuncs.h @@ -23,6 +23,9 @@ * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ #ifndef _SYS_DDI_IMPLFUNCS_H #define _SYS_DDI_IMPLFUNCS_H @@ -74,12 +77,6 @@ i_ddi_mem_alloc(dev_info_t *dip, ddi_dma_attr_t *attributes, ddi_device_acc_attr_t *accattrp, caddr_t *kaddrp, size_t *real_length, ddi_acc_hdl_t *handlep); -int -i_ddi_mem_alloc_lim(dev_info_t *dip, ddi_dma_lim_t *limits, - size_t length, int cansleep, int streaming, - ddi_device_acc_attr_t *accattrp, caddr_t *kaddrp, - uint_t *real_length, ddi_acc_hdl_t *handlep); - void i_ddi_mem_free(caddr_t kaddr, ddi_acc_hdl_t *ap); diff --git a/usr/src/uts/common/sys/ddi_obsolete.h b/usr/src/uts/common/sys/ddi_obsolete.h index f93d89fb7e..7123b47af2 100644 --- a/usr/src/uts/common/sys/ddi_obsolete.h +++ b/usr/src/uts/common/sys/ddi_obsolete.h @@ -2,6 +2,9 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ #ifndef _SYS_DDI_OBSOLETE_H #define _SYS_DDI_OBSOLETE_H @@ -33,38 +36,9 @@ int ddi_iomin(dev_info_t *dip, int initial, int streaming); extern long strtol(const char *, char **, int); extern unsigned long strtoul(const char *, char **, int); -int ddi_dma_setup(dev_info_t *dip, struct ddi_dma_req *dmareqp, - ddi_dma_handle_t *handlep); -int ddi_dma_addr_setup(dev_info_t *dip, struct as *as, caddr_t addr, size_t len, - uint_t flags, int (*waitfp)(), caddr_t arg, ddi_dma_lim_t *limits, - ddi_dma_handle_t *handlep); -int ddi_dma_buf_setup(dev_info_t *dip, struct buf *bp, uint_t flags, - int (*waitfp)(), caddr_t arg, ddi_dma_lim_t *limits, - ddi_dma_handle_t *handlep); -int ddi_dma_kvaddrp(ddi_dma_handle_t, off_t, size_t, caddr_t *); -int ddi_dma_htoc(ddi_dma_handle_t handle, off_t off, ddi_dma_cookie_t *cookiep); -int ddi_dma_coff(ddi_dma_handle_t handle, ddi_dma_cookie_t *cookiep, - off_t *offp); -int ddi_dma_curwin(ddi_dma_handle_t handle, off_t *offp, size_t *lenp); -int ddi_dma_nextwin(ddi_dma_handle_t, ddi_dma_win_t, ddi_dma_win_t *); -int ddi_dma_nextseg(ddi_dma_win_t, ddi_dma_seg_t, ddi_dma_seg_t *); -int ddi_dma_segtocookie(ddi_dma_seg_t, off_t *, off_t *, ddi_dma_cookie_t *); -int ddi_dma_free(ddi_dma_handle_t handle); -int ddi_iopb_alloc(dev_info_t *dip, ddi_dma_lim_t *limits, uint_t length, - caddr_t *iopbp); -void ddi_iopb_free(caddr_t iopb); -int ddi_mem_alloc(dev_info_t *dip, ddi_dma_lim_t *limits, uint_t length, - uint_t flags, caddr_t *kaddrp, uint_t *real_length); -void ddi_mem_free(caddr_t kaddr); -int ddi_dma_get_attr(ddi_dma_handle_t handle, ddi_dma_attr_t *attrp); -int ddi_dma_devalign(ddi_dma_handle_t handle, uint_t *alignment, - uint_t *mineffect); -void ddi_dmalim_merge(ddi_dma_lim_t *limit, ddi_dma_lim_t *modifier); - -#if defined(__sparc) -int ddi_dma_movwin(ddi_dma_handle_t, off_t *offp, size_t *lenp, - ddi_dma_cookie_t *); -#endif +/* we'd really like to remove this; unbundled nexus drivers might have it */ +int ddi_dma_map(dev_info_t *dip, dev_info_t *rdip, + struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep); uint8_t ddi_mem_get8(ddi_acc_handle_t handle, uint8_t *host_addr); uint16_t ddi_mem_get16(ddi_acc_handle_t handle, uint16_t *host_addr); diff --git a/usr/src/uts/common/sys/ddidmareq.h b/usr/src/uts/common/sys/ddidmareq.h index aac53a6555..e7b2b5f30f 100644 --- a/usr/src/uts/common/sys/ddidmareq.h +++ b/usr/src/uts/common/sys/ddidmareq.h @@ -21,6 +21,9 @@ /* * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ #ifndef _SYS_DDIDMAREQ_H #define _SYS_DDIDMAREQ_H @@ -712,21 +715,21 @@ typedef struct ddi_dma_req { */ enum ddi_dma_ctlops { - DDI_DMA_FREE, /* free reference to object */ - DDI_DMA_SYNC, /* synchronize cache references */ - DDI_DMA_HTOC, /* return DMA cookie for handle */ - DDI_DMA_KVADDR, /* return kernel virtual address */ - DDI_DMA_MOVWIN, /* change mapped DMA window on object */ - DDI_DMA_REPWIN, /* report current window on DMA object */ - DDI_DMA_GETERR, /* report any post-transfer DMA errors */ - DDI_DMA_COFF, /* convert a DMA cookie to an offset */ - DDI_DMA_NEXTWIN, /* get next window within object */ - DDI_DMA_NEXTSEG, /* get next segment within window */ - DDI_DMA_SEGTOC, /* return segment DMA cookie */ + DDI_DMA_FREE, /* obsolete - do not use */ + DDI_DMA_SYNC, /* obsolete - do not use */ + DDI_DMA_HTOC, /* obsolete - do not use */ + DDI_DMA_KVADDR, /* obsolete - do not use */ + DDI_DMA_MOVWIN, /* obsolete - do not use */ + DDI_DMA_REPWIN, /* obsolete - do not use */ + DDI_DMA_GETERR, /* obsolete - do not use */ + DDI_DMA_COFF, /* obsolete - do not use */ + DDI_DMA_NEXTWIN, /* obsolete - do not use */ + DDI_DMA_NEXTSEG, /* obsolete - do not use */ + DDI_DMA_SEGTOC, /* obsolete - do not use */ DDI_DMA_RESERVE, /* reserve some DVMA range */ DDI_DMA_RELEASE, /* free preallocated DVMA range */ - DDI_DMA_RESETH, /* reset next cookie ptr in handle */ - DDI_DMA_CKSYNC, /* sync intermediate buffer to cookies */ + DDI_DMA_RESETH, /* obsolete - do not use */ + DDI_DMA_CKSYNC, /* obsolete - do not use */ DDI_DMA_IOPB_ALLOC, /* get contiguous DMA-able memory */ DDI_DMA_IOPB_FREE, /* return contiguous DMA-able memory */ DDI_DMA_SMEM_ALLOC, /* get contiguous DMA-able memory */ diff --git a/usr/src/uts/common/sys/devops.h b/usr/src/uts/common/sys/devops.h index 6efcdcc257..9e2bf1f7cc 100644 --- a/usr/src/uts/common/sys/devops.h +++ b/usr/src/uts/common/sys/devops.h @@ -22,6 +22,9 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ #ifndef _SYS_DEVOPS_H #define _SYS_DEVOPS_H @@ -74,10 +77,12 @@ extern "C" { * c XXwrite DDI/DKI * c XXioctl DDI/DKI * c XXdevmap DDI(Sun) - * c XXmmap DKI + * c XXmmap DKI(Obsolete) * c XXsegmap DKI * c XXchpoll DDI/DKI * c XXprop_op DDI(Sun) + * c XXaread DDI(Sun) + * c XXawrite DDI(Sun) */ struct cb_ops { @@ -129,14 +134,33 @@ struct cb_ops { * they will be called from outside the ddi. * * bus_map - Map/unmap/control IU -> device mappings. - * bus_get_intrspec - get interrupt specification by number - * bus_add_intrspec - add interrupt specification, return cookie - * bus_remove_intrspec - remove interrupt specification + * bus_get_intrspec - obsolete, not called + * bus_add_intrspec - obsolete, not called + * bus_remove_intrspec - obsolete, not called * bus_map_fault - bus fault handler - * bus_dma_map - setup dma mapping - * bus_dma_mapctl - control (and free) dma mapping + * bus_dma_map - obsolete, not called + * bus_dma_allochdl - allocate a DMA handle + * bus_dma_freehdl - free a DMA handle + * bus_dma_bindhdl - bind a DMA handle to physical mapping + * bus_dma_unbindhdl - unbind a DMA handle to physical mapping + * bus_dma_flush - flush DMA caches + * bus_dma_win - access DMA windows + * bus_dma_ctl - control dma mapping (legacy use only) * bus_ctl - generic control operations - * bus_prop_op _ request for property + * bus_prop_op - request for property + * bus_get_eventcookie - get an event cookie + * bus_add_eventcall - event call management + * bus_remove_eventcall - event call management + * bus_post_event - post an event + * bus_config - child node configuration + * bus_unconfig - child node unconfiguration + * bus_fm_init - FMA support + * bus_fm_fini - FMA support + * bus_fm_access_enter - FMA support + * bus_fm_access_exit - FMA support + * bus_power - power management + * bus_intr_op - control interrupt mappings + * bus_hp_op - hotplug support */ #define BUSO_REV_3 3 diff --git a/usr/src/uts/common/sys/dma_engine.h b/usr/src/uts/common/sys/dma_engine.h index 7e3e492e8e..80f75ec8ef 100644 --- a/usr/src/uts/common/sys/dma_engine.h +++ b/usr/src/uts/common/sys/dma_engine.h @@ -19,6 +19,11 @@ * * CDDL HEADER END */ + +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ + /* * Copyright 1998 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. @@ -34,8 +39,6 @@ #ifndef _SYS_DMAENGINE_H #define _SYS_DMAENGINE_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/types.h> #include <sys/dditypes.h> @@ -232,9 +235,8 @@ int ddi_dmae_1stparty(dev_info_t *dip, int chnl); * ddi_dmae_prog() can have dmaereqp set to NULL if only the address and * count have to be updated. * - * cookiep - pointer to a ddi_dma_cookie object obtained from - * ddi_dma_segtocookie(), which contains address, count and intermediate - * memory mapping information. + * cookiep - pointer to a ddi_dma_cookie object which contains address, + * count and intermediate memory mapping information. */ int ddi_dmae_prog(dev_info_t *dip, struct ddi_dmae_req *dmaereqp, diff --git a/usr/src/uts/common/sys/sunddi.h b/usr/src/uts/common/sys/sunddi.h index 26cafb882f..1eaf3a4feb 100644 --- a/usr/src/uts/common/sys/sunddi.h +++ b/usr/src/uts/common/sys/sunddi.h @@ -21,6 +21,7 @@ /* * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. */ #ifndef _SYS_SUNDDI_H @@ -1735,10 +1736,6 @@ ddi_ctlops(dev_info_t *d, dev_info_t *r, ddi_ctl_enum_t o, void *a, void *v); */ int -ddi_dma_map(dev_info_t *dip, dev_info_t *rdip, - struct ddi_dma_req *dmareqp, ddi_dma_handle_t *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); diff --git a/usr/src/uts/common/xen/io/xpvd.c b/usr/src/uts/common/xen/io/xpvd.c index b122e03fc1..7c655becbf 100644 --- a/usr/src/uts/common/xen/io/xpvd.c +++ b/usr/src/uts/common/xen/io/xpvd.c @@ -23,6 +23,9 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* * Host to hypervisor virtual devices nexus driver @@ -123,7 +126,7 @@ struct bus_ops xpvd_bus_ops = { NULL, NULL, i_ddi_map_fault, - ddi_dma_map, + NULL, ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/i86pc/io/acpi/acpinex/acpinex_drv.c b/usr/src/uts/i86pc/io/acpi/acpinex/acpinex_drv.c index 35fb4b6af5..7cf06ba394 100644 --- a/usr/src/uts/i86pc/io/acpi/acpinex/acpinex_drv.c +++ b/usr/src/uts/i86pc/io/acpi/acpinex/acpinex_drv.c @@ -28,6 +28,9 @@ * All rights reserved. */ /* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ +/* * This module implements a nexus driver for the ACPI virtual bus. * It does not handle any of the DDI functions passed up to it by the child * drivers, but instead allows them to bubble up to the root node. @@ -87,7 +90,7 @@ static struct bus_ops acpinex_bus_ops = { NULL, /* bus_add_intrspec */ NULL, /* bus_remove_intrspec */ i_ddi_map_fault, /* bus_map_fault */ - ddi_dma_map, /* bus_dma_map */ + NULL, /* bus_dma_map */ ddi_dma_allochdl, /* bus_dma_allochdl */ ddi_dma_freehdl, /* bus_dma_freehdl */ ddi_dma_bindhdl, /* bus_dma_bindhdl */ diff --git a/usr/src/uts/i86pc/io/amd_iommu/amd_iommu_impl.c b/usr/src/uts/i86pc/io/amd_iommu/amd_iommu_impl.c index 59c004458b..b5ab7d9cf6 100644 --- a/usr/src/uts/i86pc/io/amd_iommu/amd_iommu_impl.c +++ b/usr/src/uts/i86pc/io/amd_iommu/amd_iommu_impl.c @@ -21,6 +21,7 @@ /* * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. */ #include <sys/sunddi.h> @@ -63,13 +64,6 @@ static int amd_iommu_mapobject(iommulib_handle_t handle, dev_info_t *dip, struct ddi_dma_req *dmareq, ddi_dma_obj_t *dmao); static int amd_iommu_unmapobject(iommulib_handle_t handle, dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle, ddi_dma_obj_t *dmao); -static int amd_iommu_map(iommulib_handle_t handle, dev_info_t *dip, - dev_info_t *rdip, struct ddi_dma_req *dmareq, - ddi_dma_handle_t *dma_handle); -static int amd_iommu_mctl(iommulib_handle_t handle, dev_info_t *dip, - dev_info_t *rdip, ddi_dma_handle_t dma_handle, - enum ddi_dma_ctlops request, off_t *offp, size_t *lenp, - caddr_t *objpp, uint_t cache_flags); static int unmap_current_window(amd_iommu_t *iommu, dev_info_t *rdip, ddi_dma_cookie_t *cookie_array, uint_t ccount, int ncookies, int locked); @@ -112,8 +106,6 @@ struct iommulib_ops amd_iommulib_ops = { amd_iommu_win, amd_iommu_mapobject, amd_iommu_unmapobject, - amd_iommu_map, - amd_iommu_mctl }; static kmutex_t amd_iommu_pgtable_lock; @@ -1896,30 +1888,6 @@ out: return (error); } -/* Obsoleted DMA routines */ - -/*ARGSUSED*/ -static int -amd_iommu_map(iommulib_handle_t handle, dev_info_t *dip, - dev_info_t *rdip, struct ddi_dma_req *dmareq, - ddi_dma_handle_t *dma_handle) -{ - ASSERT(0); - return (iommulib_iommu_dma_map(dip, rdip, dmareq, dma_handle)); -} - -/*ARGSUSED*/ -static int -amd_iommu_mctl(iommulib_handle_t handle, dev_info_t *dip, - dev_info_t *rdip, ddi_dma_handle_t dma_handle, - enum ddi_dma_ctlops request, off_t *offp, size_t *lenp, - caddr_t *objpp, uint_t cache_flags) -{ - ASSERT(0); - return (iommulib_iommu_dma_mctl(dip, rdip, dma_handle, - request, offp, lenp, objpp, cache_flags)); -} - /*ARGSUSED*/ static int amd_iommu_mapobject(iommulib_handle_t handle, dev_info_t *dip, diff --git a/usr/src/uts/i86pc/io/immu_dvma.c b/usr/src/uts/i86pc/io/immu_dvma.c index 4dfa9c05b4..efc30c3d64 100644 --- a/usr/src/uts/i86pc/io/immu_dvma.c +++ b/usr/src/uts/i86pc/io/immu_dvma.c @@ -26,6 +26,9 @@ * Copyright (c) 2009, Intel Corporation. * All rights reserved. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* * DVMA code @@ -105,13 +108,6 @@ static int immu_mapobject(iommulib_handle_t handle, dev_info_t *dip, struct ddi_dma_req *dmareq, ddi_dma_obj_t *dmao); static int immu_unmapobject(iommulib_handle_t handle, dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle, ddi_dma_obj_t *dmao); -static int immu_map(iommulib_handle_t handle, dev_info_t *dip, - dev_info_t *rdip, struct ddi_dma_req *dmareq, - ddi_dma_handle_t *dma_handle); -static int immu_mctl(iommulib_handle_t handle, dev_info_t *dip, - dev_info_t *rdip, ddi_dma_handle_t dma_handle, - enum ddi_dma_ctlops request, off_t *offp, size_t *lenp, - caddr_t *objpp, uint_t cachefl); /* static Globals */ @@ -154,8 +150,6 @@ struct iommulib_ops immulib_ops = { immu_win, immu_mapobject, immu_unmapobject, - immu_map, - immu_mctl }; /* @@ -3183,24 +3177,3 @@ immu_unmapobject(iommulib_handle_t handle, dev_info_t *dip, return (DDI_SUCCESS); return (immu_unmap_dvmaseg(rdip, dmao)); } - -/*ARGSUSED*/ -static int -immu_map(iommulib_handle_t handle, dev_info_t *dip, - dev_info_t *rdip, struct ddi_dma_req *dmareq, - ddi_dma_handle_t *dma_handle) -{ - ASSERT(0); - return (DDI_FAILURE); -} - -/*ARGSUSED*/ -static int -immu_mctl(iommulib_handle_t handle, dev_info_t *dip, - dev_info_t *rdip, ddi_dma_handle_t dma_handle, - enum ddi_dma_ctlops request, off_t *offp, size_t *lenp, - caddr_t *objpp, uint_t cachefl) -{ - ASSERT(0); - return (DDI_FAILURE); -} diff --git a/usr/src/uts/i86pc/io/isa.c b/usr/src/uts/i86pc/io/isa.c index d2bb59ca99..b94cc6fbb4 100644 --- a/usr/src/uts/i86pc/io/isa.c +++ b/usr/src/uts/i86pc/io/isa.c @@ -20,6 +20,7 @@ */ /* * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. */ /* @@ -168,7 +169,7 @@ struct bus_ops isa_bus_ops = { NULL, NULL, i_ddi_map_fault, - ddi_dma_map, + NULL, isa_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/i86pc/io/pci/pci.c b/usr/src/uts/i86pc/io/pci/pci.c index d3e4148b40..b67b466cd1 100644 --- a/usr/src/uts/i86pc/io/pci/pci.c +++ b/usr/src/uts/i86pc/io/pci/pci.c @@ -22,6 +22,9 @@ * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* * Host to PCI local bus driver @@ -63,7 +66,7 @@ struct bus_ops pci_bus_ops = { NULL, NULL, i_ddi_map_fault, - ddi_dma_map, + NULL, ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/i86pc/io/pciex/npe.c b/usr/src/uts/i86pc/io/pciex/npe.c index 0342d7caf2..a0728cb7e2 100644 --- a/usr/src/uts/i86pc/io/pciex/npe.c +++ b/usr/src/uts/i86pc/io/pciex/npe.c @@ -25,6 +25,10 @@ */ /* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ + +/* * Host to PCI-Express local bus driver */ @@ -87,7 +91,7 @@ struct bus_ops npe_bus_ops = { NULL, NULL, i_ddi_map_fault, - ddi_dma_map, + NULL, ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/i86pc/io/rootnex.c b/usr/src/uts/i86pc/io/rootnex.c index ab2ffb503e..10b7fcb84b 100644 --- a/usr/src/uts/i86pc/io/rootnex.c +++ b/usr/src/uts/i86pc/io/rootnex.c @@ -24,6 +24,7 @@ /* * Copyright 2011 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2011 Bayard G. Bell. All rights reserved. + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. */ /* @@ -194,8 +195,6 @@ static int rootnex_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, static int rootnex_map_fault(dev_info_t *dip, dev_info_t *rdip, struct hat *hat, struct seg *seg, caddr_t addr, struct devpage *dp, pfn_t pfn, uint_t prot, uint_t lock); -static int rootnex_dma_map(dev_info_t *dip, dev_info_t *rdip, - struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep); static int rootnex_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); @@ -266,7 +265,7 @@ static struct bus_ops rootnex_bus_ops = { NULL, NULL, rootnex_map_fault, - rootnex_dma_map, + 0, rootnex_dma_allochdl, rootnex_dma_freehdl, rootnex_dma_bindhdl, @@ -338,8 +337,6 @@ static iommulib_nexops_t iommulib_nexops = { rootnex_coredma_get_sleep_flags, rootnex_coredma_sync, rootnex_coredma_win, - rootnex_dma_map, - rootnex_dma_mctl, rootnex_coredma_hdl_setprivate, rootnex_coredma_hdl_getprivate }; @@ -5003,91 +5000,9 @@ rootnex_coredma_hdl_getprivate(dev_info_t *dip, dev_info_t *rdip, */ /* - * 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_dma_map(dev_info_t *dip, dev_info_t *rdip, - struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep) -{ -#if defined(__amd64) - /* - * this interface is not supported in 64-bit x86 kernel. See comment in - * rootnex_dma_mctl() - */ - return (DDI_DMA_NORESOURCES); - -#else /* 32-bit x86 kernel */ - ddi_dma_handle_t *lhandlep; - ddi_dma_handle_t lhandle; - ddi_dma_cookie_t cookie; - ddi_dma_attr_t dma_attr; - ddi_dma_lim_t *dma_lim; - uint_t ccnt; - int e; - - - /* - * if the driver is just testing to see if it's possible to do the bind, - * we'll use local state. Otherwise, use the handle pointer passed in. - */ - if (handlep == NULL) { - lhandlep = &lhandle; - } else { - lhandlep = handlep; - } - - /* convert the limit structure to a dma_attr one */ - dma_lim = dmareq->dmar_limits; - dma_attr.dma_attr_version = DMA_ATTR_V0; - dma_attr.dma_attr_addr_lo = dma_lim->dlim_addr_lo; - dma_attr.dma_attr_addr_hi = dma_lim->dlim_addr_hi; - dma_attr.dma_attr_minxfer = dma_lim->dlim_minxfer; - dma_attr.dma_attr_seg = dma_lim->dlim_adreg_max; - dma_attr.dma_attr_count_max = dma_lim->dlim_ctreg_max; - dma_attr.dma_attr_granular = dma_lim->dlim_granular; - dma_attr.dma_attr_sgllen = dma_lim->dlim_sgllen; - dma_attr.dma_attr_maxxfer = dma_lim->dlim_reqsize; - dma_attr.dma_attr_burstsizes = dma_lim->dlim_burstsizes; - dma_attr.dma_attr_align = MMU_PAGESIZE; - dma_attr.dma_attr_flags = 0; - - e = rootnex_dma_allochdl(dip, rdip, &dma_attr, dmareq->dmar_fp, - dmareq->dmar_arg, lhandlep); - if (e != DDI_SUCCESS) { - return (e); - } - - e = rootnex_dma_bindhdl(dip, rdip, *lhandlep, dmareq, &cookie, &ccnt); - if ((e != DDI_DMA_MAPPED) && (e != DDI_DMA_PARTIAL_MAP)) { - (void) rootnex_dma_freehdl(dip, rdip, *lhandlep); - return (e); - } - - /* - * if the driver is just testing to see if it's possible to do the bind, - * free up the local state and return the result. - */ - if (handlep == NULL) { - (void) rootnex_dma_unbindhdl(dip, rdip, *lhandlep); - (void) rootnex_dma_freehdl(dip, rdip, *lhandlep); - if (e == DDI_DMA_MAPPED) { - return (DDI_DMA_MAPOK); - } else { - return (DDI_DMA_NOMAPPING); - } - } - - return (e); -#endif /* defined(__amd64) */ -} - -/* * rootnex_dma_mctl() * - * No IOMMU in 32 bit mode. The below routine doesn't work in 64 bit mode. + * We don't support this legacy interface any more on x86. */ /* ARGSUSED */ static int @@ -5095,185 +5010,11 @@ 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) { -#if defined(__amd64) - /* - * DDI_DMA_SMEM_ALLOC & DDI_DMA_IOPB_ALLOC we're changed to have a - * common implementation in genunix, so they no longer have x86 - * specific functionality which called into dma_ctl. - * - * The rest of the obsoleted interfaces were never supported in the - * 64-bit x86 kernel. For s10, the obsoleted DDI_DMA_SEGTOC interface - * was not ported to the x86 64-bit kernel do to serious x86 rootnex - * implementation issues. - * - * If you can't use DDI_DMA_SEGTOC; DDI_DMA_NEXTSEG, DDI_DMA_FREE, and - * DDI_DMA_NEXTWIN are useless since you can get to the cookie, so we - * reflect that now too... - * - * Even though we fixed the pointer problem in DDI_DMA_SEGTOC, we are - * not going to put this functionality into the 64-bit x86 kernel now. - * It wasn't ported to the 64-bit kernel for s10, no reason to change - * that in a future release. - */ - return (DDI_FAILURE); - -#else /* 32-bit x86 kernel */ - ddi_dma_cookie_t lcookie; - ddi_dma_cookie_t *cookie; - rootnex_window_t *window; - ddi_dma_impl_t *hp; - rootnex_dma_t *dma; - uint_t nwin; - uint_t ccnt; - size_t len; - off_t off; - int e; - - /* - * DDI_DMA_SEGTOC, DDI_DMA_NEXTSEG, and DDI_DMA_NEXTWIN are a little - * hacky since were optimizing for the current interfaces and so we can - * cleanup the mess in genunix. Hopefully we will remove the this - * obsoleted routines someday soon. + * The only thing dma_mctl is usef for anymore is legacy SPARC + * dvma and sbus-specific routines. */ - - switch (request) { - - case DDI_DMA_SEGTOC: /* ddi_dma_segtocookie() */ - hp = (ddi_dma_impl_t *)handle; - cookie = (ddi_dma_cookie_t *)objpp; - - /* - * convert segment to cookie. We don't distinguish between the - * two :-) - */ - *cookie = *hp->dmai_cookie; - *lenp = cookie->dmac_size; - *offp = cookie->dmac_type & ~ROOTNEX_USES_COPYBUF; - return (DDI_SUCCESS); - - case DDI_DMA_NEXTSEG: /* ddi_dma_nextseg() */ - hp = (ddi_dma_impl_t *)handle; - dma = (rootnex_dma_t *)hp->dmai_private; - - if ((*lenp != NULL) && ((uintptr_t)*lenp != (uintptr_t)hp)) { - return (DDI_DMA_STALE); - } - - /* handle the case where we don't have any windows */ - if (dma->dp_window == NULL) { - /* - * if seg == NULL, and we don't have any windows, - * return the first cookie in the sgl. - */ - if (*lenp == NULL) { - dma->dp_current_cookie = 0; - hp->dmai_cookie = dma->dp_cookies; - *objpp = (caddr_t)handle; - return (DDI_SUCCESS); - - /* if we have more cookies, go to the next cookie */ - } else { - if ((dma->dp_current_cookie + 1) >= - dma->dp_sglinfo.si_sgl_size) { - return (DDI_DMA_DONE); - } - dma->dp_current_cookie++; - hp->dmai_cookie++; - return (DDI_SUCCESS); - } - } - - /* We have one or more windows */ - window = &dma->dp_window[dma->dp_current_win]; - - /* - * if seg == NULL, return the first cookie in the current - * window - */ - if (*lenp == NULL) { - dma->dp_current_cookie = 0; - hp->dmai_cookie = window->wd_first_cookie; - - /* - * go to the next cookie in the window then see if we done with - * this window. - */ - } else { - if ((dma->dp_current_cookie + 1) >= - window->wd_cookie_cnt) { - return (DDI_DMA_DONE); - } - dma->dp_current_cookie++; - hp->dmai_cookie++; - } - *objpp = (caddr_t)handle; - return (DDI_SUCCESS); - - case DDI_DMA_NEXTWIN: /* ddi_dma_nextwin() */ - hp = (ddi_dma_impl_t *)handle; - dma = (rootnex_dma_t *)hp->dmai_private; - - if ((*offp != NULL) && ((uintptr_t)*offp != (uintptr_t)hp)) { - return (DDI_DMA_STALE); - } - - /* if win == NULL, return the first window in the bind */ - if (*offp == NULL) { - nwin = 0; - - /* - * else, go to the next window then see if we're done with all - * the windows. - */ - } else { - nwin = dma->dp_current_win + 1; - if (nwin >= hp->dmai_nwin) { - return (DDI_DMA_DONE); - } - } - - /* switch to the next window */ - e = rootnex_dma_win(dip, rdip, handle, nwin, &off, &len, - &lcookie, &ccnt); - ASSERT(e == DDI_SUCCESS); - if (e != DDI_SUCCESS) { - return (DDI_DMA_STALE); - } - - /* reset the cookie back to the first cookie in the window */ - if (dma->dp_window != NULL) { - window = &dma->dp_window[dma->dp_current_win]; - hp->dmai_cookie = window->wd_first_cookie; - } else { - hp->dmai_cookie = dma->dp_cookies; - } - - *objpp = (caddr_t)handle; - return (DDI_SUCCESS); - - case DDI_DMA_FREE: /* ddi_dma_free() */ - (void) rootnex_dma_unbindhdl(dip, rdip, handle); - (void) rootnex_dma_freehdl(dip, rdip, handle); - if (rootnex_state->r_dvma_call_list_id) { - ddi_run_callback(&rootnex_state->r_dvma_call_list_id); - } - return (DDI_SUCCESS); - - case DDI_DMA_IOPB_ALLOC: /* get contiguous DMA-able memory */ - case DDI_DMA_SMEM_ALLOC: /* get contiguous DMA-able memory */ - /* should never get here, handled in genunix */ - ASSERT(0); - return (DDI_FAILURE); - - case DDI_DMA_KVADDR: - case DDI_DMA_GETERR: - case DDI_DMA_COFF: - return (DDI_FAILURE); - } - return (DDI_FAILURE); -#endif /* defined(__amd64) */ } /* diff --git a/usr/src/uts/i86pc/ml/offsets.in b/usr/src/uts/i86pc/ml/offsets.in index 20e0c972d4..d867ade973 100644 --- a/usr/src/uts/i86pc/ml/offsets.in +++ b/usr/src/uts/i86pc/ml/offsets.in @@ -1,5 +1,6 @@ \ \ Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. +\ Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. \ \ CDDL HEADER START \ @@ -241,7 +242,6 @@ ddi_dma_impl dev_info devi_ops DEVI_DEV_OPS devi_bus_ctl - devi_bus_dma_map devi_bus_dma_ctl devi_bus_dma_allochdl devi_bus_dma_freehdl diff --git a/usr/src/uts/i86pc/os/ddi_impl.c b/usr/src/uts/i86pc/os/ddi_impl.c index a1ae318703..60347c6168 100644 --- a/usr/src/uts/i86pc/os/ddi_impl.c +++ b/usr/src/uts/i86pc/os/ddi_impl.c @@ -21,6 +21,7 @@ /* * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. */ /* @@ -1712,50 +1713,6 @@ i_ddi_mem_alloc(dev_info_t *dip, ddi_dma_attr_t *attr, return (DDI_SUCCESS); } -/* - * covert old DMA limits structure to DMA attribute structure - * and continue - */ -int -i_ddi_mem_alloc_lim(dev_info_t *dip, ddi_dma_lim_t *limits, - size_t length, int cansleep, int streaming, - ddi_device_acc_attr_t *accattrp, caddr_t *kaddrp, - uint_t *real_length, ddi_acc_hdl_t *ap) -{ - ddi_dma_attr_t dma_attr, *attrp; - size_t rlen; - int ret; - - if (limits == NULL) { - return (DDI_FAILURE); - } - - /* - * set up DMA attribute structure to pass to i_ddi_mem_alloc() - */ - attrp = &dma_attr; - attrp->dma_attr_version = DMA_ATTR_V0; - attrp->dma_attr_addr_lo = (uint64_t)limits->dlim_addr_lo; - attrp->dma_attr_addr_hi = (uint64_t)limits->dlim_addr_hi; - attrp->dma_attr_count_max = (uint64_t)limits->dlim_ctreg_max; - attrp->dma_attr_align = 1; - attrp->dma_attr_burstsizes = (uint_t)limits->dlim_burstsizes; - attrp->dma_attr_minxfer = (uint32_t)limits->dlim_minxfer; - attrp->dma_attr_maxxfer = (uint64_t)limits->dlim_reqsize; - attrp->dma_attr_seg = (uint64_t)limits->dlim_adreg_max; - attrp->dma_attr_sgllen = limits->dlim_sgllen; - attrp->dma_attr_granular = (uint32_t)limits->dlim_granular; - attrp->dma_attr_flags = 0; - - ret = i_ddi_mem_alloc(dip, attrp, length, cansleep, streaming, - accattrp, kaddrp, &rlen, ap); - if (ret == DDI_SUCCESS) { - if (real_length) - *real_length = (uint_t)rlen; - } - return (ret); -} - /* ARGSUSED */ void i_ddi_mem_free(caddr_t kaddr, ddi_acc_hdl_t *ap) diff --git a/usr/src/uts/intel/io/iommulib.c b/usr/src/uts/intel/io/iommulib.c index 8f36f92894..f3a78bded9 100644 --- a/usr/src/uts/intel/io/iommulib.c +++ b/usr/src/uts/intel/io/iommulib.c @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. */ #pragma ident "@(#)iommulib.c 1.6 08/09/07 SMI" @@ -245,21 +246,6 @@ iommulib_nexus_register(dev_info_t *dip, iommulib_nexops_t *nexops, return (DDI_FAILURE); } - /* Check for legacy ops */ - if (nexops->nops_dma_map == NULL) { - cmn_err(CE_WARN, "%s: %s%d: NULL legacy nops_dma_map op. " - "Failing registration for ops vector: %p", f, - driver, instance, (void *)nexops); - return (DDI_FAILURE); - } - - if (nexops->nops_dma_mctl == NULL) { - cmn_err(CE_WARN, "%s: %s%d: NULL legacy nops_dma_mctl op. " - "Failing registration for ops vector: %p", f, - driver, instance, (void *)nexops); - return (DDI_FAILURE); - } - nexp = kmem_zalloc(sizeof (iommulib_nex_t), KM_SLEEP); mutex_enter(&iommulib_lock); @@ -450,21 +436,6 @@ iommulib_iommu_register(dev_info_t *dip, iommulib_ops_t *ops, return (DDI_FAILURE); } - /* Check for legacy ops */ - if (ops->ilops_dma_map == NULL) { - cmn_err(CE_WARN, "%s: %s%d: NULL legacy dma_map op. " - "Failing registration for ops vector: %p", f, - driver, instance, (void *)ops); - return (DDI_FAILURE); - } - - if (ops->ilops_dma_mctl == NULL) { - cmn_err(CE_WARN, "%s: %s%d: NULL legacy dma_mctl op. " - "Failing registration for ops vector: %p", f, - driver, instance, (void *)ops); - return (DDI_FAILURE); - } - unitp = kmem_zalloc(sizeof (iommulib_unit_t), KM_SLEEP); mutex_enter(&iommulib_lock); if (iommulib_fini == 1) { @@ -757,37 +728,6 @@ iommulib_nexdma_win(dev_info_t *dip, dev_info_t *rdip, win, offp, lenp, cookiep, ccountp)); } -/* Obsolete DMA routines */ - -int -iommulib_nexdma_map(dev_info_t *dip, dev_info_t *rdip, - struct ddi_dma_req *dmareq, ddi_dma_handle_t *dma_handle) -{ - iommulib_handle_t handle = DEVI(rdip)->devi_iommulib_handle; - iommulib_unit_t *unitp = handle; - - ASSERT(unitp); - - /* No need to grab lock - the handle is reference counted */ - return (unitp->ilu_ops->ilops_dma_map(handle, dip, rdip, dmareq, - dma_handle)); -} - -int -iommulib_nexdma_mctl(dev_info_t *dip, dev_info_t *rdip, - ddi_dma_handle_t dma_handle, enum ddi_dma_ctlops request, - off_t *offp, size_t *lenp, caddr_t *objpp, uint_t cache_flags) -{ - iommulib_handle_t handle = DEVI(rdip)->devi_iommulib_handle; - iommulib_unit_t *unitp = (iommulib_unit_t *)handle; - - ASSERT(unitp); - - /* No need to grab lock - the handle is reference counted */ - return (unitp->ilu_ops->ilops_dma_mctl(handle, dip, rdip, dma_handle, - request, offp, lenp, objpp, cache_flags)); -} - int iommulib_nexdma_mapobject(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle, struct ddi_dma_req *dmareq, @@ -928,28 +868,6 @@ iommulib_iommu_dma_win(dev_info_t *dip, dev_info_t *rdip, } int -iommulib_iommu_dma_map(dev_info_t *dip, dev_info_t *rdip, - struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep) -{ - iommulib_nexops_t *nexops; - - nexops = &DEVI(dip)->devi_iommulib_nex_handle->nex_ops; - return (nexops->nops_dma_map(dip, rdip, dmareq, handlep)); -} - -int -iommulib_iommu_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) -{ - iommulib_nexops_t *nexops; - - nexops = &DEVI(dip)->devi_iommulib_nex_handle->nex_ops; - return (nexops->nops_dma_mctl(dip, rdip, handle, request, offp, lenp, - objpp, cache_flags)); -} - -int iommulib_iommu_dmahdl_setprivate(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle, void *priv) { diff --git a/usr/src/uts/intel/io/pci/pci_pci.c b/usr/src/uts/intel/io/pci/pci_pci.c index a0ade1d026..9f0ed4d67f 100644 --- a/usr/src/uts/intel/io/pci/pci_pci.c +++ b/usr/src/uts/intel/io/pci/pci_pci.c @@ -22,6 +22,9 @@ * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* * PCI to PCI bus bridge nexus driver @@ -93,7 +96,7 @@ struct bus_ops ppb_bus_ops = { 0, 0, i_ddi_map_fault, - ddi_dma_map, + 0, ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/intel/sys/iommulib.h b/usr/src/uts/intel/sys/iommulib.h index aa456ac8bb..7fb525edec 100644 --- a/usr/src/uts/intel/sys/iommulib.h +++ b/usr/src/uts/intel/sys/iommulib.h @@ -20,13 +20,12 @@ */ /* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. */ #ifndef _SYS_IOMMULIB_H #define _SYS_IOMMULIB_H -#pragma ident "@(#)iommulib.h 1.3 08/08/31 SMI" - #ifdef __cplusplus extern "C" { #endif @@ -45,10 +44,11 @@ typedef enum { typedef enum { IOMMU_OPS_VERSION_INVALID = 0, IOMMU_OPS_VERSION_1 = 1, - IOMMU_OPS_VERSION_2 = 2 + IOMMU_OPS_VERSION_2 = 2, + IOMMU_OPS_VERSION_3 = 3 } iommulib_opsversion_t; -#define IOMMU_OPS_VERSION IOMMU_OPS_VERSION_2 +#define IOMMU_OPS_VERSION IOMMU_OPS_VERSION_3 typedef struct iommulib_ops { iommulib_opsversion_t ilops_vers; @@ -90,17 +90,6 @@ typedef struct iommulib_ops { dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle, ddi_dma_obj_t *dmao); - /* Obsolete DMA routines */ - - int (*ilops_dma_map)(iommulib_handle_t handle, dev_info_t *dip, - dev_info_t *rdip, struct ddi_dma_req *dmareq, - ddi_dma_handle_t *dma_handle); - - int (*ilops_dma_mctl)(iommulib_handle_t handle, dev_info_t *dip, - dev_info_t *rdip, ddi_dma_handle_t dma_handle, - enum ddi_dma_ctlops request, off_t *offp, size_t *lenp, - caddr_t *objpp, uint_t cache_flags); - } iommulib_ops_t; /* @@ -130,10 +119,11 @@ typedef struct iommulib_ops { typedef enum { IOMMU_NEXOPS_VERSION_INVALID = 0, IOMMU_NEXOPS_VERSION_1 = 1, - IOMMU_NEXOPS_VERSION_2 = 2 + IOMMU_NEXOPS_VERSION_2 = 2, + IOMMU_NEXOPS_VERSION_3 = 3 } iommulib_nexops_version_t; -#define IOMMU_NEXOPS_VERSION IOMMU_NEXOPS_VERSION_2 +#define IOMMU_NEXOPS_VERSION IOMMU_NEXOPS_VERSION_3 typedef struct iommulib_nexops { iommulib_nexops_version_t nops_vers; @@ -174,13 +164,6 @@ typedef struct iommulib_nexops { ddi_dma_handle_t handle, uint_t win, off_t *offp, size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp); - int (*nops_dma_map)(dev_info_t *dip, dev_info_t *rdip, - struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep); - - int (*nops_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); - int (*nops_dmahdl_setprivate)(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle, void *priv); @@ -255,13 +238,6 @@ int iommulib_nexdma_win(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle, uint_t win, off_t *offp, size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp); -int iommulib_nexdma_map(dev_info_t *dip, dev_info_t *rdip, - struct ddi_dma_req *dmareq, ddi_dma_handle_t *dma_handle); - -int iommulib_nexdma_mctl(dev_info_t *dip, dev_info_t *rdip, - ddi_dma_handle_t dma_handle, enum ddi_dma_ctlops request, - off_t *offp, size_t *lenp, caddr_t *objpp, uint_t cache_flags); - int iommulib_nexdma_mapobject(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle, struct ddi_dma_req *dmareq, ddi_dma_obj_t *dmao); @@ -322,13 +298,6 @@ int iommulib_iommu_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); -int iommulib_iommu_dma_map(dev_info_t *dip, dev_info_t *rdip, - struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep); - -int iommulib_iommu_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); - int iommulib_iommu_dmahdl_setprivate(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle, void *priv); diff --git a/usr/src/uts/sparc/ml/sparc_ddi.s b/usr/src/uts/sparc/ml/sparc_ddi.s index a14d1fa2a0..7497459b4a 100644 --- a/usr/src/uts/sparc/ml/sparc_ddi.s +++ b/usr/src/uts/sparc/ml/sparc_ddi.s @@ -23,8 +23,9 @@ * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ - -#pragma ident "%Z%%M% %I% %E% SMI" +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* * Assembler routines to make some DDI routines go faster. @@ -167,30 +168,6 @@ ddi_ctlops(dev_info_t *d, dev_info_t *r, ddi_ctl_enum_t op, void *a, void *v) /* ARGSUSED */ int -ddi_dma_map(dev_info_t *dip, dev_info_t *rdip, - struct ddi_dma_req *dmareqp, ddi_dma_handle_t *handlep) -{ - return (DDI_SUCCESS); -} - -#else /* lint */ - - ENTRY(ddi_dma_map) - ldn [%o0 + DEVI_BUS_DMA_MAP], %o0 - ! dip = (dev_info_t *)DEVI(dip)->devi_bus_dma_map; - ldn [%o0 + DEVI_DEV_OPS], %g1 ! dip->dev_ops - ldn [%g1 + DEVI_BUS_OPS], %g1 ! dip->dev_ops->devo_bus_ops - ldn [%g1 + OPS_MAP], %g1 ! dip->dev_ops->devo_bus_ops->bus_dma_map - jmpl %g1, %g0 ! bop off to new routine - nop ! as if we had never been here - SET_SIZE(ddi_dma_map) - -#endif /* lint */ - -#if defined(lint) - -/* ARGSUSED */ -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) { diff --git a/usr/src/uts/sun/io/socal.c b/usr/src/uts/sun/io/socal.c index 6064218c37..084c59f0d5 100644 --- a/usr/src/uts/sun/io/socal.c +++ b/usr/src/uts/sun/io/socal.c @@ -23,7 +23,9 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ - +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* * socal - Serial Optical Channel Arbitrated Loop host adapter driver. @@ -308,7 +310,7 @@ static struct bus_ops socal_bus_ops = { 0, /* int (*bus_add_intrspec)(); */ 0, /* void (*bus_remove_intrspec)(); */ i_ddi_map_fault, /* int (*bus_map_fault)() */ - ddi_dma_map, /* int (*bus_dma_map)() */ + 0, /* int (*bus_dma_map)() */ ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/sun4/io/ebus.c b/usr/src/uts/sun4/io/ebus.c index d8d15f484b..19001588d5 100644 --- a/usr/src/uts/sun4/io/ebus.c +++ b/usr/src/uts/sun4/io/ebus.c @@ -22,6 +22,9 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ #include <sys/types.h> @@ -126,7 +129,7 @@ static struct bus_ops ebus_bus_ops = { NULL, NULL, i_ddi_map_fault, - ddi_dma_map, + NULL, ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/sun4/io/px/px_dma.c b/usr/src/uts/sun4/io/px/px_dma.c index aa06547597..148699c267 100644 --- a/usr/src/uts/sun4/io/px/px_dma.c +++ b/usr/src/uts/sun4/io/px/px_dma.c @@ -22,6 +22,9 @@ * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* * PCI Express nexus DVMA and DMA core routines: @@ -894,107 +897,6 @@ px_dvma_ctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_impl_t *mp, uint_t cache_flags) { switch (cmd) { - case DDI_DMA_SYNC: - return (px_lib_dma_sync(dip, rdip, (ddi_dma_handle_t)mp, - *offp, *lenp, cache_flags)); - - case DDI_DMA_HTOC: { - int ret; - off_t wo_off, off = *offp; /* wo_off: wnd's obj offset */ - uint_t win_size = mp->dmai_winsize; - ddi_dma_cookie_t *cp = (ddi_dma_cookie_t *)objp; - - if (off >= mp->dmai_object.dmao_size) { - cmn_err(CE_WARN, "%s%d invalid dma_htoc offset %lx", - NAMEINST(mp->dmai_rdip), off); - return (DDI_FAILURE); - } - off += mp->dmai_roffset; - ret = px_dma_win(dip, rdip, (ddi_dma_handle_t)mp, - off / win_size, &wo_off, NULL, cp, NULL); /* lenp == NULL */ - if (ret) - return (ret); - DBG(DBG_DMA_CTL, dip, "HTOC:cookie=%x+%lx off=%lx,%lx\n", - cp->dmac_address, cp->dmac_size, off, *offp); - - /* adjust cookie addr/len if we are not on window boundary */ - ASSERT((off % win_size) == (off - - (PX_DMA_CURWIN(mp) ? mp->dmai_roffset : 0) - wo_off)); - off = PX_DMA_CURWIN(mp) ? off % win_size : *offp; - ASSERT(cp->dmac_size > off); - cp->dmac_laddress += off; - cp->dmac_size -= off; - DBG(DBG_DMA_CTL, dip, "HTOC:mp=%p cookie=%x+%lx off=%lx,%lx\n", - mp, cp->dmac_address, cp->dmac_size, off, wo_off); - } - return (DDI_SUCCESS); - - case DDI_DMA_REPWIN: - *offp = mp->dmai_offset; - *lenp = mp->dmai_size; - return (DDI_SUCCESS); - - case DDI_DMA_MOVWIN: { - off_t off = *offp; - if (off >= mp->dmai_object.dmao_size) - return (DDI_FAILURE); - off += mp->dmai_roffset; - return (px_dma_win(dip, rdip, (ddi_dma_handle_t)mp, - off / mp->dmai_winsize, offp, lenp, - (ddi_dma_cookie_t *)objp, NULL)); - } - - case DDI_DMA_NEXTWIN: { - px_window_t win = PX_DMA_CURWIN(mp); - if (offp) { - if (*(px_window_t *)offp != win) { - /* window not active */ - *(px_window_t *)objp = win; /* return cur win */ - return (DDI_DMA_STALE); - } - win++; - } else /* map win 0 */ - win = 0; - if (win >= mp->dmai_nwin) { - *(px_window_t *)objp = win - 1; - return (DDI_DMA_DONE); - } - if (px_dma_win(dip, rdip, (ddi_dma_handle_t)mp, - win, 0, 0, 0, 0)) { - *(px_window_t *)objp = win - 1; - return (DDI_FAILURE); - } - *(px_window_t *)objp = win; - } - return (DDI_SUCCESS); - - case DDI_DMA_NEXTSEG: - if (*(px_window_t *)offp != PX_DMA_CURWIN(mp)) - return (DDI_DMA_STALE); - if (lenp) /* only 1 seg allowed */ - return (DDI_DMA_DONE); - - /* return mp as seg 0 */ - *(ddi_dma_seg_t *)objp = (ddi_dma_seg_t)mp; - return (DDI_SUCCESS); - - case DDI_DMA_SEGTOC: - MAKE_DMA_COOKIE((ddi_dma_cookie_t *)objp, mp->dmai_mapping, - mp->dmai_size); - *offp = mp->dmai_offset; - *lenp = mp->dmai_size; - return (DDI_SUCCESS); - - case DDI_DMA_COFF: { - ddi_dma_cookie_t *cp = (ddi_dma_cookie_t *)offp; - if (cp->dmac_address < mp->dmai_mapping || - (cp->dmac_address + cp->dmac_size) > - (mp->dmai_mapping + mp->dmai_size)) - return (DDI_FAILURE); - *objp = (caddr_t)(cp->dmac_address - mp->dmai_mapping + - mp->dmai_offset); - } - return (DDI_SUCCESS); default: DBG(DBG_DMA_CTL, dip, "unknown command (%x): rdip=%s%d\n", cmd, ddi_driver_name(rdip), ddi_get_instance(rdip)); @@ -1343,153 +1245,6 @@ px_dma_ctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_impl_t *mp, uint_t cache_flags) { switch (cmd) { - case DDI_DMA_SYNC: - return (DDI_SUCCESS); - - case DDI_DMA_HTOC: { - off_t off = *offp; - ddi_dma_cookie_t *loop_cp, *cp; - px_dma_win_t *win_p = mp->dmai_winlst; - - if (off >= mp->dmai_object.dmao_size) - return (DDI_FAILURE); - - /* locate window */ - while (win_p->win_offset + win_p->win_size <= off) - win_p = win_p->win_next; - - loop_cp = cp = (ddi_dma_cookie_t *)(win_p + 1); - mp->dmai_offset = win_p->win_offset; - mp->dmai_size = win_p->win_size; - mp->dmai_mapping = cp->dmac_laddress; /* cookie0 start addr */ - - /* adjust cookie addr/len if we are not on cookie boundary */ - off -= win_p->win_offset; /* offset within window */ - for (; off >= loop_cp->dmac_size; loop_cp++) - off -= loop_cp->dmac_size; /* offset within cookie */ - - mp->dmai_cookie = loop_cp + 1; - win_p->win_curseg = loop_cp - cp; - cp = (ddi_dma_cookie_t *)objp; - MAKE_DMA_COOKIE(cp, loop_cp->dmac_laddress + off, - loop_cp->dmac_size - off); - - DBG(DBG_DMA_CTL, dip, - "HTOC: cookie - dmac_laddress=%p dmac_size=%x\n", - cp->dmac_laddress, cp->dmac_size); - } - return (DDI_SUCCESS); - - case DDI_DMA_REPWIN: - *offp = mp->dmai_offset; - *lenp = mp->dmai_size; - return (DDI_SUCCESS); - - case DDI_DMA_MOVWIN: { - off_t off = *offp; - ddi_dma_cookie_t *cp; - px_dma_win_t *win_p = mp->dmai_winlst; - - if (off >= mp->dmai_object.dmao_size) - return (DDI_FAILURE); - - /* locate window */ - while (win_p->win_offset + win_p->win_size <= off) - win_p = win_p->win_next; - - cp = (ddi_dma_cookie_t *)(win_p + 1); - mp->dmai_offset = win_p->win_offset; - mp->dmai_size = win_p->win_size; - mp->dmai_mapping = cp->dmac_laddress; /* cookie0 star addr */ - mp->dmai_cookie = cp + 1; - win_p->win_curseg = 0; - - *(ddi_dma_cookie_t *)objp = *cp; - *offp = win_p->win_offset; - *lenp = win_p->win_size; - DBG(DBG_DMA_CTL, dip, - "HTOC: cookie - dmac_laddress=%p dmac_size=%x\n", - cp->dmac_laddress, cp->dmac_size); - } - return (DDI_SUCCESS); - - case DDI_DMA_NEXTWIN: { - px_dma_win_t *win_p = *(px_dma_win_t **)offp; - px_dma_win_t **nw_pp = (px_dma_win_t **)objp; - ddi_dma_cookie_t *cp; - if (!win_p) { - *nw_pp = mp->dmai_winlst; - return (DDI_SUCCESS); - } - - if (win_p->win_offset != mp->dmai_offset) - return (DDI_DMA_STALE); - if (!win_p->win_next) - return (DDI_DMA_DONE); - win_p = win_p->win_next; - cp = (ddi_dma_cookie_t *)(win_p + 1); - mp->dmai_offset = win_p->win_offset; - mp->dmai_size = win_p->win_size; - mp->dmai_mapping = cp->dmac_laddress; /* cookie0 star addr */ - mp->dmai_cookie = cp + 1; - win_p->win_curseg = 0; - *nw_pp = win_p; - } - return (DDI_SUCCESS); - - case DDI_DMA_NEXTSEG: { - px_dma_win_t *w_p = *(px_dma_win_t **)offp; - if (w_p->win_offset != mp->dmai_offset) - return (DDI_DMA_STALE); - if (w_p->win_curseg + 1 >= w_p->win_ncookies) - return (DDI_DMA_DONE); - w_p->win_curseg++; - } - *(ddi_dma_seg_t *)objp = (ddi_dma_seg_t)mp; - return (DDI_SUCCESS); - - case DDI_DMA_SEGTOC: { - px_dma_win_t *win_p = mp->dmai_winlst; - off_t off = mp->dmai_offset; - ddi_dma_cookie_t *cp; - int i; - - /* locate active window */ - for (; win_p->win_offset != off; win_p = win_p->win_next) - ; - cp = (ddi_dma_cookie_t *)(win_p + 1); - for (i = 0; i < win_p->win_curseg; i++, cp++) - off += cp->dmac_size; - *offp = off; - *lenp = cp->dmac_size; - *(ddi_dma_cookie_t *)objp = *cp; /* copy cookie */ - } - return (DDI_SUCCESS); - - case DDI_DMA_COFF: { - px_dma_win_t *win_p; - ddi_dma_cookie_t *cp; - uint64_t addr, key = ((ddi_dma_cookie_t *)offp)->dmac_laddress; - size_t win_off; - - for (win_p = mp->dmai_winlst; win_p; win_p = win_p->win_next) { - int i; - win_off = 0; - cp = (ddi_dma_cookie_t *)(win_p + 1); - for (i = 0; i < win_p->win_ncookies; i++, cp++) { - size_t sz = cp->dmac_size; - - addr = cp->dmac_laddress; - if ((addr <= key) && (addr + sz >= key)) - goto found; - win_off += sz; - } - } - return (DDI_FAILURE); -found: - *objp = (caddr_t)(win_p->win_offset + win_off + (key - addr)); - return (DDI_SUCCESS); - } default: DBG(DBG_DMA_CTL, dip, "unknown command (%x): rdip=%s%d\n", cmd, ddi_driver_name(rdip), ddi_get_instance(rdip)); diff --git a/usr/src/uts/sun4/io/px/px_mmu.c b/usr/src/uts/sun4/io/px/px_mmu.c index 0c68271053..967edf917c 100644 --- a/usr/src/uts/sun4/io/px/px_mmu.c +++ b/usr/src/uts/sun4/io/px/px_mmu.c @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. */ /* @@ -257,7 +258,7 @@ px_mmu_unmap_pages(px_mmu_t *mmu_p, ddi_dma_impl_t *mp, px_dvma_addr_t dvma_pg, /* * px_mmu_map_window - map a dvma window into the mmu - * used by: px_dma_win(), px_dma_ctlops() - DDI_DMA_MOVWIN, DDI_DMA_NEXTWIN + * used by: px_dma_win() * return value: none */ /*ARGSUSED*/ diff --git a/usr/src/uts/sun4/ml/offsets.in b/usr/src/uts/sun4/ml/offsets.in index 377cfbd319..4f6d19ba01 100644 --- a/usr/src/uts/sun4/ml/offsets.in +++ b/usr/src/uts/sun4/ml/offsets.in @@ -1,5 +1,6 @@ \ offsets.in: input file to produce assym.h using the stabs program \ Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. +\ Copyright 2012 Garrett D'Amore <garett@damore.org>. All rights reserved. \ \ CDDL HEADER START \ @@ -466,7 +467,6 @@ syncq SQ_SIZE sq_exitwait bus_ops BUS_OPS_SIZE - bus_dma_map OPS_MAP bus_dma_allochdl OPS_ALLOCHDL bus_dma_freehdl OPS_FREEHDL bus_dma_bindhdl OPS_BINDHDL @@ -489,7 +489,6 @@ dev_info DEVI_SIZE devi_bus_dma_flush devi_bus_dma_unbindfunc devi_bus_ctl - devi_bus_dma_map devi_bus_dma_ctl kstat_io diff --git a/usr/src/uts/sun4/os/ddi_impl.c b/usr/src/uts/sun4/os/ddi_impl.c index f3efc433c5..6769c48b9d 100644 --- a/usr/src/uts/sun4/os/ddi_impl.c +++ b/usr/src/uts/sun4/os/ddi_impl.c @@ -23,6 +23,9 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* * sun4 specific DDI implementation @@ -1209,44 +1212,6 @@ i_ddi_mem_alloc(dev_info_t *dip, ddi_dma_attr_t *attr, } } -/* - * covert old DMA limits structure to DMA attribute structure - * and continue - */ -int -i_ddi_mem_alloc_lim(dev_info_t *dip, ddi_dma_lim_t *limits, - size_t length, int cansleep, int streaming, - ddi_device_acc_attr_t *accattrp, caddr_t *kaddrp, - uint_t *real_length, ddi_acc_hdl_t *ap) -{ - ddi_dma_attr_t dma_attr, *attrp; - size_t rlen; - int ret; - - ASSERT(limits); - attrp = &dma_attr; - attrp->dma_attr_version = DMA_ATTR_V0; - attrp->dma_attr_addr_lo = (uint64_t)limits->dlim_addr_lo; - attrp->dma_attr_addr_hi = (uint64_t)limits->dlim_addr_hi; - attrp->dma_attr_count_max = (uint64_t)-1; - attrp->dma_attr_align = 1; - attrp->dma_attr_burstsizes = (uint_t)limits->dlim_burstsizes; - attrp->dma_attr_minxfer = (uint32_t)limits->dlim_minxfer; - attrp->dma_attr_maxxfer = (uint64_t)-1; - attrp->dma_attr_seg = (uint64_t)limits->dlim_cntr_max; - attrp->dma_attr_sgllen = 1; - attrp->dma_attr_granular = 1; - attrp->dma_attr_flags = 0; - - ret = i_ddi_mem_alloc(dip, attrp, length, cansleep, streaming, - accattrp, kaddrp, &rlen, ap); - if (ret == DDI_SUCCESS) { - if (real_length) - *real_length = (uint_t)rlen; - } - return (ret); -} - /* ARGSUSED */ void i_ddi_mem_free(caddr_t kaddr, ddi_acc_hdl_t *ap) diff --git a/usr/src/uts/sun4u/io/iommu.c b/usr/src/uts/sun4u/io/iommu.c index 66d7a46dc2..75937f0b0f 100644 --- a/usr/src/uts/sun4u/io/iommu.c +++ b/usr/src/uts/sun4u/io/iommu.c @@ -22,6 +22,9 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ #include <sys/types.h> #include <sys/param.h> @@ -59,12 +62,7 @@ #define IOMMU_DMAMCTL_SYNC_DEBUG 0x8 #define IOMMU_DMAMCTL_HTOC_DEBUG 0x10 #define IOMMU_DMAMCTL_KVADDR_DEBUG 0x20 -#define IOMMU_DMAMCTL_NEXTWIN_DEBUG 0x40 -#define IOMMU_DMAMCTL_NEXTSEG_DEBUG 0x80 -#define IOMMU_DMAMCTL_MOVWIN_DEBUG 0x100 -#define IOMMU_DMAMCTL_REPWIN_DEBUG 0x200 #define IOMMU_DMAMCTL_GETERR_DEBUG 0x400 -#define IOMMU_DMAMCTL_COFF_DEBUG 0x800 #define IOMMU_DMAMCTL_DMA_FREE_DEBUG 0x1000 #define IOMMU_REGISTERS_DEBUG 0x2000 #define IOMMU_DMA_SETUP_DEBUG 0x4000 @@ -1304,85 +1302,6 @@ iommu_map_window(ddi_dma_impl_t *mp, off_t newoff, size_t winsize) } -int -iommu_dma_map(dev_info_t *dip, dev_info_t *rdip, - struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep) -{ - ddi_dma_lim_t *dma_lim = dmareq->dmar_limits; - ddi_dma_impl_t *mp; - ddi_dma_attr_t *dma_attr; - struct dma_impl_priv *mppriv; - ioaddr_t addrlow, addrhigh; - ioaddr_t segalign; - int rval; - struct sbus_soft_state *softsp = - (struct sbus_soft_state *)ddi_get_soft_state(sbusp, - ddi_get_instance(dip)); - - addrlow = dma_lim->dlim_addr_lo; - addrhigh = dma_lim->dlim_addr_hi; - if ((addrhigh <= addrlow) || - (addrhigh < (ioaddr_t)softsp->iommu_dvma_base)) { - return (DDI_DMA_NOMAPPING); - } - - /* - * Setup DMA burstsizes and min-xfer counts. - */ - (void) iommu_dma_lim_setup(dip, rdip, softsp, &dma_lim->dlim_burstsizes, - (uint_t)dma_lim->dlim_burstsizes, &dma_lim->dlim_minxfer, - dmareq->dmar_flags); - - if (dma_lim->dlim_burstsizes == 0) - return (DDI_DMA_NOMAPPING); - /* - * If not an advisory call, get a DMA handle - */ - if (!handlep) { - return (DDI_DMA_MAPOK); - } - - mppriv = kmem_zalloc(sizeof (*mppriv), - (dmareq->dmar_fp == DDI_DMA_SLEEP) ? KM_SLEEP : KM_NOSLEEP); - if (mppriv == NULL) { - if (dmareq->dmar_fp != DDI_DMA_DONTWAIT) { - ddi_set_callback(dmareq->dmar_fp, - dmareq->dmar_arg, &softsp->dvma_call_list_id); - } - return (DDI_DMA_NORESOURCES); - } - mp = (ddi_dma_impl_t *)mppriv; - mp->dmai_rdip = rdip; - mp->dmai_rflags = dmareq->dmar_flags & DMP_DDIFLAGS; - mp->dmai_minxfer = dma_lim->dlim_minxfer; - mp->dmai_burstsizes = dma_lim->dlim_burstsizes; - mp->dmai_offset = 0; - mp->dmai_ndvmapages = 0; - mp->dmai_minfo = 0; - mp->dmai_inuse = 0; - segalign = dma_lim->dlim_cntr_max; - /* See if the DMA engine has any limit restrictions. */ - if (segalign == UINT32_MAX && addrhigh == UINT32_MAX && - addrlow == 0) { - mp->dmai_rflags |= DMP_NOLIMIT; - } - mppriv->softsp = softsp; - mppriv->phys_sync_flag = va_to_pa((caddr_t)&mppriv->sync_flag); - dma_attr = &mp->dmai_attr; - dma_attr->dma_attr_align = 1; - dma_attr->dma_attr_addr_lo = addrlow; - dma_attr->dma_attr_addr_hi = addrhigh; - dma_attr->dma_attr_seg = segalign; - dma_attr->dma_attr_burstsizes = dma_lim->dlim_burstsizes; - rval = iommu_dma_bindhdl(dip, rdip, (ddi_dma_handle_t)mp, - dmareq, NULL, NULL); - if (rval && (rval != DDI_DMA_PARTIAL_MAP)) { - kmem_free(mppriv, sizeof (*mppriv)); - } else { - *handlep = (ddi_dma_handle_t)mp; - } - return (rval); -} /*ARGSUSED*/ int @@ -1390,57 +1309,11 @@ iommu_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 *objp, uint_t cache_flags) { - ioaddr_t addr; - uint_t offset; pgcnt_t npages; - size_t size; - ddi_dma_cookie_t *cp; ddi_dma_impl_t *mp = (ddi_dma_impl_t *)handle; DPRINTF(IOMMU_DMAMCTL_DEBUG, ("dma_mctl: handle %p ", (void *)mp)); switch (request) { - case DDI_DMA_FREE: - { - struct dma_impl_priv *mppriv = (struct dma_impl_priv *)mp; - struct sbus_soft_state *softsp = mppriv->softsp; - ASSERT(softsp != NULL); - - /* - * 'Free' the dma mappings. - */ - addr = (ioaddr_t)(mp->dmai_mapping & ~IOMMU_PAGEOFFSET); - npages = mp->dmai_ndvmapages; - size = iommu_ptob(npages); - - DPRINTF(IOMMU_DMAMCTL_DMA_FREE_DEBUG, ("iommu_dma_mctl dmafree:" - "freeing vaddr %x for %x pages.\n", addr, - mp->dmai_ndvmapages)); - /* sync the entire object */ - if (!(mp->dmai_rflags & DDI_DMA_CONSISTENT)) { - /* flush stream write buffers */ - sync_stream_buf(softsp, addr, npages, - (int *)&mppriv->sync_flag, mppriv->phys_sync_flag); - } - -#if defined(DEBUG) && defined(IO_MEMDEBUG) - iommu_remove_mappings(mp); -#endif /* DEBUG && IO_MEMDEBUG */ - - ASSERT(npages > (uint_t)0); - if (mp->dmai_rflags & DMP_NOLIMIT) - vmem_free(softsp->dvma_arena, - (void *)(uintptr_t)addr, size); - else - vmem_xfree(softsp->dvma_arena, - (void *)(uintptr_t)addr, size); - - kmem_free(mppriv, sizeof (*mppriv)); - - if (softsp->dvma_call_list_id != 0) - ddi_run_callback(&softsp->dvma_call_list_id); - - break; - } case DDI_DMA_SET_SBUS64: { @@ -1451,203 +1324,6 @@ iommu_dma_mctl(dev_info_t *dip, dev_info_t *rdip, DDI_DMA_SBUS_64BIT)); } - case DDI_DMA_HTOC: - DPRINTF(IOMMU_DMAMCTL_HTOC_DEBUG, ("htoc off %lx mapping %lx " - "size %x\n", *offp, mp->dmai_mapping, - mp->dmai_size)); - - if ((uint_t)(*offp) >= mp->dmai_size) - return (DDI_FAILURE); - - cp = (ddi_dma_cookie_t *)objp; - cp->dmac_notused = 0; - cp->dmac_address = (mp->dmai_mapping + (uint_t)(*offp)); - cp->dmac_size = - mp->dmai_mapping + mp->dmai_size - cp->dmac_address; - cp->dmac_type = 0; - - break; - - case DDI_DMA_KVADDR: - /* - * If a physical address mapping has percolated this high, - * that is an error (maybe?). - */ - if (mp->dmai_rflags & DMP_PHYSADDR) { - DPRINTF(IOMMU_DMAMCTL_KVADDR_DEBUG, ("kvaddr of phys " - "mapping\n")); - return (DDI_FAILURE); - } - - return (DDI_FAILURE); - - case DDI_DMA_NEXTWIN: - { - ddi_dma_win_t *owin, *nwin; - uint_t winsize, newoff; - int rval; - - DPRINTF(IOMMU_DMAMCTL_NEXTWIN_DEBUG, ("nextwin\n")); - - mp = (ddi_dma_impl_t *)handle; - owin = (ddi_dma_win_t *)offp; - nwin = (ddi_dma_win_t *)objp; - if (mp->dmai_rflags & DDI_DMA_PARTIAL) { - if (*owin == NULL) { - DPRINTF(IOMMU_DMAMCTL_NEXTWIN_DEBUG, - ("nextwin: win == NULL\n")); - mp->dmai_offset = 0; - *nwin = (ddi_dma_win_t)mp; - return (DDI_SUCCESS); - } - - offset = (uint_t)(mp->dmai_mapping & IOMMU_PAGEOFFSET); - winsize = iommu_ptob(mp->dmai_ndvmapages - - iommu_btopr(offset)); - - newoff = (uint_t)(mp->dmai_offset + winsize); - if (newoff > mp->dmai_object.dmao_size - - mp->dmai_minxfer) - return (DDI_DMA_DONE); - - if ((rval = iommu_map_window(mp, newoff, winsize)) - != DDI_SUCCESS) - return (rval); - } else { - DPRINTF(IOMMU_DMAMCTL_NEXTWIN_DEBUG, ("nextwin: no " - "partial mapping\n")); - if (*owin != NULL) - return (DDI_DMA_DONE); - mp->dmai_offset = 0; - *nwin = (ddi_dma_win_t)mp; - } - break; - } - - case DDI_DMA_NEXTSEG: - { - ddi_dma_seg_t *oseg, *nseg; - - DPRINTF(IOMMU_DMAMCTL_NEXTSEG_DEBUG, ("nextseg:\n")); - - oseg = (ddi_dma_seg_t *)lenp; - if (*oseg != NULL) - return (DDI_DMA_DONE); - nseg = (ddi_dma_seg_t *)objp; - *nseg = *((ddi_dma_seg_t *)offp); - break; - } - - case DDI_DMA_SEGTOC: - { - ddi_dma_seg_impl_t *seg; - - seg = (ddi_dma_seg_impl_t *)handle; - cp = (ddi_dma_cookie_t *)objp; - cp->dmac_notused = 0; - cp->dmac_address = (ioaddr_t)seg->dmai_mapping; - cp->dmac_size = *lenp = seg->dmai_size; - cp->dmac_type = 0; - *offp = seg->dmai_offset; - break; - } - - case DDI_DMA_MOVWIN: - { - uint_t winsize; - uint_t newoff; - int rval; - - offset = (uint_t)(mp->dmai_mapping & IOMMU_PAGEOFFSET); - winsize = iommu_ptob(mp->dmai_ndvmapages - iommu_btopr(offset)); - - DPRINTF(IOMMU_DMAMCTL_MOVWIN_DEBUG, ("movwin off %lx len %lx " - "winsize %x\n", *offp, *lenp, winsize)); - - if ((mp->dmai_rflags & DDI_DMA_PARTIAL) == 0) - return (DDI_FAILURE); - - if (*lenp != (uint_t)-1 && *lenp != winsize) { - DPRINTF(IOMMU_DMAMCTL_MOVWIN_DEBUG, ("bad length\n")); - return (DDI_FAILURE); - } - newoff = (uint_t)*offp; - if (newoff & (winsize - 1)) { - DPRINTF(IOMMU_DMAMCTL_MOVWIN_DEBUG, ("bad off\n")); - return (DDI_FAILURE); - } - - if (newoff == mp->dmai_offset) { - /* - * Nothing to do... - */ - break; - } - - /* - * Check out new address... - */ - if (newoff > mp->dmai_object.dmao_size - mp->dmai_minxfer) { - DPRINTF(IOMMU_DMAMCTL_MOVWIN_DEBUG, ("newoff out of " - "range\n")); - return (DDI_FAILURE); - } - - rval = iommu_map_window(mp, newoff, winsize); - if (rval != DDI_SUCCESS) - return (rval); - - if ((cp = (ddi_dma_cookie_t *)objp) != 0) { - cp->dmac_notused = 0; - cp->dmac_address = (ioaddr_t)mp->dmai_mapping; - cp->dmac_size = mp->dmai_size; - cp->dmac_type = 0; - } - *offp = (off_t)newoff; - *lenp = (uint_t)winsize; - break; - } - - case DDI_DMA_REPWIN: - if ((mp->dmai_rflags & DDI_DMA_PARTIAL) == 0) { - DPRINTF(IOMMU_DMAMCTL_REPWIN_DEBUG, ("repwin fail\n")); - return (DDI_FAILURE); - } - - *offp = (off_t)mp->dmai_offset; - - addr = mp->dmai_ndvmapages - - iommu_btopr(mp->dmai_mapping & IOMMU_PAGEOFFSET); - - *lenp = (uint_t)iommu_ptob(addr); - - DPRINTF(IOMMU_DMAMCTL_REPWIN_DEBUG, ("repwin off %lx len %x\n", - mp->dmai_offset, mp->dmai_size)); - - break; - - case DDI_DMA_GETERR: - DPRINTF(IOMMU_DMAMCTL_GETERR_DEBUG, - ("iommu_dma_mctl: geterr\n")); - - break; - - case DDI_DMA_COFF: - cp = (ddi_dma_cookie_t *)offp; - addr = cp->dmac_address; - - if (addr < mp->dmai_mapping || - addr >= mp->dmai_mapping + mp->dmai_size) - return (DDI_FAILURE); - - *objp = (caddr_t)(addr - mp->dmai_mapping); - - DPRINTF(IOMMU_DMAMCTL_COFF_DEBUG, ("coff off %lx mapping %lx " - "size %x\n", (ulong_t)*objp, mp->dmai_mapping, - mp->dmai_size)); - - break; - case DDI_DMA_RESERVE: { struct ddi_dma_req *dmareq = (struct ddi_dma_req *)offp; diff --git a/usr/src/uts/sun4u/io/isadma.c b/usr/src/uts/sun4u/io/isadma.c index 2372b3b11b..610391baa1 100644 --- a/usr/src/uts/sun4u/io/isadma.c +++ b/usr/src/uts/sun4u/io/isadma.c @@ -22,6 +22,9 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ #include <sys/conf.h> @@ -90,7 +93,7 @@ static struct bus_ops isadma_bus_ops = { NULL, NULL, i_ddi_map_fault, - ddi_dma_map, + NULL, ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/sun4u/io/pci/db21554.c b/usr/src/uts/sun4u/io/pci/db21554.c index 5a08ae7b5d..f51ad8c0e6 100644 --- a/usr/src/uts/sun4u/io/pci/db21554.c +++ b/usr/src/uts/sun4u/io/pci/db21554.c @@ -22,6 +22,9 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* @@ -277,7 +280,7 @@ struct bus_ops db_bus_ops = { 0, 0, i_ddi_map_fault, - ddi_dma_map, + 0, ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/sun4u/io/pci/pci_dma.c b/usr/src/uts/sun4u/io/pci/pci_dma.c index 5a614bf28d..9814a69e68 100644 --- a/usr/src/uts/sun4u/io/pci/pci_dma.c +++ b/usr/src/uts/sun4u/io/pci/pci_dma.c @@ -22,6 +22,9 @@ * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* * PCI nexus DVMA and DMA core routines: @@ -1110,106 +1113,6 @@ pci_dvma_ctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_impl_t *mp, uint_t cache_flags) { switch (cmd) { - case DDI_DMA_SYNC: - return (pci_dma_sync(dip, rdip, (ddi_dma_handle_t)mp, - *offp, *lenp, cache_flags)); - - case DDI_DMA_HTOC: { - int ret; - off_t wo_off, off = *offp; /* wo_off: wnd's obj offset */ - uint_t win_size = mp->dmai_winsize; - ddi_dma_cookie_t *cp = (ddi_dma_cookie_t *)objp; - - if (off >= mp->dmai_object.dmao_size) { - cmn_err(CE_WARN, "%s%d invalid dma_htoc offset %lx", - NAMEINST(mp->dmai_rdip), off); - return (DDI_FAILURE); - } - off += mp->dmai_roffset; - ret = pci_dma_win(dip, rdip, (ddi_dma_handle_t)mp, - off / win_size, &wo_off, NULL, cp, NULL); /* lenp == NULL */ - if (ret) - return (ret); - DEBUG4(DBG_DMA_CTL, dip, "HTOC:cookie=%x+%lx off=%lx,%lx\n", - cp->dmac_address, cp->dmac_size, off, *offp); - - /* adjust cookie addr/len if we are not on window boundary */ - ASSERT((off % win_size) == (off - - (PCI_DMA_CURWIN(mp) ? mp->dmai_roffset : 0) - wo_off)); - off = PCI_DMA_CURWIN(mp) ? off % win_size : *offp; - ASSERT(cp->dmac_size > off); - cp->dmac_laddress += off; - cp->dmac_size -= off; - DEBUG5(DBG_DMA_CTL, dip, - "HTOC:mp=%p cookie=%x+%lx off=%lx,%lx\n", - mp, cp->dmac_address, cp->dmac_size, off, wo_off); - } - return (DDI_SUCCESS); - - case DDI_DMA_REPWIN: - *offp = mp->dmai_offset; - *lenp = mp->dmai_size; - return (DDI_SUCCESS); - - case DDI_DMA_MOVWIN: { - off_t off = *offp; - if (off >= mp->dmai_object.dmao_size) - return (DDI_FAILURE); - off += mp->dmai_roffset; - return (pci_dma_win(dip, rdip, (ddi_dma_handle_t)mp, - off / mp->dmai_winsize, offp, lenp, - (ddi_dma_cookie_t *)objp, NULL)); - } - - case DDI_DMA_NEXTWIN: { - window_t win = PCI_DMA_CURWIN(mp); - if (offp) { - if (*(window_t *)offp != win) { /* window not active */ - *(window_t *)objp = win; /* return cur win */ - return (DDI_DMA_STALE); - } - win++; - } else /* map win 0 */ - win = 0; - if (win >= mp->dmai_nwin) { - *(window_t *)objp = win - 1; - return (DDI_DMA_DONE); - } - if (pci_dma_win(dip, rdip, (ddi_dma_handle_t)mp, - win, 0, 0, 0, 0)) { - *(window_t *)objp = win - 1; - return (DDI_FAILURE); - } - *(window_t *)objp = win; - } - return (DDI_SUCCESS); - - case DDI_DMA_NEXTSEG: - if (*(window_t *)offp != PCI_DMA_CURWIN(mp)) - return (DDI_DMA_STALE); - if (lenp) /* only 1 seg allowed */ - return (DDI_DMA_DONE); - /* return mp as seg 0 */ - *(ddi_dma_seg_t *)objp = (ddi_dma_seg_t)mp; - return (DDI_SUCCESS); - - case DDI_DMA_SEGTOC: - MAKE_DMA_COOKIE((ddi_dma_cookie_t *)objp, mp->dmai_mapping, - mp->dmai_size); - *offp = mp->dmai_offset; - *lenp = mp->dmai_size; - return (DDI_SUCCESS); - - case DDI_DMA_COFF: { - ddi_dma_cookie_t *cp = (ddi_dma_cookie_t *)offp; - if (cp->dmac_address < mp->dmai_mapping || - (cp->dmac_address + cp->dmac_size) > - (mp->dmai_mapping + mp->dmai_size)) - return (DDI_FAILURE); - *objp = (caddr_t)(cp->dmac_address - mp->dmai_mapping + - mp->dmai_offset); - } - return (DDI_SUCCESS); case DDI_DMA_REMAP: if (pci_dvma_remap_enabled) @@ -1524,8 +1427,6 @@ pci_dma_ctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_impl_t *mp, uint_t cache_flags) { switch (cmd) { - case DDI_DMA_SYNC: /* XXX */ - return (DDI_SUCCESS); case DDI_DMA_HTOC: { off_t off = *offp; @@ -1561,92 +1462,6 @@ pci_dma_ctl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_impl_t *mp, } return (DDI_SUCCESS); - case DDI_DMA_REPWIN: - *offp = mp->dmai_offset; - *lenp = mp->dmai_size; - return (DDI_SUCCESS); - - case DDI_DMA_MOVWIN: { - off_t off = *offp; - ddi_dma_cookie_t *cp; - pci_dma_win_t *win_p = mp->dmai_winlst; - - if (off >= mp->dmai_object.dmao_size) - return (DDI_FAILURE); - - /* locate window */ - while (win_p->win_offset + win_p->win_size <= off) - win_p = win_p->win_next; - - cp = (ddi_dma_cookie_t *)(win_p + 1); - mp->dmai_offset = win_p->win_offset; - mp->dmai_size = win_p->win_size; - mp->dmai_mapping = cp->dmac_laddress; /* cookie0 star addr */ - mp->dmai_cookie = cp + 1; - win_p->win_curseg = 0; - - *(ddi_dma_cookie_t *)objp = *cp; - *offp = win_p->win_offset; - *lenp = win_p->win_size; - DEBUG2(DBG_DMA_CTL, dip, - "HTOC: cookie - dmac_laddress=%p dmac_size=%x\n", - cp->dmac_laddress, cp->dmac_size); - } - return (DDI_SUCCESS); - - case DDI_DMA_NEXTWIN: { - pci_dma_win_t *win_p = *(pci_dma_win_t **)offp; - pci_dma_win_t **nw_pp = (pci_dma_win_t **)objp; - ddi_dma_cookie_t *cp; - if (!win_p) { - *nw_pp = mp->dmai_winlst; - return (DDI_SUCCESS); - } - - if (win_p->win_offset != mp->dmai_offset) - return (DDI_DMA_STALE); - if (!win_p->win_next) - return (DDI_DMA_DONE); - win_p = win_p->win_next; - cp = (ddi_dma_cookie_t *)(win_p + 1); - mp->dmai_offset = win_p->win_offset; - mp->dmai_size = win_p->win_size; - mp->dmai_mapping = cp->dmac_laddress; /* cookie0 star addr */ - mp->dmai_cookie = cp + 1; - win_p->win_curseg = 0; - *nw_pp = win_p; - } - return (DDI_SUCCESS); - - case DDI_DMA_NEXTSEG: { - pci_dma_win_t *w_p = *(pci_dma_win_t **)offp; - if (w_p->win_offset != mp->dmai_offset) - return (DDI_DMA_STALE); - if (w_p->win_curseg + 1 >= w_p->win_ncookies) - return (DDI_DMA_DONE); - w_p->win_curseg++; - } - *(ddi_dma_seg_t *)objp = (ddi_dma_seg_t)mp; - return (DDI_SUCCESS); - - case DDI_DMA_SEGTOC: { - pci_dma_win_t *win_p = mp->dmai_winlst; - off_t off = mp->dmai_offset; - ddi_dma_cookie_t *cp; - int i; - - /* locate active window */ - for (; win_p->win_offset != off; win_p = win_p->win_next) - ; - cp = (ddi_dma_cookie_t *)(win_p + 1); - for (i = 0; i < win_p->win_curseg; i++, cp++) - off += cp->dmac_size; - *offp = off; - *lenp = cp->dmac_size; - *(ddi_dma_cookie_t *)objp = *cp; /* copy cookie */ - } - return (DDI_SUCCESS); - case DDI_DMA_COFF: { pci_dma_win_t *win_p; ddi_dma_cookie_t *cp; diff --git a/usr/src/uts/sun4u/io/pci/pci_iommu.c b/usr/src/uts/sun4u/io/pci/pci_iommu.c index 0ae6e22e96..cc225aa0dc 100644 --- a/usr/src/uts/sun4u/io/pci/pci_iommu.c +++ b/usr/src/uts/sun4u/io/pci/pci_iommu.c @@ -22,8 +22,9 @@ * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ - -#pragma ident "%Z%%M% %I% %E% SMI" +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* * PCI iommu initialization and configuration @@ -78,26 +79,26 @@ iommu_create(pci_t *pci_p) * Determine the virtual address of iommu registers. */ iommu_p->iommu_ctrl_reg = - (uint64_t *)(a + COMMON_IOMMU_CTRL_REG_OFFSET); + (uint64_t *)(a + COMMON_IOMMU_CTRL_REG_OFFSET); iommu_p->iommu_tsb_base_addr_reg = - (uint64_t *)(a + COMMON_IOMMU_TSB_BASE_ADDR_REG_OFFSET); + (uint64_t *)(a + COMMON_IOMMU_TSB_BASE_ADDR_REG_OFFSET); iommu_p->iommu_flush_page_reg = - (uint64_t *)(a + COMMON_IOMMU_FLUSH_PAGE_REG_OFFSET); + (uint64_t *)(a + COMMON_IOMMU_FLUSH_PAGE_REG_OFFSET); /* * Configure the rest of the iommu parameters according to: * tsb_size and dvma_end */ iommu_p->iommu_tsb_vaddr = /* retrieve TSB VA reserved by system */ - iommu_tsb_cookie_to_va(pci_p->pci_tsb_cookie); + iommu_tsb_cookie_to_va(pci_p->pci_tsb_cookie); iommu_p->iommu_tsb_entries = tsb_entries = - IOMMU_TSBSIZE_TO_TSBENTRIES(iommu_p->iommu_tsb_size); + IOMMU_TSBSIZE_TO_TSBENTRIES(iommu_p->iommu_tsb_size); iommu_p->iommu_tsb_paddr = va_to_pa((caddr_t)iommu_p->iommu_tsb_vaddr); iommu_p->iommu_dvma_cache_locks = - kmem_zalloc(pci_dvma_page_cache_entries, KM_SLEEP); + kmem_zalloc(pci_dvma_page_cache_entries, KM_SLEEP); iommu_p->iommu_dvma_base = iommu_p->iommu_dvma_end + 1 - - (tsb_entries * IOMMU_PAGE_SIZE); + - (tsb_entries * IOMMU_PAGE_SIZE); iommu_p->dvma_base_pg = IOMMU_BTOP(iommu_p->iommu_dvma_base); iommu_p->iommu_dvma_reserve = tsb_entries >> 1; iommu_p->dvma_end_pg = IOMMU_BTOP(iommu_p->iommu_dvma_end); @@ -110,29 +111,29 @@ iommu_create(pci_t *pci_p) */ pci_dvma_range.dvma_base = (uint32_t)iommu_p->iommu_dvma_base; pci_dvma_range.dvma_len = (uint32_t) - iommu_p->iommu_dvma_end - iommu_p->iommu_dvma_base + 1; + iommu_p->iommu_dvma_end - iommu_p->iommu_dvma_base + 1; (void) ddi_prop_create(DDI_DEV_T_NONE, dip, DDI_PROP_CANSLEEP, - "virtual-dma", (caddr_t)&pci_dvma_range, - sizeof (pci_dvma_range)); + "virtual-dma", (caddr_t)&pci_dvma_range, + sizeof (pci_dvma_range)); DEBUG2(DBG_ATTACH, dip, "iommu_create: ctrl=%p, tsb=%p\n", - iommu_p->iommu_ctrl_reg, iommu_p->iommu_tsb_base_addr_reg); + iommu_p->iommu_ctrl_reg, iommu_p->iommu_tsb_base_addr_reg); DEBUG2(DBG_ATTACH, dip, "iommu_create: page_flush=%p, ctx_flush=%p\n", - iommu_p->iommu_flush_page_reg, iommu_p->iommu_flush_ctx_reg); + iommu_p->iommu_flush_page_reg, iommu_p->iommu_flush_ctx_reg); DEBUG2(DBG_ATTACH, dip, "iommu_create: tsb vaddr=%p tsb_paddr=%p\n", - iommu_p->iommu_tsb_vaddr, iommu_p->iommu_tsb_paddr); + iommu_p->iommu_tsb_vaddr, iommu_p->iommu_tsb_paddr); DEBUG1(DBG_ATTACH, dip, "iommu_create: allocated size=%x\n", - iommu_tsb_cookie_to_size(pci_p->pci_tsb_cookie)); + iommu_tsb_cookie_to_size(pci_p->pci_tsb_cookie)); DEBUG2(DBG_ATTACH, dip, "iommu_create: fast tsb tte addr: %x + %x\n", - iommu_p->iommu_tsb_vaddr, - pci_dvma_page_cache_entries * pci_dvma_page_cache_clustsz); + iommu_p->iommu_tsb_vaddr, + pci_dvma_page_cache_entries * pci_dvma_page_cache_clustsz); DEBUG3(DBG_ATTACH, dip, - "iommu_create: tsb size=%x, tsb entries=%x, dvma base=%x\n", - iommu_p->iommu_tsb_size, iommu_p->iommu_tsb_entries, - iommu_p->iommu_dvma_base); + "iommu_create: tsb size=%x, tsb entries=%x, dvma base=%x\n", + iommu_p->iommu_tsb_size, iommu_p->iommu_tsb_entries, + iommu_p->iommu_dvma_base); DEBUG2(DBG_ATTACH, dip, - "iommu_create: dvma_cache_locks=%x cache_entries=%x\n", - iommu_p->iommu_dvma_cache_locks, pci_dvma_page_cache_entries); + "iommu_create: dvma_cache_locks=%x cache_entries=%x\n", + iommu_p->iommu_dvma_cache_locks, pci_dvma_page_cache_entries); /* * zero out the area to be used for iommu tsb @@ -144,16 +145,16 @@ iommu_create(pci_t *pci_p) * Reserve 'size' bytes of low dvma space for fast track cache. */ (void) snprintf(map_name, sizeof (map_name), "%s%d_dvma", - ddi_driver_name(dip), ddi_get_instance(dip)); + ddi_driver_name(dip), ddi_get_instance(dip)); cache_size = IOMMU_PTOB(pci_dvma_page_cache_entries * - pci_dvma_page_cache_clustsz); + pci_dvma_page_cache_clustsz); iommu_p->iommu_dvma_fast_end = iommu_p->iommu_dvma_base + - cache_size - 1; + cache_size - 1; iommu_p->iommu_dvma_map = vmem_create(map_name, - (void *)(iommu_p->iommu_dvma_fast_end + 1), - IOMMU_PTOB(tsb_entries) - cache_size, IOMMU_PAGE_SIZE, - NULL, NULL, NULL, IOMMU_PAGE_SIZE, VM_SLEEP); + (void *)(iommu_p->iommu_dvma_fast_end + 1), + IOMMU_PTOB(tsb_entries) - cache_size, IOMMU_PAGE_SIZE, + NULL, NULL, NULL, IOMMU_PAGE_SIZE, VM_SLEEP); mutex_init(&iommu_p->dvma_debug_lock, NULL, MUTEX_DRIVER, NULL); @@ -229,14 +230,13 @@ iommu_configure(iommu_t *iommu_p) dev_info_t *dip = iommu_p->iommu_pci_p->pci_dip; dev_info_t *cdip = NULL; volatile uint64_t ctl_val = (uint64_t) - ((iommu_p->iommu_tsb_size << COMMON_IOMMU_CTRL_TSB_SZ_SHIFT) | - (0 /* 8k page */ << COMMON_IOMMU_CTRL_TBW_SZ_SHIFT) | - COMMON_IOMMU_CTRL_ENABLE | - COMMON_IOMMU_CTRL_DIAG_ENABLE | - (pci_lock_tlb ? COMMON_IOMMU_CTRL_LCK_ENABLE : 0)); + ((iommu_p->iommu_tsb_size << COMMON_IOMMU_CTRL_TSB_SZ_SHIFT) | + (0 /* 8k page */ << COMMON_IOMMU_CTRL_TBW_SZ_SHIFT) | + COMMON_IOMMU_CTRL_ENABLE | COMMON_IOMMU_CTRL_DIAG_ENABLE | + (pci_lock_tlb ? COMMON_IOMMU_CTRL_LCK_ENABLE : 0)); DEBUG2(DBG_ATTACH, dip, "iommu_configure: iommu_ctl=%08x.%08x\n", - HI32(ctl_val), LO32(ctl_val)); + HI32(ctl_val), LO32(ctl_val)); if (!pci_preserve_iommu_tsb || !(*iommu_p->iommu_tsb_base_addr_reg)) { *iommu_p->iommu_ctrl_reg = COMMON_IOMMU_CTRL_DIAG_ENABLE; iommu_tlb_flushall(iommu_p); @@ -247,7 +247,7 @@ iommu_configure(iommu_t *iommu_p) uint32_t *reg_p; int reg_len; if (ddi_getlongprop(DDI_DEV_T_ANY, cdip, DDI_PROP_DONTPASS, - "reg", (caddr_t)®_p, ®_len) != DDI_PROP_SUCCESS) + "reg", (caddr_t)®_p, ®_len) != DDI_PROP_SUCCESS) continue; cfgpa += (*reg_p) & (PCI_CONF_ADDR_MASK ^ PCI_REG_REG_M); kmem_free(reg_p, reg_len); @@ -274,45 +274,45 @@ iommu_map_pages(iommu_t *iommu_p, ddi_dma_impl_t *mp, ASSERT(pfn_last <= mp->dmai_ndvmapages); DEBUG5(DBG_MAP_WIN, dip, - "iommu_map_pages:%x+%x=%x npages=0x%x pfn_index=0x%x\n", - (uint_t)iommu_p->dvma_base_pg, (uint_t)pg_index, dvma_pg, - (uint_t)npages, (uint_t)pfn_index); + "iommu_map_pages:%x+%x=%x npages=0x%x pfn_index=0x%x\n", + (uint_t)iommu_p->dvma_base_pg, (uint_t)pg_index, dvma_pg, + (uint_t)npages, (uint_t)pfn_index); for (i = pfn_index; i < pfn_last; i++, pg_index++, tte_addr++) { iopfn_t pfn = PCI_GET_MP_PFN(mp, i); volatile uint64_t cur_tte = IOMMU_PTOB(pfn) | tte; DEBUG3(DBG_MAP_WIN, dip, "iommu_map_pages: mp=%p pg[%x]=%x\n", - mp, i, (uint_t)pfn); + mp, i, (uint_t)pfn); DEBUG3(DBG_MAP_WIN, dip, - "iommu_map_pages: pg_index=%x tte=%08x.%08x\n", - pg_index, HI32(cur_tte), LO32(cur_tte)); + "iommu_map_pages: pg_index=%x tte=%08x.%08x\n", + pg_index, HI32(cur_tte), LO32(cur_tte)); ASSERT(TTE_IS_INVALID(*tte_addr)); *tte_addr = cur_tte; #ifdef DEBUG if (pfn == 0 && pci_warn_pp0) cmn_err(CE_WARN, "%s%d <%p> doing DMA to pp0\n", - ddi_driver_name(mp->dmai_rdip), - ddi_get_instance(mp->dmai_rdip), mp); + ddi_driver_name(mp->dmai_rdip), + ddi_get_instance(mp->dmai_rdip), mp); #endif } ASSERT(tte_addr == iommu_p->iommu_tsb_vaddr + pg_index); #ifdef DEBUG if (HAS_REDZONE(mp)) { DEBUG1(DBG_MAP_WIN, dip, "iommu_map_pages: redzone pg=%x\n", - pg_index); + pg_index); ASSERT(TTE_IS_INVALID(iommu_p->iommu_tsb_vaddr[pg_index])); } #endif if (DVMA_DBG_ON(iommu_p)) pci_dvma_alloc_debug(iommu_p, (char *)mp->dmai_mapping, - mp->dmai_size, mp); + mp->dmai_size, mp); } /* * iommu_map_window - map a dvma window into the iommu * - * used by: pci_dma_win(), pci_dma_ctlops() - DDI_DMA_MOVWIN, DDI_DMA_NEXTWIN + * used by: pci_dma_win(), pci_dma_ctlops() - DDI_DMA_MOVWIN * * return value: none */ @@ -404,7 +404,7 @@ iommu_unmap_window(iommu_t *iommu_p, ddi_dma_impl_t *mp) if (DVMA_DBG_ON(iommu_p)) pci_dvma_free_debug(iommu_p, (char *)mp->dmai_mapping, - mp->dmai_size, mp); + mp->dmai_size, mp); } int @@ -465,11 +465,11 @@ iommu_tlb_flushall(iommu_t *iommu_p) { int i; uint64_t base = (uint64_t)(iommu_p->iommu_ctrl_reg) - - COMMON_IOMMU_CTRL_REG_OFFSET; + COMMON_IOMMU_CTRL_REG_OFFSET; volatile uint64_t *tlb_tag = (volatile uint64_t *) - (base + COMMON_IOMMU_TLB_TAG_DIAG_ACC_OFFSET); + (base + COMMON_IOMMU_TLB_TAG_DIAG_ACC_OFFSET); volatile uint64_t *tlb_data = (volatile uint64_t *) - (base + COMMON_IOMMU_TLB_DATA_DIAG_ACC_OFFSET); + (base + COMMON_IOMMU_TLB_DATA_DIAG_ACC_OFFSET); for (i = 0; i < IOMMU_TLB_ENTRIES; i++) tlb_tag[i] = tlb_data[i] = 0ull; } @@ -486,32 +486,32 @@ iommu_preserve_tsb(iommu_t *iommu_p) uint64_t *base_tte_addr; DEBUG3(DBG_ATTACH, dip, - "iommu_tsb_base_addr_reg=0x%08x (0x%08x.0x%08x)\n", - iommu_p->iommu_tsb_base_addr_reg, - (uint32_t)(*iommu_p->iommu_tsb_base_addr_reg >> 32), - (uint32_t)(*iommu_p->iommu_tsb_base_addr_reg & 0xffffffff)); + "iommu_tsb_base_addr_reg=0x%08x (0x%08x.0x%08x)\n", + iommu_p->iommu_tsb_base_addr_reg, + (uint32_t)(*iommu_p->iommu_tsb_base_addr_reg >> 32), + (uint32_t)(*iommu_p->iommu_tsb_base_addr_reg & 0xffffffff)); obp_tsb_size = IOMMU_CTL_TO_TSBSIZE(ctl); obp_tsb_entries = IOMMU_TSBSIZE_TO_TSBENTRIES(obp_tsb_size); base_pg_index = iommu_p->dvma_end_pg - obp_tsb_entries + 1; base_tte_addr = iommu_p->iommu_tsb_vaddr + - (iommu_p->iommu_tsb_entries - obp_tsb_entries); + (iommu_p->iommu_tsb_entries - obp_tsb_entries); /* * old darwin prom does not set tsb size correctly, bail out. */ if ((obp_tsb_size == IOMMU_DARWIN_BOGUS_TSBSIZE) && - (CHIP_TYPE(iommu_p->iommu_pci_p) == PCI_CHIP_SABRE)) - return; + (CHIP_TYPE(iommu_p->iommu_pci_p) == PCI_CHIP_SABRE)) + return; DEBUG3(DBG_ATTACH, dip, "iommu_preserve_tsb: kernel info\n" - "iommu_tsb_vaddr=%08x copy to base_tte_addr=%08x " - "base_pg_index=%x\n", iommu_p->iommu_tsb_vaddr, - base_tte_addr, base_pg_index); + "iommu_tsb_vaddr=%08x copy to base_tte_addr=%08x " + "base_pg_index=%x\n", iommu_p->iommu_tsb_vaddr, + base_tte_addr, base_pg_index); DEBUG3(DBG_ATTACH | DBG_CONT, dip, "iommu_preserve_tsb: obp info " - "obp_tsb_entries=0x%x obp_tsb_pa=%08x.%08x\n", obp_tsb_entries, - (uint32_t)(obp_tsb_pa >> 32), (uint32_t)obp_tsb_pa); + "obp_tsb_entries=0x%x obp_tsb_pa=%08x.%08x\n", obp_tsb_entries, + (uint32_t)(obp_tsb_pa >> 32), (uint32_t)obp_tsb_pa); for (i = 0; i < obp_tsb_entries; i++) { uint64_t tte = lddphys(obp_tsb_pa + i * 8); @@ -524,8 +524,8 @@ iommu_preserve_tsb(iommu_t *iommu_p) base_tte_addr[i] = tte; DEBUG3(DBG_ATTACH | DBG_CONT, dip, - "\npreserve_tsb: (%x)=%08x.%08x\n", base_tte_addr + i, - (uint_t)(tte >> 32), (uint_t)(tte & 0xffffffff)); + "\npreserve_tsb: (%x)=%08x.%08x\n", base_tte_addr + i, + (uint_t)(tte >> 32), (uint_t)(tte & 0xffffffff)); /* * permanantly reserve this page from dvma address space @@ -534,7 +534,7 @@ iommu_preserve_tsb(iommu_t *iommu_p) va = (caddr_t)(IOMMU_PTOB(base_pg_index + i)); (void) vmem_xalloc(iommu_p->iommu_dvma_map, IOMMU_PAGE_SIZE, - IOMMU_PAGE_SIZE, 0, 0, va, va + IOMMU_PAGE_SIZE, - VM_NOSLEEP | VM_BESTFIT | VM_PANIC); + IOMMU_PAGE_SIZE, 0, 0, va, va + IOMMU_PAGE_SIZE, + VM_NOSLEEP | VM_BESTFIT | VM_PANIC); } } diff --git a/usr/src/uts/sun4u/io/pci/pci_pci.c b/usr/src/uts/sun4u/io/pci/pci_pci.c index 8ec953f18b..0196c3d2b4 100644 --- a/usr/src/uts/sun4u/io/pci/pci_pci.c +++ b/usr/src/uts/sun4u/io/pci/pci_pci.c @@ -22,6 +22,9 @@ * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* * Sun4u PCI to PCI bus bridge nexus driver @@ -108,7 +111,7 @@ struct bus_ops ppb_bus_ops = { 0, 0, i_ddi_map_fault, - ddi_dma_map, + 0, ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/sun4u/io/pci/simba.c b/usr/src/uts/sun4u/io/pci/simba.c index 480117ce24..fbce93e6a6 100644 --- a/usr/src/uts/sun4u/io/pci/simba.c +++ b/usr/src/uts/sun4u/io/pci/simba.c @@ -22,6 +22,9 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ /* @@ -123,7 +126,7 @@ struct bus_ops simba_bus_ops = { 0, 0, i_ddi_map_fault, - ddi_dma_map, + 0, ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/sun4u/io/pmubus.c b/usr/src/uts/sun4u/io/pmubus.c index 502ace5b73..66a969c698 100644 --- a/usr/src/uts/sun4u/io/pmubus.c +++ b/usr/src/uts/sun4u/io/pmubus.c @@ -22,6 +22,9 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ #include <sys/types.h> @@ -95,7 +98,7 @@ static struct bus_ops pmubus_bus_ops = { NULL, NULL, i_ddi_map_fault, - ddi_dma_map, + NULL, ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/sun4u/io/sysiosbus.c b/usr/src/uts/sun4u/io/sysiosbus.c index fbfde87d14..71ec224b19 100644 --- a/usr/src/uts/sun4u/io/sysiosbus.c +++ b/usr/src/uts/sun4u/io/sysiosbus.c @@ -23,6 +23,9 @@ * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ #include <sys/types.h> #include <sys/conf.h> @@ -308,7 +311,7 @@ static struct bus_ops sbus_bus_ops = { 0, 0, i_ddi_map_fault, - iommu_dma_map, + 0, iommu_dma_allochdl, iommu_dma_freehdl, iommu_dma_bindhdl, diff --git a/usr/src/uts/sun4u/montecarlo/io/acebus.c b/usr/src/uts/sun4u/montecarlo/io/acebus.c index 5c7ffcf8ba..f1c92ea5b2 100644 --- a/usr/src/uts/sun4u/montecarlo/io/acebus.c +++ b/usr/src/uts/sun4u/montecarlo/io/acebus.c @@ -23,6 +23,9 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ #include <sys/types.h> @@ -99,7 +102,7 @@ static struct bus_ops acebus_bus_ops = { NULL, NULL, i_ddi_map_fault, - ddi_dma_map, + NULL, ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/sun4u/serengeti/io/ssm.c b/usr/src/uts/sun4u/serengeti/io/ssm.c index 4aba952a86..ccd68ed9b5 100644 --- a/usr/src/uts/sun4u/serengeti/io/ssm.c +++ b/usr/src/uts/sun4u/serengeti/io/ssm.c @@ -23,6 +23,9 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ #include <sys/types.h> #include <sys/conf.h> #include <sys/ddi.h> @@ -161,7 +164,7 @@ static struct bus_ops ssm_bus_ops = { 0, /* add_intrspec */ 0, /* remove_intrspec */ i_ddi_map_fault, /* map_fault */ - ddi_dma_map, /* dma_map */ + 0, /* dma_map */ ddi_dma_allochdl, ddi_dma_freehdl, ddi_dma_bindhdl, diff --git a/usr/src/uts/sun4u/sys/iommu.h b/usr/src/uts/sun4u/sys/iommu.h index 947427280d..f2731f4699 100644 --- a/usr/src/uts/sun4u/sys/iommu.h +++ b/usr/src/uts/sun4u/sys/iommu.h @@ -23,12 +23,13 @@ * Copyright (c) 1991-2000 by Sun Microsystems, Inc. * All rights reserved. */ +/* + * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. + */ #ifndef _SYS_IOMMU_H #define _SYS_IOMMU_H -#pragma ident "%Z%%M% %I% %E% SMI" - #if defined(_KERNEL) && !defined(_ASM) #include <sys/sunddi.h> #include <sys/sysiosbus.h> @@ -131,8 +132,6 @@ extern int iommu_init(struct sbus_soft_state *, caddr_t); extern int iommu_resume_init(struct sbus_soft_state *); extern int iommu_dma_mctl(dev_info_t *, dev_info_t *, ddi_dma_handle_t, enum ddi_dma_ctlops, off_t *, size_t *, caddr_t *, uint_t); -extern int iommu_dma_map(dev_info_t *, dev_info_t *, struct ddi_dma_req *, - ddi_dma_handle_t *); extern int iommu_dma_allochdl(dev_info_t *, dev_info_t *, ddi_dma_attr_t *, int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *); extern int iommu_dma_freehdl(dev_info_t *, dev_info_t *, ddi_dma_handle_t); |