1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-12 09:58:36 +00:00

sound(4): Remove pointless Giant from bus_dma_tag_create().

None of the drivers really implement asynchronous buffer loading, so
they don't need lock there.  The only question is which of them have
BUS_DMA_NOWAIT flag there already, and to which it should be added.
This commit is contained in:
Alexander Motin 2021-09-04 18:22:53 -04:00
parent 440320b620
commit 1f7a6325fe
18 changed files with 45 additions and 70 deletions

View File

@ -620,8 +620,8 @@ ad1816_attach(device_t dev)
/*filter*/NULL, /*filterarg*/NULL,
/*maxsize*/ad1816->bufsize, /*nsegments*/1,
/*maxsegz*/0x3ffff,
/*flags*/0, /*lockfunc*/busdma_lock_mutex,
/*lockarg*/ &Giant, &ad1816->parent_dmat) != 0) {
/*flags*/0, /*lockfunc*/NULL, /*lockarg*/NULL,
&ad1816->parent_dmat) != 0) {
device_printf(dev, "unable to create dma tag\n");
goto no;
}

View File

@ -859,8 +859,8 @@ ess_attach(device_t dev)
/*filter*/NULL, /*filterarg*/NULL,
/*maxsize*/sc->bufsize, /*nsegments*/1,
/*maxsegz*/0x3ffff,
/*flags*/0, /*lockfunc*/busdma_lock_mutex,
/*lockarg*/&Giant, &sc->parent_dmat) != 0) {
/*flags*/0, /*lockfunc*/NULL, /*lockarg*/NULL,
&sc->parent_dmat) != 0) {
device_printf(dev, "unable to create dma tag\n");
goto no;
}

View File

@ -1732,7 +1732,7 @@ mss_doattach(device_t dev, struct mss_info *mss)
/*filter*/NULL, /*filterarg*/NULL,
/*maxsize*/mss->bufsize, /*nsegments*/1,
/*maxsegz*/0x3ffff, /*flags*/0,
/*lockfunc*/busdma_lock_mutex, /*lockarg*/&Giant,
/*lockfunc*/NULL, /*lockarg*/NULL,
&mss->parent_dmat) != 0) {
device_printf(dev, "unable to create dma tag\n");
goto no;

View File

@ -846,7 +846,7 @@ sb16_attach(device_t dev)
/*filter*/NULL, /*filterarg*/NULL,
/*maxsize*/sb->bufsize, /*nsegments*/1,
/*maxsegz*/0x3ffff, /*flags*/0,
/*lockfunc*/busdma_lock_mutex, /*lockarg*/&Giant,
/*lockfunc*/NULL, /*lockarg*/NULL,
&sb->parent_dmat) != 0) {
device_printf(dev, "unable to create dma tag\n");
goto no;

View File

@ -743,7 +743,7 @@ sb_attach(device_t dev)
/*filter*/NULL, /*filterarg*/NULL,
/*maxsize*/sb->bufsize, /*nsegments*/1,
/*maxsegz*/0x3ffff, /*flags*/0,
/*lockfunc*/busdma_lock_mutex, /*lockarg*/&Giant,
/*lockfunc*/NULL, /*lockarg*/NULL,
&sb->parent_dmat) != 0) {
device_printf(dev, "unable to create dma tag\n");
goto no;

View File

@ -642,8 +642,8 @@ au_pci_attach(device_t dev)
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
/*maxsize*/AU_BUFFSIZE, /*nsegments*/1, /*maxsegz*/0x3ffff,
/*flags*/0, /*lockfunc*/busdma_lock_mutex,
/*lockarg*/&Giant, &au->parent_dmat) != 0) {
/*flags*/0, /*lockfunc*/NULL, /*lockarg*/NULL,
&au->parent_dmat) != 0) {
device_printf(dev, "unable to create dma tag\n");
goto bad;
}

View File

@ -823,8 +823,8 @@ cs4281_pci_attach(device_t dev)
/*filter*/NULL, /*filterarg*/NULL,
/*maxsize*/sc->bufsz, /*nsegments*/1,
/*maxsegz*/0x3ffff,
/*flags*/0, /*lockfunc*/busdma_lock_mutex,
/*lockarg*/&Giant, &sc->parent_dmat) != 0) {
/*flags*/0, /*lockfunc*/NULL, /*lockarg*/NULL,
&sc->parent_dmat) != 0) {
device_printf(dev, "unable to create dma tag\n");
goto bad;
}

