Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/acpi Allow MD code to provide custom bus_dma tags on...



details:   https://anonhg.NetBSD.org/src/rev/d29f8f34b08c
branches:  trunk
changeset: 967963:d29f8f34b08c
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Dec 29 23:47:56 2019 +0000

description:
Allow MD code to provide custom bus_dma tags on a per-node basis. On Arm
this is required to return non-coherent bus_dma tags for device nodes with
_CCA=0

diffstat:

 sys/arch/arm/acpi/acpi_machdep.c |  24 ++++++++++++++++++++++--
 sys/arch/arm/acpi/acpipchb.c     |  11 +++--------
 sys/arch/arm/fdt/acpi_fdt.c      |  10 ++++------
 sys/dev/acpi/acpi.c              |  29 +++++++++++++++++++++++------
 sys/dev/acpi/acpivar.h           |   5 ++++-
 5 files changed, 56 insertions(+), 23 deletions(-)

diffs (213 lines):

diff -r 829ae669fff4 -r d29f8f34b08c sys/arch/arm/acpi/acpi_machdep.c
--- a/sys/arch/arm/acpi/acpi_machdep.c  Sun Dec 29 23:03:20 2019 +0000
+++ b/sys/arch/arm/acpi/acpi_machdep.c  Sun Dec 29 23:47:56 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.13 2019/12/28 17:19:43 jmcneill Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.14 2019/12/29 23:47:56 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "pci.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.13 2019/12/28 17:19:43 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.14 2019/12/29 23:47:56 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -59,6 +59,10 @@
 #include <machine/acpi_machdep.h>
 
 extern struct bus_space arm_generic_bs_tag;
+extern struct arm32_bus_dma_tag acpi_coherent_dma_tag;
+extern struct arm32_bus_dma_tag arm_generic_dma_tag;
+
+bus_dma_tag_t  arm_acpi_dma_tag(struct acpi_softc *, struct acpi_devnode *);
 
 static int
 acpi_md_pmapflags(paddr_t pa)
@@ -362,3 +366,19 @@
        if (ACPI_SUCCESS(AcpiGetTable(ACPI_SIG_GTDT, 0, &hdrp)))
                config_found_ia(sc->sc_dev, "acpisdtbus", hdrp, NULL);
 }
