From owner-svn-src-all@freebsd.org Wed Jun 21 18:25:36 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7A89CD95C03; Wed, 21 Jun 2017 18:25:36 +0000 (UTC) (envelope-from zbb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 54DA777A64; Wed, 21 Jun 2017 18:25:36 +0000 (UTC) (envelope-from zbb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v5LIPZU0065773; Wed, 21 Jun 2017 18:25:35 GMT (envelope-from zbb@FreeBSD.org) Received: (from zbb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v5LIPZXQ065771; Wed, 21 Jun 2017 18:25:35 GMT (envelope-from zbb@FreeBSD.org) Message-Id: <201706211825.v5LIPZXQ065771@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: zbb set sender to zbb@FreeBSD.org using -f From: Zbigniew Bodek Date: Wed, 21 Jun 2017 18:25:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r320198 - head/sys/arm/arm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jun 2017 18:25:36 -0000 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 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 #include +#include + #ifdef FDT #include #include @@ -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 + * 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 +