MFp4 (114068):

Use bus_get_dma_tag() to obtain the parent DMA tag to make the drivers
        a little bit more non-ia32/amd64 friendly.

        There is no man page for bus_get_dma_tag, so this is modelled after
        rev. 1.62 of src/sys/dev/sound/pci/es137x.c by marius.

        Inspired by:	commit by marius
This commit is contained in:
Alexander Leidinger 2007-02-23 13:47:34 +00:00
parent ef544f6312
commit 0b989078d7
26 changed files with 70 additions and 43 deletions

View File

@ -613,7 +613,8 @@ ad1816_attach(device_t dev)
if (mixer_init(dev, &ad1816mixer_class, ad1816)) goto no;
snd_setup_intr(dev, ad1816->irq, 0, ad1816_intr, ad1816, &ad1816->ih);
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_24BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,

View File

@ -851,7 +851,8 @@ ess_attach(device_t dev)
if (!sc->duplex)
pcm_setflags(dev, pcm_getflags(dev) | SD_F_SIMPLEX);
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_24BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,

View File

@ -1744,7 +1744,8 @@ mss_doattach(device_t dev, struct mss_info *mss)
}
if (pdma == rdma)
pcm_setflags(dev, pcm_getflags(dev) | SD_F_SIMPLEX);
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_24BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,

View File

@ -841,7 +841,8 @@ sb16_attach(device_t dev)
sb->prio = 0;
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_24BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,

View File

@ -735,7 +735,8 @@ sb_attach(device_t dev)
pcm_setflags(dev, pcm_getflags(dev) | SD_F_SIMPLEX);
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_24BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,

View File

@ -773,7 +773,7 @@ als_resource_grab(device_t dev, struct sc_info *sc)
sc->bufsz = pcm_getbuffersize(dev, 4096, ALS_DEFAULT_BUFSZ, 65536);
if (bus_dma_tag_create(/*parent*/NULL,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev),
/*alignment*/2, /*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_24BIT,
/*highaddr*/BUS_SPACE_MAXADDR,

View File

@ -1194,7 +1194,8 @@ atiixp_pci_attach(device_t dev)
/*
* DMA tag for scatter-gather buffers and link pointers
*/
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
@ -1205,7 +1206,8 @@ atiixp_pci_attach(device_t dev)
goto bad;
}
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,

View File

@ -636,7 +636,7 @@ au88x0_pci_attach(device_t dev)
/* DMA mapping */
aui->aui_bufsize = pcm_getbuffersize(dev, AU88X0_BUFSIZE_MIN,
AU88X0_BUFSIZE_DFLT, AU88X0_BUFSIZE_MAX);
error = bus_dma_tag_create(NULL,
error = bus_dma_tag_create(bus_get_dma_tag(dev),
2, 0, /* 16-bit alignment, no boundary */
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, /* restrict to 4GB */
NULL, NULL, /* no filter */

View File

@ -637,7 +637,8 @@ au_pci_attach(device_t dev)
if (codec == NULL) goto bad;
if (mixer_init(dev, ac97_getmixerclass(), codec) == -1) goto bad;
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,

View File

@ -959,7 +959,8 @@ cmi_attach(device_t dev)
sc->bufsz = pcm_getbuffersize(dev, 4096, CMI_DEFAULT_BUFSZ, 65536);
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,

View File

@ -824,7 +824,8 @@ cs4281_pci_attach(device_t dev)
sc->bufsz = pcm_getbuffersize(dev, 4096, CS4281_DEFAULT_BUFSZ, 65536);
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,

View File

@ -704,7 +704,9 @@ csa_allocres(struct csa_info *csa, device_t dev)
if (resp->irq == NULL)
return (1);
}
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/CS461x_BUFFSIZE, /*boundary*/CS461x_BUFFSIZE,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev),
/*alignment*/CS461x_BUFFSIZE,
/*boundary*/CS461x_BUFFSIZE,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,

View File

