Module Name: src
Committed By: khorben
Date: Wed Sep 7 00:44:07 UTC 2022
Modified Files:
src/sys/dev/pci: emuxki.c
Log Message:
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!
To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/dev/pci/emuxki.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/pci/emuxki.c
diff -u src/sys/dev/pci/emuxki.c:1.73 src/sys/dev/pci/emuxki.c:1.74
--- src/sys/dev/pci/emuxki.c:1.73 Wed Sep 7 00:29:23 2022
+++ src/sys/dev/pci/emuxki.c Wed Sep 7 00:44:07 2022
@@ -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
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 |