From patchwork Fri Oct 10 11:51:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 5064991 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 CCCE59F2F1 for ; Fri, 10 Oct 2014 11:58:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0C19B20222 for ; Fri, 10 Oct 2014 11:58:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (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 2F20720220 for ; Fri, 10 Oct 2014 11:58:17 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XcYnR-000187-DC; Fri, 10 Oct 2014 11:55:45 +0000 Received: from smtp.citrix.com ([66.165.176.89]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XcYmJ-0007a9-LT for linux-arm-kernel@lists.infradead.org; Fri, 10 Oct 2014 11:54:37 +0000 X-IronPort-AV: E=Sophos;i="5.04,691,1406592000"; d="scan'208";a="180114186" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.3.181.6; Fri, 10 Oct 2014 07:54:09 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1XcYln-0008ML-SY; Fri, 10 Oct 2014 12:54:03 +0100 From: Stefano Stabellini To: Subject: [PATCH v4 3/7] [RFC] arm/arm64: introduce is_dma_coherent Date: Fri, 10 Oct 2014 12:51:44 +0100 Message-ID: <1412941908-5850-3-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-DLP: MIA1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141010_045435_895434_5EC73174 X-CRM114-Status: UNSURE ( 7.39 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -6.0 (------) Cc: linux@arm.linux.org.uk, Ian.Campbell@citrix.com, Stefano Stabellini , catalin.marinas@arm.com, konrad.wilk@oracle.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, david.vrabel@citrix.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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=-2.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 Introduce a function to check whether a device is dma coherent. Signed-off-by: Stefano Stabellini CC: linux@arm.linux.org.uk CC: catalin.marinas@arm.com CC: will.deacon@arm.com CC: linux-arm-kernel@lists.infradead.org --- arch/arm/include/asm/dma-mapping.h | 6 ++++++ arch/arm64/include/asm/dma-mapping.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index c45b61a..bededbb 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h @@ -126,6 +126,12 @@ static inline int set_arch_dma_coherent_ops(struct device *dev) set_dma_ops(dev, &arm_coherent_dma_ops); return 0; } + +static inline bool is_dma_coherent(struct device *dev) +{ + return (__generic_dma_ops(dev) == &arm_coherent_dma_ops); +} + #define set_arch_dma_coherent_ops(dev) set_arch_dma_coherent_ops(dev) static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h index dc82e52..d51d67e 100644 --- a/arch/arm64/include/asm/dma-mapping.h +++ b/arch/arm64/include/asm/dma-mapping.h @@ -52,6 +52,11 @@ static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops) dev->archdata.dma_ops = ops; } +static inline bool is_dma_coherent(struct device *dev) +{ + return (__generic_dma_ops(dev) == &coherent_swiotlb_dma_ops); +} + #include static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)