From patchwork Fri Feb 6 00:31:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 5787771 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D35939F302 for ; Fri, 6 Feb 2015 00:34:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D55BC201E4 for ; Fri, 6 Feb 2015 00:34:52 +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 E7E2C20117 for ; Fri, 6 Feb 2015 00:34:51 +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 1YJWqp-0002wj-6l; Fri, 06 Feb 2015 00:32:51 +0000 Received: from smtp.codeaurora.org ([198.145.11.231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YJWqU-0002q1-HV for linux-arm-kernel@lists.infradead.org; Fri, 06 Feb 2015 00:32:32 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 6EF1613FFF2; Fri, 6 Feb 2015 00:32:09 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 5F303140003; Fri, 6 Feb 2015 00:32:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: 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 Received: from linux-kernel-memory-lab-01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: lauraa@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 8A7F813FFF2; Fri, 6 Feb 2015 00:32:08 +0000 (UTC) From: Laura Abbott To: Will Deacon , Robin Murphy , Arnd Bergmann Subject: [PATCH/RFC 1/4] dma-mapping: Make arch_setup_dma_ops return an error code Date: Thu, 5 Feb 2015 16:31:59 -0800 Message-Id: <1423182722-16646-2-git-send-email-lauraa@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1423182722-16646-1-git-send-email-lauraa@codeaurora.org> References: <1423182722-16646-1-git-send-email-lauraa@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150205_163230_650835_E8CD4800 X-CRM114-Status: GOOD ( 18.94 ) X-Spam-Score: -0.0 (/) Cc: devicetree@vger.kernel.org, Laurent Pinchart , Laura Abbott , Joreg Roedel , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Grant Likely , Mitchel Humpherys , linux-arm-kernel@lists.infradead.org, Marek Szyprowski 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Setting up the DMA operations may trigger a probe deferral. Return a proper error code to let probe deferral do its thing. Signed-off-by: Laura Abbott --- arch/arm/include/asm/dma-mapping.h | 2 +- arch/arm/mm/dma-mapping.c | 4 +++- arch/arm64/include/asm/dma-mapping.h | 2 +- arch/arm64/mm/dma-mapping.c | 16 ++++++++++------ include/linux/dma-mapping.h | 7 +++++-- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index b52101d..68bff4e 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h @@ -122,7 +122,7 @@ static inline unsigned long dma_max_pfn(struct device *dev) #define dma_max_pfn(dev) dma_max_pfn(dev) #define arch_setup_dma_ops arch_setup_dma_ops -extern void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, +extern int arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, struct iommu_ops *iommu, bool coherent); #define arch_teardown_dma_ops arch_teardown_dma_ops diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 7864797..ba20196 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -2048,7 +2048,7 @@ static struct dma_map_ops *arm_get_dma_map_ops(bool coherent) return coherent ? &arm_coherent_dma_ops : &arm_dma_ops; } -void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, +int arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, struct iommu_ops *iommu, bool coherent) { struct dma_map_ops *dma_ops; @@ -2060,6 +2060,8 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, dma_ops = arm_get_dma_map_ops(coherent); set_dma_ops(dev, dma_ops); + + return 0; } void arch_teardown_dma_ops(struct device *dev) diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h index 0791a78..f7968af 100644 --- a/arch/arm64/include/asm/dma-mapping.h +++ b/arch/arm64/include/asm/dma-mapping.h @@ -45,7 +45,7 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev) return __generic_dma_ops(dev); } -void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, +int arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, struct iommu_ops *iommu, bool coherent); #define arch_setup_dma_ops arch_setup_dma_ops diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index d52175d..1e3c8f9 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -704,22 +704,24 @@ static struct dma_map_ops iommu_dma_ops = { .mapping_error = iommu_dma_mapping_error, }; -static void __iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, +static int __iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, struct iommu_ops *ops) { struct iommu_dma_mapping *mapping; + int ret; if (!ops) - return; + return 0; mapping = iommu_dma_create_mapping(ops, dma_base, size); if (!mapping) { pr_warn("Failed to create %llu-byte IOMMU mapping for device %s\n", size, dev_name(dev)); - return; + return -EINVAL; } - if (iommu_dma_attach_device(dev, mapping)) + ret = iommu_dma_attach_device(dev, mapping); + if (ret) pr_warn("Failed to attach device %s to IOMMU mapping\n", dev_name(dev)); else @@ -727,6 +729,8 @@ static void __iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, /* drop the initial mapping refcount */ iommu_dma_release_mapping(mapping); + + return ret; } static void __iommu_teardown_dma_ops(struct device *dev) @@ -747,11 +751,11 @@ static void __iommu_teardown_dma_ops(struct device *dev) { } #endif /* CONFIG_IOMMU_DMA */ -void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, +int arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, struct iommu_ops *iommu, bool coherent) { dev->archdata.dma_coherent = coherent; - __iommu_setup_dma_ops(dev, dma_base, size, iommu); + return __iommu_setup_dma_ops(dev, dma_base, size, iommu); } void arch_teardown_dma_ops(struct device *dev) diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index c3007cb..dfd8060 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -130,9 +130,12 @@ static inline int dma_coerce_mask_and_coherent(struct device *dev, u64 mask) extern u64 dma_get_required_mask(struct device *dev); #ifndef arch_setup_dma_ops -static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base, +static inline int arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, struct iommu_ops *iommu, - bool coherent) { } + bool coherent) +{ + return 0; +} #endif #ifndef arch_teardown_dma_ops