From patchwork Mon Jan 5 10:46:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 5566461 Return-Path: X-Original-To: patchwork-dmaengine@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 7BF16BF6C3 for ; Mon, 5 Jan 2015 10:46:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7FC252014A for ; Mon, 5 Jan 2015 10:46:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 502EC2012D for ; Mon, 5 Jan 2015 10:46:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753409AbbAEKqi (ORCPT ); Mon, 5 Jan 2015 05:46:38 -0500 Received: from xavier.telenet-ops.be ([195.130.132.52]:48051 "EHLO xavier.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753082AbbAEKqi (ORCPT ); Mon, 5 Jan 2015 05:46:38 -0500 Received: from ayla.of.borg ([84.193.93.87]) by xavier.telenet-ops.be with bizsmtp id cAmc1p0011t5w8s01AmccQ; Mon, 05 Jan 2015 11:46:36 +0100 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1Y85BD-0007TU-QO; Mon, 05 Jan 2015 11:46:35 +0100 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1Y85BF-00030r-7V; Mon, 05 Jan 2015 11:46:37 +0100 From: Geert Uytterhoeven To: Vinod Koul , Dan Williams Cc: dmaengine@vger.kernel.org, linux-pm@vger.kernel.org, linux-sh@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2] dmaengine: shdma: Runtime-resume device in .shutdown() Date: Mon, 5 Jan 2015 11:46:29 +0100 Message-Id: <1420454789-11547-1-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 During system reboot, the sh-dma-engine device may be runtime-suspended, causing a crash: Unhandled fault: imprecise external abort (0x1406) at 0x0002c02c Internal error: : 1406 [#1] SMP ARM ... PC is at sh_dmae_ctl_stop+0x28/0x64 LR is at sh_dmae_ctl_stop+0x24/0x64 If the sh-dma-engine is runtime-suspended, its module clock is turned off, and its registers cannot be accessed. To fix this, change the driver's .shutdown() callback: - If the device is runtime suspended, do nothing, - Else, explicitly runtime-resume the device, to avoid the device from being suspended while sh_dmae_ctl_stop() is being executed. Signed-off-by: Geert Uytterhoeven --- v2: - Do nothing if we're runtime suspended. --- drivers/dma/sh/shdmac.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/dma/sh/shdmac.c b/drivers/dma/sh/shdmac.c index aec8a84784a469d7..2de30e8e7d9290b9 100644 --- a/drivers/dma/sh/shdmac.c +++ b/drivers/dma/sh/shdmac.c @@ -585,7 +585,13 @@ static void sh_dmae_chan_remove(struct sh_dmae_device *shdev) static void sh_dmae_shutdown(struct platform_device *pdev) { struct sh_dmae_device *shdev = platform_get_drvdata(pdev); + + if (pm_runtime_suspended(&pdev->dev)) + return; + + pm_runtime_get_sync(&pdev->dev); sh_dmae_ctl_stop(shdev); + pm_runtime_put(&pdev->dev); } static int sh_dmae_runtime_suspend(struct device *dev)