Author: zbb
Date: Wed Jun 21 18:25:35 2017
New Revision: 320198
URL: https://svnweb.freebsd.org/changeset/base/320198

Log:
  Enable setting the dma tag at the nexus level
  
  Allow to set the dma tag for nexus in the platform init code,
  so that all busses and devices would be able to inherit it.
  This change is useful e.g. for setting coherent dma tag for
  the platforms with hardware IO cache coherency.
  
  Submitted by: ian
                      Michal Mazur <m...@semihalf.com>
  Reviewed by: ian
  Differential revision: https://reviews.freebsd.org/D11202

Added:
  head/sys/arm/arm/nexusvar.h   (contents, props changed)
Modified:
  head/sys/arm/arm/nexus.c

Modified: head/sys/arm/arm/nexus.c
==============================================================================
--- head/sys/arm/arm/nexus.c    Wed Jun 21 18:23:28 2017        (r320197)
+++ head/sys/arm/arm/nexus.c    Wed Jun 21 18:25:35 2017        (r320198)
@@ -62,6 +62,8 @@ __FBSDID("$FreeBSD$");
 #include <machine/resource.h>
 #include <machine/intr.h>
 
+#include <arm/arm/nexusvar.h>
+
 #ifdef FDT
 #include <machine/fdt.h>
 #include <dev/ofw/ofw_bus_subr.h>
@@ -87,6 +89,7 @@ static        struct resource *nexus_alloc_resource(device_t,
 static int nexus_activate_resource(device_t, device_t, int, int,
     struct resource *);
 static bus_space_tag_t nexus_get_bus_tag(device_t, device_t);
+static bus_dma_tag_t nexus_get_dma_tag(device_t dev, device_t child);
 #ifdef INTRNG
 #ifdef SMP
 static int nexus_bind_intr(device_t, device_t, struct resource *, int);
@@ -112,6 +115,13 @@ static int nexus_ofw_map_intr(device_t dev, device_t c
     int icells, pcell_t *intr);
 #endif
 
+/*
+ * Normally NULL (which results in defaults which are handled in
+ * busdma_machdep), platform init code can use nexus_set_dma_tag() to set this
+ * to a tag that will be inherited by all busses and devices on the platform.
+ */
+static bus_dma_tag_t nexus_dma_tag;
+
 static device_method_t nexus_methods[] = {
        /* Device interface */
        DEVMETHOD(device_probe,         nexus_probe),
@@ -127,6 +137,7 @@ static device_method_t nexus_methods[] = {
        DEVMETHOD(bus_setup_intr,       nexus_setup_intr),
        DEVMETHOD(bus_teardown_intr,    nexus_teardown_intr),
        DEVMETHOD(bus_get_bus_tag,      nexus_get_bus_tag),
+       DEVMETHOD(bus_get_dma_tag,      nexus_get_dma_tag),
 #ifdef INTRNG
        DEVMETHOD(bus_describe_intr,    nexus_describe_intr),
 #ifdef SMP
@@ -273,6 +284,20 @@ nexus_get_bus_tag(device_t bus __unused, device_t chil
 #else
                return((void *)1);
 #endif
+}
+
+static bus_dma_tag_t
+nexus_get_dma_tag(device_t dev, device_t child)
+{
+
+       return nexus_dma_tag;
+}
+
+void
+nexus_set_dma_tag(bus_dma_tag_t tag)
+{
+
+       nexus_dma_tag = tag;
 }
 
 static int

Added: head/sys/arm/arm/nexusvar.h
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/arm/nexusvar.h Wed Jun 21 18:25:35 2017        (r320198)
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2017 Ian Lepore <i...@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef        _ARM_ARM_NEXUSVAR_H_
+#define        _ARM_ARM_NEXUSVAR_H_
+
+/* Set a platform busdma tag to be inherited by all busses and devices. */
+void nexus_set_dma_tag(bus_dma_tag_t _tag);
+
+#endif
+
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to