From patchwork Thu May 14 23:00:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 6410391 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4785AC0432 for ; Thu, 14 May 2015 23:08:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 74B4320444 for ; Thu, 14 May 2015 23:08: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 A74BD20411 for ; Thu, 14 May 2015 23:08: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 1Yt2BN-0007AD-HY; Thu, 14 May 2015 23:04:49 +0000 Received: from galahad.ideasonboard.com ([2001:4b98:dc2:45:216:3eff:febb:480d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yt28N-0005D4-Vs for linux-arm-kernel@lists.infradead.org; Thu, 14 May 2015 23:01:46 +0000 Received: from avalon.ideasonboard.com (dsl-hkibrasgw3-50ddcc-40.dhcp.inet.fi [80.221.204.40]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 56B3E203B0; Fri, 15 May 2015 01:00:07 +0200 (CEST) From: Laurent Pinchart To: linux-kernel@vger.kernel.org Subject: [RFC/PATCH 6/9] drivers: platform: Configure dma operations at probe time Date: Fri, 15 May 2015 02:00:07 +0300 Message-Id: <1431644410-2997-7-git-send-email-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.3.6 In-Reply-To: <1431644410-2997-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> References: <1431644410-2997-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150514_160144_568003_EAE26520 X-CRM114-Status: GOOD ( 10.94 ) X-Spam-Score: -0.0 (/) Cc: Laura Abbott , Arnd Bergmann , Robin Murphy , Joreg Roedel , Will Deacon , iommu@lists.linux-foundation.org, Thierry Reding , Greg Kroah-Hartman , 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-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 Configuring DMA ops at probe time will allow deferring device probe when the IOMMU isn't available yet. Signed-off-by: Laurent Pinchart Acked-by: Greg Kroah-Hartman --- drivers/base/platform.c | 9 +++++++++ drivers/of/platform.c | 7 +++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index ebf034b97278..508a866859dc 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -516,6 +516,10 @@ static int platform_drv_probe(struct device *_dev) if (ret < 0) return ret; + ret = of_dma_configure_ops(_dev, _dev->of_node); + if (ret < 0) + goto done; + ret = dev_pm_domain_attach(_dev, true); if (ret != -EPROBE_DEFER) { ret = drv->probe(dev); @@ -523,6 +527,10 @@ static int platform_drv_probe(struct device *_dev) dev_pm_domain_detach(_dev, true); } + if (ret) + of_dma_deconfigure(_dev); + +done: if (drv->prevent_deferred_probe && ret == -EPROBE_DEFER) { dev_warn(_dev, "probe deferral not supported\n"); ret = -ENXIO; @@ -544,6 +552,7 @@ static int platform_drv_remove(struct device *_dev) ret = drv->remove(dev); dev_pm_domain_detach(_dev, true); + of_dma_deconfigure(_dev); return ret; } diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 9a29f09b7723..fc939bec799e 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -178,10 +178,8 @@ static struct platform_device *of_platform_device_create_pdata( dev->dev.bus = &platform_bus_type; dev->dev.platform_data = platform_data; of_dma_configure_masks(&dev->dev, dev->dev.of_node); - of_dma_configure_ops(&dev->dev, dev->dev.of_node); if (of_device_add(dev) != 0) { - of_dma_deconfigure(&dev->dev); platform_device_put(dev); goto err_clear_flag; } @@ -465,11 +463,12 @@ static int of_platform_device_destroy(struct device *dev, void *data) if (dev->bus == &platform_bus_type) platform_device_unregister(to_platform_device(dev)); #ifdef CONFIG_ARM_AMBA - else if (dev->bus == &amba_bustype) + else if (dev->bus == &amba_bustype) { amba_device_unregister(to_amba_device(dev)); + of_dma_deconfigure(dev); + } #endif - of_dma_deconfigure(dev); of_node_clear_flag(dev->of_node, OF_POPULATED); of_node_clear_flag(dev->of_node, OF_POPULATED_BUS); return 0;