summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorkhorben <khorben@NetBSD.org>2022-09-07 00:44:07 +0000
committerkhorben <khorben@NetBSD.org>2022-09-07 00:44:07 +0000
commit4c460f51f6faf23cd338e9b005c22014f7236502 (patch)
tree2654ef4203f41e5da0d7d6b899b9e0849d1ad01c /sys/dev
parent87531432ebac4749498c085f0265d48bd021652a (diff)
emuxki(4): restrict DMA memory within the first 2GB
As implemented in the driver, the EMU10K1 chip can only address memory up to 31-bit addresses. Tested on NetBSD/amd64 with a Sound Blaster Live! Value (CT4870, PCI) and with a Sound Blaster Audigy Rx 7.1 (SB1550, PCIe). Additional sound cards sponsored by the NetBSD Foundation; thanks!
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/emuxki.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/dev/pci/emuxki.c b/sys/dev/pci/emuxki.c
index ccff2bf4064..7b3272fc2f5 100644
--- a/sys/dev/pci/emuxki.c
+++ b/sys/dev/pci/emuxki.c
@@ -1,4 +1,4 @@
-/* $NetBSD: emuxki.c,v 1.73 2022/09/07 00:29:23 khorben Exp $ */
+/* $NetBSD: emuxki.c,v 1.74 2022/09/07 00:44:07 khorben Exp $ */
/*-
* Copyright (c) 2001, 2007 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1.73 2022/09/07 00:29:23 khorben Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1.74 2022/09/07 00:44:07 khorben Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -506,7 +506,15 @@ emuxki_attach(device_t parent, device_t self, void *aux)
mutex_init(&sc->sc_index_lock, MUTEX_DEFAULT, IPL_AUDIO);
sc->sc_pc = pa->pa_pc;
- sc->sc_dmat = pa->pa_dmat;
+
+ /* EMU10K1 can only address 31 bits (2GB) */
+ if (bus_dmatag_subregion(pa->pa_dmat, 0, ((uint32_t)1 << 31) - 1,
+ &(sc->sc_dmat), BUS_DMA_NOWAIT) != 0) {
+ aprint_error_dev(self,
+ "WARNING: failed to restrict dma range,"
+ " falling back to parent bus dma range\n");
+ sc->sc_dmat = pa->pa_dmat;
+ }
reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
reg |= PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MASTER_ENABLE |