@ -157,7 +157,7 @@ struct {
*/
/* stuff */
static int ds_init(struct sc_info *);
static int ds_init(struct sc_info *, device_t);
static void ds_intr(void *);
/* talk to the card */
@ -785,7 +785,7 @@ ds_setmap(void *arg, bus_dma_segment_t *segs, int nseg, int error)
}
static int
ds_init(struct sc_info *sc)
ds_init(struct sc_info *sc, device_t dev)
{
int i;
u_int32_t *ci, r, pcs, rcs, ecs, ws, memsz, cb;
@ -833,7 +833,9 @@ ds_init(struct sc_info *sc)
memsz += (64 + 1) * 4;
if (sc->regbase == NULL) {
if (bus_dma_tag_create(NULL, 2, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
if (bus_dma_tag_create(bus_get_dma_tag(dev), 2, 0,
BUS_SPACE_MAXADDR_32BIT,
BUS_SPACE_MAXADDR,
NULL, NULL, memsz, 1, memsz, 0, NULL,
NULL, &sc->control_dmat))
return -1;
@ -970,7 +972,8 @@ ds_pci_attach(device_t dev)
sc->bufsz = pcm_getbuffersize(dev, 4096, DS1_BUFFSIZE, 65536);
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
@ -982,7 +985,7 @@ ds_pci_attach(device_t dev)
}
sc->regbase = NULL;
if (ds_init(sc) == -1) {
if (ds_init(sc, dev) == -1) {
device_printf(dev, "unable to initialize the card\n");
goto bad;
}
@ -1050,7 +1053,7 @@ ds_pci_resume(device_t dev)
sc = pcm_getdevinfo(dev);
if (ds_init(sc) == -1) {
if (ds_init(sc, dev) == -1) {
device_printf(dev, "unable to reinitialize the card\n");
return ENXIO;
}

View File

@ -2011,7 +2011,8 @@ emu_pci_attach(device_t dev)
sc->bufsz = pcm_getbuffersize(dev, 4096, EMU_DEFAULT_BUFSZ, 65536);
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/1 << 31, /* can only access 0-2gb */
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,

View File

@ -385,7 +385,7 @@ static void emu_addefxop(struct emu_sc_info *sc, unsigned int op, unsigned int z
static void emu_initefx(struct emu_sc_info *sc);
static int emu_cardbus_init(struct emu_sc_info *sc);
static int emu_init(struct emu_sc_info *sc);
static int emu_init(struct emu_sc_info *sc, device_t dev);
static int emu_uninit(struct emu_sc_info *sc);
static int emu_read_ivar(device_t bus __unused, device_t dev, int ivar_index, uintptr_t * result);
@ -2338,7 +2338,7 @@ emu_cardbus_init(struct emu_sc_info *sc)
/* Probe and attach the card */
static int
emu_init(struct emu_sc_info *sc)
emu_init(struct emu_sc_info *sc, device_t dev)
{
uint32_t ch, tmp;
uint32_t spdif_sr;
@ -2385,7 +2385,8 @@ emu_init(struct emu_sc_info *sc)
emu_wrptr(sc, 0, SPBYPASS, 0xf00); /* What will happen if
* we write 1 here? */
if (bus_dma_tag_create( /* parent */ NULL, /* alignment */ 2, /* boundary */ 0,
if (bus_dma_tag_create( /* parent */ bus_get_dma_tag(dev),
/* alignment */ 2, /* boundary */ 0,
/* lowaddr */ 1 << 31, /* can only access 0-2gb */
/* highaddr */ BUS_SPACE_MAXADDR,
/* filter */ NULL, /* filterarg */ NULL,
@ -2853,7 +2854,7 @@ emu_pci_attach(device_t dev)
sc->root = device_get_sysctl_tree(dev);
if (sc->root == NULL)
goto bad;
if (emu_init(sc) == -1) {
if (emu_init(sc, dev) == -1) {
device_printf(dev, "unable to initialize the card\n");
goto bad;
}

View File

@ -2301,7 +2301,7 @@ envy24_init(struct sc_info *sc)
}
static int
envy24_alloc_resource(struct sc_info *sc)
envy24_alloc_resource(struct sc_info *sc, device_t dev)
{
/* allocate I/O port resource */
sc->csid = PCIR_CCS;
@ -2348,7 +2348,8 @@ envy24_alloc_resource(struct sc_info *sc)
}
/* allocate DMA resource */
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/4, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/4,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_ENVY24,
/*highaddr*/BUS_SPACE_MAXADDR_ENVY24,
/*filter*/NULL, /*filterarg*/NULL,
@ -2394,7 +2395,7 @@ envy24_pci_attach(device_t dev)
data = pci_read_config(dev, PCIR_COMMAND, 2);
/* allocate resources */
err = envy24_alloc_resource(sc);
err = envy24_alloc_resource(sc, dev);
if (err) {
device_printf(dev, "unable to allocate system resources\n");
goto bad;

View File

@ -2332,7 +2332,7 @@ envy24ht_init(struct sc_info *sc)
}
static int
envy24ht_alloc_resource(struct sc_info *sc)
envy24ht_alloc_resource(struct sc_info *sc, device_t dev)
{
/* allocate I/O port resource */
sc->csid = PCIR_CCS;
@ -2367,7 +2367,8 @@ envy24ht_alloc_resource(struct sc_info *sc)
}
/* allocate DMA resource */
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/4, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/4,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_ENVY24,
/*highaddr*/BUS_SPACE_MAXADDR_ENVY24,
/*filter*/NULL, /*filterarg*/NULL,
@ -2413,7 +2414,7 @@ envy24ht_pci_attach(device_t dev)
data = pci_read_config(dev, PCIR_COMMAND, 2);
/* allocate resources */
err = envy24ht_alloc_resource(sc);
err = envy24ht_alloc_resource(sc, dev);
if (err) {
device_printf(dev, "unable to allocate system resources\n");
goto bad;

View File

@ -630,7 +630,8 @@ fm801_pci_attach(device_t dev)
goto oops;
}
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,

View File

@ -934,7 +934,8 @@ ich_pci_attach(device_t dev)
else
sc->fixedrate = 0;
if (bus_dma_tag_create(NULL, 8, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
if (bus_dma_tag_create(bus_get_dma_tag(dev), 8, 0,
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
NULL, NULL, sc->bufsz, 1, 0x3ffff, 0,
NULL, NULL, &sc->dmat) != 0) {
device_printf(dev, "unable to create dma tag\n");

View File

@ -1791,7 +1791,7 @@ agg_attach(device_t dev)
#endif
ess->bufsz = pcm_getbuffersize(dev, 4096, AGG_DEFAULT_BUFSZ, 65536);
if (bus_dma_tag_create(/*parent*/ NULL,
if (bus_dma_tag_create(/*parent*/ bus_get_dma_tag(dev),
/*align */ 4, 1 << (16+1),
/*limit */ MAESTRO_MAXADDR, BUS_SPACE_MAXADDR,
/*filter*/ NULL, NULL,
@ -1806,7 +1806,7 @@ agg_attach(device_t dev)
goto bad;
}
if (bus_dma_tag_create(/*parent*/NULL,
if (bus_dma_tag_create(/*parent*/ bus_get_dma_tag(dev),
/*align */ 1 << WAVCACHE_BASEADDR_SHIFT,
1 << (16+1),
/*limit */ MAESTRO_MAXADDR, BUS_SPACE_MAXADDR,

View File

@ -1240,7 +1240,7 @@ m3_pci_attach(device_t dev)
M3_BUFSIZE_MAX);
if (bus_dma_tag_create(
NULL, /* parent */
bus_get_dma_tag(dev), /* parent */
2, 0, /* alignment, boundary */
M3_MAXADDR, /* lowaddr */
BUS_SPACE_MAXADDR, /* highaddr */

View File

@ -1030,9 +1030,9 @@ ess_attach(device_t dev)
pcm_setflags(dev, pcm_getflags(dev) | SD_F_SIMPLEX);
#if 0
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/65536, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/65536, /*boundary*/0,
#endif
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2, /*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_24BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,

View File

@ -860,7 +860,8 @@ tr_pci_attach(device_t dev)
goto bad;
}
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/TR_MAXADDR,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,

View File

@ -1237,7 +1237,8 @@ via_attach(device_t dev)
nsegs = (via_dxs_chnum + via_sgd_chnum + NWRCHANS) * via->blkcnt;
/* DMA tag for buffers */
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
@ -1253,7 +1254,8 @@ via_attach(device_t dev)
* requires a list in memory of work to do. We need only 16 bytes
* for this list, and it is wasteful to allocate 16K.
*/
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,

View File

@ -555,7 +555,8 @@ via_attach(device_t dev)
via->codec_caps & (AC97_EXTCAP_VRA | AC97_EXTCAP_VRM));
/* DMA tag for buffers */
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
@ -571,7 +572,8 @@ via_attach(device_t dev)
* requires a list in memory of work to do. We need only 16 bytes
* for this list, and it is wasteful to allocate 16K.
*/
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,

View File

@ -768,7 +768,8 @@ sv_attach(device_t dev) {
}
sc->bufsz = pcm_getbuffersize(dev, 4096, SV_DEFAULT_BUFSZ, 65536);
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
/*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_24BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,