From patchwork Thu Mar 6 09:19:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Shilimkar X-Patchwork-Id: 3782431 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D1A019F369 for ; Thu, 6 Mar 2014 09:24:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E63CC20203 for ; Thu, 6 Mar 2014 09:24:48 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DB70A200CC for ; Thu, 6 Mar 2014 09:24:47 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WLUVV-0007aD-7I; Thu, 06 Mar 2014 09:22:25 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WLUUz-0000O5-CJ; Thu, 06 Mar 2014 09:21:53 +0000 Received: from devils.ext.ti.com ([198.47.26.153]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WLUUL-0000GF-SM for linux-arm-kernel@lists.infradead.org; Thu, 06 Mar 2014 09:21:15 +0000 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s269Kbn3025017; Thu, 6 Mar 2014 03:20:37 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s269KasS003305; Thu, 6 Mar 2014 03:20:36 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Thu, 6 Mar 2014 03:20:36 -0600 Received: from ula0393909.itg.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s269K8N3031770; Thu, 6 Mar 2014 03:20:33 -0600 From: Santosh Shilimkar To: Subject: [PATCH 5/7] of: Add set_arch_dma_coherent_ops() and setup coherent dma_ops Date: Thu, 6 Mar 2014 17:19:56 +0800 Message-ID: <1394097598-17622-6-git-send-email-santosh.shilimkar@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1394097598-17622-1-git-send-email-santosh.shilimkar@ti.com> References: <1394097598-17622-1-git-send-email-santosh.shilimkar@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140306_042114_070412_196B5856 X-CRM114-Status: GOOD ( 11.24 ) X-Spam-Score: -3.9 (---) Cc: devicetree@vger.kernel.org, Grygorii Strashko , Russell King , Arnd Bergmann , Greg Kroah-Hartman , Linus Walleij , Grant Likely , Rob Herring , Santosh Shilimkar , Catalin Marinas , Olof Johansson , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add set_arch_dma_coherent_ops() for architectures to setup coherent dma_ops. Update dt_dma_configure() to look for a "dma-coherent" property in the device's node, and its ancestors If this property is found, we call set_arch_dma_coherent_ops() per device to apply coherent DMA configuartion. The set_arch_dma_coherent_ops() is declared as __weak and it's expected that the arch's needing it will imlepment it. Cc: Greg Kroah-Hartman Cc: Russell King Cc: Arnd Bergmann Cc: Olof Johansson Cc: Grant Likely Cc: Rob Herring Cc: Catalin Marinas Cc: Linus Walleij Signed-off-by: Grygorii Strashko Signed-off-by: Santosh Shilimkar --- drivers/of/platform.c | 5 +++++ include/linux/dma-mapping.h | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 53bb12f..272e390 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -255,6 +255,11 @@ static void dt_dma_configure(struct device *dev) dev_err(dev, "failed to set coherent DMA mask %pad\n", &dma_mask); } + + if (of_dma_is_coherent(dev->of_node)) { + set_arch_dma_coherent_ops(dev); + dev_dbg(dev, "device is dma coherent\n"); + } } /** diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index fd4aee2..c7d9b1b 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -123,6 +123,13 @@ static inline int dma_coerce_mask_and_coherent(struct device *dev, u64 mask) extern u64 dma_get_required_mask(struct device *dev); +#ifndef set_arch_dma_coherent_ops +static inline int set_arch_dma_coherent_ops(struct device *dev) +{ + return 0; +} +#endif + static inline unsigned int dma_get_max_seg_size(struct device *dev) { return dev->dma_parms ? dev->dma_parms->max_segment_size : 65536;