Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/acpi Provide a properly constrained 32-bit DMA ...



details:   https://anonhg.NetBSD.org/src/rev/1ff243630a41
branches:  trunk
changeset: 1006625:1ff243630a41
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Tue Jan 21 11:24:47 2020 +0000

description:
Provide a properly constrained 32-bit DMA tag to ACPI.

diffstat:

 sys/arch/arm/acpi/acpi_machdep.c |  36 ++++++++++++++++++++++++++++--------
 sys/arch/arm/acpi/acpipchb.c     |  12 ++++--------
 2 files changed, 32 insertions(+), 16 deletions(-)

diffs (121 lines):

diff -r 0e33368afc7f -r 1ff243630a41 sys/arch/arm/acpi/acpi_machdep.c
--- a/sys/arch/arm/acpi/acpi_machdep.c  Tue Jan 21 10:54:11 2020 +0000
+++ b/sys/arch/arm/acpi/acpi_machdep.c  Tue Jan 21 11:24:47 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.18 2019/12/31 17:26:04 jmcneill Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.19 2020/01/21 11:24:47 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.18 2019/12/31 17:26:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.19 2020/01/21 11:24:47 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -63,7 +63,8 @@
 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 *);
+bus_dma_tag_t  arm_acpi_dma32_tag(struct acpi_softc *, struct acpi_devnode *);
+bus_dma_tag_t  arm_acpi_dma64_tag(struct acpi_softc *, struct acpi_devnode *);
 
 static int
 acpi_md_pmapflags(paddr_t pa)
@@ -473,14 +474,34 @@
        return cca ? _BUS_DMAMAP_COHERENT : 0;
 }
 
+bus_dma_tag_t
+arm_acpi_dma32_tag(struct acpi_softc *sc, struct acpi_devnode *ad)
+{
+       bus_dma_tag_t dmat64, dmat32;
+       int error;
+
+       if (ad->ad_dmat != NULL)
+               return ad->ad_dmat;
+
+       dmat64 = arm_acpi_dma64_tag(sc, ad);
+
+       const uint32_t flags = arm_acpi_dma_flags(sc, ad);
+       error = bus_dmatag_subregion(dmat64, 0, UINT32_MAX, &dmat32, flags);
+       if (error != 0)
+               panic("arm_acpi_dma32_tag: bus_dmatag_subregion returned %d",
+                   error);
+
+       return dmat32;
+}
+__strong_alias(acpi_get_dma_tag,arm_acpi_dma32_tag);
 
 bus_dma_tag_t
-arm_acpi_dma_tag(struct acpi_softc *sc, struct acpi_devnode *ad)
+arm_acpi_dma64_tag(struct acpi_softc *sc, struct acpi_devnode *ad)
 {
        struct arm32_bus_dma_tag *dmat;
 
-       if (ad->ad_dmat != NULL)
-               return ad->ad_dmat;
+       if (ad->ad_dmat64 != NULL)
+               return ad->ad_dmat64;
                
        dmat = kmem_alloc(sizeof(*dmat), KM_SLEEP);
        *dmat = arm_generic_dma_tag;
@@ -490,5 +511,4 @@
 
        return dmat;
 }
-__strong_alias(acpi_get_dma_tag,arm_acpi_dma_tag);
-__strong_alias(acpi_get_dma64_tag,arm_acpi_dma_tag);
+__strong_alias(acpi_get_dma64_tag,arm_acpi_dma64_tag);
diff -r 0e33368afc7f -r 1ff243630a41 sys/arch/arm/acpi/acpipchb.c
--- a/sys/arch/arm/acpi/acpipchb.c      Tue Jan 21 10:54:11 2020 +0000
+++ b/sys/arch/arm/acpi/acpipchb.c      Tue Jan 21 11:24:47 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.16 2020/01/17 17:06:33 jmcneill Exp $ */
+/* $NetBSD: acpipchb.c,v 1.17 2020/01/21 11:24:47 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.16 2020/01/17 17:06:33 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.17 2020/01/21 11:24:47 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -84,8 +84,6 @@
 
        bus_space_tag_t         sc_memt;
 
-       struct arm32_bus_dma_tag sc_dmat;
-
        ACPI_HANDLE             sc_handle;
        ACPI_INTEGER            sc_bus;
 
@@ -139,8 +137,6 @@
        aprint_naive("\n");
        aprint_normal(": PCI Express Host Bridge\n");
 
-       sc->sc_dmat = *aa->aa_dmat;
-
        if (acpi_pci_ignore_boot_config(sc->sc_handle)) {
                if (acpimcfg_configure_bus(self, aa->aa_pc, sc->sc_handle, sc->sc_bus, PCIHOST_CACHELINE_SIZE) != 0)
                        aprint_error_dev(self, "failed to configure bus\n");
@@ -150,9 +146,9 @@
        pba.pba_flags = aa->aa_pciflags & ~(PCI_FLAGS_MEM_OKAY | PCI_FLAGS_IO_OKAY);
        pba.pba_memt = 0;
        pba.pba_iot = 0;
-       pba.pba_dmat = &sc->sc_dmat;
+       pba.pba_dmat = aa->aa_dmat;
 #ifdef _PCI_HAVE_DMA64
-       pba.pba_dmat64 = &sc->sc_dmat;
+       pba.pba_dmat64 = aa->aa_dmat64;
 #endif
        pba.pba_pc = aa->aa_pc;
        pba.pba_bus = sc->sc_bus;



Home | Main Index | Thread Index | Old Index