From patchwork Tue Aug 12 12:29:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 4712581 Return-Path: X-Original-To: patchwork-dmaengine@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 9EB2A9F319 for ; Tue, 12 Aug 2014 12:29:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B372E2014A for ; Tue, 12 Aug 2014 12:29:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9A78320115 for ; Tue, 12 Aug 2014 12:29:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752457AbaHLM3z (ORCPT ); Tue, 12 Aug 2014 08:29:55 -0400 Received: from baptiste.telenet-ops.be ([195.130.132.51]:52774 "EHLO baptiste.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752431AbaHLM3x (ORCPT ); Tue, 12 Aug 2014 08:29:53 -0400 Received: from ayla.of.borg ([84.193.84.167]) by baptiste.telenet-ops.be with bizsmtp id doVr1o0043cczKo01oVrb4; Tue, 12 Aug 2014 14:29:51 +0200 Received: from geert (helo=localhost) by ayla.of.borg with local-esmtp (Exim 4.76) (envelope-from ) id 1XHBD4-0005iB-UD; Tue, 12 Aug 2014 14:29:51 +0200 Date: Tue, 12 Aug 2014 14:29:50 +0200 (CEST) From: Geert Uytterhoeven To: Laurent Pinchart cc: dmaengine@vger.kernel.org, Linux-sh list Subject: Re: rcar-dmac: DMAOR initialization failed In-Reply-To: Message-ID: References: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 On Tue, 12 Aug 2014, Geert Uytterhoeven wrote: > I tried a few things to fix this, but I'm not so sure what's the best solution: > > Works: > - Calling clk_enable(dmac->clk)/clk_disable(dmac->clk) before resp. > after the call to rcar_dmac_init(). This also needs rcar_dmac.clk setup, > cfr. the first version of the rcar-dmac driver. It never hurts to send an actual patch... From 6f3288de9fe8f107896e65203d3c098989966870 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 12 Aug 2014 14:24:45 +0200 Subject: [PATCH] [RFC] dmaengine: rcar-dmac: Fix reinitialization on resume When resuming from s2ram on Koelsch ("echo mem > /sys/power/state" to suspend, and press any of the SW3x to resume), DMAOR initialization fails: rcar-dmac e6700000.dma-controller: DMAOR initialization failed. dpm_run_callback(): platform_pm_resume+0x0/0x54 returns -5 PM: Device e6700000.dma-controller failed to resume: error -5 rcar-dmac e6720000.dma-controller: DMAOR initialization failed. dpm_run_callback(): platform_pm_resume+0x0/0x54 returns -5 PM: Device e6720000.dma-controller failed to resume: error -5 (note that DMA still works after this) This is due to rcar_dmac_resume() calling rcar_dmac_init() while the device's clock is disabled. Explicitly enable the clock before calling rcar_dmac_init() to fix this, and disable the clock again afterwards. Signed-off-by: Geert Uytterhoeven --- drivers/dma/sh/rcar-dmac.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c index 0997322b70f8..334ddd3a37c0 100644 --- a/drivers/dma/sh/rcar-dmac.c +++ b/drivers/dma/sh/rcar-dmac.c @@ -10,6 +10,7 @@ * published by the Free Software Foundation. */ +#include #include #include #include @@ -155,6 +156,7 @@ struct rcar_dmac { struct dma_device engine; struct device *dev; void __iomem *iomem; + struct clk *clk; char *irqname; unsigned int n_channels; @@ -1282,8 +1284,16 @@ static int rcar_dmac_suspend(struct device *dev) static int rcar_dmac_resume(struct device *dev) { struct rcar_dmac *dmac = dev_get_drvdata(dev); + int ret; - return rcar_dmac_init(dmac); + ret = clk_enable(dmac->clk); + if (ret < 0) + return ret; + + ret = rcar_dmac_init(dmac); + + clk_disable(dmac->clk); + return ret; } #endif @@ -1336,6 +1346,12 @@ static int rcar_dmac_chan_probe(struct rcar_dmac *dmac, return ret; } + dmac->clk = clk_get(&pdev->dev, "fck"); + if (IS_ERR(dmac->clk)) { + dev_err(&pdev->dev, "unable to get fck clock\n"); + return PTR_ERR(dmac->clk); + } + /* * Initialize the DMA engine channel and add it to the DMA engine * channels list.