Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm Provide a 64-bit dma tag and use a coherent tag...



details:   https://anonhg.NetBSD.org/src/rev/b3356926e84d
branches:  trunk
changeset: 452142:b3356926e84d
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Wed Jun 19 13:39:18 2019 +0000

description:
Provide a 64-bit dma tag and use a coherent tag unless CCA=0

diffstat:

 sys/arch/arm/acpi/acpi_platform.c |  36 ++++++++++++++++++++++++++++++++----
 sys/arch/arm/acpi/acpipchb.c      |  21 +++++----------------
 sys/arch/arm/fdt/acpi_fdt.c       |  11 +++++++----
 3 files changed, 44 insertions(+), 24 deletions(-)

diffs (170 lines):

diff -r 2f09f47df0e5 -r b3356926e84d sys/arch/arm/acpi/acpi_platform.c
--- a/sys/arch/arm/acpi/acpi_platform.c Wed Jun 19 12:55:01 2019 +0000
+++ b/sys/arch/arm/acpi/acpi_platform.c Wed Jun 19 13:39:18 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.12 2019/05/23 15:54:28 ryo Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.13 2019/06/19 13:39:18 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "opt_multiprocessor.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.12 2019/05/23 15:54:28 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.13 2019/06/19 13:39:18 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -94,6 +94,26 @@
 static struct plcom_instance plcom_console;
 #endif
 
+struct arm32_bus_dma_tag acpi_coherent32_dma_tag;
+static struct arm32_dma_range acpi_coherent32_ranges[] = {
+       [0] = {
+               .dr_sysbase = 0,
+               .dr_busbase = 0,
+               .dr_len = 0xffffffffU,
+               .dr_flags = _BUS_DMAMAP_COHERENT,
+       }
+};
+
+struct arm32_bus_dma_tag acpi_coherent64_dma_tag;
+static struct arm32_dma_range acpi_coherent64_ranges[] = {
+       [0] = {
+               .dr_sysbase = 0,
+               .dr_busbase = 0,
+               .dr_len = UINTPTR_MAX,
+               .dr_flags = _BUS_DMAMAP_COHERENT,
+       }
+};
+
 static const struct pmap_devmap *
 acpi_platform_devmap(void)
 {
@@ -107,6 +127,15 @@
 static void
 acpi_platform_bootstrap(void)
 {
+       extern struct arm32_bus_dma_tag arm_generic_dma_tag;
+
+       acpi_coherent32_dma_tag = arm_generic_dma_tag;
+       acpi_coherent32_dma_tag._ranges = acpi_coherent32_ranges;
+       acpi_coherent32_dma_tag._nranges = __arraycount(acpi_coherent32_ranges);
+
+       acpi_coherent64_dma_tag = arm_generic_dma_tag;
+       acpi_coherent64_dma_tag._ranges = acpi_coherent64_ranges;
+       acpi_coherent64_dma_tag._nranges = __arraycount(acpi_coherent64_ranges);
 }
 
 static void
@@ -222,13 +251,12 @@
 static void
 acpi_platform_init_attach_args(struct fdt_attach_args *faa)
 {
-       extern struct arm32_bus_dma_tag arm_generic_dma_tag;
        extern struct bus_space arm_generic_bs_tag;
        extern struct bus_space arm_generic_a4x_bs_tag;
 
        faa->faa_bst = &arm_generic_bs_tag;
        faa->faa_a4x_bst = &arm_generic_a4x_bs_tag;
-       faa->faa_dmat = &arm_generic_dma_tag;
+       faa->faa_dmat = &acpi_coherent64_dma_tag;
 }
 
 static void
diff -r 2f09f47df0e5 -r b3356926e84d sys/arch/arm/acpi/acpipchb.c
--- a/sys/arch/arm/acpi/acpipchb.c      Wed Jun 19 12:55:01 2019 +0000
+++ b/sys/arch/arm/acpi/acpipchb.c      Wed Jun 19 13:39:18 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.7 2018/11/19 10:45:47 jmcneill Exp $ */
+/* $NetBSD: acpipchb.c,v 1.8 2019/06/19 13:39:18 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.7 2018/11/19 10:45:47 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.8 2019/06/19 13:39:18 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -82,15 +82,6 @@
        struct acpipchb_bus_space sc_pciio_bst;
 };
 
-static struct arm32_dma_range ahcipchb_coherent_ranges[] = {
-       [0] = {
-               .dr_sysbase = 0,
-               .dr_busbase = 0,
-               .dr_len = UINTPTR_MAX,
-               .dr_flags = _BUS_DMAMAP_COHERENT,
-       }
-};
-
 static int     acpipchb_match(device_t, cfdata_t, void *);
 static void    acpipchb_attach(device_t, device_t, void *);
 
@@ -133,16 +124,14 @@
                seg = 0;
 
        if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_CCA", &cca)))
-               cca = 0;
+               cca = 1;
 
        aprint_naive("\n");
        aprint_normal(": PCI Express Host Bridge\n");
 
        sc->sc_dmat = *aa->aa_dmat;
-       if (cca) {
-               sc->sc_dmat._ranges = ahcipchb_coherent_ranges;
-               sc->sc_dmat._nranges = __arraycount(ahcipchb_coherent_ranges);
-       }
+       if (cca == 0)
+               sc->sc_dmat._nranges = 0;
 
        sc->sc_ap.ap_pc = *aa->aa_pc;
        sc->sc_ap.ap_pc.pc_conf_v = &sc->sc_ap;
diff -r 2f09f47df0e5 -r b3356926e84d sys/arch/arm/fdt/acpi_fdt.c
--- a/sys/arch/arm/fdt/acpi_fdt.c       Wed Jun 19 12:55:01 2019 +0000
+++ b/sys/arch/arm/fdt/acpi_fdt.c       Wed Jun 19 13:39:18 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_fdt.c,v 1.9 2018/11/12 12:56:05 jmcneill Exp $ */
+/* $NetBSD: acpi_fdt.c,v 1.10 2019/06/19 13:39:18 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -30,7 +30,7 @@
 #include "opt_efi.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.9 2018/11/12 12:56:05 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.10 2019/06/19 13:39:18 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -70,6 +70,9 @@
 
 static void    acpi_fdt_sysctl_init(void);
 
+extern struct arm32_bus_dma_tag acpi_coherent32_dma_tag;
+extern struct arm32_bus_dma_tag acpi_coherent64_dma_tag;
+
 #if NPCI > 0
 static struct acpi_pci_context acpi_fdt_pci_context;
 #endif
@@ -134,9 +137,9 @@
 #endif
 
        aa.aa_memt = faa->faa_bst;
-       aa.aa_dmat = faa->faa_dmat;
+       aa.aa_dmat = &acpi_coherent32_dma_tag;
 #ifdef _PCI_HAVE_DMA64
-       aa.aa_dmat64 = faa->faa_dmat;
+       aa.aa_dmat64 = &acpi_coherent64_dma_tag;
 #endif
        config_found_ia(self, "acpibus", &aa, 0);
 



Home | Main Index | Thread Index | Old Index