+
+bus_dma_tag_t
+arm_acpi_dma_tag(struct acpi_softc *sc, struct acpi_devnode *ad)
+{
+       ACPI_INTEGER cca;
+
+       if (ACPI_FAILURE(acpi_eval_integer(ad->ad_handle, "_CCA", &cca)))
+               cca = 1;
+
+       if (cca)
+               return &acpi_coherent_dma_tag;
+       else
+               return &arm_generic_dma_tag;
+}
+__strong_alias(acpi_get_dma_tag,arm_acpi_dma_tag);
+__strong_alias(acpi_get_dma64_tag,arm_acpi_dma_tag);
diff -r 829ae669fff4 -r d29f8f34b08c sys/arch/arm/acpi/acpipchb.c
--- a/sys/arch/arm/acpi/acpipchb.c      Sun Dec 29 23:03:20 2019 +0000
+++ b/sys/arch/arm/acpi/acpipchb.c      Sun Dec 29 23:47:56 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.14 2019/12/28 17:19:43 jmcneill Exp $ */
+/* $NetBSD: acpipchb.c,v 1.15 2019/12/29 23:47:56 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.14 2019/12/28 17:19:43 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.15 2019/12/29 23:47:56 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -242,7 +242,7 @@
        struct acpi_attach_args *aa = aux;
        struct pcibus_attach_args pba;
        const struct acpipchb_quirk *q;
-       ACPI_INTEGER cca, seg;
+       ACPI_INTEGER seg;
 
        sc->sc_dev = self;
        sc->sc_memt = aa->aa_memt;
@@ -254,15 +254,10 @@
        if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_SEG", &seg)))
                seg = 0;
 
-       if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_CCA", &cca)))
-               cca = 1;
-
        aprint_naive("\n");
        aprint_normal(": PCI Express Host Bridge\n");
 
        sc->sc_dmat = *aa->aa_dmat;
-       if (cca == 0)
-               sc->sc_dmat._nranges = 0;
 
        sc->sc_ap.ap_dev = self;
        sc->sc_ap.ap_pc = *aa->aa_pc;
diff -r 829ae669fff4 -r d29f8f34b08c sys/arch/arm/fdt/acpi_fdt.c
--- a/sys/arch/arm/fdt/acpi_fdt.c       Sun Dec 29 23:03:20 2019 +0000
+++ b/sys/arch/arm/fdt/acpi_fdt.c       Sun Dec 29 23:47:56 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_fdt.c,v 1.12 2019/06/22 19:47:27 jmcneill Exp $ */
+/* $NetBSD: acpi_fdt.c,v 1.13 2019/12/29 23:47:56 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.12 2019/06/22 19:47:27 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.13 2019/12/29 23:47:56 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -136,10 +136,8 @@
 #endif
 
        aa.aa_memt = faa->faa_bst;
-       aa.aa_dmat = &acpi_coherent_dma_tag;
-#ifdef _PCI_HAVE_DMA64
-       aa.aa_dmat64 = &acpi_coherent_dma_tag;
-#endif
+       aa.aa_dmat = NULL;
+       aa.aa_dmat64 = NULL;
        config_found_ia(self, "acpibus", &aa, 0);
 
        acpi_fdt_sysctl_init();
diff -r 829ae669fff4 -r d29f8f34b08c sys/dev/acpi/acpi.c
--- a/sys/dev/acpi/acpi.c       Sun Dec 29 23:03:20 2019 +0000
+++ b/sys/dev/acpi/acpi.c       Sun Dec 29 23:47:56 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi.c,v 1.278 2018/10/21 13:41:15 jmcneill Exp $      */
+/*     $NetBSD: acpi.c,v 1.279 2019/12/29 23:47:56 jmcneill Exp $      */
 
 /*-
  * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -100,7 +100,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.278 2018/10/21 13:41:15 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.279 2019/12/29 23:47:56 jmcneill Exp $");
 
 #include "pci.h"
 #include "opt_acpi.h"
@@ -237,6 +237,9 @@
 void (*acpi_print_verbose)(struct acpi_softc *) = acpi_print_verbose_stub;
 void (*acpi_print_dev)(const char *) = acpi_print_dev_stub;
 
+bus_dma_tag_t          acpi_default_dma_tag(struct acpi_softc *, struct acpi_devnode *);
+bus_dma_tag_t          acpi_default_dma64_tag(struct acpi_softc *, struct acpi_devnode *);
+
 CFATTACH_DECL2_NEW(acpi, sizeof(struct acpi_softc),
     acpi_match, acpi_attach, acpi_detach, NULL, acpi_rescan, acpi_childdet);
 
@@ -808,6 +811,20 @@
                ad->ad_name[0] = '_';
 }
 
+bus_dma_tag_t
+acpi_default_dma_tag(struct acpi_softc *sc, struct acpi_devnode *ad)
+{
+       return sc->sc_dmat;
+}
+__weak_alias(acpi_get_dma_tag,acpi_default_dma_tag);
+
+bus_dma_tag_t
+acpi_default_dma64_tag(struct acpi_softc *sc, struct acpi_devnode *ad)
+{
+       return sc->sc_dmat64;
+}
+__weak_alias(acpi_get_dma64_tag,acpi_default_dma64_tag);
+
 /*
  * Device attachment.
  */
@@ -877,8 +894,8 @@
                aa.aa_pc = sc->sc_pc;
                aa.aa_pciflags = sc->sc_pciflags;
                aa.aa_ic = sc->sc_ic;
-               aa.aa_dmat = sc->sc_dmat;
-               aa.aa_dmat64 = sc->sc_dmat64;
+               aa.aa_dmat = acpi_get_dma_tag(sc, ad);
+               aa.aa_dmat64 = acpi_get_dma64_tag(sc, ad);
 
                ad->ad_device = config_found_ia(sc->sc_dev,
                    "acpinodebus", &aa, acpi_print);
@@ -939,8 +956,8 @@
                aa.aa_pc = sc->sc_pc;
                aa.aa_pciflags = sc->sc_pciflags;
                aa.aa_ic = sc->sc_ic;
-               aa.aa_dmat = sc->sc_dmat;
-               aa.aa_dmat64 = sc->sc_dmat64;
+               aa.aa_dmat = acpi_get_dma_tag(sc, ad);
+               aa.aa_dmat64 = acpi_get_dma64_tag(sc, ad);
 
                ad->ad_device = config_found_ia(sc->sc_dev,
                    "acpinodebus", &aa, acpi_print);
diff -r 829ae669fff4 -r d29f8f34b08c sys/dev/acpi/acpivar.h
--- a/sys/dev/acpi/acpivar.h    Sun Dec 29 23:03:20 2019 +0000
+++ b/sys/dev/acpi/acpivar.h    Sun Dec 29 23:47:56 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpivar.h,v 1.77 2018/10/25 10:38:57 jmcneill Exp $    */
+/*     $NetBSD: acpivar.h,v 1.78 2019/12/29 23:47:56 jmcneill Exp $    */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -384,6 +384,9 @@
 void   acpi_debug_init(void);
 #endif
 
+bus_dma_tag_t  acpi_get_dma_tag(struct acpi_softc *, struct acpi_devnode *);
+bus_dma_tag_t  acpi_get_dma64_tag(struct acpi_softc *, struct acpi_devnode *);
+
 /*
  * Misc routines with vectors updated by acpiverbose module.
  */



Home | Main Index | Thread Index | Old Index