View File

@ -716,8 +716,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, /*lockfunc*/busdma_lock_mutex,
/*lockarg*/&Giant, &csa->parent_dmat) != 0)
/*flags*/0, /*lockfunc*/NULL, /*lockarg*/NULL,
&csa->parent_dmat) != 0)
return (1);
return (0);

View File

@ -1328,8 +1328,8 @@ emu_malloc(struct sc_info *sc, u_int32_t sz, bus_addr_t *addr,
*addr = 0;
if (bus_dmamem_alloc(sc->parent_dmat, &buf, BUS_DMA_NOWAIT, map))
return NULL;
if (bus_dmamap_load(sc->parent_dmat, *map, buf, sz, emu_setmap, addr, 0)
|| !*addr) {
if (bus_dmamap_load(sc->parent_dmat, *map, buf, sz, emu_setmap, addr,
BUS_DMA_NOWAIT) || !*addr) {
bus_dmamem_free(sc->parent_dmat, buf, *map);
return NULL;
}
@ -2107,8 +2107,8 @@ emu_pci_attach(device_t dev)
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
/*maxsize*/sc->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff,
/*flags*/0, /*lockfunc*/busdma_lock_mutex,
/*lockarg*/&Giant, &sc->parent_dmat) != 0) {
/*flags*/0, /*lockfunc*/NULL, /*lockarg*/NULL,
&sc->parent_dmat) != 0) {
device_printf(dev, "unable to create dma tag\n");
goto bad;
}

View File

@ -2700,8 +2700,8 @@ emu_init(struct emu_sc_info *sc)
/* highaddr */ BUS_SPACE_MAXADDR,
/* filter */ NULL, /* filterarg */ NULL,
/* maxsize */ EMU_MAX_BUFSZ, /* nsegments */ 1, /* maxsegz */ 0x3ffff,
/* flags */ 0, /* lockfunc */ busdma_lock_mutex,
/* lockarg */ &Giant, &(sc->mem.dmat)) != 0) {
/* flags */ 0, /* lockfunc */NULL, /* lockarg */NULL,
&sc->mem.dmat) != 0) {
device_printf(sc->dev, "unable to create dma tag\n");
bus_dma_tag_destroy(sc->mem.dmat);
return (ENOMEM);

View File

@ -2264,12 +2264,14 @@ envy24_dmainit(struct sc_info *sc)
#if(0)
device_printf(sc->dev, "envy24_dmainit(): bus_dmamem_load(): sc->pmap\n");
#endif
if (bus_dmamap_load(sc->dmat, sc->pmap, sc->pbuf, sc->psize, envy24_dmapsetmap, sc, 0))
if (bus_dmamap_load(sc->dmat, sc->pmap, sc->pbuf, sc->psize,
envy24_dmapsetmap, sc, BUS_DMA_NOWAIT))
goto bad;
#if(0)
device_printf(sc->dev, "envy24_dmainit(): bus_dmamem_load(): sc->rmap\n");
#endif
if (bus_dmamap_load(sc->dmat, sc->rmap, sc->rbuf, sc->rsize, envy24_dmarsetmap, sc, 0))
if (bus_dmamap_load(sc->dmat, sc->rmap, sc->rbuf, sc->rsize,
envy24_dmarsetmap, sc, BUS_DMA_NOWAIT))
goto bad;
bzero(sc->pbuf, sc->psize);
bzero(sc->rbuf, sc->rsize);
@ -2534,8 +2536,8 @@ envy24_alloc_resource(struct sc_info *sc)
/*filter*/NULL, /*filterarg*/NULL,
/*maxsize*/BUS_SPACE_MAXSIZE_ENVY24,
/*nsegments*/1, /*maxsegsz*/0x3ffff,
/*flags*/0, /*lockfunc*/busdma_lock_mutex,
/*lockarg*/&Giant, &sc->dmat) != 0) {
/*flags*/0, /*lockfunc*/NULL, /*lockarg*/NULL,
&sc->dmat) != 0) {
device_printf(sc->dev, "unable to create dma tag\n");
return ENXIO;
}

View File

@ -632,8 +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, /*lockfunc*/busdma_lock_mutex,
/*lockarg*/&Giant, &fm801->parent_dmat) != 0) {
/*flags*/0, /*lockfunc*/NULL, /*lockarg*/NULL,
&fm801->parent_dmat) != 0) {
device_printf(dev, "unable to create dma tag\n");
goto oops;
}

