From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757446AbcAaMcm (ORCPT ); Sun, 31 Jan 2016 07:32:42 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33900 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757278AbcAaMck (ORCPT ); Sun, 31 Jan 2016 07:32:40 -0500 From: Sergey Senozhatsky X-Google-Original-From: Sergey Senozhatsky To: Peter Hurley Cc: Byungchul Park , akpm@linux-foundation.org, mingo@kernel.org, linux-kernel@vger.kernel.org, akinobu.mita@gmail.com, jack@suse.cz, torvalds@linux-foundation.org, Sergey Senozhatsky , Sergey Senozhatsky Subject: [PATCH 2/3] printk: introduce reset_console_drivers() Date: Sun, 31 Jan 2016 21:33:42 +0900 Message-Id: <1454243623-15109-2-git-send-email-sergey.senozhatsky@gmail.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1454243623-15109-1-git-send-email-sergey.senozhatsky@gmail.com> References: <20160131123041.GA1306@swordfish> <1454243623-15109-1-git-send-email-sergey.senozhatsky@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Console driver(-s) can be in any state when CPU stop IPI arrives from panic() issued on another CPU, so console_flush_on_panic()->console_unlock() can call con->write() callback on a locked console driver. Introduce reset_console_drivers() that attempts to reset() every console in via a console driver specific ->reset() call. Invoke reset_console_drivers() from console_reset_on_panic(). WARNING ======= console_reset_on_panic() needs to be fixed. Not-Yet-Signed-off-by: Sergey Senozhatsky --- include/linux/console.h | 1 + kernel/printk/printk.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/include/linux/console.h b/include/linux/console.h index 6edc2ea..f745ffe 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -125,6 +125,7 @@ struct console { void (*unblank)(void); int (*setup)(struct console *, char *); int (*match)(struct console *, char *name, int idx, char *options); + void (*reset)(struct console *); short flags; short index; int cflag; diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 34642f7..e245f9f 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -1462,6 +1462,15 @@ static void call_console_drivers(int level, } } +static void reset_console_drivers(void) +{ + struct console *con; + + for_each_console(con) + if ((con->flags & CON_ENABLED) && con->reset) + con->reset(con); +} + /* * Zap console related locks when oopsing. * To leave time for slow consoles to print a full oops, @@ -2397,6 +2406,7 @@ void console_flush_on_panic(void) void console_reset_on_panic(void) { zap_locks(); + reset_console_drivers(); } /* -- 2.7.0