From patchwork Thu Mar 6 09:19:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Shilimkar X-Patchwork-Id: 25788 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9932C203C3 for ; Thu, 6 Mar 2014 09:21:25 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f73sf5892272yha.3 for ; Thu, 06 Mar 2014 01:21:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=r7Spq4HWklBWhZUzVchOyZRyuHZ2kx4VvDlkWIJ6W3M=; b=c2Yh4sWPj6us4UiPI6491rh37NdmHqAnGKmeVI+jPumF9BVE/A+NwfUo84rx65qsSo YR3Iq2OvHrtSzSl5syiA6iG5mBPKxtnteqHhfHwW+Fu7S5PUQArBDu2PYKvzUtHoi4/E WG53vbAAeQNo7udgLzfDWuY1fb3Rq4pjLg100vFcn1HOlcXQQXB33XsP6QZ0vcQuNVQF MwRmeCv+ThS7RXoJOQFyAkYARcRGONnnVL1Oy+Etxc/J2CneG41BjyRMM5WtEtrboc22 RcXfOX5qTlwr2PE2R890ynng6rjwoSmDlHbb8X2sOwiEX1KNIOhT52D685VxZMYLTyBa Lszw== X-Gm-Message-State: ALoCoQnOGJqj0/0Zfr6AIShK0bcbGZRAhWG96mF2hkwqCwC3PNhiaWOwAYoic8s5nB7+aEFa3JSE X-Received: by 10.52.37.33 with SMTP id v1mr4301459vdj.1.1394097685307; Thu, 06 Mar 2014 01:21:25 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.41.85 with SMTP id y79ls611964qgy.92.gmail; Thu, 06 Mar 2014 01:21:25 -0800 (PST) X-Received: by 10.52.242.167 with SMTP id wr7mr305327vdc.32.1394097685151; Thu, 06 Mar 2014 01:21:25 -0800 (PST) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id ry8si1651859vdc.58.2014.03.06.01.21.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Mar 2014 01:21:25 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id jw12so2280964veb.23 for ; Thu, 06 Mar 2014 01:21:25 -0800 (PST) X-Received: by 10.220.147.16 with SMTP id j16mr157771vcv.28.1394097685012; Thu, 06 Mar 2014 01:21:25 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp25102vck; Thu, 6 Mar 2014 01:21:24 -0800 (PST) X-Received: by 10.66.102.66 with SMTP id fm2mr13036322pab.51.1394097684119; Thu, 06 Mar 2014 01:21:24 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3si4467809pay.339.2014.03.06.01.21.23; Thu, 06 Mar 2014 01:21:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752801AbaCFJVN (ORCPT + 26 others); Thu, 6 Mar 2014 04:21:13 -0500 Received: from comal.ext.ti.com ([198.47.26.152]:33307 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752734AbaCFJVJ (ORCPT ); Thu, 6 Mar 2014 04:21:09 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s269KRbw031368; Thu, 6 Mar 2014 03:20:27 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s269KR7k029340; Thu, 6 Mar 2014 03:20:27 -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:26 -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 s269K8N1031770; Thu, 6 Mar 2014 03:20:24 -0600 From: Santosh Shilimkar To: CC: , , Santosh Shilimkar , Greg Kroah-Hartman , Russell King , Arnd Bergmann , Olof Johansson , Grant Likely , Rob Herring , Catalin Marinas , Linus Walleij Subject: [PATCH 3/7] of: introduce of_dma_is_coherent() helper Date: Thu, 6 Mar 2014 17:19:54 +0800 Message-ID: <1394097598-17622-4-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 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: santosh.shilimkar@ti.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The of_dma_is_coherent() helper parses the given DT device node to see if the "dma-coherent" property is supported and returns true or false accordingly. For the architectures which are fully dma coherent and don't need per device property, it can enable CONFIG_ARCH_IS_DMA_COHERENT config option which enables DMA coherent for all devices by default. 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: Santosh Shilimkar --- drivers/of/platform.c | 31 +++++++++++++++++++++++++++++++ include/linux/of_platform.h | 6 ++++++ 2 files changed, 37 insertions(+) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 2265a55..bd080db 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -570,4 +570,35 @@ out: return ret; } EXPORT_SYMBOL_GPL(of_dma_get_range); + +/** + * of_dma_is_coherent - Check if device is coherent + * @np: device node + * + * It returns true if "dma-coherent" property was found + * for this device in DT. + */ +#ifndef CONFIG_ARCH_IS_DMA_COHERENT +bool of_dma_is_coherent(struct device_node *np) +{ + struct device_node *node = np; + + while (node) { + if (of_property_read_bool(node, "dma-coherent")) { + of_node_put(node); + return true; + } + node = of_get_next_parent(node); + } + return false; +} +EXPORT_SYMBOL_GPL(of_dma_is_coherent); +#else +inline bool of_dma_is_coherent(struct device_node *np) +{ + /* ARCH is fully dma coherent and don't need per device control */ + return true; +} +EXPORT_SYMBOL_GPL(of_dma_is_coherent); +#endif #endif /* CONFIG_OF_ADDRESS */ diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index ba7d3dc..48e0748 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -74,6 +74,7 @@ extern int of_platform_populate(struct device_node *root, struct device *parent); extern int of_dma_get_range(struct device_node *np, dma_addr_t *dma_addr, phys_addr_t *paddr, phys_addr_t *size); +extern bool of_dma_is_coherent(struct device_node *np); #else static inline int of_platform_populate(struct device_node *root, const struct of_device_id *matches, @@ -88,6 +89,11 @@ static inline int of_dma_get_range(struct device_node *np, dma_addr_t *dma_addr, { return -ENODEV; } + +static inline bool of_dma_is_coherent(struct device_node *np) +{ + return false; +} #endif #endif /* _LINUX_OF_PLATFORM_H */