From patchwork Fri Feb 6 00:32:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 5787761 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 B14D09F39B for ; Fri, 6 Feb 2015 00:34:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C591720274 for ; Fri, 6 Feb 2015 00:34:51 +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 E7987201E4 for ; Fri, 6 Feb 2015 00:34:50 +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 1YJWqj-0002vZ-GR; Fri, 06 Feb 2015 00:32:45 +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-0002q2-HY 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 06C5713FFFE; Fri, 6 Feb 2015 00:32:10 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id CA41814000F; 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 11A3F13FFFE; Fri, 6 Feb 2015 00:32:09 +0000 (UTC) From: Laura Abbott To: Will Deacon , Robin Murphy , Arnd Bergmann Subject: [PATCH/RFC 2/4] of: Return error codes from of_dma_configure Date: Thu, 5 Feb 2015 16:32:00 -0800 Message-Id: <1423182722-16646-3-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_671222_56A1652F X-CRM114-Status: GOOD ( 16.61 ) 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 of_dma_configure is currently a void function. IOMMU configuration may need to defer probing so return appropriate values. Signed-off-by: Laura Abbott --- drivers/iommu/of_iommu.c | 14 +++++++++++--- drivers/of/device.c | 9 +++++++-- include/linux/of_device.h | 4 ++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c index 396bc77..01cd540 100644 --- a/drivers/iommu/of_iommu.c +++ b/drivers/iommu/of_iommu.c @@ -138,7 +138,7 @@ struct iommu_ops *of_iommu_configure(struct device *dev, { struct of_phandle_args iommu_spec; struct device_node *np; - struct iommu_ops *ops = NULL; + struct iommu_ops *ops = ERR_PTR(-ENODEV); int idx = 0; if (dev_is_pci(dev)) { @@ -154,11 +154,19 @@ struct iommu_ops *of_iommu_configure(struct device *dev, while (!of_parse_phandle_with_args(node, "iommus", "#iommu-cells", idx, &iommu_spec)) { + int ret; + np = iommu_spec.np; ops = of_iommu_get_ops(np); - if (!ops || !ops->of_xlate || ops->of_xlate(dev, &iommu_spec)) + if (!ops || !ops->of_xlate) + goto err_put_node; + + ret = ops->of_xlate(dev, &iommu_spec); + if (ret) { + ops = ERR_PTR(ret); goto err_put_node; + } of_node_put(np); idx++; @@ -168,7 +176,7 @@ struct iommu_ops *of_iommu_configure(struct device *dev, err_put_node: of_node_put(np); - return NULL; + return ops; } void __init of_iommu_init(void) diff --git a/drivers/of/device.c b/drivers/of/device.c index ccbc958..1ff7a7a 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -81,7 +81,7 @@ int of_device_add(struct platform_device *ofdev) * can use Platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE event * to fix up DMA configuration. */ -void of_dma_configure(struct device *dev, struct device_node *np) +int of_dma_configure(struct device *dev, struct device_node *np) { u64 dma_addr, paddr, size; int ret; @@ -117,10 +117,15 @@ void of_dma_configure(struct device *dev, struct device_node *np) coherent ? " " : " not "); iommu = of_iommu_configure(dev, np); + if (PTR_ERR(iommu) == -EPROBE_DEFER) + return -EPROBE_DEFER; + else if (IS_ERR(iommu)) + iommu = NULL; + dev_dbg(dev, "device is%sbehind an iommu\n", iommu ? " " : " not "); - arch_setup_dma_ops(dev, dma_addr, size, iommu, coherent); + return arch_setup_dma_ops(dev, dma_addr, size, iommu, coherent); } EXPORT_SYMBOL_GPL(of_dma_configure); diff --git a/include/linux/of_device.h b/include/linux/of_device.h index c661496..c0821c0 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h @@ -53,7 +53,7 @@ static inline struct device_node *of_cpu_device_node_get(int cpu) return of_node_get(cpu_dev->of_node); } -void of_dma_configure(struct device *dev, struct device_node *np); +int of_dma_configure(struct device *dev, struct device_node *np); #else /* CONFIG_OF */ static inline int of_driver_match_device(struct device *dev, @@ -91,7 +91,7 @@ static inline struct device_node *of_cpu_device_node_get(int cpu) { return NULL; } -void of_dma_configure(struct device *dev, struct device_node *np) { } +int of_dma_configure(struct device *dev, struct device_node *np) { return -ENXIO; } #endif /* CONFIG_OF */ #endif /* _LINUX_OF_DEVICE_H */