From owner-p4-projects@FreeBSD.ORG Tue Jul 1 19:47:48 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3081F37B404; Tue, 1 Jul 2003 19:47:48 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D7DDB37B401 for ; Tue, 1 Jul 2003 19:47:47 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A843E43F93 for ; Tue, 1 Jul 2003 19:47:46 -0700 (PDT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h622lk0U052549 for ; Tue, 1 Jul 2003 19:47:46 -0700 (PDT) (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h622ljhJ052537 for perforce@freebsd.org; Tue, 1 Jul 2003 19:47:45 -0700 (PDT) Date: Tue, 1 Jul 2003 19:47:45 -0700 (PDT) Message-Id: <200307020247.h622ljhJ052537@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Subject: PERFORCE change 33961 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Jul 2003 02:47:49 -0000 http://perforce.freebsd.org/chv.cgi?CH=33961 Change 33961 by marcel@marcel_nfs on 2003/07/01 19:46:59 IFC @33957 Affected files ... .. //depot/projects/uart/alpha/alpha/busdma_machdep.c#2 integrate .. //depot/projects/uart/alpha/include/bus.h#2 integrate .. //depot/projects/uart/alpha/isa/isa_dma.c#2 integrate .. //depot/projects/uart/amd64/amd64/busdma_machdep.c#2 integrate .. //depot/projects/uart/amd64/include/bus_dma.h#2 integrate .. //depot/projects/uart/boot/ficl/Makefile#2 integrate .. //depot/projects/uart/boot/forth/loader.conf#2 integrate .. //depot/projects/uart/boot/i386/btx/lib/Makefile#2 integrate .. //depot/projects/uart/boot/pc98/btx/lib/Makefile#2 integrate .. //depot/projects/uart/conf/files.sparc64#3 integrate .. //depot/projects/uart/conf/options.sparc64#2 integrate .. //depot/projects/uart/dev/aac/aac.c#2 integrate .. //depot/projects/uart/dev/aac/aac_pci.c#2 integrate .. //depot/projects/uart/dev/acpica/acpi_pci.c#2 integrate .. //depot/projects/uart/dev/advansys/adv_eisa.c#2 integrate .. //depot/projects/uart/dev/advansys/adv_isa.c#2 integrate .. //depot/projects/uart/dev/advansys/adv_pci.c#2 integrate .. //depot/projects/uart/dev/advansys/advansys.c#2 integrate .. //depot/projects/uart/dev/advansys/adw_pci.c#2 integrate .. //depot/projects/uart/dev/advansys/adwcam.c#2 integrate .. //depot/projects/uart/dev/aha/aha.c#2 integrate .. //depot/projects/uart/dev/aha/aha_isa.c#2 integrate .. //depot/projects/uart/dev/aha/aha_mca.c#2 integrate .. //depot/projects/uart/dev/ahb/ahb.c#2 integrate .. //depot/projects/uart/dev/aic7xxx/ahc_eisa.c#2 integrate .. //depot/projects/uart/dev/aic7xxx/ahc_pci.c#2 integrate .. //depot/projects/uart/dev/aic7xxx/ahd_pci.c#2 integrate .. //depot/projects/uart/dev/aic7xxx/aic79xx_osm.h#2 integrate .. //depot/projects/uart/dev/aic7xxx/aic7xxx_osm.h#2 integrate .. //depot/projects/uart/dev/amd/amd.c#2 integrate .. //depot/projects/uart/dev/amr/amr_pci.c#2 integrate .. //depot/projects/uart/dev/an/if_an_pci.c#2 integrate .. //depot/projects/uart/dev/ata/ata-dma.c#2 integrate .. //depot/projects/uart/dev/ath/if_ath.c#2 integrate .. //depot/projects/uart/dev/ath/if_ath_pci.c#2 integrate .. //depot/projects/uart/dev/buslogic/bt.c#2 integrate .. //depot/projects/uart/dev/buslogic/bt_eisa.c#2 integrate .. //depot/projects/uart/dev/buslogic/bt_isa.c#2 integrate .. //depot/projects/uart/dev/buslogic/bt_mca.c#2 integrate .. //depot/projects/uart/dev/buslogic/bt_pci.c#2 integrate .. //depot/projects/uart/dev/cardbus/cardbus.c#2 integrate .. //depot/projects/uart/dev/ciss/ciss.c#2 integrate .. //depot/projects/uart/dev/ct/ct_isa.c#2 integrate .. //depot/projects/uart/dev/dpt/dpt_eisa.c#2 integrate .. //depot/projects/uart/dev/dpt/dpt_isa.c#2 integrate .. //depot/projects/uart/dev/dpt/dpt_pci.c#2 integrate .. //depot/projects/uart/dev/dpt/dpt_scsi.c#2 integrate .. //depot/projects/uart/dev/em/if_em.c#2 integrate .. //depot/projects/uart/dev/en/midway.c#2 integrate .. //depot/projects/uart/dev/fatm/if_fatm.c#2 integrate .. //depot/projects/uart/dev/firewire/firewire.c#2 integrate .. //depot/projects/uart/dev/firewire/fwdma.c#2 integrate .. //depot/projects/uart/dev/firewire/fwmem.c#2 integrate .. //depot/projects/uart/dev/firewire/fwohci.c#2 integrate .. //depot/projects/uart/dev/firewire/fwohci_pci.c#2 integrate .. //depot/projects/uart/dev/firewire/sbp.c#2 integrate .. //depot/projects/uart/dev/fxp/if_fxp.c#2 integrate .. //depot/projects/uart/dev/gem/if_gem.c#2 integrate .. //depot/projects/uart/dev/gem/if_gem_pci.c#2 integrate .. //depot/projects/uart/dev/hatm/if_hatm.c#2 integrate .. //depot/projects/uart/dev/hifn/hifn7751.c#2 integrate .. //depot/projects/uart/dev/hme/if_hme.c#2 integrate .. //depot/projects/uart/dev/hme/if_hme_pci.c#2 integrate .. //depot/projects/uart/dev/ida/ida.c#2 integrate .. //depot/projects/uart/dev/ida/ida_eisa.c#2 integrate .. //depot/projects/uart/dev/ida/ida_pci.c#2 integrate .. //depot/projects/uart/dev/iir/iir.c#2 integrate .. //depot/projects/uart/dev/iir/iir_pci.c#2 integrate .. //depot/projects/uart/dev/ips/ips.c#2 integrate .. //depot/projects/uart/dev/ips/ips_commands.c#2 integrate .. //depot/projects/uart/dev/ips/ips_ioctl.c#2 integrate .. //depot/projects/uart/dev/ips/ips_pci.c#2 integrate .. //depot/projects/uart/dev/isp/isp_pci.c#2 integrate .. //depot/projects/uart/dev/isp/isp_sbus.c#2 integrate .. //depot/projects/uart/dev/lnc/if_lnc_cbus.c#2 integrate .. //depot/projects/uart/dev/lnc/if_lnc_isa.c#2 integrate .. //depot/projects/uart/dev/lnc/if_lnc_pci.c#2 integrate .. //depot/projects/uart/dev/mlx/mlx.c#2 integrate .. //depot/projects/uart/dev/mlx/mlx_pci.c#2 integrate .. //depot/projects/uart/dev/mly/mly.c#2 integrate .. //depot/projects/uart/dev/mpt/mpt_pci.c#2 integrate .. //depot/projects/uart/dev/pci/pci.c#2 integrate .. //depot/projects/uart/dev/pci/pci_if.m#2 integrate .. //depot/projects/uart/dev/pci/pci_private.h#2 integrate .. //depot/projects/uart/dev/sound/isa/ad1816.c#2 integrate .. //depot/projects/uart/dev/sound/isa/ess.c#2 integrate .. //depot/projects/uart/dev/sound/isa/mss.c#2 integrate .. //depot/projects/uart/dev/sound/isa/sb16.c#2 integrate .. //depot/projects/uart/dev/sound/isa/sb8.c#2 integrate .. //depot/projects/uart/dev/sound/pci/als4000.c#2 integrate .. //depot/projects/uart/dev/sound/pci/au88x0.c#2 integrate .. //depot/projects/uart/dev/sound/pci/aureal.c#2 integrate .. //depot/projects/uart/dev/sound/pci/cmi.c#2 integrate .. //depot/projects/uart/dev/sound/pci/cs4281.c#2 integrate .. //depot/projects/uart/dev/sound/pci/csapcm.c#2 integrate .. //depot/projects/uart/dev/sound/pci/ds1.c#2 integrate .. //depot/projects/uart/dev/sound/pci/emu10k1.c#2 integrate .. //depot/projects/uart/dev/sound/pci/es137x.c#2 integrate .. //depot/projects/uart/dev/sound/pci/fm801.c#2 integrate .. //depot/projects/uart/dev/sound/pci/ich.c#2 integrate .. //depot/projects/uart/dev/sound/pci/maestro.c#2 integrate .. //depot/projects/uart/dev/sound/pci/maestro3.c#2 integrate .. //depot/projects/uart/dev/sound/pci/solo.c#2 integrate .. //depot/projects/uart/dev/sound/pci/t4dwave.c#2 integrate .. //depot/projects/uart/dev/sound/pci/via8233.c#2 integrate .. //depot/projects/uart/dev/sound/pci/via82c686.c#2 integrate .. //depot/projects/uart/dev/sound/pci/vibes.c#2 integrate .. //depot/projects/uart/dev/sound/usb/uaudio_pcm.c#2 integrate .. //depot/projects/uart/dev/sym/sym_hipd.c#2 integrate .. //depot/projects/uart/dev/trm/trm.c#2 integrate .. //depot/projects/uart/dev/twe/twe_freebsd.c#2 integrate .. //depot/projects/uart/dev/tx/if_tx.c#2 integrate .. //depot/projects/uart/dev/ubsec/ubsec.c#2 integrate .. //depot/projects/uart/dev/usb/usbdevs#2 integrate .. //depot/projects/uart/dev/usb/usbdevs.h#2 integrate .. //depot/projects/uart/dev/usb/usbdevs_data.h#2 integrate .. //depot/projects/uart/dev/usb/uscanner.c#2 integrate .. //depot/projects/uart/dev/vinum/vinumconfig.c#2 integrate .. //depot/projects/uart/dev/wds/wd7000.c#2 integrate .. //depot/projects/uart/dev/wi/if_wi.c#3 integrate .. //depot/projects/uart/i386/acpica/acpi_wakeup.c#2 integrate .. //depot/projects/uart/i386/i386/busdma_machdep.c#2 integrate .. //depot/projects/uart/i386/include/bus_dma.h#2 integrate .. //depot/projects/uart/i4b/layer1/itjc/i4b_itjc_pci.c#2 integrate .. //depot/projects/uart/ia64/ia64/busdma_machdep.c#2 integrate .. //depot/projects/uart/ia64/include/bus.h#2 integrate .. //depot/projects/uart/ia64/isa/isa_dma.c#2 integrate .. //depot/projects/uart/isa/psm.c#2 integrate .. //depot/projects/uart/kern/kern_condvar.c#2 integrate .. //depot/projects/uart/kern/kern_intr.c#2 integrate .. //depot/projects/uart/kern/kern_thread.c#2 integrate .. //depot/projects/uart/kern/vfs_mount.c#2 integrate .. //depot/projects/uart/modules/ath_hal/Makefile#2 integrate .. //depot/projects/uart/netipsec/ipsec_output.c#2 integrate .. //depot/projects/uart/netipsec/xform_ah.c#2 integrate .. //depot/projects/uart/netipsec/xform_esp.c#2 integrate .. //depot/projects/uart/netipsec/xform_ipcomp.c#2 integrate .. //depot/projects/uart/opencrypto/crypto.c#2 integrate .. //depot/projects/uart/opencrypto/cryptodev.h#2 integrate .. //depot/projects/uart/pci/if_rl.c#3 integrate .. //depot/projects/uart/pci/if_sis.c#2 integrate .. //depot/projects/uart/pci/if_xl.c#2 integrate .. //depot/projects/uart/powerpc/include/bus.h#2 integrate .. //depot/projects/uart/powerpc/powerpc/busdma_machdep.c#2 integrate .. //depot/projects/uart/sparc64/conf/GENERIC#2 integrate .. //depot/projects/uart/sparc64/conf/NOTES#2 integrate .. //depot/projects/uart/sparc64/ebus/ebus.c#2 integrate .. //depot/projects/uart/sparc64/include/bus.h#2 integrate .. //depot/projects/uart/sparc64/include/ofw_bus.h#2 integrate .. //depot/projects/uart/sparc64/isa/isa.c#2 integrate .. //depot/projects/uart/sparc64/isa/ofw_isa.c#2 integrate .. //depot/projects/uart/sparc64/isa/ofw_isa.h#2 integrate .. //depot/projects/uart/sparc64/pci/apb.c#2 integrate .. //depot/projects/uart/sparc64/pci/ofw_pci.c#2 integrate .. //depot/projects/uart/sparc64/pci/ofw_pci.h#2 integrate .. //depot/projects/uart/sparc64/pci/ofw_pci_if.m#2 integrate .. //depot/projects/uart/sparc64/pci/ofw_pcib.c#1 branch .. //depot/projects/uart/sparc64/pci/ofw_pcib_subr.c#1 branch .. //depot/projects/uart/sparc64/pci/ofw_pcib_subr.h#1 branch .. //depot/projects/uart/sparc64/pci/ofw_pcibus.c#1 branch .. //depot/projects/uart/sparc64/pci/psycho.c#2 integrate .. //depot/projects/uart/sparc64/pci/psychovar.h#2 integrate .. //depot/projects/uart/sparc64/sbus/sbus.c#2 integrate .. //depot/projects/uart/sparc64/sparc64/bus_machdep.c#3 integrate .. //depot/projects/uart/sparc64/sparc64/ofw_bus.c#2 integrate .. //depot/projects/uart/sparc64/sparc64/sparcbus_if.m#2 delete .. //depot/projects/uart/sys/mount.h#2 integrate .. //depot/projects/uart/vm/vm_contig.c#2 integrate .. //depot/projects/uart/vm/vm_map.c#3 integrate .. //depot/projects/uart/vm/vm_page.c#2 integrate Differences ... ==== //depot/projects/uart/alpha/alpha/busdma_machdep.c#2 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/alpha/alpha/busdma_machdep.c,v 1.39 2003/06/27 08:31:47 scottl Exp $"); +__FBSDID("$FreeBSD: src/sys/alpha/alpha/busdma_machdep.c,v 1.42 2003/07/01 21:20:51 mux Exp $"); #include #include @@ -64,6 +64,8 @@ int flags; int ref_count; int map_count; + bus_dma_lock_t *lockfunc; + void *lockfuncarg; }; struct bounce_page { @@ -94,7 +96,6 @@ vm_offset_t busaddress; /* address in bus space */ bus_dmamap_callback_t *callback; void *callback_arg; - struct mtx *callback_mtx; void *sgmaphandle; /* handle into sgmap */ STAILQ_ENTRY(bus_dmamap) links; }; @@ -105,12 +106,21 @@ static void init_bounce_pages(void *dummy); static int alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages); -static int reserve_bounce_pages(bus_dma_tag_t dmat, bus_dmamap_t map); -static vm_offset_t add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, +static int reserve_bounce_pages(bus_dma_tag_t dmat, bus_dmamap_t map, + int commit); +static bus_addr_t add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr, bus_size_t size); static void free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage); static __inline int run_filter(bus_dma_tag_t dmat, bus_addr_t paddr); +/* + * Return true if a match is made. + * + * To find a match walk the chain of bus_dma_tag_t's looking for 'paddr'. + * + * If paddr is within the bounds of the dma tag then call the filter callback + * to check for a match, if there is no filter callback then assume a match. + */ static __inline int run_filter(bus_dma_tag_t dmat, bus_addr_t paddr) { @@ -129,6 +139,46 @@ return (retval); } +/* + * Convenience function for manipulating driver locks from busdma (during + * busdma_swi, for example). Drivers that don't provide their own locks + * should specify &Giant to dmat->lockfuncarg. Drivers that use their own + * non-mutex locking scheme don't have to use this at all. + */ +void +busdma_lock_mutex(void *arg, bus_dma_lock_op_t op) +{ + struct mtx *dmtx; + + dmtx = (struct mtx *)arg; + switch (op) { + case BUS_DMA_LOCK: + mtx_lock(dmtx); + break; + case BUS_DMA_UNLOCK: + mtx_unlock(dmtx); + break; + default: + panic("Unknown operation 0x%x for busdma_lock_mutex!", op); + } +} + +/* + * dflt_lock should never get called. It gets put into the dma tag when + * lockfunc == NULL, which is only valid if the maps that are associated + * with the tag are meant to never be defered. + * XXX Should have a way to identify which driver is responsible here. + */ +static void +dflt_lock(void *arg, bus_dma_lock_op_t op) +{ +#ifdef INVARIANTS + panic("driver error: busdma dflt_lock called"); +#else + printf("DRIVER_ERROR: busdma dflt_lock called\n"); +#endif +} + #define BUS_DMA_MIN_ALLOC_COMP BUS_DMA_BUS4 /* * Allocate a device specific dma_tag. @@ -138,7 +188,8 @@ bus_size_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr, bus_dma_filter_t *filter, void *filterarg, bus_size_t maxsize, int nsegments, - bus_size_t maxsegsz, int flags, bus_dma_tag_t *dmat) + bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc, + void *lockfuncarg, bus_dma_tag_t *dmat) { bus_dma_tag_t newtag; int error = 0; @@ -163,6 +214,13 @@ newtag->flags = flags; newtag->ref_count = 1; /* Count ourself */ newtag->map_count = 0; + if (lockfunc != NULL) { + newtag->lockfunc = lockfunc; + newtag->lockfuncarg = lockfuncarg; + } else { + newtag->lockfunc = dflt_lock; + newtag->lockfuncarg = NULL; + } /* Take into account any restrictions imposed by our parent tag */ if (parent != NULL) { @@ -233,8 +291,14 @@ atomic_subtract_int(&dmat->ref_count, 1); if (dmat->ref_count == 0) { free(dmat, M_DEVBUF); - } - dmat = parent; + /* + * Last reference count, so + * release our reference + * count on our parent. + */ + dmat = parent; + } else + dmat = NULL; } } return (0); @@ -330,16 +394,10 @@ sgmap_free_region(chipset.sgmap, map->sgmaphandle); } - if (map != NULL) { + if (map != NULL && map != &nobounce_dmamap) { if (STAILQ_FIRST(&map->bpages) != NULL) return (EBUSY); - /* - * The nobounce_dmamap map is not dynamically - * allocated, thus we should on no account try to - * free it. - */ - if (map != &nobounce_dmamap) - free(map, M_DEVBUF); + free(map, M_DEVBUF); } dmat->map_count--; return (0); @@ -381,7 +439,7 @@ /* * Free a piece of memory and it's allociated dmamap, that was allocated - * via bus_dmamem_alloc. + * via bus_dmamem_alloc. Make the same choice for free/contigfree. */ void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map) @@ -476,18 +534,24 @@ /* Reserve Necessary Bounce Pages */ if (map->pagesneeded != 0) { mtx_lock(&bounce_lock); - if (reserve_bounce_pages(dmat, map) != 0) { - - /* Queue us for resources */ - map->dmat = dmat; - map->buf = buf; - map->buflen = buflen; - map->callback = callback; - map->callback_arg = callback_arg; - - STAILQ_INSERT_TAIL(&bounce_map_waitinglist, map, links); - mtx_unlock(&bounce_lock); - return (EINPROGRESS); + if (flags & BUS_DMA_NOWAIT) { + if (reserve_bounce_pages(dmat, map, 0) != 0) { + mtx_unlock(&bounce_lock); + return (ENOMEM); + } + } else { + if (reserve_bounce_pages(dmat, map, 1) != 0) { + /* Queue us for resources */ + map->dmat = dmat; + map->buf = buf; + map->buflen = buflen; + map->callback = callback; + map->callback_arg = callback_arg; + STAILQ_INSERT_TAIL(&bounce_map_waitinglist, + map, links); + mtx_unlock(&bounce_lock); + return (EINPROGRESS); + } } mtx_unlock(&bounce_lock); } @@ -570,7 +634,7 @@ pmap = NULL; lastaddr = *lastaddrp; - bmask = ~(dmat->boundary - 1); + bmask = ~(dmat->boundary - 1); for (seg = *segp; buflen > 0 ; ) { /* @@ -657,7 +721,7 @@ error = 0; if (m0->m_pkthdr.len <= dmat->maxsize) { int first = 1; - vm_offset_t lastaddr = 0; + bus_addr_t lastaddr = 0; struct mbuf *m; for (m = m0; m != NULL && error == 0; m = m->m_next) { @@ -693,7 +757,7 @@ bus_dmamap_callback2_t *callback, void *callback_arg, int flags) { - vm_offset_t lastaddr; + bus_addr_t lastaddr; #ifdef __GNUC__ bus_dma_segment_t dm_segments[dmat->nsegments]; #else @@ -776,7 +840,6 @@ struct bounce_page *bpage; if ((bpage = STAILQ_FIRST(&map->bpages)) != NULL) { - /* * Handle data bouncing. We might also * want to add support for invalidating @@ -838,7 +901,7 @@ PAGE_SIZE, dmat->boundary); mtx_unlock(&Giant); - if (bpage->vaddr == NULL) { + if (bpage->vaddr == 0) { free(bpage, M_DEVBUF); break; } @@ -855,12 +918,14 @@ } static int -reserve_bounce_pages(bus_dma_tag_t dmat, bus_dmamap_t map) +reserve_bounce_pages(bus_dma_tag_t dmat, bus_dmamap_t map, int commit) { int pages; mtx_assert(&bounce_lock, MA_OWNED); pages = MIN(free_bpages, map->pagesneeded - map->pagesreserved); + if (commit == 0 && map->pagesneeded > (map->pagesreserved + pages)) + return (map->pagesneeded - (map->pagesreserved + pages)); free_bpages -= pages; reserved_bpages += pages; map->pagesreserved += pages; @@ -869,7 +934,7 @@ return (pages); } -static vm_offset_t +static bus_addr_t add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr, bus_size_t size) { @@ -912,7 +977,7 @@ free_bpages++; active_bpages--; if ((map = STAILQ_FIRST(&bounce_map_waitinglist)) != NULL) { - if (reserve_bounce_pages(map->dmat, map) == 0) { + if (reserve_bounce_pages(map->dmat, map, 1) == 0) { STAILQ_REMOVE_HEAD(&bounce_map_waitinglist, links); STAILQ_INSERT_TAIL(&bounce_map_callbacklist, map, links); @@ -926,18 +991,18 @@ void busdma_swi(void) { + bus_dma_tag_t dmat; struct bus_dmamap *map; mtx_lock(&bounce_lock); while ((map = STAILQ_FIRST(&bounce_map_callbacklist)) != NULL) { STAILQ_REMOVE_HEAD(&bounce_map_callbacklist, links); mtx_unlock(&bounce_lock); - if (map->callback_mtx != NULL) - mtx_lock(map->callback_mtx); + dmat = map->dmat; + (dmat->lockfunc)(dmat->lockfuncarg, BUS_DMA_LOCK); bus_dmamap_load(map->dmat, map, map->buf, map->buflen, map->callback, map->callback_arg, /*flags*/0); - if (map->callback_mtx != NULL) - mtx_unlock(map->callback_mtx); + (dmat->lockfunc)(dmat->lockfuncarg, BUS_DMA_UNLOCK); mtx_lock(&bounce_lock); } mtx_unlock(&bounce_lock); ==== //depot/projects/uart/alpha/include/bus.h#2 (text+ko) ==== @@ -67,7 +67,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* $FreeBSD: src/sys/alpha/include/bus.h,v 1.21 2003/05/30 20:40:32 hmp Exp $ */ +/* $FreeBSD: src/sys/alpha/include/bus.h,v 1.22 2003/07/01 15:51:50 scottl Exp $ */ #ifndef _ALPHA_BUS_H_ #define _ALPHA_BUS_H_ @@ -523,6 +523,17 @@ typedef int bus_dma_filter_t(void *, bus_addr_t); /* + * A function that performs driver-specific syncronization on behalf of + * busdma. + */ +typedef enum { + BUS_DMA_LOCK = 0x01, + BUS_DMA_UNLOCK = 0x02, +} bus_dma_lock_op_t; + +typedef void bus_dma_lock_t(void *, bus_dma_lock_op_t); + +/* * Allocate a device specific dma_tag encapsulating the constraints of * the parent tag in addition to other restrictions specified: * @@ -547,7 +558,8 @@ bus_size_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr, bus_dma_filter_t *filtfunc, void *filtfuncarg, bus_size_t maxsize, int nsegments, - bus_size_t maxsegsz, int flags, bus_dma_tag_t *dmat); + bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc, + void *lockfuncarg, bus_dma_tag_t *dmat); int bus_dma_tag_destroy(bus_dma_tag_t dmat); @@ -629,4 +641,9 @@ if ((dmamap) != NULL) \ _bus_dmamap_unload(dmat, dmamap) +/* + * Generic helper function for manipulating mutexes. + */ +void busdma_lock_mutex(void *arg, bus_dma_lock_op_t op); + #endif /* _ALPHA_BUS_H_ */ ==== //depot/projects/uart/alpha/isa/isa_dma.c#2 (text+ko) ==== @@ -48,11 +48,13 @@ */ #include -__FBSDID("$FreeBSD: src/sys/alpha/isa/isa_dma.c,v 1.8 2003/06/10 16:57:28 obrien Exp $"); +__FBSDID("$FreeBSD: src/sys/alpha/isa/isa_dma.c,v 1.9 2003/07/01 15:51:50 scottl Exp $"); #include #include #include +#include +#include #include #include #include @@ -131,6 +133,8 @@ /*maxsize*/bouncebufsize, /*nsegments*/1, /*maxsegz*/0x3ffff, /*flags*/BUS_DMA_ISA, + /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &dma_tag[chan]) != 0) { panic("isa_dmainit: unable to create dma tag\n"); } ==== //depot/projects/uart/amd64/amd64/busdma_machdep.c#2 (text+ko) ==== @@ -22,10 +22,11 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD: src/sys/amd64/amd64/busdma_machdep.c,v 1.46 2003/06/28 06:07:06 scottl Exp $ */ +#include +__FBSDID("$FreeBSD: src/sys/amd64/amd64/busdma_machdep.c,v 1.49 2003/07/01 19:16:48 mux Exp $"); + #include #include #include @@ -62,6 +63,8 @@ int flags; int ref_count; int map_count; + bus_dma_lock_t *lockfunc; + void *lockfuncarg; }; struct bounce_page { @@ -74,6 +77,7 @@ int busdma_swi_pending; +static struct mtx bounce_lock; static STAILQ_HEAD(bp_list, bounce_page) bounce_page_list; static int free_bpages; static int reserved_bpages; @@ -90,7 +94,6 @@ bus_size_t buflen; /* unmapped buffer length */ bus_dmamap_callback_t *callback; void *callback_arg; - struct mtx *callback_mtx; STAILQ_ENTRY(bus_dmamap) links; }; @@ -101,20 +104,17 @@ static void init_bounce_pages(void *dummy); static int alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages); static int reserve_bounce_pages(bus_dma_tag_t dmat, bus_dmamap_t map, - int commit); + int commit); static bus_addr_t add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr, bus_size_t size); static void free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage); static __inline int run_filter(bus_dma_tag_t dmat, bus_addr_t paddr); -/* To protect all the the bounce pages related lists and data. */ -static struct mtx bounce_lock; - /* * Return true if a match is made. - * + * * To find a match walk the chain of bus_dma_tag_t's looking for 'paddr'. - * + * * If paddr is within the bounds of the dma tag then call the filter callback * to check for a match, if there is no filter callback then assume a match. */ @@ -136,6 +136,46 @@ return (retval); } +/* + * Convenience function for manipulating driver locks from busdma (during + * busdma_swi, for example). Drivers that don't provide their own locks + * should specify &Giant to dmat->lockfuncarg. Drivers that use their own + * non-mutex locking scheme don't have to use this at all. + */ +void +busdma_lock_mutex(void *arg, bus_dma_lock_op_t op) +{ + struct mtx *dmtx; + + dmtx = (struct mtx *)arg; + switch (op) { + case BUS_DMA_LOCK: + mtx_lock(dmtx); + break; + case BUS_DMA_UNLOCK: + mtx_unlock(dmtx); + break; + default: + panic("Unknown operation 0x%x for busdma_lock_mutex!", op); + } +} + +/* + * dflt_lock should never get called. It gets put into the dma tag when + * lockfunc == NULL, which is only valid if the maps that are associated + * with the tag are meant to never be defered. + * XXX Should have a way to identify which driver is responsible here. + */ +static void +dflt_lock(void *arg, bus_dma_lock_op_t op) +{ +#ifdef INVARIANTS + panic("driver error: busdma dflt_lock called"); +#else + printf("DRIVER_ERROR: busdma dflt_lock called\n"); +#endif +} + #define BUS_DMA_MIN_ALLOC_COMP BUS_DMA_BUS4 /* * Allocate a device specific dma_tag. @@ -145,7 +185,8 @@ bus_size_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr, bus_dma_filter_t *filter, void *filterarg, bus_size_t maxsize, int nsegments, - bus_size_t maxsegsz, int flags, bus_dma_tag_t *dmat) + bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc, + void *lockfuncarg, bus_dma_tag_t *dmat) { bus_dma_tag_t newtag; int error = 0; @@ -171,6 +212,13 @@ newtag->flags = flags; newtag->ref_count = 1; /* Count ourself */ newtag->map_count = 0; + if (lockfunc != NULL) { + newtag->lockfunc = lockfunc; + newtag->lockfuncarg = lockfuncarg; + } else { + newtag->lockfunc = dflt_lock; + newtag->lockfuncarg = NULL; + } /* Take into account any restrictions imposed by our parent tag */ if (parent != NULL) { @@ -323,7 +371,7 @@ int bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map) { - if (map != NULL) { + if (map != NULL && map != &nobounce_dmamap) { if (STAILQ_FIRST(&map->bpages) != NULL) return (EBUSY); free(map, M_DEVBUF); @@ -460,7 +508,7 @@ map->buf = buf; map->buflen = buflen; STAILQ_INSERT_TAIL(&bounce_map_waitinglist, - map, links); + map, links); mtx_unlock(&bounce_lock); return (EINPROGRESS); } @@ -590,8 +638,7 @@ #endif int nsegs, error; - KASSERT(m0->m_flags & M_PKTHDR, - ("bus_dmamap_load_mbuf: no packet header")); + M_ASSERTPKTHDR(m0); flags |= BUS_DMA_NOWAIT; nsegs = 0; @@ -767,7 +814,7 @@ M_NOWAIT, 0ul, dmat->lowaddr, PAGE_SIZE, - 0); + dmat->boundary); mtx_unlock(&Giant); if (bpage->vaddr == 0) { free(bpage, M_DEVBUF); @@ -862,18 +909,18 @@ void busdma_swi(void) { + bus_dma_tag_t dmat; struct bus_dmamap *map; mtx_lock(&bounce_lock); while ((map = STAILQ_FIRST(&bounce_map_callbacklist)) != NULL) { STAILQ_REMOVE_HEAD(&bounce_map_callbacklist, links); mtx_unlock(&bounce_lock); - if (map->callback_mtx != NULL) - mtx_lock(map->callback_mtx); + dmat = map->dmat; + (dmat->lockfunc)(dmat->lockfuncarg, BUS_DMA_LOCK); bus_dmamap_load(map->dmat, map, map->buf, map->buflen, map->callback, map->callback_arg, /*flags*/0); - if (map->callback_mtx != NULL) - mtx_unlock(map->callback_mtx); + (dmat->lockfunc)(dmat->lockfuncarg, BUS_DMA_UNLOCK); mtx_lock(&bounce_lock); } mtx_unlock(&bounce_lock); ==== //depot/projects/uart/amd64/include/bus_dma.h#2 (text+ko) ==== @@ -67,7 +67,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* $FreeBSD: src/sys/amd64/include/bus_dma.h,v 1.22 2003/05/30 20:40:33 hmp Exp $ */ +/* $FreeBSD: src/sys/amd64/include/bus_dma.h,v 1.23 2003/07/01 15:51:51 scottl Exp $ */ #ifndef _AMD64_BUS_DMA_H_ #define _AMD64_BUS_DMA_H_ @@ -132,6 +132,17 @@ typedef int bus_dma_filter_t(void *, bus_addr_t); /* + * A function that performs driver-specific syncronization on behalf of + * busdma. + */ +typedef enum { + BUS_DMA_LOCK = 0x01, + BUS_DMA_UNLOCK = 0x02, +} bus_dma_lock_op_t; + +typedef void bus_dma_lock_t(void *, bus_dma_lock_op_t); + +/* * Allocate a device specific dma_tag encapsulating the constraints of * the parent tag in addition to other restrictions specified: * @@ -156,7 +167,8 @@ bus_size_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr, bus_dma_filter_t *filtfunc, void *filtfuncarg, bus_size_t maxsize, int nsegments, - bus_size_t maxsegsz, int flags, bus_dma_tag_t *dmat); + bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc, + void *lockfuncarg, bus_dma_tag_t *dmat); int bus_dma_tag_destroy(bus_dma_tag_t dmat); @@ -238,4 +250,8 @@ if ((dmamap) != NULL) \ _bus_dmamap_unload(dmat, dmamap) +/* + * Generic helper function for manipulating mutexes. + */ +void busdma_lock_mutex(void *arg, bus_dma_lock_op_t op); #endif /* _AMD64_BUS_DMA_H_ */ ==== //depot/projects/uart/boot/ficl/Makefile#2 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/boot/ficl/Makefile,v 1.34 2003/06/26 03:51:57 peter Exp $ +# $FreeBSD: src/sys/boot/ficl/Makefile,v 1.35 2003/06/30 19:08:49 ru Exp $ # .if ${MACHINE_ARCH} == "amd64" .MAKEFLAGS: MACHINE_ARCH=i386 MACHINE=i386 REALLY_AMD64=true @@ -43,7 +43,6 @@ .if defined(REALLY_AMD64) CFLAGS+= -m32 -I. -LDFLAGS= -m elf_i386_fbsd .endif CFLAGS+= -I${.CURDIR} -I${.CURDIR}/${MACHINE_ARCH} -I${.CURDIR}/../common ==== //depot/projects/uart/boot/forth/loader.conf#2 (text+ko) ==== @@ -6,7 +6,7 @@ # # All arguments must be in double quotes. # -# $FreeBSD: src/sys/boot/forth/loader.conf,v 1.71 2003/05/16 04:31:00 murray Exp $ +# $FreeBSD: src/sys/boot/forth/loader.conf,v 1.72 2003/07/01 01:03:32 brueffer Exp $ ############################################################## ### Basic configuration options ############################ @@ -46,6 +46,7 @@ ############################################################## #autoboot_delay="10" # Delay in seconds before autobooting +#beastie_disable="NO" # Turn the beastie boot menu on and off #console="vidconsole" # Set the current console #currdev="disk1s1a" # Set the current device module_path="/boot/kernel;/boot/modules" # Set the module search path ==== //depot/projects/uart/boot/i386/btx/lib/Makefile#2 (text+ko) ==== @@ -1,14 +1,11 @@ -# $FreeBSD: src/sys/boot/i386/btx/lib/Makefile,v 1.10 2002/09/17 01:48:55 peter Exp $ +# $FreeBSD: src/sys/boot/i386/btx/lib/Makefile,v 1.11 2003/06/30 14:10:57 ru Exp $ OBJS= btxcsu.o btxsys.o btxv86.o -CLEANFILES+= crt0.o ${OBJS} +CLEANFILES= crt0.o all: crt0.o crt0.o: ${OBJS} ${LD} ${LDFLAGS} -i -o ${.TARGET} ${OBJS} -.include - -.s.o: - ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} +.include ==== //depot/projects/uart/boot/pc98/btx/lib/Makefile#2 (text+ko) ==== @@ -1,14 +1,11 @@ -# $FreeBSD: src/sys/boot/pc98/btx/lib/Makefile,v 1.7 2002/09/19 13:43:02 nyan Exp $ +# $FreeBSD: src/sys/boot/pc98/btx/lib/Makefile,v 1.8 2003/06/30 14:10:58 ru Exp $ OBJS= btxcsu.o btxsys.o btxv86.o -CLEANFILES+= crt0.o ${OBJS} +CLEANFILES= crt0.o all: crt0.o crt0.o: ${OBJS} ${LD} ${LDFLAGS} -i -o ${.TARGET} ${OBJS} -.include - -.s.o: - ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} +.include ==== //depot/projects/uart/conf/files.sparc64#3 (text+ko) ==== @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $FreeBSD: src/sys/conf/files.sparc64,v 1.43 2003/06/19 18:06:58 jake Exp $ +# $FreeBSD: src/sys/conf/files.sparc64,v 1.44 2003/07/01 14:52:46 tmm Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -35,6 +35,10 @@ sparc64/isa/ofw_isa.c optional isa sparc64/pci/apb.c optional apb sparc64/pci/ofw_pci.c optional pci +sparc64/pci/ofw_pcib.c optional pci ofw_newpci +sparc64/pci/ofw_pcib_subr.c optional pci ofw_newpci +sparc64/pci/ofw_pcibus.c optional pci ofw_newpci +sparc64/pci/ofw_pci_if.m optional pci sparc64/pci/psycho.c optional pci sparc64/sbus/sbus.c optional sbus sparc64/sparc64/autoconf.c standard @@ -72,7 +76,6 @@ sparc64/sparc64/pmap.c standard sparc64/sparc64/prof_machdep.c optional profiling-routine sparc64/sparc64/rwindow.c standard -sparc64/sparc64/sparcbus_if.m standard sparc64/sparc64/spitfire.c standard sparc64/sparc64/support.S standard sparc64/sparc64/sys_machdep.c standard ==== //depot/projects/uart/conf/options.sparc64#2 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/options.sparc64,v 1.6 2003/06/12 15:00:34 tmm Exp $ +# $FreeBSD: src/sys/conf/options.sparc64,v 1.7 2003/07/01 14:52:46 tmm Exp $ SUN4U opt_global.h @@ -6,6 +6,7 @@ PSYCHO_DEBUG opt_psycho.h DEBUGGER_ON_POWERFAIL opt_psycho.h OFW_PCI_DEBUG opt_ofw_pci.h +OFW_NEWPCI opt_ofw_pci.h # Normal IOMMU debugging IOMMU_DEBUG opt_iommu.h # Debug IOMMU inserts/removes using diagnostic accesses. Very loud. ==== //depot/projects/uart/dev/aac/aac.c#2 (text+ko) ==== @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/aac/aac.c,v 1.69 2003/06/03 02:10:55 scottl Exp $ + * $FreeBSD: src/sys/dev/aac/aac.c,v 1.70 2003/07/01 15:51:51 scottl Exp $ */ /* @@ -233,8 +233,15 @@ if ((error = aac_check_firmware(sc)) != 0) return(error); - /* Init the sync fib lock */ + /* + * Initialize locks + */ AAC_LOCK_INIT(&sc->aac_sync_lock, "AAC sync FIB lock"); + AAC_LOCK_INIT(&sc->aac_aifq_lock, "AAC AIF lock"); + AAC_LOCK_INIT(&sc->aac_io_lock, "AAC I/O lock"); + AAC_LOCK_INIT(&sc->aac_container_lock, "AAC container lock"); + TAILQ_INIT(&sc->aac_container_tqh); + /* * Initialise the adapter. @@ -248,14 +255,6 @@ aac_describe_controller(sc); /* - * Initialize locks - */ - AAC_LOCK_INIT(&sc->aac_aifq_lock, "AAC AIF lock"); - TAILQ_INIT(&sc->aac_container_tqh); - AAC_LOCK_INIT(&sc->aac_container_lock, "AAC container lock"); - AAC_LOCK_INIT(&sc->aac_io_lock, "AAC I/O lock"); - - /* * Register to probe our containers later. */ sc->aac_ich.ich_func = aac_startup; @@ -1450,6 +1449,8 @@ AAC_MAXSGENTRIES, /* nsegments */ MAXBSIZE, /* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ + busdma_lock_mutex, /* lockfunc */ + &sc->aac_io_lock, /* lockfuncarg */ &sc->aac_buffer_dmat)) { device_printf(sc->aac_dev, "can't allocate buffer DMA tag\n"); goto out; @@ -1471,6 +1472,7 @@ AAC_FIB_COUNT * sizeof(struct aac_fib), /* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ + NULL, NULL, /* No locking needed */ &sc->aac_fib_dmat)) { device_printf(sc->aac_dev, "can't allocate FIB DMA tag\n");; goto out; @@ -1490,6 +1492,7 @@ 1, /* nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ >>> TRUNCATED FOR MAIL (1000 lines) <<<