From patchwork Thu May 19 04:21:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scot Doyle X-Patchwork-Id: 9123871 Return-Path: X-Original-To: patchwork-linux-fbdev@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 794949F1C3 for ; Thu, 19 May 2016 04:28:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 93609201FA for ; Thu, 19 May 2016 04:28:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A4602201C0 for ; Thu, 19 May 2016 04:28:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750764AbcESE2R (ORCPT ); Thu, 19 May 2016 00:28:17 -0400 Received: from [23.226.141.211] ([23.226.141.211]:56942 "EHLO mx1.scotdoyle.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1750739AbcESE2R (ORCPT ); Thu, 19 May 2016 00:28:17 -0400 X-Greylist: delayed 338 seconds by postgrey-1.27 at vger.kernel.org; Thu, 19 May 2016 00:28:17 EDT Received: by mx1.scotdoyle.com (Postfix) id 66255103A00CB; Thu, 19 May 2016 04:21:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx1.scotdoyle.com (Postfix) with ESMTP id 299C1103A008B; Thu, 19 May 2016 04:21:54 +0000 (UTC) Date: Wed, 18 May 2016 23:21:53 -0500 (CDT) From: Scot Doyle To: Tomi Valkeinen , Jean-Christophe Plagniol-Villard cc: David Daney , Ming Lei , Dann Frazier , Peter Hurley , Pavel Machek , Jonathan Liu , Alistair Popple , Jean-Philippe Brucker , "Chintakuntla, Radha" , Greg Kroah-Hartman , Jiri Slaby , David Airlie , ddaney.cavm@gmail.com, lkml14@scotdoyle.com, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] fbcon: use default if cursor blink interval is not valid In-Reply-To: Message-ID: References: <1463510464-28124-1-git-send-email-ddaney.cavm@gmail.com> <20160517204912.GA29719@amd> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Two current [1] and three previous [2] systems locked during boot because the cursor flash timer was set using an ops->cur_blink_jiffies value of 0. Previous patches attempted to solve the problem by moving variable initialization earlier in the setup sequence [2]. Use the normal cursor blink default interval of 200 ms if ops->cur_blink_jiffies is not in the range specified in commit bd63364caa8d. Since invalid values are not used, specific system initialization timings should not cause lockups. [1] https://bugs.launchpad.net/bugs/1574814 [2] see commits: 2a17d7e80f1d, f235f664a8af, a1e533ec07d5 Signed-off-by: Scot Doyle Cc: [v4.2] Acked-by: Jeremy Kerr Tested-by: Ming Lei Acked-by: Pavel Machek --- drivers/video/console/fbcon.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c index 6e92917..da61d87 100644 --- a/drivers/video/console/fbcon.c +++ b/drivers/video/console/fbcon.c @@ -396,13 +396,23 @@ static void fb_flashcursor(struct work_struct *work) console_unlock(); } +static int cursor_blink_jiffies(int candidate) +{ + if (candidate >= msecs_to_jiffies(50) && + candidate <= msecs_to_jiffies(USHRT_MAX)) + return candidate; + else + return HZ / 5; +} + static void cursor_timer_handler(unsigned long dev_addr) { struct fb_info *info = (struct fb_info *) dev_addr; struct fbcon_ops *ops = info->fbcon_par; queue_work(system_power_efficient_wq, &info->queue); - mod_timer(&ops->cursor_timer, jiffies + ops->cur_blink_jiffies); + mod_timer(&ops->cursor_timer, jiffies + + cursor_blink_jiffies(ops->cur_blink_jiffies)); } static void fbcon_add_cursor_timer(struct fb_info *info) @@ -417,7 +427,8 @@ static void fbcon_add_cursor_timer(struct fb_info *info) init_timer(&ops->cursor_timer); ops->cursor_timer.function = cursor_timer_handler; - ops->cursor_timer.expires = jiffies + ops->cur_blink_jiffies; + ops->cursor_timer.expires = jiffies + + cursor_blink_jiffies(ops->cur_blink_jiffies); ops->cursor_timer.data = (unsigned long ) info; add_timer(&ops->cursor_timer); ops->flags |= FBCON_FLAGS_CURSOR_TIMER; @@ -709,7 +720,6 @@ static int con2fb_acquire_newinfo(struct vc_data *vc, struct fb_info *info, } if (!err) { - ops->cur_blink_jiffies = HZ / 5; info->fbcon_par = ops; if (vc) @@ -957,7 +967,6 @@ static const char *fbcon_startup(void) ops->currcon = -1; ops->graphics = 1; ops->cur_rotate = -1; - ops->cur_blink_jiffies = HZ / 5; info->fbcon_par = ops; p->con_rotate = initial_rotation; set_blitting_type(vc, info);