Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/fdt Enforce 32-bit limits on ADMA2 capable controlle...



details:   https://anonhg.NetBSD.org/src/rev/3e383fc0b44e
branches:  trunk
changeset: 962194:3e383fc0b44e
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Wed Jul 03 19:46:02 2019 +0000

description:
Enforce 32-bit limits on ADMA2 capable controllers that do not support 64-bit descriptors

diffstat:

 sys/dev/fdt/arasan_sdhc_fdt.c |  18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diffs (47 lines):

diff -r 22a08ba63850 -r 3e383fc0b44e sys/dev/fdt/arasan_sdhc_fdt.c
--- a/sys/dev/fdt/arasan_sdhc_fdt.c     Wed Jul 03 19:45:14 2019 +0000
+++ b/sys/dev/fdt/arasan_sdhc_fdt.c     Wed Jul 03 19:46:02 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arasan_sdhc_fdt.c,v 1.1 2019/03/13 12:17:45 jmcneill Exp $ */
+/* $NetBSD: arasan_sdhc_fdt.c,v 1.2 2019/07/03 19:46:02 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arasan_sdhc_fdt.c,v 1.1 2019/03/13 12:17:45 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arasan_sdhc_fdt.c,v 1.2 2019/07/03 19:46:02 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -224,6 +224,7 @@
        bus_addr_t addr;
        bus_size_t size;
        u_int bus_width;
+       int error;
        void *ih;
 
        fdtbus_clock_assign(phandle);
@@ -263,8 +264,19 @@
        sc->sc_bsz = size;
        sc->sc_type = of_search_compatible(phandle, compat_data)->data;
 
+       const uint32_t caps = bus_space_read_4(sc->sc_bst, sc->sc_bsh, SDHC_CAPABILITIES);
+       if ((caps & (SDHC_ADMA2_SUPP|SDHC_64BIT_SYS_BUS)) == SDHC_ADMA2_SUPP) {
+               error = bus_dmatag_subregion(faa->faa_dmat, 0, 0xffffffff,
+                   &sc->sc_base.sc_dmat, BUS_DMA_WAITOK);
+               if (error != 0) {
+                       aprint_error(": couldn't create DMA tag: %d\n", error);
+                       return;
+               }
+       } else {
+               sc->sc_base.sc_dmat = faa->faa_dmat;
+       }
+
        sc->sc_base.sc_dev = self;
-       sc->sc_base.sc_dmat = faa->faa_dmat;
        sc->sc_base.sc_host = sc->sc_host;
        sc->sc_base.sc_flags = SDHC_FLAG_NO_CLKBASE |
                               SDHC_FLAG_USE_DMA |



Home | Main Index | Thread Index | Old Index