View File

@ -172,8 +172,8 @@ hdspe_alloc_resources(struct sc_info *sc)
/*nsegments*/2,
/*maxsegsz*/HDSPE_DMASEGSIZE,
/*flags*/0,
/*lockfunc*/busdma_lock_mutex,
/*lockarg*/&Giant,
/*lockfunc*/NULL,
/*lockarg*/NULL,
/*dmatag*/&sc->dmat) != 0) {
device_printf(sc->dev, "Unable to create dma tag.\n");
return (ENXIO);
@ -182,27 +182,27 @@ hdspe_alloc_resources(struct sc_info *sc)
sc->bufsize = HDSPE_DMASEGSIZE;
/* pbuf (play buffer). */
if (bus_dmamem_alloc(sc->dmat, (void **)&sc->pbuf,
BUS_DMA_NOWAIT, &sc->pmap)) {
if (bus_dmamem_alloc(sc->dmat, (void **)&sc->pbuf, BUS_DMA_WAITOK,
&sc->pmap)) {
device_printf(sc->dev, "Can't alloc pbuf.\n");
return (ENXIO);
}
if (bus_dmamap_load(sc->dmat, sc->pmap, sc->pbuf, sc->bufsize,
hdspe_dmapsetmap, sc, 0)) {
hdspe_dmapsetmap, sc, BUS_DMA_NOWAIT)) {
device_printf(sc->dev, "Can't load pbuf.\n");
return (ENXIO);
}
/* rbuf (rec buffer). */
if (bus_dmamem_alloc(sc->dmat, (void **)&sc->rbuf,
BUS_DMA_NOWAIT, &sc->rmap)) {
if (bus_dmamem_alloc(sc->dmat, (void **)&sc->rbuf, BUS_DMA_WAITOK,
&sc->rmap)) {
device_printf(sc->dev, "Can't alloc rbuf.\n");
return (ENXIO);
}
if (bus_dmamap_load(sc->dmat, sc->rmap, sc->rbuf, sc->bufsize,
hdspe_dmapsetmap, sc, 0)) {
hdspe_dmapsetmap, sc, BUS_DMA_NOWAIT)) {
device_printf(sc->dev, "Can't load rbuf.\n");
return (ENXIO);
}

View File

@ -1716,8 +1716,8 @@ dma_malloc(bus_dma_tag_t dmat, u_int32_t sz, bus_addr_t *phys,
if (bus_dmamem_alloc(dmat, &buf, BUS_DMA_NOWAIT, map))
return NULL;
if (bus_dmamap_load(dmat, *map, buf, sz, setmap, phys, 0) != 0 ||
*phys == 0) {
if (bus_dmamap_load(dmat, *map, buf, sz, setmap, phys,
BUS_DMA_NOWAIT) != 0 || *phys == 0) {
bus_dmamem_free(dmat, buf, *map);
return NULL;
}
@ -1793,7 +1793,7 @@ agg_attach(device_t dev)
/*filter*/ NULL, NULL,
/*size */ ess->bufsz, 1, 0x3ffff,
/*flags */ 0,
/*lock */ busdma_lock_mutex, &Giant,
/*lock */ NULL, NULL,
&ess->buf_dmat) != 0) {
device_printf(dev, "unable to create dma tag\n");
ret = ENOMEM;
@ -1807,7 +1807,7 @@ agg_attach(device_t dev)
/*filter*/ NULL, NULL,
/*size */ 3*ess->bufsz, 1, 0x3ffff,
/*flags */ 0,
/*lock */ busdma_lock_mutex, &Giant,
/*lock */ NULL, NULL,
&ess->stat_dmat) != 0) {
device_printf(dev, "unable to create dma tag\n");
ret = ENOMEM;

View File

@ -50,9 +50,6 @@ SND_DECLARE_FILE("$FreeBSD$");
/* more accurate clocks and split audio1/audio2 rates */
#define ESS18XX_NEWSPEED
/* 1 = INTR_MPSAFE, 0 = GIANT */
#define ESS18XX_MPSAFE 1
static u_int32_t ess_playfmt[] = {
SND_FORMAT(AFMT_U8, 1, 0),
SND_FORMAT(AFMT_U8, 2, 0),
@ -103,20 +100,12 @@ struct ess_info {
unsigned int bufsz;
struct ess_chinfo pch, rch;
#if ESS18XX_MPSAFE == 1
struct mtx *lock;
#endif
};
#if ESS18XX_MPSAFE == 1
#define ess_lock(_ess) snd_mtxlock((_ess)->lock)
#define ess_unlock(_ess) snd_mtxunlock((_ess)->lock)
#define ess_lock_assert(_ess) snd_mtxassert((_ess)->lock)
#else
#define ess_lock(_ess)
#define ess_unlock(_ess)
#define ess_lock_assert(_ess)
#endif
static int ess_rd(struct ess_info *sc, int reg);
static void ess_wr(struct ess_info *sc, int reg, u_int8_t val);
@ -868,12 +857,10 @@ ess_release_resources(struct ess_info *sc, device_t dev)
sc->parent_dmat = 0;
}
#if ESS18XX_MPSAFE == 1
if (sc->lock) {
snd_mtxfree(sc->lock);
sc->lock = NULL;
}
#endif
free(sc, M_DEVBUF);
}
@ -902,14 +889,10 @@ ess_alloc_resources(struct ess_info *sc, device_t dev)
sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
RF_ACTIVE | RF_SHAREABLE);
#if ESS18XX_MPSAFE == 1
sc->lock = snd_mtxcreate(device_get_nameunit(dev), "snd_solo softc");
return (sc->irq && sc->io && sc->sb && sc->vc &&
sc->mpu && sc->gp && sc->lock)? 0 : ENXIO;
#else
return (sc->irq && sc->io && sc->sb && sc->vc && sc->mpu && sc->gp)? 0 : ENXIO;
#endif
}
static int
@ -1008,13 +991,7 @@ ess_attach(device_t dev)
#else
sc->newspeed = 0;
#endif
if (snd_setup_intr(dev, sc->irq,
#if ESS18XX_MPSAFE == 1
INTR_MPSAFE
#else
0
#endif
, ess_intr, sc, &sc->ih)) {
if (snd_setup_intr(dev, sc->irq, INTR_MPSAFE, ess_intr, sc, &sc->ih)) {
device_printf(dev, "unable to map interrupt\n");
goto no;
}
@ -1032,11 +1009,7 @@ ess_attach(device_t dev)
/*maxsize*/sc->bufsz, /*nsegments*/1,
/*maxsegz*/0x3ffff,
/*flags*/0,
#if ESS18XX_MPSAFE == 1
/*lockfunc*/NULL, /*lockarg*/NULL,
#else
/*lockfunc*/busdma_lock_mutex, /*lockarg*/&Giant,
#endif
&sc->parent_dmat) != 0) {
device_printf(dev, "unable to create dma tag\n");
goto no;

View File

@ -913,8 +913,8 @@ tr_pci_attach(device_t dev)
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
/*maxsize*/tr->bufsz, /*nsegments*/1, /*maxsegz*/tr->bufsz,
/*flags*/0, /*lockfunc*/busdma_lock_mutex,
/*lockarg*/&Giant, &tr->parent_dmat) != 0) {
/*flags*/0, /*lockfunc*/NULL, /*lockarg*/NULL,
&tr->parent_dmat) != 0) {
device_printf(dev, "unable to create dma tag\n");
goto bad;
}

View File

@ -776,8 +776,8 @@ sv_attach(device_t dev) {
/*filter*/NULL, /*filterarg*/NULL,
/*maxsize*/sc->bufsz, /*nsegments*/1,
/*maxsegz*/0x3ffff, /*flags*/0,
/*lockfunc*/busdma_lock_mutex,
/*lockarg*/&Giant, &sc->parent_dmat) != 0) {
/*lockfunc*/NULL, /*lockarg*/NULL,
&sc->parent_dmat) != 0) {
device_printf(dev, "sv_attach: Unable to create dma tag\n");
goto fail;
}

View File

@ -107,7 +107,7 @@ sndbuf_alloc(struct snd_dbuf *b, bus_dma_tag_t dmatag, int dmaflags,
return (ENOMEM);
}
if (bus_dmamap_load(b->dmatag, b->dmamap, b->buf, b->maxsize,
sndbuf_setmap, b, 0) != 0 || b->buf_addr == 0) {
sndbuf_setmap, b, BUS_DMA_NOWAIT) != 0 || b->buf_addr == 0) {
sndbuf_free(b);
return (ENOMEM);
}