From 4d495abb9d6f6e6d703264c4133ce1f0c4e7df92 Mon Sep 17 00:00:00 2001 From: scottl Date: Tue, 1 Jul 2003 15:52:06 +0000 Subject: Mega busdma API commit. Add two new arguments to bus_dma_tag_create(): lockfunc and lockfuncarg. Lockfunc allows a driver to provide a function for managing its locking semantics while using busdma. At the moment, this is used for the asynchronous busdma_swi and callback mechanism. Two lockfunc implementations are provided: busdma_lock_mutex() performs standard mutex operations on the mutex that is specified from lockfuncarg. dftl_lock() is a panic implementation and is defaulted to when NULL, NULL are passed to bus_dma_tag_create(). The only time that NULL, NULL should ever be used is when the driver ensures that bus_dmamap_load() will not be deferred. Drivers that do not provide their own locking can pass busdma_lock_mutex,&Giant args in order to preserve the former behaviour. sparc64 and powerpc do not provide real busdma_swi functions, so this is largely a noop on those platforms. The busdma_swi on is64 is not properly locked yet, so warnings will be emitted on this platform when busdma callback deferrals happen. If anyone gets panics or warnings from dflt_lock() being called, please let me know right away. Reviewed by: tmm, gibbs --- sys/alpha/alpha/busdma_machdep.c | 61 +++++++++++++++++++++++++++---- sys/alpha/include/bus.h | 19 +++++++++- sys/alpha/isa/isa_dma.c | 4 +++ sys/amd64/amd64/busdma_machdep.c | 61 +++++++++++++++++++++++++++---- sys/amd64/include/bus_dma.h | 18 +++++++++- sys/dev/aac/aac.c | 21 ++++++----- sys/dev/aac/aac_pci.c | 1 + sys/dev/advansys/adv_eisa.c | 8 +++++ sys/dev/advansys/adv_isa.c | 6 ++++ sys/dev/advansys/adv_pci.c | 6 ++++ sys/dev/advansys/advansys.c | 6 ++++ sys/dev/advansys/adw_pci.c | 4 +++ sys/dev/advansys/adwcam.c | 10 ++++++ sys/dev/aha/aha.c | 10 ++++++ sys/dev/aha/aha_isa.c | 4 +++ sys/dev/aha/aha_mca.c | 4 +++ sys/dev/ahb/ahb.c | 6 ++++ sys/dev/aic7xxx/ahc_eisa.c | 4 ++- sys/dev/aic7xxx/ahc_pci.c | 4 ++- sys/dev/aic7xxx/ahd_pci.c | 4 ++- sys/dev/aic7xxx/aic79xx_osm.h | 2 +- sys/dev/aic7xxx/aic7xxx_osm.h | 4 +-- sys/dev/amd/amd.c | 8 ++++- sys/dev/amr/amr_pci.c | 6 ++++ sys/dev/an/if_an_pci.c | 2 ++ sys/dev/ata/ata-dma.c | 11 ++++-- sys/dev/ath/if_ath_pci.c | 2 ++ sys/dev/buslogic/bt.c | 10 ++++++ sys/dev/buslogic/bt_eisa.c | 4 +++ sys/dev/buslogic/bt_isa.c | 6 ++++ sys/dev/buslogic/bt_mca.c | 6 ++++ sys/dev/buslogic/bt_pci.c | 4 +++ sys/dev/ciss/ciss.c | 3 ++ sys/dev/ct/ct_isa.c | 5 +-- sys/dev/dpt/dpt_eisa.c | 6 +++- sys/dev/dpt/dpt_isa.c | 2 ++ sys/dev/dpt/dpt_pci.c | 4 +++ sys/dev/dpt/dpt_scsi.c | 6 ++++ sys/dev/em/if_em.c | 6 ++++ sys/dev/en/midway.c | 6 ++-- sys/dev/fatm/if_fatm.c | 19 +++++----- sys/dev/firewire/fwdma.c | 9 +++-- sys/dev/firewire/fwohci.c | 4 ++- sys/dev/firewire/fwohci_pci.c | 5 ++- sys/dev/firewire/sbp.c | 5 ++- sys/dev/fxp/if_fxp.c | 10 +++--- sys/dev/gem/if_gem.c | 8 ++--- sys/dev/hatm/if_hatm.c | 11 +++--- sys/dev/hifn/hifn7751.c | 2 ++ sys/dev/hme/if_hme.c | 9 ++--- sys/dev/ida/ida.c | 6 ++-- sys/dev/ida/ida_eisa.c | 2 ++ sys/dev/ida/ida_pci.c | 2 +- sys/dev/iir/iir.c | 4 ++- sys/dev/iir/iir_pci.c | 5 ++- sys/dev/ips/ips.c | 6 ++++ sys/dev/ips/ips_commands.c | 6 ++++ sys/dev/ips/ips_ioctl.c | 2 ++ sys/dev/ips/ips_pci.c | 2 ++ sys/dev/isp/isp_pci.c | 6 ++-- sys/dev/isp/isp_sbus.c | 6 ++-- sys/dev/lnc/if_lnc_cbus.c | 2 ++ sys/dev/lnc/if_lnc_isa.c | 2 ++ sys/dev/lnc/if_lnc_pci.c | 2 ++ sys/dev/mlx/mlx.c | 4 +++ sys/dev/mlx/mlx_pci.c | 2 ++ sys/dev/mly/mly.c | 10 ++++++ sys/dev/mpt/mpt_pci.c | 8 ++--- sys/dev/sound/isa/ad1816.c | 3 +- sys/dev/sound/isa/ess.c | 3 +- sys/dev/sound/isa/mss.c | 5 +-- sys/dev/sound/isa/sb16.c | 5 +-- sys/dev/sound/isa/sb8.c | 5 +-- sys/dev/sound/pci/als4000.c | 3 +- sys/dev/sound/pci/au88x0.c | 2 +- sys/dev/sound/pci/aureal.c | 3 +- sys/dev/sound/pci/cmi.c | 2 ++ sys/dev/sound/pci/cs4281.c | 3 +- sys/dev/sound/pci/csapcm.c | 3 +- sys/dev/sound/pci/ds1.c | 6 ++-- sys/dev/sound/pci/emu10k1.c | 3 +- sys/dev/sound/pci/es137x.c | 3 +- sys/dev/sound/pci/fm801.c | 3 +- sys/dev/sound/pci/ich.c | 3 +- sys/dev/sound/pci/maestro.c | 3 +- sys/dev/sound/pci/maestro3.c | 3 +- sys/dev/sound/pci/solo.c | 3 +- sys/dev/sound/pci/t4dwave.c | 3 +- sys/dev/sound/pci/via8233.c | 6 ++-- sys/dev/sound/pci/via82c686.c | 6 ++-- sys/dev/sound/pci/vibes.c | 3 +- sys/dev/sound/usb/uaudio_pcm.c | 2 ++ sys/dev/sym/sym_hipd.c | 8 +++-- sys/dev/trm/trm.c | 36 +++++++++++-------- sys/dev/twe/twe_freebsd.c | 4 +++ sys/dev/tx/if_tx.c | 11 +++--- sys/dev/ubsec/ubsec.c | 2 ++ sys/dev/wds/wd7000.c | 2 ++ sys/dev/wi/if_wi.c | 10 ++++++ sys/i386/acpica/acpi_wakeup.c | 3 +- sys/i386/i386/busdma_machdep.c | 61 +++++++++++++++++++++++++++---- sys/i386/include/bus_dma.h | 18 +++++++++- sys/i4b/layer1/itjc/i4b_itjc_pci.c | 1 + sys/ia64/ia64/busdma_machdep.c | 69 ++++++++++++++++++++++++++++++------ sys/ia64/include/bus.h | 18 +++++++++- sys/ia64/isa/isa_dma.c | 4 +++ sys/pci/if_rl.c | 3 ++ sys/pci/if_sis.c | 7 ++++ sys/pci/if_xl.c | 9 +++-- sys/powerpc/include/bus.h | 18 +++++++++- sys/powerpc/powerpc/busdma_machdep.c | 53 +++++++++++++++++++++++++-- sys/sparc64/include/bus.h | 19 +++++++++- sys/sparc64/pci/psycho.c | 2 +- sys/sparc64/sbus/sbus.c | 2 +- sys/sparc64/sparc64/bus_machdep.c | 55 ++++++++++++++++++++++++++-- sys/sys/bus_dma.h | 18 +++++++++- 116 files changed, 878 insertions(+), 162 deletions(-) diff --git a/sys/alpha/alpha/busdma_machdep.c b/sys/alpha/alpha/busdma_machdep.c index 7e50116..4df7bd2 100644 --- a/sys/alpha/alpha/busdma_machdep.c +++ b/sys/alpha/alpha/busdma_machdep.c @@ -64,6 +64,8 @@ struct bus_dma_tag { int flags; int ref_count; int map_count; + bus_dma_lock_t *lockfunc; + void *lockfuncarg; }; struct bounce_page { @@ -94,7 +96,6 @@ struct bus_dmamap { 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; }; @@ -129,6 +130,46 @@ run_filter(bus_dma_tag_t dmat, bus_addr_t paddr) 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 +179,8 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, 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 +205,13 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, 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) { @@ -926,18 +975,18 @@ free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage) 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); diff --git a/sys/alpha/include/bus.h b/sys/alpha/include/bus.h index 76f6477..582484c 100644 --- a/sys/alpha/include/bus.h +++ b/sys/alpha/include/bus.h @@ -523,6 +523,17 @@ typedef struct bus_dma_segment { 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 @@ int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignemnt, 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 @@ void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map); 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_ */ diff --git a/sys/alpha/isa/isa_dma.c b/sys/alpha/isa/isa_dma.c index ef671be..22eea8a 100644 --- a/sys/alpha/isa/isa_dma.c +++ b/sys/alpha/isa/isa_dma.c @@ -53,6 +53,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include #include @@ -131,6 +133,8 @@ isa_dmainit(chan, bouncebufsize) /*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"); } diff --git a/sys/amd64/amd64/busdma_machdep.c b/sys/amd64/amd64/busdma_machdep.c index e46bacc..b701ab0 100644 --- a/sys/amd64/amd64/busdma_machdep.c +++ b/sys/amd64/amd64/busdma_machdep.c @@ -62,6 +62,8 @@ struct bus_dma_tag { int flags; int ref_count; int map_count; + bus_dma_lock_t *lockfunc; + void *lockfuncarg; }; struct bounce_page { @@ -90,7 +92,6 @@ struct bus_dmamap { bus_size_t buflen; /* unmapped buffer length */ bus_dmamap_callback_t *callback; void *callback_arg; - struct mtx *callback_mtx; STAILQ_ENTRY(bus_dmamap) links; }; @@ -136,6 +137,46 @@ run_filter(bus_dma_tag_t dmat, bus_addr_t paddr) 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 +186,8 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, 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 +213,13 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, 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) { @@ -862,18 +911,18 @@ free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage) 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); diff --git a/sys/amd64/include/bus_dma.h b/sys/amd64/include/bus_dma.h index 6a434cf..b0928f1 100644 --- a/sys/amd64/include/bus_dma.h +++ b/sys/amd64/include/bus_dma.h @@ -132,6 +132,17 @@ typedef struct bus_dma_segment { 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 @@ int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, 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 @@ void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map); 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_ */ diff --git a/sys/dev/aac/aac.c b/sys/dev/aac/aac.c index 21935a8..72fee9c 100644 --- a/sys/dev/aac/aac.c +++ b/sys/dev/aac/aac.c @@ -233,8 +233,15 @@ aac_attach(struct aac_softc *sc) 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_attach(struct aac_softc *sc) 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_init(struct aac_softc *sc) 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_init(struct aac_softc *sc) 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 @@ aac_init(struct aac_softc *sc) 1, /* nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ + NULL, NULL, /* No locking needed */ &sc->aac_common_dmat)) { device_printf(sc->aac_dev, "can't allocate common structure DMA tag\n"); diff --git a/sys/dev/aac/aac_pci.c b/sys/dev/aac/aac_pci.c index 0a71d02..bedb80a 100644 --- a/sys/dev/aac/aac_pci.c +++ b/sys/dev/aac/aac_pci.c @@ -248,6 +248,7 @@ aac_pci_attach(device_t dev) AAC_MAXSGENTRIES, /* nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ + NULL, NULL, /* No locking needed */ &sc->aac_parent_dmat)) { device_printf(sc->aac_dev, "can't allocate parent DMA tag\n"); goto out; diff --git a/sys/dev/advansys/adv_eisa.c b/sys/dev/advansys/adv_eisa.c index 4884317..aba0f7d 100644 --- a/sys/dev/advansys/adv_eisa.c +++ b/sys/dev/advansys/adv_eisa.c @@ -39,6 +39,8 @@ #include #include #include +#include +#include #include #include @@ -183,6 +185,8 @@ adv_eisa_attach(device_t dev) /* nsegments */ ~0, /* maxsegsz */ ADV_EISA_MAX_DMA_COUNT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &adv_b->parent_dmat); if (error != 0) { @@ -221,6 +225,8 @@ adv_eisa_attach(device_t dev) /* nsegments */ ~0, /* maxsegsz */ ADV_EISA_MAX_DMA_COUNT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &adv->parent_dmat); if (error != 0) { @@ -252,6 +258,8 @@ adv_eisa_attach(device_t dev) /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &overrun_dmat) != 0) { adv_free(adv); goto bad; diff --git a/sys/dev/advansys/adv_isa.c b/sys/dev/advansys/adv_isa.c index e8eca4e..fdeafc2 100644 --- a/sys/dev/advansys/adv_isa.c +++ b/sys/dev/advansys/adv_isa.c @@ -50,6 +50,8 @@ #include #include #include +#include +#include #include #include @@ -230,6 +232,8 @@ adv_isa_probe(device_t dev) /* nsegments */ ~0, /* maxsegsz */ maxsegsz, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &adv->parent_dmat); if (error != 0) { @@ -256,6 +260,8 @@ adv_isa_probe(device_t dev) /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ NULL, + /* lockarg */ NULL, &overrun_dmat) != 0) { adv_free(adv); bus_release_resource(dev, SYS_RES_IOPORT, 0, diff --git a/sys/dev/advansys/adv_pci.c b/sys/dev/advansys/adv_pci.c index 0891f48..1719972 100644 --- a/sys/dev/advansys/adv_pci.c +++ b/sys/dev/advansys/adv_pci.c @@ -63,6 +63,8 @@ #include #include #include +#include +#include #include #include @@ -197,6 +199,8 @@ adv_pci_attach(device_t dev) /* nsegments */ ~0, /* maxsegsz */ ADV_PCI_MAX_DMA_COUNT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &adv->parent_dmat); if (error != 0) { @@ -223,6 +227,8 @@ adv_pci_attach(device_t dev) /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &overrun_dmat) != 0) { bus_dma_tag_destroy(adv->parent_dmat); adv_free(adv); diff --git a/sys/dev/advansys/advansys.c b/sys/dev/advansys/advansys.c index 3a50c3e..b581625 100644 --- a/sys/dev/advansys/advansys.c +++ b/sys/dev/advansys/advansys.c @@ -51,6 +51,8 @@ #include #include #include +#include +#include #include #include @@ -1331,6 +1333,8 @@ adv_attach(adv) /* nsegments */ max_sg, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ BUS_DMA_ALLOCNOW, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &adv->buffer_dmat) != 0) { return (ENXIO); } @@ -1350,6 +1354,8 @@ adv_attach(adv) /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &adv->sense_dmat) != 0) { return (ENXIO); } diff --git a/sys/dev/advansys/adw_pci.c b/sys/dev/advansys/adw_pci.c index b843005..c0ed436 100644 --- a/sys/dev/advansys/adw_pci.c +++ b/sys/dev/advansys/adw_pci.c @@ -39,6 +39,8 @@ #include #include #include +#include +#include #include #include @@ -268,6 +270,8 @@ adw_pci_attach(device_t dev) /* nsegments */ ~0, /* maxsegsz */ ADW_PCI_MAX_DMA_COUNT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &adw->parent_dmat); adw->init_level++; diff --git a/sys/dev/advansys/adwcam.c b/sys/dev/advansys/adwcam.c index 74bd9ce..aedf3b3 100644 --- a/sys/dev/advansys/adwcam.c +++ b/sys/dev/advansys/adwcam.c @@ -49,6 +49,8 @@ #include #include #include +#include +#include #include #include @@ -1022,6 +1024,8 @@ adw_init(struct adw_softc *adw) /* nsegments */ ADW_SGSIZE, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ BUS_DMA_ALLOCNOW, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &adw->buffer_dmat) != 0) { return (ENOMEM); } @@ -1043,6 +1047,8 @@ adw_init(struct adw_softc *adw) /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &adw->carrier_dmat) != 0) { return (ENOMEM); } @@ -1102,6 +1108,8 @@ adw_init(struct adw_softc *adw) /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &adw->acb_dmat) != 0) { return (ENOMEM); } @@ -1137,6 +1145,8 @@ adw_init(struct adw_softc *adw) /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &adw->sg_dmat) != 0) { return (ENOMEM); } diff --git a/sys/dev/aha/aha.c b/sys/dev/aha/aha.c index 7fe6f25..9317883 100644 --- a/sys/dev/aha/aha.c +++ b/sys/dev/aha/aha.c @@ -62,6 +62,8 @@ #include #include #include +#include +#include #include #include @@ -492,6 +494,8 @@ aha_init(struct aha_softc* aha) /* nsegments */ AHA_NSEG, /* maxsegsz */ BUS_SPACE_MAXSIZE_24BIT, /* flags */ BUS_DMA_ALLOCNOW, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &aha->buffer_dmat) != 0) { goto error_exit; } @@ -511,6 +515,8 @@ aha_init(struct aha_softc* aha) /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_24BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &aha->mailbox_dmat) != 0) { goto error_exit; } @@ -551,6 +557,8 @@ aha_init(struct aha_softc* aha) /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_24BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &aha->ccb_dmat) != 0) { goto error_exit; } @@ -585,6 +593,8 @@ aha_init(struct aha_softc* aha) /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_24BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &aha->sg_dmat) != 0) { goto error_exit; } diff --git a/sys/dev/aha/aha_isa.c b/sys/dev/aha/aha_isa.c index 095bd1b..fa5c9f6 100644 --- a/sys/dev/aha/aha_isa.c +++ b/sys/dev/aha/aha_isa.c @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include #include @@ -255,6 +257,8 @@ aha_isa_attach(device_t dev) /* nsegments */ ~0, /* maxsegsz */ BUS_SPACE_MAXSIZE_24BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &aha->parent_dmat) != 0) { aha_free(aha); bus_release_resource(dev, SYS_RES_IOPORT, aha->portrid, aha->port); diff --git a/sys/dev/aha/aha_mca.c b/sys/dev/aha/aha_mca.c index 761504e..10ce088 100644 --- a/sys/dev/aha/aha_mca.c +++ b/sys/dev/aha/aha_mca.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include #include @@ -184,6 +186,8 @@ aha_mca_attach (device_t dev) /* nsegments */ ~0, /* maxsegsz */ BUS_SPACE_MAXSIZE_24BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &sc->parent_dmat); if (error) { device_printf(dev, "bus_dma_tag_create() failed!\n"); diff --git a/sys/dev/ahb/ahb.c b/sys/dev/ahb/ahb.c index a3902ae..2d2d373 100644 --- a/sys/dev/ahb/ahb.c +++ b/sys/dev/ahb/ahb.c @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include @@ -303,6 +305,8 @@ ahbattach(device_t dev) /* nsegments */ AHB_NSEG, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ BUS_DMA_ALLOCNOW, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &ahb->buffer_dmat) != 0) goto error_exit; @@ -322,6 +326,8 @@ ahbattach(device_t dev) /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &ahb->ecb_dmat) != 0) goto error_exit; diff --git a/sys/dev/aic7xxx/ahc_eisa.c b/sys/dev/aic7xxx/ahc_eisa.c index 9c5a96e..8e843ec 100644 --- a/sys/dev/aic7xxx/ahc_eisa.c +++ b/sys/dev/aic7xxx/ahc_eisa.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_eisa.c#11 $ + * $Id: ahc_eisa.c,v 1.29 2003/05/03 23:27:57 gibbs Exp $ * * $FreeBSD$ */ @@ -140,6 +140,8 @@ aic7770_attach(device_t dev) /*nsegments*/AHC_NSEG, /*maxsegsz*/AHC_MAXTRANSFER_SIZE, /*flags*/0, + /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &ahc->parent_dmat); if (error != 0) { diff --git a/sys/dev/aic7xxx/ahc_pci.c b/sys/dev/aic7xxx/ahc_pci.c index 24465ed..6d44929 100644 --- a/sys/dev/aic7xxx/ahc_pci.c +++ b/sys/dev/aic7xxx/ahc_pci.c @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_pci.c#13 $ + * $Id: ahc_pci.c,v 1.53 2003/05/03 23:27:57 gibbs Exp $ * * $FreeBSD$ */ @@ -120,6 +120,8 @@ ahc_pci_attach(device_t dev) /*nsegments*/AHC_NSEG, /*maxsegsz*/AHC_MAXTRANSFER_SIZE, /*flags*/0, + /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &ahc->parent_dmat); if (error != 0) { diff --git a/sys/dev/aic7xxx/ahd_pci.c b/sys/dev/aic7xxx/ahd_pci.c index 2f1c8ed..9f7a1b5 100644 --- a/sys/dev/aic7xxx/ahd_pci.c +++ b/sys/dev/aic7xxx/ahd_pci.c @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/ahd_pci.c#13 $ + * $Id: ahd_pci.c,v 1.8 2003/05/03 23:27:57 gibbs Exp $ * * $FreeBSD$ */ @@ -123,6 +123,8 @@ ahd_pci_attach(device_t dev) /*nsegments*/AHD_NSEG, /*maxsegsz*/AHD_MAXTRANSFER_SIZE, /*flags*/0, + /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &ahd->parent_dmat); if (error != 0) { diff --git a/sys/dev/aic7xxx/aic79xx_osm.h b/sys/dev/aic7xxx/aic79xx_osm.h index 7631958..681c10d 100644 --- a/sys/dev/aic7xxx/aic79xx_osm.h +++ b/sys/dev/aic7xxx/aic79xx_osm.h @@ -109,7 +109,7 @@ typedef union ccb *ahd_io_ctx_t; bus_dma_tag_create(parent_tag, alignment, boundary, \ lowaddr, highaddr, filter, filterarg, \ maxsize, nsegments, maxsegsz, flags, \ - dma_tagp) + busdma_lock_mutex, &Giant, dma_tagp) #define ahd_dma_tag_destroy(ahd, tag) \ bus_dma_tag_destroy(tag) diff --git a/sys/dev/aic7xxx/aic7xxx_osm.h b/sys/dev/aic7xxx/aic7xxx_osm.h index 7faa1a6..952a605 100644 --- a/sys/dev/aic7xxx/aic7xxx_osm.h +++ b/sys/dev/aic7xxx/aic7xxx_osm.h @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/aic7xxx_osm.h#15 $ + * $Id: aic7xxx_osm.h,v 1.22 2003/06/10 03:25:24 gibbs Exp $ * * $FreeBSD$ */ @@ -122,7 +122,7 @@ typedef union ccb *ahc_io_ctx_t; bus_dma_tag_create(parent_tag, alignment, boundary, \ lowaddr, highaddr, filter, filterarg, \ maxsize, nsegments, maxsegsz, flags, \ - dma_tagp) + busdma_lock_mutex, &Giant, dma_tagp) #define ahc_dma_tag_destroy(ahc, tag) \ bus_dma_tag_destroy(tag) diff --git a/sys/dev/amd/amd.c b/sys/dev/amd/amd.c index 6267ce0..fe398ad 100644 --- a/sys/dev/amd/amd.c +++ b/sys/dev/amd/amd.c @@ -55,6 +55,8 @@ #include #include #include +#include +#include #include #include @@ -2290,6 +2292,8 @@ amd_init(device_t dev) /*maxsize*/MAXBSIZE, /*nsegments*/AMD_NSEG, /*maxsegsz*/AMD_MAXTRANSFER_SIZE, /*flags*/BUS_DMA_ALLOCNOW, + /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &amd->buffer_dmat) != 0) { if (bootverbose) printf("amd_init: bus_dma_tag_create failure!\n"); @@ -2305,7 +2309,9 @@ amd_init(device_t dev) sizeof(struct scsi_sense_data) * MAX_SRB_CNT, /*nsegments*/1, /*maxsegsz*/AMD_MAXTRANSFER_SIZE, - /*flags*/0, &amd->sense_dmat) != 0) { + /*flags*/0, + /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &amd->sense_dmat) != 0) { if (bootverbose) device_printf(dev, "cannot create sense buffer dmat\n"); return (ENXIO); diff --git a/sys/dev/amr/amr_pci.c b/sys/dev/amr/amr_pci.c index eacb1bd..d9dca76 100644 --- a/sys/dev/amr/amr_pci.c +++ b/sys/dev/amr/amr_pci.c @@ -249,6 +249,7 @@ amr_pci_attach(device_t dev) MAXBSIZE, AMR_NSEG, /* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ &sc->amr_parent_dmat)) { device_printf(dev, "can't allocate parent DMA tag\n"); goto out; @@ -265,6 +266,7 @@ amr_pci_attach(device_t dev) MAXBSIZE, AMR_NSEG, /* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, &Giant, /* lockfunc, lockarg */ &sc->amr_buffer_dmat)) { device_printf(sc->amr_dev, "can't allocate buffer DMA tag\n"); goto out; @@ -505,6 +507,8 @@ amr_sglist_map(struct amr_softc *sc) segsize, 1, /* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, /* lockfunc */ + &Giant, /* lockarg */ &sc->amr_sg_dmat); if (error != 0) { device_printf(sc->amr_dev, "can't allocate scatter/gather DMA tag\n"); @@ -575,6 +579,8 @@ amr_setup_mbox(struct amr_softc *sc) sizeof(struct amr_mailbox) + 16, 1, /* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, /* lockfunc */ + &Giant, /* lockarg */ &sc->amr_mailbox_dmat); if (error != 0) { device_printf(sc->amr_dev, "can't allocate mailbox tag\n"); diff --git a/sys/dev/an/if_an_pci.c b/sys/dev/an/if_an_pci.c index eba74db..8ed13c6 100644 --- a/sys/dev/an/if_an_pci.c +++ b/sys/dev/an/if_an_pci.c @@ -216,6 +216,8 @@ an_attach_pci(dev) 1, /* nsegments */ 0xffff, /* maxsegsize XXX */ BUS_DMA_ALLOCNOW, /* flags */ + NULL, /* lockfunc */ + NULL, /* lockarg */ &sc->an_dtag); if (error) { printf("an%d: couldn't get DMA region\n", unit); diff --git a/sys/dev/ata/ata-dma.c b/sys/dev/ata/ata-dma.c index 805a04a..a2f108e 100644 --- a/sys/dev/ata/ata-dma.c +++ b/sys/dev/ata/ata-dma.c @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include #include #include @@ -96,7 +98,8 @@ ata_dmaalloc(struct ata_channel *ch) if (bus_dma_tag_create(NULL, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MAXCTLDMASZ, ATA_DMA_ENTRIES, - BUS_SPACE_MAXSIZE_32BIT, 0, &ch->dma->dmatag)) { + BUS_SPACE_MAXSIZE_32BIT, 0, busdma_lock_mutex, + &Giant, &ch->dma->dmatag)) { printf("DMA tag allocation failed, disabling DMA\n"); } } @@ -105,7 +108,8 @@ ata_dmaalloc(struct ata_channel *ch) BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MAXTABSZ, 1, MAXTABSZ, - BUS_DMA_ALLOCNOW, &ch->dma->cdmatag))) + BUS_DMA_ALLOCNOW, busdma_lock_mutex, + &Giant, &ch->dma->cdmatag))) return error; } if (!ch->dma->ddmatag) { @@ -113,7 +117,8 @@ ata_dmaalloc(struct ata_channel *ch) BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MAXPHYS, ATA_DMA_ENTRIES, MAXSEGSZ, - BUS_DMA_ALLOCNOW, &ch->dma->ddmatag))) + BUS_DMA_ALLOCNOW, busdma_lock_mutex, + &Giant, &ch->dma->ddmatag))) return error; } if (!ch->dma->mdmatab) { diff --git a/sys/dev/ath/if_ath_pci.c b/sys/dev/ath/if_ath_pci.c index db69cda..34459de 100644 --- a/sys/dev/ath/if_ath_pci.c +++ b/sys/dev/ath/if_ath_pci.c @@ -182,6 +182,8 @@ ath_pci_attach(device_t dev) ATH_MAX_SCATTER, /* nsegments */ 0xffff, /* maxsegsize XXX */ BUS_DMA_ALLOCNOW, /* flags */ + NULL, /* lockfunc */ + NULL, /* lockarg */ &sc->sc_dmat)) { device_printf(dev, "cannot allocate DMA tag\n"); goto bad3; diff --git a/sys/dev/buslogic/bt.c b/sys/dev/buslogic/bt.c index 4944a07..da8d017 100644 --- a/sys/dev/buslogic/bt.c +++ b/sys/dev/buslogic/bt.c @@ -45,6 +45,8 @@ #include #include #include +#include +#include #include #include @@ -723,6 +725,8 @@ bt_init(device_t dev) /* nsegments */ BT_NSEG, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ BUS_DMA_ALLOCNOW, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &bt->buffer_dmat) != 0) { goto error_exit; } @@ -742,6 +746,8 @@ bt_init(device_t dev) /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &bt->mailbox_dmat) != 0) { goto error_exit; } @@ -782,6 +788,8 @@ bt_init(device_t dev) /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &bt->ccb_dmat) != 0) { goto error_exit; } @@ -816,6 +824,8 @@ bt_init(device_t dev) /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &bt->sg_dmat) != 0) { goto error_exit; } diff --git a/sys/dev/buslogic/bt_eisa.c b/sys/dev/buslogic/bt_eisa.c index e9c1965..e03e8d4 100644 --- a/sys/dev/buslogic/bt_eisa.c +++ b/sys/dev/buslogic/bt_eisa.c @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include @@ -313,6 +315,8 @@ bt_eisa_attach(device_t dev) /* nsegments */ ~0, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg, */ &Giant, &bt->parent_dmat) != 0) { bt_eisa_release_resources(dev); return -1; diff --git a/sys/dev/buslogic/bt_isa.c b/sys/dev/buslogic/bt_isa.c index f76aa16..305d02e 100644 --- a/sys/dev/buslogic/bt_isa.c +++ b/sys/dev/buslogic/bt_isa.c @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include @@ -243,6 +245,8 @@ bt_isa_attach(device_t dev) /* nsegments */ ~0, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &bt->parent_dmat) != 0) { bt_isa_release_resources(dev); return (ENOMEM); @@ -269,6 +273,8 @@ bt_isa_attach(device_t dev) /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &bt->sense_dmat) != 0) { bt_isa_release_resources(dev); return (ENOMEM); diff --git a/sys/dev/buslogic/bt_mca.c b/sys/dev/buslogic/bt_mca.c index cf237e1..acaab29 100644 --- a/sys/dev/buslogic/bt_mca.c +++ b/sys/dev/buslogic/bt_mca.c @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include #include @@ -228,6 +230,8 @@ bt_mca_attach (device_t dev) /* nsegments */ ~0, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &bt->parent_dmat) != 0) { bt_mca_release_resources(dev); return (ENOMEM); @@ -251,6 +255,8 @@ bt_mca_attach (device_t dev) /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &bt->sense_dmat) != 0) { bt_mca_release_resources(dev); return (ENOMEM); diff --git a/sys/dev/buslogic/bt_pci.c b/sys/dev/buslogic/bt_pci.c index f2f6158..2e10020 100644 --- a/sys/dev/buslogic/bt_pci.c +++ b/sys/dev/buslogic/bt_pci.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include @@ -184,6 +186,8 @@ bt_pci_attach(device_t dev) /* nsegments */ ~0, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &bt->parent_dmat) != 0) { bt_pci_release_resources(dev); return (ENOMEM); diff --git a/sys/dev/ciss/ciss.c b/sys/dev/ciss/ciss.c index ed76fed..ba642de 100644 --- a/sys/dev/ciss/ciss.c +++ b/sys/dev/ciss/ciss.c @@ -600,6 +600,7 @@ ciss_init_pci(struct ciss_softc *sc) MAXBSIZE, CISS_COMMAND_SG_LENGTH, /* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ &sc->ciss_parent_dmat)) { ciss_printf(sc, "can't allocate parent DMA tag\n"); return(ENOMEM); @@ -617,6 +618,7 @@ ciss_init_pci(struct ciss_softc *sc) MAXBSIZE, CISS_COMMAND_SG_LENGTH, /* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, &Giant, /* lockfunc, lockarg */ &sc->ciss_buffer_dmat)) { ciss_printf(sc, "can't allocate buffer DMA tag\n"); return(ENOMEM); @@ -745,6 +747,7 @@ ciss_init_requests(struct ciss_softc *sc) sc->ciss_max_requests, 1, /* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, &Giant, /* lockfunc, lockarg */ &sc->ciss_command_dmat)) { ciss_printf(sc, "can't allocate command DMA tag\n"); return(ENOMEM); diff --git a/sys/dev/ct/ct_isa.c b/sys/dev/ct/ct_isa.c index c4555a9..d7b2be5 100644 --- a/sys/dev/ct/ct_isa.c +++ b/sys/dev/ct/ct_isa.c @@ -240,7 +240,8 @@ ct_isa_attach(device_t dev) BUS_SPACE_MAXADDR_24BIT, BUS_SPACE_MAXADDR, NULL, NULL, MAXBSIZE, 1, BUS_SPACE_MAXSIZE_32BIT, - BUS_DMA_ALLOCNOW, &ct->sc_dmat) != 0) { + BUS_DMA_ALLOCNOW, NULL, NULL, + &ct->sc_dmat) != 0) { device_printf(dev, "can't set up ISA DMA map\n"); ct_space_unmap(dev, ct); return ENXIO; @@ -254,7 +255,7 @@ ct_isa_attach(device_t dev) } bus_dmamap_load(ct->sc_dmat, ct->sc_dmamapt, vaddr, MAXBSIZE, - ct_dmamap, &addr, 0); + ct_dmamap, &addr, BUS_DMA_NOWAIT); /* setup machdep softc */ bs->sc_hw = hw; diff --git a/sys/dev/dpt/dpt_eisa.c b/sys/dev/dpt/dpt_eisa.c index 1479403..9ad30c4 100644 --- a/sys/dev/dpt/dpt_eisa.c +++ b/sys/dev/dpt/dpt_eisa.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -128,7 +130,9 @@ dpt_eisa_attach (device_t dev) /* maxsize */ BUS_SPACE_MAXSIZE_32BIT, /* nsegments */ ~0, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, - /* flags */0, + /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &dpt->parent_dmat) != 0) { error = ENXIO; goto bad; diff --git a/sys/dev/dpt/dpt_isa.c b/sys/dev/dpt/dpt_isa.c index 708bb69..183b9fb 100644 --- a/sys/dev/dpt/dpt_isa.c +++ b/sys/dev/dpt/dpt_isa.c @@ -189,6 +189,8 @@ dpt_isa_attach (device_t dev) /* nsegments */ ~0, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &dpt->parent_dmat) != 0) { error = ENXIO; goto bad; diff --git a/sys/dev/dpt/dpt_pci.c b/sys/dev/dpt/dpt_pci.c index 88e88da..4da3d80 100644 --- a/sys/dev/dpt/dpt_pci.c +++ b/sys/dev/dpt/dpt_pci.c @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include @@ -144,6 +146,8 @@ dpt_pci_attach (device_t dev) /* nsegments */ ~0, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &dpt->parent_dmat) != 0) { dpt_free(dpt); error = ENXIO; diff --git a/sys/dev/dpt/dpt_scsi.c b/sys/dev/dpt/dpt_scsi.c index 913578f..dc54d4b 100644 --- a/sys/dev/dpt/dpt_scsi.c +++ b/sys/dev/dpt/dpt_scsi.c @@ -1304,6 +1304,8 @@ dpt_init(struct dpt_softc *dpt) /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &dpt->sg_dmat) != 0) { goto error_exit; } @@ -1431,6 +1433,8 @@ dpt_init(struct dpt_softc *dpt) /* nsegments */ dpt->sgsize, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ BUS_DMA_ALLOCNOW, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &dpt->buffer_dmat) != 0) { printf("dpt: bus_dma_tag_create(...,dpt->buffer_dmat) failed\n"); goto error_exit; @@ -1452,6 +1456,8 @@ dpt_init(struct dpt_softc *dpt) /* nsegments */ 1, /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &dpt->dccb_dmat) != 0) { printf("dpt: bus_dma_tag_create(...,dpt->dccb_dmat) failed\n"); goto error_exit; diff --git a/sys/dev/em/if_em.c b/sys/dev/em/if_em.c index ce1c55a..ceb4e1f 100644 --- a/sys/dev/em/if_em.c +++ b/sys/dev/em/if_em.c @@ -1804,6 +1804,8 @@ em_dma_malloc(struct adapter *adapter, bus_size_t size, 1, /* nsegments */ size, /* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ + NULL, /* lockfunc */ + NULL, /* lockarg */ &dma->dma_tag); if (r != 0) { printf("em%d: em_dma_malloc: bus_dma_tag_create failed; " @@ -1908,6 +1910,8 @@ em_setup_transmit_structures(struct adapter * adapter) EM_MAX_SCATTER, /* nsegments */ MCLBYTES * 8, /* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ + NULL, /* lockfunc */ + NULL, /* lockarg */ &adapter->txtag)) { printf("em%d: Unable to allocate TX DMA tag\n", adapter->unit); return (ENOMEM); @@ -2283,6 +2287,8 @@ em_allocate_receive_structures(struct adapter * adapter) 1, /* nsegments */ MCLBYTES, /* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ + NULL, /* lockfunc */ + NULL, /* lockarg */ &adapter->rxtag); if (error != 0) { printf("em%d: em_allocate_receive_structures: " diff --git a/sys/dev/en/midway.c b/sys/dev/en/midway.c index 86a60c9..bc6bcde 100644 --- a/sys/dev/en/midway.c +++ b/sys/dev/en/midway.c @@ -2706,7 +2706,8 @@ en_dmaprobe(struct en_softc *sc) */ err = bus_dma_tag_create(NULL, MIDDMA_MAXBURST, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - 3 * MIDDMA_MAXBURST, 1, 3 * MIDDMA_MAXBURST, 0, &tag); + 3 * MIDDMA_MAXBURST, 1, 3 * MIDDMA_MAXBURST, 0, busdma_lock_mutex, + &Giant, &tag); if (err) panic("%s: cannot create test DMA tag %d", __func__, err); @@ -2918,7 +2919,8 @@ en_attach(struct en_softc *sc) if (bus_dma_tag_create(NULL, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - EN_TXSZ * 1024, EN_MAX_DMASEG, EN_TXSZ * 1024, 0, &sc->txtag)) + EN_TXSZ * 1024, EN_MAX_DMASEG, EN_TXSZ * 1024, 0, busdma_lock_mutex, + &Giant, &sc->txtag)) goto fail; sc->map_zone = uma_zcreate("en dma maps", sizeof(struct en_map), diff --git a/sys/dev/fatm/if_fatm.c b/sys/dev/fatm/if_fatm.c index 933f748..27ef48c 100644 --- a/sys/dev/fatm/if_fatm.c +++ b/sys/dev/fatm/if_fatm.c @@ -935,9 +935,8 @@ alloc_dma_memory(struct fatm_softc *sc, const char *nm, struct fatm_mem *mem) if (bus_dma_tag_create(sc->parent_dmat, mem->align, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, - NULL, NULL, - mem->size, 1, - BUS_SPACE_MAXSIZE_32BIT, BUS_DMA_ALLOCNOW, &mem->dmat)) { + NULL, NULL, mem->size, 1, BUS_SPACE_MAXSIZE_32BIT, + BUS_DMA_ALLOCNOW, NULL, NULL, &mem->dmat)) { if_printf(&sc->ifatm.ifnet, "could not allocate %s DMA tag\n", nm); return (ENOMEM); @@ -980,7 +979,7 @@ alloc_dma_memoryX(struct fatm_softc *sc, const char *nm, struct fatm_mem *mem) if (bus_dma_tag_create(NULL, mem->align, 0, BUS_SPACE_MAXADDR_24BIT, BUS_SPACE_MAXADDR, NULL, NULL, mem->size, 1, mem->size, - BUS_DMA_ALLOCNOW, &mem->dmat)) { + BUS_DMA_ALLOCNOW, NULL, NULL, &mem->dmat)) { if_printf(&sc->ifatm.ifnet, "could not allocate %s DMA tag\n", nm); return (ENOMEM); @@ -2877,9 +2876,9 @@ fatm_attach(device_t dev) */ if (bus_dma_tag_create(NULL, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, - NULL, NULL, - BUS_SPACE_MAXSIZE_32BIT, MAXDMASEGS, - BUS_SPACE_MAXSIZE_32BIT, 0, &sc->parent_dmat)) { + NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, MAXDMASEGS, + BUS_SPACE_MAXSIZE_32BIT, 0, busdma_lock_mutex, &Giant, + &sc->parent_dmat)) { if_printf(ifp, "could not allocate parent DMA tag\n"); error = ENOMEM; goto fail; @@ -2891,8 +2890,8 @@ fatm_attach(device_t dev) */ if (bus_dma_tag_create(sc->parent_dmat, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, - NULL, NULL, - MCLBYTES, 1, MCLBYTES, 0, &sc->rbuf_tag)) { + NULL, NULL, MCLBYTES, 1, MCLBYTES, 0, + busdma_lock_mutex, &Giant, &sc->rbuf_tag)) { if_printf(ifp, "could not allocate rbuf DMA tag\n"); error = ENOMEM; goto fail; @@ -2905,7 +2904,7 @@ fatm_attach(device_t dev) BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, FATM_MAXPDU, TPD_EXTENSIONS + TXD_FIXED, MCLBYTES, 0, - &sc->tx_tag)) { + busdma_lock_mutex, &Giant, &sc->tx_tag)) { if_printf(ifp, "could not allocate tx DMA tag\n"); error = ENOMEM; goto fail; diff --git a/sys/dev/firewire/fwdma.c b/sys/dev/firewire/fwdma.c index 14b4903..a16d233 100644 --- a/sys/dev/firewire/fwdma.c +++ b/sys/dev/firewire/fwdma.c @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include #include @@ -74,7 +76,8 @@ fwdma_malloc(struct firewire_comm *fc, int alignment, bus_size_t size, /*maxsize*/ size, /*nsegments*/ 1, /*maxsegsz*/ BUS_SPACE_MAXSIZE_32BIT, - /*flags*/ BUS_DMA_ALLOCNOW, &dma->dma_tag); + /*flags*/ BUS_DMA_ALLOCNOW, + /*lockfunc*/busdma_lock_mutex,/*lockarg*/&Giant, &dma->dma_tag); if (err) { printf("fwdma_malloc: failed(1)\n"); return(NULL); @@ -167,7 +170,9 @@ fwdma_malloc_multiseg(struct firewire_comm *fc, int alignment, /*maxsize*/ ssize, /*nsegments*/ 1, /*maxsegsz*/ BUS_SPACE_MAXSIZE_32BIT, - /*flags*/ BUS_DMA_ALLOCNOW, &am->dma_tag)) { + /*flags*/ BUS_DMA_ALLOCNOW, + /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &am->dma_tag)) { printf("fwdma_malloc_multiseg: tag_create failed\n"); free(am, M_FW); return(NULL); diff --git a/sys/dev/firewire/fwohci.c b/sys/dev/firewire/fwohci.c index e02caeb..58f924e 100644 --- a/sys/dev/firewire/fwohci.c +++ b/sys/dev/firewire/fwohci.c @@ -1187,7 +1187,9 @@ fwohci_db_init(struct fwohci_softc *sc, struct fwohci_dbch *dbch) /*maxsize*/ dbch->xferq.psize, /*nsegments*/ dbch->ndesc > 3 ? dbch->ndesc - 2 : 1, /*maxsegsz*/ MAX_REQCOUNT, - /*flags*/ 0, &dbch->dmat)) + /*flags*/ 0, + /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &dbch->dmat)) return; /* allocate DB entries and attach one to each DMA channels */ diff --git a/sys/dev/firewire/fwohci_pci.c b/sys/dev/firewire/fwohci_pci.c index 9745ce8..044621f 100644 --- a/sys/dev/firewire/fwohci_pci.c +++ b/sys/dev/firewire/fwohci_pci.c @@ -45,6 +45,8 @@ #include #include #include +#include +#include #include #if __FreeBSD_version < 500000 @@ -299,7 +301,8 @@ fwohci_pci_attach(device_t self) /*nsegments*/0x20, /*maxsegsz*/0x8000, /*flags*/BUS_DMA_ALLOCNOW, - &sc->fc.dmat); + /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &sc->fc.dmat); if (err != 0) { printf("fwohci_pci_attach: Could not allocate DMA tag " "- error %d\n", err); diff --git a/sys/dev/firewire/sbp.c b/sys/dev/firewire/sbp.c index 8e296dd..6f1b111 100644 --- a/sys/dev/firewire/sbp.c +++ b/sys/dev/firewire/sbp.c @@ -43,6 +43,8 @@ #include #include #include +#include +#include #if __FreeBSD_version < 500106 #include /* for struct devstat */ @@ -1828,7 +1830,8 @@ END_DEBUG /*maxsize*/0x100000, /*nsegments*/SBP_IND_MAX, /*maxsegsz*/SBP_SEG_MAX, /*flags*/BUS_DMA_ALLOCNOW, - &sbp->dmat); + /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &sbp->dmat); if (error != 0) { printf("sbp_attach: Could not allocate DMA tag " "- error %d\n", error); diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c index 80f0bac..69bb5de 100644 --- a/sys/dev/fxp/if_fxp.c +++ b/sys/dev/fxp/if_fxp.c @@ -622,7 +622,7 @@ fxp_attach(device_t dev) maxtxseg = sc->flags & FXP_FLAG_EXT_RFA ? FXP_NTXSEG - 1 : FXP_NTXSEG; error = bus_dma_tag_create(NULL, 2, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES * maxtxseg, - maxtxseg, MCLBYTES, 0, &sc->fxp_mtag); + maxtxseg, MCLBYTES, 0, busdma_lock_mutex, &Giant, &sc->fxp_mtag); if (error) { device_printf(dev, "could not allocate dma tag\n"); goto fail; @@ -630,7 +630,8 @@ fxp_attach(device_t dev) error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, sizeof(struct fxp_stats), 1, - sizeof(struct fxp_stats), 0, &sc->fxp_stag); + sizeof(struct fxp_stats), 0, busdma_lock_mutex, &Giant, + &sc->fxp_stag); if (error) { device_printf(dev, "could not allocate dma tag\n"); goto fail; @@ -650,7 +651,7 @@ fxp_attach(device_t dev) error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, FXP_TXCB_SZ, 1, - FXP_TXCB_SZ, 0, &sc->cbl_tag); + FXP_TXCB_SZ, 0, busdma_lock_mutex, &Giant, &sc->cbl_tag); if (error) { device_printf(dev, "could not allocate dma tag\n"); goto fail; @@ -672,7 +673,8 @@ fxp_attach(device_t dev) error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, sizeof(struct fxp_cb_mcs), 1, - sizeof(struct fxp_cb_mcs), 0, &sc->mcs_tag); + sizeof(struct fxp_cb_mcs), 0, busdma_lock_mutex, &Giant, + &sc->mcs_tag); if (error) { device_printf(dev, "could not allocate dma tag\n"); goto fail; diff --git a/sys/dev/gem/if_gem.c b/sys/dev/gem/if_gem.c index 6f1a3b1..8395215 100644 --- a/sys/dev/gem/if_gem.c +++ b/sys/dev/gem/if_gem.c @@ -133,13 +133,13 @@ gem_attach(sc) error = bus_dma_tag_create(NULL, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, GEM_NSEGS, - BUS_SPACE_MAXSIZE_32BIT, 0, &sc->sc_pdmatag); + BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL, &sc->sc_pdmatag); if (error) return (error); error = bus_dma_tag_create(sc->sc_pdmatag, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MAXBSIZE, - 1, BUS_SPACE_MAXSIZE_32BIT, BUS_DMA_ALLOCNOW, + 1, BUS_SPACE_MAXSIZE_32BIT, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->sc_rdmatag); if (error) goto fail_ptag; @@ -147,7 +147,7 @@ gem_attach(sc) error = bus_dma_tag_create(sc->sc_pdmatag, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, GEM_TD_BUFSIZE, GEM_NTXDESC, BUS_SPACE_MAXSIZE_32BIT, - BUS_DMA_ALLOCNOW, &sc->sc_tdmatag); + BUS_DMA_ALLOCNOW, NULL, NULL, &sc->sc_tdmatag); if (error) goto fail_rtag; @@ -155,7 +155,7 @@ gem_attach(sc) BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, sizeof(struct gem_control_data), 1, sizeof(struct gem_control_data), BUS_DMA_ALLOCNOW, - &sc->sc_cdmatag); + busdma_lock_mutex, &Giant, &sc->sc_cdmatag); if (error) goto fail_ttag; diff --git a/sys/dev/hatm/if_hatm.c b/sys/dev/hatm/if_hatm.c index 48c45b8..30835b5 100644 --- a/sys/dev/hatm/if_hatm.c +++ b/sys/dev/hatm/if_hatm.c @@ -214,7 +214,8 @@ hatm_alloc_dmamem(struct hatm_softc *sc, const char *what, struct dmamem *mem) error = bus_dma_tag_create(sc->parent_tag, mem->align, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, mem->size, 1, - BUS_SPACE_MAXSIZE_32BIT, BUS_DMA_ALLOCNOW, &mem->tag); + BUS_SPACE_MAXSIZE_32BIT, BUS_DMA_ALLOCNOW, + busdma_lock_mutex, &Giant, &mem->tag); if (error) { if_printf(&sc->ifatm.ifnet, "DMA tag create (%s)\n", what); return (error); @@ -1712,7 +1713,8 @@ hatm_attach(device_t dev) BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 1, - BUS_SPACE_MAXSIZE_32BIT, 0, &sc->parent_tag)) { + BUS_SPACE_MAXSIZE_32BIT, 0, + busdma_lock_mutex, &Giant, &sc->parent_tag)) { device_printf(dev, "could not allocate DMA tag\n"); error = ENOMEM; goto failed; @@ -1722,7 +1724,8 @@ hatm_attach(device_t dev) BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MBUF_ALLOC_SIZE, 1, - MBUF_ALLOC_SIZE, 0, &sc->mbuf_tag)) { + MBUF_ALLOC_SIZE, 0, + busdma_lock_mutex, &Giant, &sc->mbuf_tag)) { device_printf(dev, "could not allocate mbuf DMA tag\n"); error = ENOMEM; goto failed; @@ -1738,7 +1741,7 @@ hatm_attach(device_t dev) if (bus_dma_tag_create(NULL, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, HE_MAX_PDU, 3 * HE_CONFIG_MAX_TPD_PER_PACKET, HE_MAX_PDU, 0, - &sc->tx_tag)) { + busdma_lock_mutex, &Giant, &sc->tx_tag)) { device_printf(dev, "could not allocate TX tag\n"); error = ENOMEM; goto failed; diff --git a/sys/dev/hifn/hifn7751.c b/sys/dev/hifn/hifn7751.c index 61dde34..4486845 100644 --- a/sys/dev/hifn/hifn7751.c +++ b/sys/dev/hifn/hifn7751.c @@ -340,6 +340,8 @@ hifn_attach(device_t dev) MAX_SCATTER, /* nsegments */ HIFN_MAX_SEGLEN, /* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ + NULL, /* lockfunc */ + NULL, /* lockarg */ &sc->sc_dmat)) { device_printf(dev, "cannot allocate DMA tag\n"); goto fail_io1; diff --git a/sys/dev/hme/if_hme.c b/sys/dev/hme/if_hme.c index 83d15fd..ed30027 100644 --- a/sys/dev/hme/if_hme.c +++ b/sys/dev/hme/if_hme.c @@ -191,27 +191,28 @@ hme_config(struct hme_softc *sc) error = bus_dma_tag_create(NULL, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, size, HME_NTXDESC + HME_NRXDESC + 1, - BUS_SPACE_MAXSIZE_32BIT, 0, &sc->sc_pdmatag); + BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL, &sc->sc_pdmatag); if (error) return (error); error = bus_dma_tag_create(sc->sc_pdmatag, 2048, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, size, - 1, BUS_SPACE_MAXSIZE_32BIT, BUS_DMA_ALLOCNOW, &sc->sc_cdmatag); + 1, BUS_SPACE_MAXSIZE_32BIT, BUS_DMA_ALLOCNOW, busdma_lock_mutex, + &Giant, &sc->sc_cdmatag); if (error) goto fail_ptag; error = bus_dma_tag_create(sc->sc_pdmatag, max(0x10, sc->sc_burst), 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, HME_NRXDESC, BUS_SPACE_MAXSIZE_32BIT, BUS_DMA_ALLOCNOW, - &sc->sc_rdmatag); + NULL, NULL, &sc->sc_rdmatag); if (error) goto fail_ctag; error = bus_dma_tag_create(sc->sc_pdmatag, max(0x10, sc->sc_burst), 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, HME_NTXDESC, BUS_SPACE_MAXSIZE_32BIT, BUS_DMA_ALLOCNOW, - &sc->sc_tdmatag); + NULL, NULL, &sc->sc_tdmatag); if (error) goto fail_rtag; diff --git a/sys/dev/ida/ida.c b/sys/dev/ida/ida.c index c141749..ea273a1 100644 --- a/sys/dev/ida/ida.c +++ b/sys/dev/ida/ida.c @@ -205,7 +205,8 @@ ida_init(struct ida_softc *ida) /*filter*/NULL, /*filterarg*/NULL, IDA_QCB_MAX * sizeof(struct ida_hardware_qcb), /*nsegments*/1, /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT, - /*flags*/0, &ida->hwqcb_dmat); + /*flags*/0, /*lockfunc*/busdma_lock_mutex, /*lockarg*/&Giant, + &ida->hwqcb_dmat); if (error) return (ENOMEM); @@ -215,7 +216,8 @@ ida_init(struct ida_softc *ida) /*lowaddr*/BUS_SPACE_MAXADDR, /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/MAXBSIZE, /*nsegments*/IDA_NSEG, - /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT, /*flags*/0, &ida->buffer_dmat); + /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT, /*flags*/0, + /*lockfunc*/busdma_lock_mutex, /*lockarg*/&Giant, &ida->buffer_dmat); if (error) return (ENOMEM); diff --git a/sys/dev/ida/ida_eisa.c b/sys/dev/ida/ida_eisa.c index a6f3419..0c7ac5f 100644 --- a/sys/dev/ida/ida_eisa.c +++ b/sys/dev/ida/ida_eisa.c @@ -303,6 +303,8 @@ ida_eisa_attach(device_t dev) /* nsegments */ IDA_NSEG, /* maxsegsize */ BUS_SPACE_MAXSIZE_32BIT, /* flags */ BUS_DMA_ALLOCNOW, + /* lockfunc */ NULL, + /* lockarg */ NULL, &ida->parent_dmat); if (error != 0) { diff --git a/sys/dev/ida/ida_pci.c b/sys/dev/ida/ida_pci.c index c836de0..92cdba7 100644 --- a/sys/dev/ida/ida_pci.c +++ b/sys/dev/ida/ida_pci.c @@ -267,7 +267,7 @@ ida_pci_attach(device_t dev) /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/MAXBSIZE, /*nsegments*/IDA_NSEG, /*maxsegsize*/BUS_SPACE_MAXSIZE_32BIT, /*flags*/BUS_DMA_ALLOCNOW, - &ida->parent_dmat); + /*lockfunc*/NULL, /*lockarg*/NULL, &ida->parent_dmat); if (error != 0) { device_printf(dev, "can't allocate DMA tag\n"); ida_free(ida); diff --git a/sys/dev/iir/iir.c b/sys/dev/iir/iir.c index 6f0fb9c..e0a1999 100644 --- a/sys/dev/iir/iir.c +++ b/sys/dev/iir/iir.c @@ -212,6 +212,7 @@ iir_init(struct gdt_softc *gdt) /*maxsize*/MAXBSIZE, /*nsegments*/GDT_MAXSG, /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT, /*flags*/BUS_DMA_ALLOCNOW, + /*lockfunc*/busdma_lock_mutex, /*lockarg*/&Giant, &gdt->sc_buffer_dmat) != 0) { printf("iir%d: bus_dma_tag_create(...,gdt->sc_buffer_dmat) failed\n", gdt->sc_hanum); @@ -230,7 +231,8 @@ iir_init(struct gdt_softc *gdt) GDT_MAXCMDS * sizeof(struct gdt_ccb), /* maxsize */ /*nsegments*/1, /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT, - /*flags*/0, &gdt->sc_gccb_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &gdt->sc_gccb_dmat) != 0) { printf("iir%d: bus_dma_tag_create(...,gdt->sc_gccb_dmat) failed\n", gdt->sc_hanum); return (1); diff --git a/sys/dev/iir/iir_pci.c b/sys/dev/iir/iir_pci.c index a9ed75c..cb61f31 100644 --- a/sys/dev/iir/iir_pci.c +++ b/sys/dev/iir/iir_pci.c @@ -46,6 +46,8 @@ #include #include #include +#include +#include #include #include @@ -322,7 +324,8 @@ iir_pci_attach(device_t dev) /*maxsize*/BUS_SPACE_MAXSIZE_32BIT, /*nsegments*/GDT_MAXSG, /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT, - /*flags*/0, &gdt->sc_parent_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &gdt->sc_parent_dmat) != 0) { error = ENXIO; goto err; } diff --git a/sys/dev/ips/ips.c b/sys/dev/ips/ips.c index bd329d6..98a09d3 100644 --- a/sys/dev/ips/ips.c +++ b/sys/dev/ips/ips.c @@ -337,6 +337,8 @@ int ips_adapter_init(ips_softc_t *sc) /* maxsegsize*/ IPS_COMMAND_LEN + IPS_MAX_SG_LEN, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &sc->command_dmatag) != 0) { device_printf(sc->dev, "can't alloc command dma tag\n"); goto error; @@ -352,6 +354,8 @@ int ips_adapter_init(ips_softc_t *sc) /* numsegs */ IPS_MAX_SG_ELEMENTS, /* maxsegsize*/ IPS_MAX_IOBUF_SIZE, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &sc->sg_dmatag) != 0) { device_printf(sc->dev, "can't alloc SG dma tag\n"); goto error; @@ -546,6 +550,8 @@ static int ips_copperhead_queue_init(ips_softc_t *sc) /* numsegs */ 1, /* maxsegsize*/ sizeof(ips_copper_queue_t), /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &dmatag) != 0) { device_printf(sc->dev, "can't alloc dma tag for statue queue\n"); error = ENOMEM; diff --git a/sys/dev/ips/ips_commands.c b/sys/dev/ips/ips_commands.c index bcdb925..c83de4c 100644 --- a/sys/dev/ips/ips_commands.c +++ b/sys/dev/ips/ips_commands.c @@ -224,6 +224,8 @@ static int ips_send_adapter_info_cmd(ips_command_t *command) /* numsegs */ 1, /* maxsegsize*/ IPS_ADAPTER_INFO_LEN, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &command->data_dmatag) != 0) { printf("ips: can't alloc dma tag for adapter status\n"); error = ENOMEM; @@ -329,6 +331,8 @@ static int ips_send_drive_info_cmd(ips_command_t *command) /* numsegs */ 1, /* maxsegsize*/ IPS_DRIVE_INFO_LEN, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &command->data_dmatag) != 0) { printf("ips: can't alloc dma tag for drive status\n"); error = ENOMEM; @@ -497,6 +501,8 @@ static int ips_read_nvram(ips_command_t *command){ /* numsegs */ 1, /* maxsegsize*/ IPS_NVRAM_PAGE_SIZE, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &command->data_dmatag) != 0) { printf("ips: can't alloc dma tag for nvram\n"); error = ENOMEM; diff --git a/sys/dev/ips/ips_ioctl.c b/sys/dev/ips/ips_ioctl.c index 9c31dfc..4788ffc 100644 --- a/sys/dev/ips/ips_ioctl.c +++ b/sys/dev/ips/ips_ioctl.c @@ -98,6 +98,8 @@ static int ips_ioctl_cmd(ips_softc_t *sc, ips_ioctl_t *ioctl_cmd, ips_user_reque /* numsegs */ 1, /* maxsegsize*/ ioctl_cmd->datasize, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &ioctl_cmd->dmatag) != 0) { return ENOMEM; } diff --git a/sys/dev/ips/ips_pci.c b/sys/dev/ips/ips_pci.c index f998732..81fa0e6 100644 --- a/sys/dev/ips/ips_pci.c +++ b/sys/dev/ips/ips_pci.c @@ -128,6 +128,8 @@ static int ips_pci_attach(device_t dev) /* numsegs */ IPS_MAX_SG_ELEMENTS, /* maxsegsize*/ BUS_SPACE_MAXSIZE_32BIT, /* flags */ 0, + /* lockfunc */ busdma_lock_mutex, + /* lockarg */ &Giant, &sc->adapter_dmatag) != 0) { printf("IPS can't alloc dma tag\n"); goto error; diff --git a/sys/dev/isp/isp_pci.c b/sys/dev/isp/isp_pci.c index 9636a7f..0bb854f 100644 --- a/sys/dev/isp/isp_pci.c +++ b/sys/dev/isp/isp_pci.c @@ -1097,7 +1097,8 @@ isp_pci_mbxdma(struct ispsoftc *isp) ISP_UNLOCK(isp); if (bus_dma_tag_create(NULL, 1, slim+1, alim, alim, - NULL, NULL, BUS_SPACE_MAXSIZE, ISP_NSEGS, slim, 0, &pcs->dmat)) { + NULL, NULL, BUS_SPACE_MAXSIZE, ISP_NSEGS, slim, 0, + busdma_lock_mutex, &Giant, &pcs->dmat)) { isp_prt(isp, ISP_LOGERR, "could not create master dma tag"); ISP_LOCK(isp); return(1); @@ -1131,7 +1132,8 @@ isp_pci_mbxdma(struct ispsoftc *isp) ns = (len / PAGE_SIZE) + 1; if (bus_dma_tag_create(pcs->dmat, QENTRY_LEN, slim+1, alim, alim, - NULL, NULL, len, ns, slim, 0, &isp->isp_cdmat)) { + NULL, NULL, len, ns, slim, 0, busdma_lock_mutex, &Giant, + &isp->isp_cdmat)) { isp_prt(isp, ISP_LOGERR, "cannot create a dma tag for control spaces"); free(pcs->dmaps, M_DEVBUF); diff --git a/sys/dev/isp/isp_sbus.c b/sys/dev/isp/isp_sbus.c index d2af1a5..47bb9ef 100644 --- a/sys/dev/isp/isp_sbus.c +++ b/sys/dev/isp/isp_sbus.c @@ -491,7 +491,8 @@ isp_sbus_mbxdma(struct ispsoftc *isp) if (bus_dma_tag_create(NULL, 1, BUS_SPACE_MAXADDR_24BIT-1, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR_32BIT, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, ISP_NSEGS, - BUS_SPACE_MAXADDR_24BIT, 0, &sbs->dmat)) { + BUS_SPACE_MAXADDR_24BIT, 0, busdma_lock_mutex, &Giant, + &sbs->dmat)) { isp_prt(isp, ISP_LOGERR, "could not create master dma tag"); ISP_LOCK(isp); return(1); @@ -522,7 +523,8 @@ isp_sbus_mbxdma(struct ispsoftc *isp) ns = (len / PAGE_SIZE) + 1; if (bus_dma_tag_create(sbs->dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT-1, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR_32BIT, NULL, NULL, - len, ns, BUS_SPACE_MAXADDR_24BIT, 0, &isp->isp_cdmat)) { + len, ns, BUS_SPACE_MAXADDR_24BIT, 0, busdma_lock_mutex, &Giant, + &isp->isp_cdmat)) { isp_prt(isp, ISP_LOGERR, "cannot create a dma tag for control spaces"); free(sbs->dmaps, M_DEVBUF); diff --git a/sys/dev/lnc/if_lnc_cbus.c b/sys/dev/lnc/if_lnc_cbus.c index 5fae93e..7de87dd 100644 --- a/sys/dev/lnc/if_lnc_cbus.c +++ b/sys/dev/lnc/if_lnc_cbus.c @@ -215,6 +215,8 @@ lnc_isa_attach(device_t dev) 1, /* nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, /* lockfunc */ + &Giant, /* lockarg */ &sc->dmat); if (err) { diff --git a/sys/dev/lnc/if_lnc_isa.c b/sys/dev/lnc/if_lnc_isa.c index cd643b3..9182623 100644 --- a/sys/dev/lnc/if_lnc_isa.c +++ b/sys/dev/lnc/if_lnc_isa.c @@ -212,6 +212,8 @@ lnc_isa_attach(device_t dev) 1, /* nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, /* lockfunc */ + &Giant, /* lockarg */ &sc->dmat); if (err) { diff --git a/sys/dev/lnc/if_lnc_pci.c b/sys/dev/lnc/if_lnc_pci.c index c129e2e..fafb4cc 100644 --- a/sys/dev/lnc/if_lnc_pci.c +++ b/sys/dev/lnc/if_lnc_pci.c @@ -154,6 +154,8 @@ lnc_pci_attach(device_t dev) 1, /* nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, /* lockfunc */ + &Giant, /* lockarg */ &sc->dmat); if (err) { diff --git a/sys/dev/mlx/mlx.c b/sys/dev/mlx/mlx.c index b68dd71..5e3ee2b 100644 --- a/sys/dev/mlx/mlx.c +++ b/sys/dev/mlx/mlx.c @@ -249,6 +249,8 @@ mlx_sglist_map(struct mlx_softc *sc) segsize, 1, /* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, /* lockfunc */ + &Giant, /* lockarg */ &sc->mlx_sg_dmat); if (error != 0) { device_printf(sc->mlx_dev, "can't allocate scatter/gather DMA tag\n"); @@ -375,6 +377,8 @@ mlx_attach(struct mlx_softc *sc) MAXBSIZE, MLX_NSEG, /* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, /* lockfunc */ + &Giant, /* lockarg */ &sc->mlx_buffer_dmat); if (error != 0) { device_printf(sc->mlx_dev, "can't allocate buffer DMA tag\n"); diff --git a/sys/dev/mlx/mlx_pci.c b/sys/dev/mlx/mlx_pci.c index a2c1792..b36f143 100644 --- a/sys/dev/mlx/mlx_pci.c +++ b/sys/dev/mlx/mlx_pci.c @@ -196,6 +196,8 @@ mlx_pci_attach(device_t dev) MAXBSIZE, MLX_NSEG, /* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ + NULL, /* lockfunc */ + NULL, /* lockarg */ &sc->mlx_parent_dmat); if (error != 0) { device_printf(dev, "can't allocate parent DMA tag\n"); diff --git a/sys/dev/mly/mly.c b/sys/dev/mly/mly.c index cdf1943..d220773 100644 --- a/sys/dev/mly/mly.c +++ b/sys/dev/mly/mly.c @@ -407,6 +407,8 @@ mly_pci_attach(struct mly_softc *sc) MAXBSIZE, MLY_MAX_SGENTRIES, /* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ + NULL, /* lockfunc */ + NULL, /* lockarg */ &sc->mly_parent_dmat)) { mly_printf(sc, "can't allocate parent DMA tag\n"); goto fail; @@ -423,6 +425,8 @@ mly_pci_attach(struct mly_softc *sc) MAXBSIZE, MLY_MAX_SGENTRIES, /* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, /* lockfunc */ + &Giant, /* lockarg */ &sc->mly_buffer_dmat)) { mly_printf(sc, "can't allocate buffer DMA tag\n"); goto fail; @@ -439,6 +443,8 @@ mly_pci_attach(struct mly_softc *sc) sizeof(union mly_command_packet) * MLY_MAX_COMMANDS, 1, /* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, /* lockfunc */ + &Giant, /* lockarg */ &sc->mly_packet_dmat)) { mly_printf(sc, "can't allocate command packet DMA tag\n"); goto fail; @@ -586,6 +592,8 @@ mly_sg_map(struct mly_softc *sc) segsize, 1, /* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, /* lockfunc */ + &Giant, /* lockarg */ &sc->mly_sg_dmat)) { mly_printf(sc, "can't allocate scatter/gather DMA tag\n"); return(ENOMEM); @@ -639,6 +647,8 @@ mly_mmbox_map(struct mly_softc *sc) sizeof(struct mly_mmbox), 1, /* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, /* lockfunc */ + &Giant, /* lockarg */ &sc->mly_mmbox_dmat)) { mly_printf(sc, "can't allocate memory mailbox DMA tag\n"); return(ENOMEM); diff --git a/sys/dev/mpt/mpt_pci.c b/sys/dev/mpt/mpt_pci.c index 1351354..09c2847 100644 --- a/sys/dev/mpt/mpt_pci.c +++ b/sys/dev/mpt/mpt_pci.c @@ -502,7 +502,7 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) if (bus_dma_tag_create(NULL, PAGE_SIZE, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, BUS_SPACE_MAXSIZE_32BIT, BUS_SPACE_UNRESTRICTED, 0, - &mpt->parent_dmat) != 0) { + busdma_lock_mutex, &Giant, &mpt->parent_dmat) != 0) { device_printf(dev, "cannot create parent dma tag\n"); return (1); } @@ -511,7 +511,7 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) if (bus_dma_tag_create(mpt->parent_dmat, PAGE_SIZE, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, PAGE_SIZE, 1, BUS_SPACE_MAXSIZE_32BIT, 0, - &mpt->reply_dmat) != 0) { + busdma_lock_mutex, &Giant, &mpt->reply_dmat) != 0) { device_printf(dev, "cannot create a dma tag for replies\n"); return (1); } @@ -542,7 +542,7 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) if (bus_dma_tag_create(mpt->parent_dmat, PAGE_SIZE, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, MAXBSIZE, MPT_SGL_MAX, BUS_SPACE_MAXSIZE_32BIT, 0, - &mpt->buffer_dmat) != 0) { + busdma_lock_mutex, &Giant, &mpt->buffer_dmat) != 0) { device_printf(dev, "cannot create a dma tag for data buffers\n"); return (1); @@ -552,7 +552,7 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) if (bus_dma_tag_create(mpt->parent_dmat, PAGE_SIZE, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, MPT_REQ_MEM_SIZE(mpt), 1, BUS_SPACE_MAXSIZE_32BIT, 0, - &mpt->request_dmat) != 0) { + busdma_lock_mutex, &Giant, &mpt->request_dmat) != 0) { device_printf(dev, "cannot create a dma tag for requests\n"); return (1); } diff --git a/sys/dev/sound/isa/ad1816.c b/sys/dev/sound/isa/ad1816.c index 2554af2..c4763bcb 100644 --- a/sys/dev/sound/isa/ad1816.c +++ b/sys/dev/sound/isa/ad1816.c @@ -611,7 +611,8 @@ ad1816_attach(device_t dev) /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/ad1816->bufsize, /*nsegments*/1, /*maxsegz*/0x3ffff, - /*flags*/0, &ad1816->parent_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/ &Giant, &ad1816->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto no; } diff --git a/sys/dev/sound/isa/ess.c b/sys/dev/sound/isa/ess.c index 38e3198..a0b2c2c 100644 --- a/sys/dev/sound/isa/ess.c +++ b/sys/dev/sound/isa/ess.c @@ -855,7 +855,8 @@ ess_attach(device_t dev) /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/sc->bufsize, /*nsegments*/1, /*maxsegz*/0x3ffff, - /*flags*/0, &sc->parent_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &sc->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto no; } diff --git a/sys/dev/sound/isa/mss.c b/sys/dev/sound/isa/mss.c index dc0c43e..ff7062d 100644 --- a/sys/dev/sound/isa/mss.c +++ b/sys/dev/sound/isa/mss.c @@ -1720,8 +1720,9 @@ mss_doattach(device_t dev, struct mss_info *mss) /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/mss->bufsize, /*nsegments*/1, - /*maxsegz*/0x3ffff, - /*flags*/0, &mss->parent_dmat) != 0) { + /*maxsegz*/0x3ffff, /*flags*/0, + /*lockfunc*/busdma_lock_mutex, /*lockarg*/&Giant, + &mss->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto no; } diff --git a/sys/dev/sound/isa/sb16.c b/sys/dev/sound/isa/sb16.c index 4851eeb..1f674c1 100644 --- a/sys/dev/sound/isa/sb16.c +++ b/sys/dev/sound/isa/sb16.c @@ -812,8 +812,9 @@ sb16_attach(device_t dev) /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/sb->bufsize, /*nsegments*/1, - /*maxsegz*/0x3ffff, - /*flags*/0, &sb->parent_dmat) != 0) { + /*maxsegz*/0x3ffff, /*flags*/0, + /*lockfunc*/busdma_lock_mutex, /*lockarg*/&Giant, + &sb->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto no; } diff --git a/sys/dev/sound/isa/sb8.c b/sys/dev/sound/isa/sb8.c index 095d817..819f838 100644 --- a/sys/dev/sound/isa/sb8.c +++ b/sys/dev/sound/isa/sb8.c @@ -723,8 +723,9 @@ sb_attach(device_t dev) /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/sb->bufsize, /*nsegments*/1, - /*maxsegz*/0x3ffff, - /*flags*/0, &sb->parent_dmat) != 0) { + /*maxsegz*/0x3ffff, /*flags*/0, + /*lockfunc*/busdma_lock_mutex, /*lockarg*/&Giant, + &sb->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto no; } diff --git a/sys/dev/sound/pci/als4000.c b/sys/dev/sound/pci/als4000.c index 3007736..77b3984 100644 --- a/sys/dev/sound/pci/als4000.c +++ b/sys/dev/sound/pci/als4000.c @@ -745,7 +745,8 @@ als_resource_grab(device_t dev, struct sc_info *sc) /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/sc->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, - /*flags*/0, &sc->parent_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &sc->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto bad; } diff --git a/sys/dev/sound/pci/au88x0.c b/sys/dev/sound/pci/au88x0.c index 3bf227b..81416dd 100644 --- a/sys/dev/sound/pci/au88x0.c +++ b/sys/dev/sound/pci/au88x0.c @@ -545,7 +545,7 @@ au88x0_pci_attach(device_t dev) BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, /* restrict to 4GB */ NULL, NULL, /* no filter */ aui->aui_bufsize, 1, aui->aui_bufsize, - 0, &aui->aui_dmat); + 0, busdma_lock_mutex, &Giant, &aui->aui_dmat); if (error != 0) { device_printf(dev, "failed to create DMA tag\n"); goto failed; diff --git a/sys/dev/sound/pci/aureal.c b/sys/dev/sound/pci/aureal.c index d301fd8..3630699 100644 --- a/sys/dev/sound/pci/aureal.c +++ b/sys/dev/sound/pci/aureal.c @@ -641,7 +641,8 @@ au_pci_attach(device_t dev) /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/AU_BUFFSIZE, /*nsegments*/1, /*maxsegz*/0x3ffff, - /*flags*/0, &au->parent_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &au->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto bad; } diff --git a/sys/dev/sound/pci/cmi.c b/sys/dev/sound/pci/cmi.c index 14c6c8e..f466114 100644 --- a/sys/dev/sound/pci/cmi.c +++ b/sys/dev/sound/pci/cmi.c @@ -876,6 +876,8 @@ cmi_attach(device_t dev) /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/sc->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, /*flags*/0, + /*lockfunc*/busdma_lock_mutex, + /*lockfunc*/&Giant, &sc->parent_dmat) != 0) { device_printf(dev, "cmi_attach: Unable to create dma tag\n"); goto bad; diff --git a/sys/dev/sound/pci/cs4281.c b/sys/dev/sound/pci/cs4281.c index a700394..d9b91dd 100644 --- a/sys/dev/sound/pci/cs4281.c +++ b/sys/dev/sound/pci/cs4281.c @@ -830,7 +830,8 @@ cs4281_pci_attach(device_t dev) /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/sc->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, - /*flags*/0, &sc->parent_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &sc->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto bad; } diff --git a/sys/dev/sound/pci/csapcm.c b/sys/dev/sound/pci/csapcm.c index b445e48..d379528 100644 --- a/sys/dev/sound/pci/csapcm.c +++ b/sys/dev/sound/pci/csapcm.c @@ -679,7 +679,8 @@ csa_allocres(struct csa_info *csa, device_t dev) /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/CS461x_BUFFSIZE, /*nsegments*/1, /*maxsegz*/0x3ffff, - /*flags*/0, &csa->parent_dmat) != 0) + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &csa->parent_dmat) != 0) return (1); return (0); diff --git a/sys/dev/sound/pci/ds1.c b/sys/dev/sound/pci/ds1.c index 1f1a2fe..e3a9a6e 100644 --- a/sys/dev/sound/pci/ds1.c +++ b/sys/dev/sound/pci/ds1.c @@ -828,7 +828,8 @@ ds_init(struct sc_info *sc) if (sc->regbase == NULL) { if (bus_dma_tag_create(NULL, 2, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, - NULL, NULL, memsz, 1, memsz, 0, &sc->control_dmat)) + NULL, NULL, memsz, 1, memsz, 0, busdma_lock_mutex, + &Giant, &sc->control_dmat)) return -1; if (bus_dmamem_alloc(sc->control_dmat, &buf, BUS_DMA_NOWAIT, &sc->map)) return -1; @@ -968,7 +969,8 @@ ds_pci_attach(device_t dev) /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/sc->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, - /*flags*/0, &sc->buffer_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &sc->buffer_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto bad; } diff --git a/sys/dev/sound/pci/emu10k1.c b/sys/dev/sound/pci/emu10k1.c index c847016..a0a986f 100644 --- a/sys/dev/sound/pci/emu10k1.c +++ b/sys/dev/sound/pci/emu10k1.c @@ -1494,7 +1494,8 @@ emu_pci_attach(device_t dev) /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/sc->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, - /*flags*/0, &sc->parent_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &sc->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto bad; } diff --git a/sys/dev/sound/pci/es137x.c b/sys/dev/sound/pci/es137x.c index f864b4a..9ae6606 100644 --- a/sys/dev/sound/pci/es137x.c +++ b/sys/dev/sound/pci/es137x.c @@ -902,7 +902,8 @@ es_pci_attach(device_t dev) /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/es->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, - /*flags*/0, &es->parent_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &es->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto bad; } diff --git a/sys/dev/sound/pci/fm801.c b/sys/dev/sound/pci/fm801.c index c42da08..417ed99 100644 --- a/sys/dev/sound/pci/fm801.c +++ b/sys/dev/sound/pci/fm801.c @@ -632,7 +632,8 @@ fm801_pci_attach(device_t dev) /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/fm801->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, - /*flags*/0, &fm801->parent_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &fm801->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto oops; } diff --git a/sys/dev/sound/pci/ich.c b/sys/dev/sound/pci/ich.c index aa5e856..7d5faa5 100644 --- a/sys/dev/sound/pci/ich.c +++ b/sys/dev/sound/pci/ich.c @@ -708,7 +708,8 @@ ich_pci_attach(device_t dev) sc->bufsz = pcm_getbuffersize(dev, 4096, ICH_DEFAULT_BUFSZ, ICH_MAX_BUFSZ); if (bus_dma_tag_create(NULL, 8, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, - NULL, NULL, sc->bufsz, 1, 0x3ffff, 0, &sc->dmat) != 0) { + NULL, NULL, sc->bufsz, 1, 0x3ffff, 0, + busdma_lock_mutex, &Giant, &sc->dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto bad; } diff --git a/sys/dev/sound/pci/maestro.c b/sys/dev/sound/pci/maestro.c index c479171..10613ed 100644 --- a/sys/dev/sound/pci/maestro.c +++ b/sys/dev/sound/pci/maestro.c @@ -972,7 +972,8 @@ agg_attach(device_t dev) /*lowaddr*/MAESTRO_MAXADDR, /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/ess->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, - /*flags*/0, &ess->parent_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &ess->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto bad; } diff --git a/sys/dev/sound/pci/maestro3.c b/sys/dev/sound/pci/maestro3.c index ae679ca..2f9f802 100644 --- a/sys/dev/sound/pci/maestro3.c +++ b/sys/dev/sound/pci/maestro3.c @@ -1146,7 +1146,8 @@ m3_pci_attach(device_t dev) /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/sc->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, - /*flags*/0, &sc->parent_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &sc->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto bad; } diff --git a/sys/dev/sound/pci/solo.c b/sys/dev/sound/pci/solo.c index a077cca..e13da9f 100644 --- a/sys/dev/sound/pci/solo.c +++ b/sys/dev/sound/pci/solo.c @@ -991,7 +991,8 @@ ess_attach(device_t dev) /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/sc->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, - /*flags*/0, &sc->parent_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &sc->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto no; } diff --git a/sys/dev/sound/pci/t4dwave.c b/sys/dev/sound/pci/t4dwave.c index cd7de77..19a92dc 100644 --- a/sys/dev/sound/pci/t4dwave.c +++ b/sys/dev/sound/pci/t4dwave.c @@ -854,7 +854,8 @@ tr_pci_attach(device_t dev) /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/tr->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, - /*flags*/0, &tr->parent_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &tr->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto bad; } diff --git a/sys/dev/sound/pci/via8233.c b/sys/dev/sound/pci/via8233.c index f8f136e..598e88f 100644 --- a/sys/dev/sound/pci/via8233.c +++ b/sys/dev/sound/pci/via8233.c @@ -792,7 +792,8 @@ via_attach(device_t dev) /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/via->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, - /*flags*/0, &via->parent_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &via->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto bad; } @@ -808,7 +809,8 @@ via_attach(device_t dev) /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/NSEGS * sizeof(struct via_dma_op), /*nsegments*/1, /*maxsegz*/0x3ffff, - /*flags*/0, &via->sgd_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &via->sgd_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto bad; } diff --git a/sys/dev/sound/pci/via82c686.c b/sys/dev/sound/pci/via82c686.c index 2e958ac..95c20f1 100644 --- a/sys/dev/sound/pci/via82c686.c +++ b/sys/dev/sound/pci/via82c686.c @@ -544,7 +544,8 @@ via_attach(device_t dev) /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/via->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, - /*flags*/0, &via->parent_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &via->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto bad; } @@ -560,7 +561,8 @@ via_attach(device_t dev) /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/NSEGS * sizeof(struct via_dma_op), /*nsegments*/1, /*maxsegz*/0x3ffff, - /*flags*/0, &via->sgd_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &via->sgd_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto bad; } diff --git a/sys/dev/sound/pci/vibes.c b/sys/dev/sound/pci/vibes.c index 7eb4955..589be74 100644 --- a/sys/dev/sound/pci/vibes.c +++ b/sys/dev/sound/pci/vibes.c @@ -776,7 +776,8 @@ sv_attach(device_t dev) { /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/sc->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, /*flags*/0, - &sc->parent_dmat) != 0) { + /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &sc->parent_dmat) != 0) { device_printf(dev, "sv_attach: Unable to create dma tag\n"); goto fail; } diff --git a/sys/dev/sound/usb/uaudio_pcm.c b/sys/dev/sound/usb/uaudio_pcm.c index 4ea33f3..b676aa1 100644 --- a/sys/dev/sound/usb/uaudio_pcm.c +++ b/sys/dev/sound/usb/uaudio_pcm.c @@ -307,6 +307,8 @@ ua_attach(device_t dev) /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/bufsz, /*nsegments*/1, /*maxsegz*/0x3fff, /*flags*/0, + /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &ua->parent_dmat) != 0) { device_printf(dev, "unable to create dma tag\n"); goto bad; diff --git a/sys/dev/sym/sym_hipd.c b/sys/dev/sym/sym_hipd.c index 619f7d0..084179e 100644 --- a/sys/dev/sym/sym_hipd.c +++ b/sys/dev/sym/sym_hipd.c @@ -89,6 +89,8 @@ #include #include #include +#include +#include #ifdef FreeBSD_Bus_Io_Abstraction #include #include @@ -783,7 +785,8 @@ static m_pool_s *___cre_dma_pool(bus_dma_tag_t dev_dmat) BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR_32BIT, NULL, NULL, MEMO_CLUSTER_SIZE, 1, - MEMO_CLUSTER_SIZE, 0, &mp->dmat)) { + MEMO_CLUSTER_SIZE, 0, + busdma_lock_mutex, &Giant, &mp->dmat)) { mp->getp = ___dma_getp; #ifdef MEMO_FREE_UNUSED mp->freep = ___dma_freep; @@ -9130,7 +9133,8 @@ sym_pci_attach2(pcici_t pci_tag, int unit) BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE, SYM_CONF_MAX_SG, - (1<<24), 0, &np->data_dmat)) { + (1<<24), 0, busdma_lock_mutex, &Giant, + &np->data_dmat)) { device_printf(dev, "failed to create DMA tag.\n"); goto attach_failed; } diff --git a/sys/dev/trm/trm.c b/sys/dev/trm/trm.c index 14f2d97..385d220 100644 --- a/sys/dev/trm/trm.c +++ b/sys/dev/trm/trm.c @@ -3016,6 +3016,8 @@ trm_initSRB(PACB pACB) /*nsegments*/ 1, /*maxsegsz*/ TRM_MAXTRANSFER_SIZE, /*flags*/ 0, + /*lockfunc*/ busdma_lock_mutex, + /*lockarg*/ &Giant, /*dmat*/ &pSRB->sg_dmat) != 0) { return ENXIO; } @@ -3408,18 +3410,21 @@ trm_init(u_int16_t unit, device_t dev) pACB->dev = dev; pACB->tag = rman_get_bustag(pACB->iores); pACB->bsh = rman_get_bushandle(pACB->iores); - if (bus_dma_tag_create(/*parent_dmat*/ pACB->parent_dmat, - /*alignment*/ 1, - /*boundary*/ 0, - /*lowaddr*/ BUS_SPACE_MAXADDR, - /*highaddr*/ BUS_SPACE_MAXADDR, - /*filter*/ NULL, - /*filterarg*/ NULL, - /*maxsize*/ MAXBSIZE, - /*nsegments*/ TRM_NSEG, - /*maxsegsz*/ TRM_MAXTRANSFER_SIZE, - /*flags*/ BUS_DMA_ALLOCNOW, - &pACB->buffer_dmat) != 0) + if (bus_dma_tag_create( + /*parent_dmat*/ pACB->parent_dmat, + /*alignment*/ 1, + /*boundary*/ 0, + /*lowaddr*/ BUS_SPACE_MAXADDR, + /*highaddr*/ BUS_SPACE_MAXADDR, + /*filter*/ NULL, + /*filterarg*/ NULL, + /*maxsize*/ MAXBSIZE, + /*nsegments*/ TRM_NSEG, + /*maxsegsz*/ TRM_MAXTRANSFER_SIZE, + /*flags*/ BUS_DMA_ALLOCNOW, + /*lockfunc*/ busdma_lock_mutex, + /*lockarg*/ &Giant, + /* dmat */ &pACB->buffer_dmat) != 0) goto bad; /* DMA tag for our ccb structures */ if (bus_dma_tag_create( @@ -3433,7 +3438,9 @@ trm_init(u_int16_t unit, device_t dev) /*maxsize*/ TRM_MAX_SRB_CNT * sizeof(TRM_SRB), /*nsegments*/ 1, /*maxsegsz*/ TRM_MAXTRANSFER_SIZE, - /*flags*/ 0, + /*flags*/ 0, + /*lockfunc*/ busdma_lock_mutex, + /*lockarg*/ &Giant, /*dmat*/ &pACB->srb_dmat) != 0) { printf("trm_init %d: bus_dma_tag_create SRB failure\n", unit); goto bad; @@ -3455,7 +3462,8 @@ trm_init(u_int16_t unit, device_t dev) sizeof(struct scsi_sense_data) * TRM_MAX_SRB_CNT, /*nsegments*/1, /*maxsegsz*/TRM_MAXTRANSFER_SIZE, - /*flags*/0, &pACB->sense_dmat) != 0) { + /*flags*/0, /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &pACB->sense_dmat) != 0) { if (bootverbose) device_printf(dev, "cannot create sense buffer dmat\n"); goto bad; diff --git a/sys/dev/twe/twe_freebsd.c b/sys/dev/twe/twe_freebsd.c index 1a41f16..efe63da 100644 --- a/sys/dev/twe/twe_freebsd.c +++ b/sys/dev/twe/twe_freebsd.c @@ -233,6 +233,8 @@ twe_attach(device_t dev) MAXBSIZE, TWE_MAX_SGL_LENGTH, /* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ + NULL, /* lockfunc */ + NULL, /* lockarg */ &sc->twe_parent_dmat)) { twe_printf(sc, "can't allocate parent DMA tag\n"); twe_free(sc); @@ -265,6 +267,8 @@ twe_attach(device_t dev) MAXBSIZE, TWE_MAX_SGL_LENGTH,/* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, /* lockfunc */ + &Giant, /* lockarg */ &sc->twe_buffer_dmat)) { twe_printf(sc, "can't allocate data buffer DMA tag\n"); twe_free(sc); diff --git a/sys/dev/tx/if_tx.c b/sys/dev/tx/if_tx.c index f4bf170..cdd5844 100644 --- a/sys/dev/tx/if_tx.c +++ b/sys/dev/tx/if_tx.c @@ -280,7 +280,7 @@ epic_attach(dev) /* Allocate DMA tags. */ error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES * EPIC_MAX_FRAGS, - EPIC_MAX_FRAGS, MCLBYTES, 0, &sc->mtag); + EPIC_MAX_FRAGS, MCLBYTES, 0, busdma_lock_mutex, &Giant, &sc->mtag); if (error) { device_printf(dev, "couldn't allocate dma tag\n"); goto fail; @@ -289,7 +289,8 @@ epic_attach(dev) error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, sizeof(struct epic_rx_desc) * RX_RING_SIZE, - 1, sizeof(struct epic_rx_desc) * RX_RING_SIZE, 0, &sc->rtag); + 1, sizeof(struct epic_rx_desc) * RX_RING_SIZE, 0, busdma_lock_mutex, + &Giant, &sc->rtag); if (error) { device_printf(dev, "couldn't allocate dma tag\n"); goto fail; @@ -298,7 +299,8 @@ epic_attach(dev) error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, sizeof(struct epic_tx_desc) * TX_RING_SIZE, - 1, sizeof(struct epic_tx_desc) * TX_RING_SIZE, 0, &sc->ttag); + 1, sizeof(struct epic_tx_desc) * TX_RING_SIZE, 0, + busdma_lock_mutex, &Giant, &sc->ttag); if (error) { device_printf(dev, "couldn't allocate dma tag\n"); goto fail; @@ -307,7 +309,8 @@ epic_attach(dev) error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, sizeof(struct epic_frag_list) * TX_RING_SIZE, - 1, sizeof(struct epic_frag_list) * TX_RING_SIZE, 0, &sc->ftag); + 1, sizeof(struct epic_frag_list) * TX_RING_SIZE, 0, + busdma_lock_mutex, &Giant, &sc->ftag); if (error) { device_printf(dev, "couldn't allocate dma tag\n"); goto fail; diff --git a/sys/dev/ubsec/ubsec.c b/sys/dev/ubsec/ubsec.c index 6f62982..c9382ba 100644 --- a/sys/dev/ubsec/ubsec.c +++ b/sys/dev/ubsec/ubsec.c @@ -367,6 +367,7 @@ ubsec_attach(device_t dev) UBS_MAX_SCATTER, /* nsegments */ 0xffff, /* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ &sc->sc_dmat)) { device_printf(dev, "cannot allocate DMA tag\n"); goto bad4; @@ -1851,6 +1852,7 @@ ubsec_dma_malloc( 1, /* nsegments */ size, /* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ &dma->dma_tag); if (r != 0) { device_printf(sc->sc_dev, "ubsec_dma_malloc: " diff --git a/sys/dev/wds/wd7000.c b/sys/dev/wds/wd7000.c index c78bb61..bf525ac 100644 --- a/sys/dev/wds/wd7000.c +++ b/sys/dev/wds/wd7000.c @@ -553,6 +553,8 @@ wds_attach(device_t dev) /*maxsize*/ sizeof(* wp->dx), /*nsegments*/ 1, /*maxsegsz*/ sizeof(* wp->dx), /*flags*/ 0, + /*lockfunc*/busdma_lock_mutex, + /*lockarg*/&Giant, &wp->bustag); if (error) goto bad; diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c index f9f0b8f..bed991a 100644 --- a/sys/dev/wi/if_wi.c +++ b/sys/dev/wi/if_wi.c @@ -765,6 +765,14 @@ wi_stop(struct ifnet *ifp, int disable) ieee80211_new_state(ifp, IEEE80211_S_INIT, -1); if (sc->sc_enabled && !sc->wi_gone) { + int i; + /* wait for the busy bit to clear */ + for (i = 50; i > 0; i--) { /* 5s */ + if (!(CSR_READ_2(sc, WI_COMMAND) & WI_CMD_BUSY)) + break; + printf("Sleeping for 10ms in wi_stop\n"); + DELAY(10*10000); /* 10 m sec */ + } CSR_WRITE_2(sc, WI_INT_EN, 0); wi_cmd(sc, WI_CMD_DISABLE | sc->sc_portnum, 0, 0, 0); if (disable) { @@ -1440,7 +1448,9 @@ wi_rx_intr(struct wi_softc *sc) if (ic->ic_opmode == IEEE80211_M_IBSS && dir == IEEE80211_FC1_DIR_NODS) wi_sync_bssid(sc, wh->i_addr3); + WI_UNLOCK(sc); ieee80211_input(ifp, m, rssi, rstamp, 0); + WI_LOCK(sc); } static void diff --git a/sys/i386/acpica/acpi_wakeup.c b/sys/i386/acpica/acpi_wakeup.c index 306533e..81a396a 100644 --- a/sys/i386/acpica/acpi_wakeup.c +++ b/sys/i386/acpica/acpi_wakeup.c @@ -315,7 +315,8 @@ acpi_alloc_wakeup_handler(void) if (bus_dma_tag_create(/* parent */ NULL, /* alignment */ 2, 0, /* lowaddr below 1MB */ 0x9ffff, /* highaddr */ BUS_SPACE_MAXADDR, NULL, NULL, - PAGE_SIZE, 1, PAGE_SIZE, 0, &acpi_waketag) != 0) { + PAGE_SIZE, 1, PAGE_SIZE, 0, busdma_lock_mutex, + &Giant, &acpi_waketag) != 0) { printf("acpi_alloc_wakeup_handler: unable to create wake tag\n"); return; } diff --git a/sys/i386/i386/busdma_machdep.c b/sys/i386/i386/busdma_machdep.c index 183b0f7..02db2bd 100644 --- a/sys/i386/i386/busdma_machdep.c +++ b/sys/i386/i386/busdma_machdep.c @@ -64,6 +64,8 @@ struct bus_dma_tag { int flags; int ref_count; int map_count; + bus_dma_lock_t *lockfunc; + void *lockfuncarg; }; struct bounce_page { @@ -92,7 +94,6 @@ struct bus_dmamap { bus_size_t buflen; /* unmapped buffer length */ bus_dmamap_callback_t *callback; void *callback_arg; - struct mtx *callback_mtx; STAILQ_ENTRY(bus_dmamap) links; }; @@ -138,6 +139,46 @@ run_filter(bus_dma_tag_t dmat, bus_addr_t paddr) 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. @@ -147,7 +188,8 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, 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; @@ -173,6 +215,13 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, 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) { @@ -864,18 +913,18 @@ free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage) 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); diff --git a/sys/i386/include/bus_dma.h b/sys/i386/include/bus_dma.h index 8a54fe3..3539a33 100644 --- a/sys/i386/include/bus_dma.h +++ b/sys/i386/include/bus_dma.h @@ -132,6 +132,17 @@ typedef struct bus_dma_segment { 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 @@ int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, 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 @@ void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map); 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 /* _I386_BUS_DMA_H_ */ diff --git a/sys/i4b/layer1/itjc/i4b_itjc_pci.c b/sys/i4b/layer1/itjc/i4b_itjc_pci.c index c16f1b1..6047216 100644 --- a/sys/i4b/layer1/itjc/i4b_itjc_pci.c +++ b/sys/i4b/layer1/itjc/i4b_itjc_pci.c @@ -1608,6 +1608,7 @@ itjc_attach(device_t dev) 1, /* nsegments*/ ITJC_DMA_POOL_BYTES, /* maxsegsz*/ BUS_DMA_ALLOCNOW | BUS_DMA_COHERENT, /* flags*/ + NULL, NULL, /* lockfuunc, lockarg */ &ctx->tag); if (error) diff --git a/sys/ia64/ia64/busdma_machdep.c b/sys/ia64/ia64/busdma_machdep.c index 466e995..dd29ff6 100644 --- a/sys/ia64/ia64/busdma_machdep.c +++ b/sys/ia64/ia64/busdma_machdep.c @@ -61,6 +61,8 @@ struct bus_dma_tag { int flags; int ref_count; int map_count; + bus_dma_lock_t *lockfunc; + void *lockfuncarg; }; struct bounce_page { @@ -90,7 +92,6 @@ struct bus_dmamap { 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; }; @@ -124,6 +125,46 @@ run_filter(bus_dma_tag_t dmat, bus_addr_t paddr) 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. @@ -133,7 +174,8 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, 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; @@ -158,6 +200,13 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, 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) { @@ -914,20 +963,18 @@ free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage) void busdma_swi(void) { - int s; + bus_dma_tag_t dmat; struct bus_dmamap *map; - s = splhigh(); + printf("WARNING: busdma_swi is not properly locked!\n"); + mtx_lock(&Giant); while ((map = STAILQ_FIRST(&bounce_map_callbacklist)) != NULL) { STAILQ_REMOVE_HEAD(&bounce_map_callbacklist, links); - splx(s); - 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); - s = splhigh(); + (dmat->lockfunc)(dmat->lockfuncarg, BUS_DMA_UNLOCK); } - splx(s); + mtx_unlock(&Giant); } diff --git a/sys/ia64/include/bus.h b/sys/ia64/include/bus.h index bc15d08..7a5c0f4 100644 --- a/sys/ia64/include/bus.h +++ b/sys/ia64/include/bus.h @@ -905,6 +905,17 @@ typedef struct bus_dma_segment { 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: * @@ -928,7 +939,8 @@ typedef int bus_dma_filter_t(void *, bus_addr_t); int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignemnt, 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); + int nsegments, 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); @@ -1016,4 +1028,8 @@ bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t dmamap) _bus_dmamap_unload(dmat, dmamap); } +/* + * Generic helper function for manipulating mutexes. + */ +void busdma_lock_mutex(void *arg, bus_dma_lock_op_t op); #endif /* _MACHINE_BUS_H_ */ diff --git a/sys/ia64/isa/isa_dma.c b/sys/ia64/isa/isa_dma.c index e749663..305c674 100644 --- a/sys/ia64/isa/isa_dma.c +++ b/sys/ia64/isa/isa_dma.c @@ -51,6 +51,8 @@ #include #include #include +#include +#include #include #include #include @@ -129,6 +131,8 @@ isa_dmainit(chan, bouncebufsize) /*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"); } diff --git a/sys/pci/if_rl.c b/sys/pci/if_rl.c index 861eb51..b26b837 100644 --- a/sys/pci/if_rl.c +++ b/sys/pci/if_rl.c @@ -996,6 +996,7 @@ rl_attach(dev) MAXBSIZE, RL_NSEG_NEW, /* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT,/* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ &sc->rl_parent_tag); if (error) goto fail; @@ -1013,6 +1014,8 @@ rl_attach(dev) RL_RXBUFLEN + 1518, 1, /* maxsize,nsegments */ BUS_SPACE_MAXSIZE_32BIT,/* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, /* lockfunc */ + &Giant, /* lockarg */ &sc->rl_tag); if (error) goto fail; diff --git a/sys/pci/if_sis.c b/sys/pci/if_sis.c index 962f3c8..d169c98 100644 --- a/sys/pci/if_sis.c +++ b/sys/pci/if_sis.c @@ -1243,6 +1243,7 @@ sis_attach(dev) MAXBSIZE, SIS_NSEG_NEW, /* maxsize, nsegments */ BUS_SPACE_MAXSIZE_32BIT,/* maxsegsize */ BUS_DMA_ALLOCNOW, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ &sc->sis_parent_tag); if (error) goto fail; @@ -1262,6 +1263,8 @@ sis_attach(dev) SIS_RX_LIST_SZ, 1, /* maxsize,nsegments */ BUS_SPACE_MAXSIZE_32BIT,/* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, /* lockfunc */ + &Giant, /* lockarg */ &sc->sis_ldata.sis_rx_tag); if (error) goto fail; @@ -1299,6 +1302,8 @@ sis_attach(dev) SIS_TX_LIST_SZ, 1, /* maxsize,nsegments */ BUS_SPACE_MAXSIZE_32BIT,/* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, /* lockfunc */ + &Giant, /* lockarg */ &sc->sis_ldata.sis_tx_tag); if (error) goto fail; @@ -1336,6 +1341,8 @@ sis_attach(dev) MCLBYTES, 1, /* maxsize,nsegments */ BUS_SPACE_MAXSIZE_32BIT,/* maxsegsize */ 0, /* flags */ + busdma_lock_mutex, /* lockfunc */ + &Giant, /* lockarg */ &sc->sis_tag); if (error) goto fail; diff --git a/sys/pci/if_xl.c b/sys/pci/if_xl.c index b4a43fc..060c859 100644 --- a/sys/pci/if_xl.c +++ b/sys/pci/if_xl.c @@ -1481,7 +1481,8 @@ xl_attach(dev) */ error = bus_dma_tag_create(NULL, 8, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - XL_RX_LIST_SZ, 1, XL_RX_LIST_SZ, 0, &sc->xl_ldata.xl_rx_tag); + XL_RX_LIST_SZ, 1, XL_RX_LIST_SZ, 0, busdma_lock_mutex, &Giant, + &sc->xl_ldata.xl_rx_tag); if (error) { printf("xl%d: failed to allocate rx dma tag\n", unit); goto fail; @@ -1512,7 +1513,8 @@ xl_attach(dev) error = bus_dma_tag_create(NULL, 8, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - XL_TX_LIST_SZ, 1, XL_TX_LIST_SZ, 0, &sc->xl_ldata.xl_tx_tag); + XL_TX_LIST_SZ, 1, XL_TX_LIST_SZ, 0, busdma_lock_mutex, &Giant, + &sc->xl_ldata.xl_tx_tag); if (error) { printf("xl%d: failed to allocate tx dma tag\n", unit); goto fail; @@ -1546,7 +1548,8 @@ xl_attach(dev) */ error = bus_dma_tag_create(NULL, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - MCLBYTES * XL_MAXFRAGS, XL_MAXFRAGS, MCLBYTES, 0, &sc->xl_mtag); + MCLBYTES * XL_MAXFRAGS, XL_MAXFRAGS, MCLBYTES, 0, busdma_lock_mutex, + &Giant, &sc->xl_mtag); if (error) { printf("xl%d: failed to allocate mbuf dma tag\n", unit); goto fail; diff --git a/sys/powerpc/include/bus.h b/sys/powerpc/include/bus.h index eff6e8f..3ee2de5 100644 --- a/sys/powerpc/include/bus.h +++ b/sys/powerpc/include/bus.h @@ -797,6 +797,17 @@ typedef struct bus_dma_segment { 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: * @@ -820,7 +831,8 @@ int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, 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); @@ -896,4 +908,8 @@ void bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t); */ void bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map); +/* + * Generic helper function for manipulating mutexes. + */ +void busdma_lock_mutex(void *arg, bus_dma_lock_op_t op); #endif /* _MACPPC_BUS_H_ */ diff --git a/sys/powerpc/powerpc/busdma_machdep.c b/sys/powerpc/powerpc/busdma_machdep.c index 3d6d402..f3ef3e3 100644 --- a/sys/powerpc/powerpc/busdma_machdep.c +++ b/sys/powerpc/powerpc/busdma_machdep.c @@ -67,6 +67,8 @@ struct bus_dma_tag { int flags; int ref_count; int map_count; + bus_dma_lock_t *lockfunc; + void *lockfuncarg; }; struct bus_dmamap { @@ -75,10 +77,49 @@ struct bus_dmamap { bus_size_t buflen; /* unmapped buffer length */ bus_dmamap_callback_t *callback; void *callback_arg; - struct mtx *callback_mtx; }; /* + * 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 +} + +/* * Allocate a device specific dma_tag. */ int @@ -86,7 +127,8 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, 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; @@ -111,6 +153,13 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, 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 diff --git a/sys/sparc64/include/bus.h b/sys/sparc64/include/bus.h index 2a3e5a6..4e0c2b4 100644 --- a/sys/sparc64/include/bus.h +++ b/sys/sparc64/include/bus.h @@ -957,6 +957,17 @@ typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int); typedef void bus_dmamap_callback2_t(void *, bus_dma_segment_t *, int, bus_size_t, int); /* + * 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); + +/* * Method table for a bus_dma_tag. */ struct bus_dma_methods { @@ -996,13 +1007,15 @@ struct bus_dma_tag { int dt_flags; int dt_ref_count; int dt_map_count; + bus_dma_lock_t *dt_lockfunc; + void * *dt_lockfuncarg; struct bus_dma_methods *dt_mt; }; int bus_dma_tag_create(bus_dma_tag_t, bus_size_t, bus_size_t, bus_addr_t, bus_addr_t, bus_dma_filter_t *, void *, bus_size_t, int, bus_size_t, - int, bus_dma_tag_t *); + int, bus_dma_lock_t *, void *, bus_dma_tag_t *); int bus_dma_tag_destroy(bus_dma_tag_t); @@ -1025,4 +1038,8 @@ int bus_dma_tag_destroy(bus_dma_tag_t); #define bus_dmamem_free(t, v, m) \ ((t)->dt_mt->dm_dmamem_free((t), (v), (m))) +/* + * Generic helper function for manipulating mutexes. + */ +void busdma_lock_mutex(void *arg, bus_dma_lock_op_t op); #endif /* !_MACHINE_BUS_H_ */ diff --git a/sys/sparc64/pci/psycho.c b/sys/sparc64/pci/psycho.c index a1d7fee..bf76c3c 100644 --- a/sys/sparc64/pci/psycho.c +++ b/sys/sparc64/pci/psycho.c @@ -553,7 +553,7 @@ psycho_attach(device_t dev) sc->sc_iot = psycho_alloc_bus_tag(sc, PCI_IO_BUS_SPACE); sc->sc_cfgt = psycho_alloc_bus_tag(sc, PCI_CONFIG_BUS_SPACE); if (bus_dma_tag_create(sc->sc_dmatag, 8, 1, 0, 0x3ffffffff, NULL, NULL, - 0x3ffffffff, 0xff, 0xffffffff, 0, &sc->sc_dmat) != 0) + 0x3ffffffff, 0xff, 0xffffffff, 0, NULL, NULL, &sc->sc_dmat) != 0) panic("psycho_attach: bus_dma_tag_create failed"); /* Customize the tag. */ sc->sc_dmat->dt_cookie = sc->sc_is; diff --git a/sys/sparc64/sbus/sbus.c b/sys/sparc64/sbus/sbus.c index 22a0aeb..028933e 100644 --- a/sys/sparc64/sbus/sbus.c +++ b/sys/sparc64/sbus/sbus.c @@ -393,7 +393,7 @@ sbus_probe(device_t dev) /* Create the DMA tag. */ sc->sc_dmatag = nexus_get_dmatag(dev); if (bus_dma_tag_create(sc->sc_dmatag, 8, 1, 0, 0x3ffffffff, NULL, NULL, - 0x3ffffffff, 0xff, 0xffffffff, 0, &sc->sc_cdmatag) != 0) + 0x3ffffffff, 0xff, 0xffffffff, 0, NULL, NULL, &sc->sc_cdmatag) != 0) panic("bus_dma_tag_create failed"); /* Customize the tag. */ sc->sc_cdmatag->dt_cookie = &sc->sc_is; diff --git a/sys/sparc64/sparc64/bus_machdep.c b/sys/sparc64/sparc64/bus_machdep.c index 90d6ffd..b9fa29e 100644 --- a/sys/sparc64/sparc64/bus_machdep.c +++ b/sys/sparc64/sparc64/bus_machdep.c @@ -155,7 +155,47 @@ int bus_stream_asi[] = { }; /* - * Since there is now way for a device to obtain a dma tag from its parent + * 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 +} + +/* + * Since there is no way for a device to obtain a dma tag from its parent * we use this kluge to handle different the different supported bus systems. * The sparc64_root_dma_tag is used as parent for tags that have none, so that * the correct methods will be used. @@ -169,7 +209,8 @@ int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, 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) + int nsegments, bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc, + void *lockfuncarg, bus_dma_tag_t *dmat) { bus_dma_tag_t impptag; bus_dma_tag_t newtag; @@ -204,6 +245,14 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, newtag->dt_ref_count = 1; /* Count ourselves */ newtag->dt_map_count = 0; + if (lockfunc != NULL) { + newtag->dt_lockfunc = lockfunc; + newtag->dt_lockfuncarg = lockfuncarg; + } else { + newtag->dt_lockfunc = dflt_lock; + newtag->dt_lockfuncarg = NULL; + } + /* Take into account any restrictions imposed by our parent tag */ if (parent != NULL) { newtag->dt_lowaddr = ulmin(parent->dt_lowaddr, @@ -630,6 +679,8 @@ struct bus_dma_tag nexus_dmatag = { 0, 0, 0, + NULL, + NULL, &nexus_dma_methods, }; diff --git a/sys/sys/bus_dma.h b/sys/sys/bus_dma.h index 8a54fe3..3539a33 100644 --- a/sys/sys/bus_dma.h +++ b/sys/sys/bus_dma.h @@ -132,6 +132,17 @@ typedef struct bus_dma_segment { 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 @@ int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, 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 @@ void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map); 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 /* _I386_BUS_DMA_H_ */ -- cgit v1.1