Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci emuxki(4): restrict DMA memory within the first 2GB



details:   https://anonhg.NetBSD.org/src/rev/9198057cf7bb
branches:  trunk
changeset: 369901:9198057cf7bb
user:      khorben <khorben%NetBSD.org@localhost>
date:      Wed Sep 07 00:44:07 2022 +0000

description:
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:

 sys/dev/pci/emuxki.c |  14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diffs (35 lines):

diff -r a5293fcb521b -r 9198057cf7bb sys/dev/pci/emuxki.c
--- a/sys/dev/pci/emuxki.c      Wed Sep 07 00:40:18 2022 +0000
+++ b/sys/dev/pci/emuxki.c      Wed Sep 07 00:44:07 2022 +0000
@@ -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 @@
        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 |



Home | Main Index | Thread Index | Old Index