From patchwork Mon Apr 25 15:58:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sricharan Ramabadhran X-Patchwork-Id: 8930321 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 1EC519F1C1 for ; Mon, 25 Apr 2016 16:01:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4362B201EC for ; Mon, 25 Apr 2016 16:01:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4E8AA201C7 for ; Mon, 25 Apr 2016 16:01:25 +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 1auivU-0006IH-O8; Mon, 25 Apr 2016 15:59:56 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1auiuf-0005DG-Jl for linux-arm-kernel@lists.infradead.org; Mon, 25 Apr 2016 15:59:06 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id E79836130D; Mon, 25 Apr 2016 15:58:41 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1000) id CD0FB612EE; Mon, 25 Apr 2016 15:58:41 +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=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from blr-ubuntu-32.ap.qualcomm.com (unknown [202.46.23.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: sricharan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 9C3F061307; Mon, 25 Apr 2016 15:58:36 +0000 (UTC) From: Sricharan R To: will.deacon@arm.com, robin.murphy@arm.com, joro@8bytes.org, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, laurent.pinchart@ideasonboard.com Subject: [RFC 5/9] drivers: platform: Configure dma operations at probe time Date: Mon, 25 Apr 2016 21:28:10 +0530 Message-Id: <1461599894-1969-6-git-send-email-sricharan@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1461599894-1969-1-git-send-email-sricharan@codeaurora.org> References: <1461599894-1969-1-git-send-email-sricharan@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160425_085905_909424_913024C7 X-CRM114-Status: GOOD ( 13.19 ) X-Spam-Score: -2.9 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sricharan@codeaurora.org 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 From: Laurent Pinchart Configuring DMA ops at probe time will allow deferring device probe when the IOMMU isn't available yet. Signed-off-by: Laurent Pinchart --- drivers/base/platform.c | 13 +++++++++++++ drivers/of/platform.c | 7 +++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index f437afa..17e64a4 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -557,6 +557,12 @@ static int platform_drv_probe(struct device *_dev) if (ret < 0) return ret; + if (of_have_populated_dt()) { + 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) { if (drv->probe) { @@ -569,6 +575,11 @@ static int platform_drv_probe(struct device *_dev) } } + if (of_have_populated_dt()) { + 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; @@ -591,6 +602,8 @@ static int platform_drv_remove(struct device *_dev) if (drv->remove) ret = drv->remove(dev); dev_pm_domain_detach(_dev, true); + if (of_have_populated_dt()) + of_dma_deconfigure(_dev); return ret; } diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 17ee8d5..12bbc8e1 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -180,11 +180,9 @@ 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); of_msi_configure(&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; } @@ -481,11 +479,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;