From patchwork Mon Oct 8 22:23:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 1567101 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id C3BC5DFF71 for ; Mon, 8 Oct 2012 22:25:52 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TLLkG-0005CG-Iq; Mon, 08 Oct 2012 22:24:16 +0000 Received: from mail-yh0-f49.google.com ([209.85.213.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TLLkC-0005Az-3E for linux-arm-kernel@lists.infradead.org; Mon, 08 Oct 2012 22:24:13 +0000 Received: by mail-yh0-f49.google.com with SMTP id j52so1047570yhj.36 for ; Mon, 08 Oct 2012 15:24:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=fSuupNh0oDtDOapenQcaRQBPq9y8vW5aLk618oReezs=; b=O2RRhbwNUWRmujw67BqXyhYolilJCtjI9LKmi6PKjubhP4lw9v0EbIeJ67jD4S9x89 KCOz+ZqB4c4BY6tIdO9ZRt2BHR3trldORGqQafuCTy7ab4BI1G5H0m8ePh2ebQllIl87 58Yd1fmMoDSpdJ01yaWWtY5lWGndBnUO3cKX/B1V1Delp+r0O718ubrhfxOc8OJgWqw4 sSgKKyo0mAjTWYKz4cbmmWpv6NOb1mqiNUbdeM2TBRzTZk+H9TDcUdh6r4dUQky2zx8x 6Up/5aEMdrOv+jAH5GLI6G/SMWj9Yhz2XjWbaVHczEII6eJ9AAoL/jBEi/8m0azCVC94 01xw== Received: by 10.236.146.239 with SMTP id r75mr17659039yhj.100.1349735049894; Mon, 08 Oct 2012 15:24:09 -0700 (PDT) Received: from fabio-Latitude-E6410.cps.virtua.com.br ([201.82.136.72]) by mx.google.com with ESMTPS id g2sm18647579yhj.9.2012.10.08.15.24.07 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 08 Oct 2012 15:24:09 -0700 (PDT) From: Fabio Estevam To: kernel@pengutronix.de Subject: [PATCH v2] video: imxfb: Do not crash on reboot Date: Mon, 8 Oct 2012 19:23:58 -0300 Message-Id: <1349735038-19196-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.213.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (festevam[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Fabio Estevam , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, FlorianSchandinat@gmx.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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. Signed-off-by: Fabio Estevam --- Changes since v1: - Protect the whole function instead of only the clocks drivers/video/imxfb.c | 63 +++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c index cf2688d..32c71e5 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,47 +514,53 @@ static void imxfb_exit_backlight(struct imxfb_info *fbi) static void imxfb_enable_controller(struct imxfb_info *fbi) { - pr_debug("Enabling LCD controller\n"); + if (!fbi->enabled) { + pr_debug("Enabling LCD controller\n"); - writel(fbi->screen_dma, fbi->regs + LCDC_SSA); + writel(fbi->screen_dma, fbi->regs + LCDC_SSA); - /* panning offset 0 (0 pixel offset) */ - writel(0x00000000, fbi->regs + LCDC_POS); + /* panning offset 0 (0 pixel offset) */ + writel(0x00000000, fbi->regs + LCDC_POS); - /* disable hardware cursor */ - writel(readl(fbi->regs + LCDC_CPOS) & ~(CPOS_CC0 | CPOS_CC1), - fbi->regs + LCDC_CPOS); + /* disable hardware cursor */ + writel(readl(fbi->regs + LCDC_CPOS) & ~(CPOS_CC0 | CPOS_CC1), + fbi->regs + LCDC_CPOS); - /* - * RMCR_LCDC_EN_MX1 is present on i.MX1 only, but doesn't hurt - * on other SoCs - */ - writel(RMCR_LCDC_EN_MX1, fbi->regs + LCDC_RMCR); + /* + * RMCR_LCDC_EN_MX1 is present on i.MX1 only, but doesn't hurt + * on other SoCs + */ + writel(RMCR_LCDC_EN_MX1, fbi->regs + LCDC_RMCR); - clk_prepare_enable(fbi->clk_ipg); - clk_prepare_enable(fbi->clk_ahb); - clk_prepare_enable(fbi->clk_per); + 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); - if (fbi->lcd_power) - fbi->lcd_power(1); + if (fbi->backlight_power) + fbi->backlight_power(1); + if (fbi->lcd_power) + fbi->lcd_power(1); + } } static void imxfb_disable_controller(struct imxfb_info *fbi) { - pr_debug("Disabling LCD controller\n"); + if (fbi->enabled) { + pr_debug("Disabling LCD controller\n"); - if (fbi->backlight_power) - fbi->backlight_power(0); - if (fbi->lcd_power) - fbi->lcd_power(0); + if (fbi->backlight_power) + fbi->backlight_power(0); + if (fbi->lcd_power) + fbi->lcd_power(0); - clk_disable_unprepare(fbi->clk_per); - clk_disable_unprepare(fbi->clk_ipg); - clk_disable_unprepare(fbi->clk_ahb); + 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); + writel(0, fbi->regs + LCDC_RMCR); + } } static int imxfb_blank(int blank, struct fb_info *info)