From patchwork Tue Jan 29 02:39:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 2058841 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id B0A6CE00C6 for ; Tue, 29 Jan 2013 02:46:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753360Ab3A2CqJ (ORCPT ); Mon, 28 Jan 2013 21:46:09 -0500 Received: from mail-gh0-f173.google.com ([209.85.160.173]:41775 "EHLO mail-gh0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753359Ab3A2CqG (ORCPT ); Mon, 28 Jan 2013 21:46:06 -0500 X-Greylist: delayed 378 seconds by postgrey-1.27 at vger.kernel.org; Mon, 28 Jan 2013 21:46:06 EST Received: by mail-gh0-f173.google.com with SMTP id g2so541383ghb.4 for ; Mon, 28 Jan 2013 18:46:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=Be8cnV4zkUCfFTMMoCdqOT62xKTTZduFtT9nHPOcs7A=; b=fqkkhJocclDRVfuEyqzAgublveH55l/TyAHDRBL/gh6+IQ0M3GiXZ5/LJwCvER7WFT NG1r6gxXfSHszEgcIgUmbN3lnOOyMRgjptBoLkVaJYppaZn351kBLglIL+7oWYOjvg+m WU2Kt2gJsduq/V2K2W0AG63qHuIqZJHlpAPwpZ3jdQuU06yFBHJ7QgFIuxIUd//muhQC Jd2OExjd3KBrwf+TjGy2eawxBdi9yKIuCefy3L+1D0u5I3M9t3TU5TP//81tFWREq/4Z m3ULPxyZ0q+wpMWxK8OdX6TJkr1868qN1lACE7u3lzB+LuL128jga7ZYOJA3mS+pPJNK XMoA== X-Received: by 10.236.126.138 with SMTP id b10mr6019316yhi.78.1359427188023; Mon, 28 Jan 2013 18:39:48 -0800 (PST) Received: from fabio-Latitude-E6410.cps.virtua.com.br ([201.82.74.153]) by mx.google.com with ESMTPS id d17sm10733675ann.11.2013.01.28.18.39.45 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 28 Jan 2013 18:39:47 -0800 (PST) From: Fabio Estevam To: akpm@linux-foundation.org Cc: shawn.guo@linaro.org, s.hauer@pengutronix.de, linux-fbdev@vger.kernel.org, Fabio Estevam Subject: [PATCH RESEND v4] video: imxfb: Do not crash on reboot Date: Tue, 29 Jan 2013 00:39:31 -0200 Message-Id: <1359427171-18109-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org From: Fabio Estevam Issuing a "reboot" command after the LCD times out causes the following warnings: Requesting system reboot ------------[ cut here ]------------ WARNING: at drivers/clk/clk.c:471 clk_disable+0x24/0x50() Modules linked in: [] (unwind_backtrace+0x0/0xf4) from [] (warn_slowpath_common+0x48/0x60) [] (warn_slowpath_common+0x48/0x60) from [] (warn_slowpath_null+0x1c/0x24) [] (warn_slowpath_null+0x1c/0x24) from [] (clk_disable+0x24/0x50) [] (clk_disable+0x24/0x50) from [] (imxfb_disable_controller+0x48/0x7c) [] (imxfb_disable_controller+0x48/0x7c) from [] (platform_drv_shutdown+0x18/0x1c) [] (platform_drv_shutdown+0x18/0x1c) from [] (device_shutdown+0x48/0x14c) [] (device_shutdown+0x48/0x14c) from [] (kernel_restart_prepare+0x2c/0x3c) [] (kernel_restart_prepare+0x2c/0x3c) from [] (kernel_restart+0xc/0x48) [] (kernel_restart+0xc/0x48) from [] (sys_reboot+0xc0/0x1bc) [] (sys_reboot+0xc0/0x1bc) from [] (ret_fast_syscall+0x0/0x2c) ---[ end trace da6b502ca79c854f ]--- ------------[ cut here ]------------ WARNING: at drivers/clk/clk.c:380 clk_unprepare+0x1c/0x2c() Modules linked in: [] (unwind_backtrace+0x0/0xf4) from [] (warn_slowpath_common+0x48/0x60) [] (warn_slowpath_common+0x48/0x60) from [] (warn_slowpath_null+0x1c/0x24) [] (warn_slowpath_null+0x1c/0x24) from [] (clk_unprepare+0x1c/0x2c) [] (clk_unprepare+0x1c/0x2c) from [] (imxfb_disable_controller+0x50/0x7c) [] (imxfb_disable_controller+0x50/0x7c) from [] (platform_drv_shutdown+0x18/0x1c) [] (platform_drv_shutdown+0x18/0x1c) from [] (device_shutdown+0x48/0x14c) [] (device_shutdown+0x48/0x14c) from [] (kernel_restart_prepare+0x2c/0x3c) [] (kernel_restart_prepare+0x2c/0x3c) from [] (kernel_restart+0xc/0x48) [] (kernel_restart+0xc/0x48) from [] (sys_reboot+0xc0/0x1bc) [] (sys_reboot+0xc0/0x1bc) from [] (ret_fast_syscall+0x0/0x2c) ---[ end trace da6b502ca79c8550 ]--- ------------[ cut here ]------------ This happens because "reboot" triggers imxfb_shutdown(), which calls imxfb_disable_controller with the clocks already disabled. To prevent this, add a clock enabled status so that we can check if the clocks are enabled before disabling them. Acked-by: Sascha Hauer Signed-off-by: Fabio Estevam --- Changes since v3: - Changed from 'clks_enabled' to 'enabled' Changes since v2: - Use a better naming for the clk enabled variable - Return immediately in imxfb_enable_controller/imxfb_disable_controller if the the clocks are already enabled/disabled. Changes since v1: - Protect the whole function instead of only the clocks drivers/video/imxfb.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c index cf2688d..ce7de9f 100644 --- a/drivers/video/imxfb.c +++ b/drivers/video/imxfb.c @@ -134,6 +134,7 @@ struct imxfb_info { struct clk *clk_ipg; struct clk *clk_ahb; struct clk *clk_per; + int enabled; /* * These are the addresses we mapped @@ -513,6 +514,10 @@ static void imxfb_exit_backlight(struct imxfb_info *fbi) static void imxfb_enable_controller(struct imxfb_info *fbi) { + + if (fbi->enabled) + return; + pr_debug("Enabling LCD controller\n"); writel(fbi->screen_dma, fbi->regs + LCDC_SSA); @@ -533,6 +538,7 @@ static void imxfb_enable_controller(struct imxfb_info *fbi) clk_prepare_enable(fbi->clk_ipg); clk_prepare_enable(fbi->clk_ahb); clk_prepare_enable(fbi->clk_per); + fbi->enabled = 1; if (fbi->backlight_power) fbi->backlight_power(1); @@ -542,6 +548,9 @@ static void imxfb_enable_controller(struct imxfb_info *fbi) static void imxfb_disable_controller(struct imxfb_info *fbi) { + if (!fbi->enabled) + return; + pr_debug("Disabling LCD controller\n"); if (fbi->backlight_power) @@ -552,6 +561,7 @@ static void imxfb_disable_controller(struct imxfb_info *fbi) clk_disable_unprepare(fbi->clk_per); clk_disable_unprepare(fbi->clk_ipg); clk_disable_unprepare(fbi->clk_ahb); + fbi->enabled = 0; writel(0, fbi->regs + LCDC_RMCR); }