summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2018-03-17 13:33:08 +0000
committerratchov <ratchov@openbsd.org>2018-03-17 13:33:08 +0000
commit8295e4db24d4a279ec883d5f0dd9f87bf92f6e5f (patch)
tree41c8bdd0519d0ec94fe9b4d35cb56181d3b23201
parentFix use after free that caused the creation of a spurious file. (diff)
downloadwireguard-openbsd-8295e4db24d4a279ec883d5f0dd9f87bf92f6e5f.tar.xz
wireguard-openbsd-8295e4db24d4a279ec883d5f0dd9f87bf92f6e5f.zip
Set base DMA pointers when DMA starts.
The allocm() functions are supposed to allocate memory and it's bad style to access the hardware there, so move the DMA base pointers setup to the trigger_xxx(). ok kettenis@
-rw-r--r--sys/dev/pci/envy.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/sys/dev/pci/envy.c b/sys/dev/pci/envy.c
index c620a27335c..a12d15e4bd6 100644
--- a/sys/dev/pci/envy.c
+++ b/sys/dev/pci/envy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: envy.c,v 1.70 2017/03/28 05:23:15 ratchov Exp $ */
+/* $OpenBSD: envy.c,v 1.71 2018/03/17 13:33:08 ratchov Exp $ */
/*
* Copyright (c) 2007 Alexandre Ratchov <alex@caoua.org>
*
@@ -1742,17 +1742,11 @@ void *
envy_allocm(void *self, int dir, size_t size, int type, int flags)
{
struct envy_softc *sc = (struct envy_softc *)self;
- int err, basereg, wait;
+ int err, wait;
struct envy_buf *buf;
bus_addr_t dma_addr;
- if (dir == AUMODE_RECORD) {
- buf = &sc->ibuf;
- basereg = ENVY_MT_RADDR;
- } else {
- buf = &sc->obuf;
- basereg = ENVY_MT_PADDR;
- }
+ buf = (dir == AUMODE_RECORD) ? &sc->ibuf : &sc->obuf;
if (buf->addr != NULL) {
DPRINTF("%s: multiple alloc, dir = %d\n", DEVNAME(sc), dir);
return NULL;
@@ -1789,7 +1783,6 @@ envy_allocm(void *self, int dir, size_t size, int type, int flags)
printf("%s: DMA address beyond 0x10000000\n", DEVNAME(sc));
goto err_unload;
}
- envy_mt_write_4(sc, basereg, dma_addr);
return buf->addr;
err_unload:
bus_dmamap_unload(sc->pci_dmat, buf->map);
@@ -2051,6 +2044,7 @@ envy_trigger_output(void *self, void *start, void *end, int blksz,
}
#endif
mtx_enter(&audio_lock);
+ envy_mt_write_4(sc, ENVY_MT_PADDR, sc->obuf.map->dm_segs[0].ds_addr);
envy_mt_write_2(sc, ENVY_MT_PBUFSZ, bufsz / 4 - 1);
envy_mt_write_2(sc, ENVY_MT_PBLKSZ(sc), blksz / 4 - 1);
@@ -2097,6 +2091,7 @@ envy_trigger_input(void *self, void *start, void *end, int blksz,
}
#endif
mtx_enter(&audio_lock);
+ envy_mt_write_4(sc, ENVY_MT_RADDR, sc->ibuf.map->dm_segs[0].ds_addr);
envy_mt_write_2(sc, ENVY_MT_RBUFSZ, bufsz / 4 - 1);
envy_mt_write_2(sc, ENVY_MT_RBLKSZ, blksz / 4 - 1);