From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EED1C4363A for ; Tue, 27 Oct 2020 00:12:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 26CBB20709 for ; Tue, 27 Oct 2020 00:12:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603757537; bh=pBOUouxRazNOA/2s+89q6iNjjXLS8Dm04ufAMoxfdlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=wkkLZogwSHhgfPlO5U5FZXFdb9vld80myPEAtzwfgt8olo6DtOiwnNhwy5cPrZTqZ 8icsIm3ckCXM+JdZhMQqNQQP09C8RFBKBo+gEdr++baf3gRXO8dWA0jxxmbTmDfvB2 qd8QBe7wrqHaZLfVs5gbepg55W3elIHC4tvGZ1do= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439307AbgJ0AMP (ORCPT ); Mon, 26 Oct 2020 20:12:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:33160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2411783AbgJ0ALh (ORCPT ); Mon, 26 Oct 2020 20:11:37 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 05B952087C; Tue, 27 Oct 2020 00:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603757496; bh=pBOUouxRazNOA/2s+89q6iNjjXLS8Dm04ufAMoxfdlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uhND1EJfoBgZzloGeJ4feJybfsiGmlRzuYg55RFkGQfXE7XuiFJcdaVzHbTQ1iqv/ 7EqeYPkxL8jisShlwTUvHfnRwKAxg3tgcbyOKslQGesiKraY2DK7/5agWiWBcSyNky duO1gXmfUOZYtXoyyADgykwKi3ezUMxb/mo0++5E= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Douglas Anderson , Daniel Thompson , Sasha Levin , kgdb-bugreport@lists.sourceforge.net Subject: [PATCH AUTOSEL 4.4 10/25] kgdb: Make "kgdbcon" work properly with "kgdb_earlycon" Date: Mon, 26 Oct 2020 20:11:08 -0400 Message-Id: <20201027001123.1027642-10-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201027001123.1027642-1-sashal@kernel.org> References: <20201027001123.1027642-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Douglas Anderson [ Upstream commit b18b099e04f450cdc77bec72acefcde7042bd1f3 ] On my system the kernel processes the "kgdb_earlycon" parameter before the "kgdbcon" parameter. When we setup "kgdb_earlycon" we'll end up in kgdb_register_callbacks() and "kgdb_use_con" won't have been set yet so we'll never get around to starting "kgdbcon". Let's remedy this by detecting that the IO module was already registered when setting "kgdb_use_con" and registering the console then. As part of this, to avoid pre-declaring things, move the handling of the "kgdbcon" further down in the file. Signed-off-by: Douglas Anderson Link: https://lore.kernel.org/r/20200630151422.1.I4aa062751ff5e281f5116655c976dff545c09a46@changeid Signed-off-by: Daniel Thompson Signed-off-by: Sasha Levin --- kernel/debug/debug_core.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 321ccdbb73649..bc791cec58e63 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -94,14 +94,6 @@ int dbg_switch_cpu; /* Use kdb or gdbserver mode */ int dbg_kdb_mode = 1; -static int __init opt_kgdb_con(char *str) -{ - kgdb_use_con = 1; - return 0; -} - -early_param("kgdbcon", opt_kgdb_con); - module_param(kgdb_use_con, int, 0644); module_param(kgdbreboot, int, 0644); @@ -811,6 +803,20 @@ static struct console kgdbcons = { .index = -1, }; +static int __init opt_kgdb_con(char *str) +{ + kgdb_use_con = 1; + + if (kgdb_io_module_registered && !kgdb_con_registered) { + register_console(&kgdbcons); + kgdb_con_registered = 1; + } + + return 0; +} + +early_param("kgdbcon", opt_kgdb_con); + #ifdef CONFIG_MAGIC_SYSRQ static void sysrq_handle_dbg(int key) { -- 2.25.1