Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp860203pxx; Tue, 27 Oct 2020 02:10:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmDHfatAsTgP8cHanQvVZn5sR/D2evojO8tHu1fzfWcgUSfNcxGIqUUFXUqF7dmEh9fvn+ X-Received: by 2002:a17:906:b24c:: with SMTP id ce12mr1361712ejb.386.1603789854007; Tue, 27 Oct 2020 02:10:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603789853; cv=none; d=google.com; s=arc-20160816; b=EshJi5W3APR1C1c1MlMOp9ihhgIfRMua6jscxb8f673HdIG+bf2buy0lI2byfHw0Nr cbZBIWOhbyX+Thp2T2tzaYy+McfyMWW25dM1hdbz6jx6sy41OJ+aZHnkX7A17KuCyqSP 1wW5Wz1jXJyxcBbdldEejw0PwGFLE0B/wdq6QihZ6ElMxArIoG8FmH3l3QIuO7vbddnQ 33AmSRk4rAOzGcV0acvYJeDbCm+6Aizou5aOeQOozc2mQ1RkwROrXTel81rz0sH/HlZx ujwVmIouY3aPvJVqgoxbwwo+zBXBO4zsmdnPoA+1HE+NHNRsgvaI0Ble0dUy4ThrZ3k7 Yffw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1gwSjcVFQQVpov2V1NGZq/fX0s/e+BFlIFBepLprVYs=; b=yBD/n+eZikUuJ3hro/qzSyvotVC4/+6SE3yoyOJrYnULG0nQx0XoDMN22lAUUX3Dju J0qTH0qLi0Qys7kUWgcqNzjYB3Knhn7ijtOGDYfWSkcZU8XMuTCeZosTFn7WUstSUOye kgdzmYdExX2KlOvV8iQdd5MQ09PRODzHVLYVk9ZE2TTZZkidoqUVFk/myK1pTPxQEuII W0wL7yunfuzJp66ByOZ5cpjWQeLJ0aqH7o3wRWbY9BTEceoFwyBflaFcR4SFSti695sS HkL8QsetME5skOq5mwQt0Ya/t6Tb02SEsyj1/vOUZohD0bCV8q2z3AUdmzfs1AmSFQGF y0ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NK+LFwWP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 11si544830ejv.311.2020.10.27.02.10.31; Tue, 27 Oct 2020 02:10:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NK+LFwWP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2409220AbgJZXuw (ORCPT + 99 others); Mon, 26 Oct 2020 19:50:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:49604 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409087AbgJZXuT (ORCPT ); Mon, 26 Oct 2020 19:50:19 -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 7E0C420878; Mon, 26 Oct 2020 23:50:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756219; bh=w3JkVNCIRSKrBRbmcS4UCLqmpO6rnt5fDhHhUT7MU18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NK+LFwWPPgBnJphHsKzhj9SjJcujNIS4pgXRs6IQzrtu2vOeORVZ/uJzRclsvlCV9 PeJheW4w6/jsOF9mWtnRg1yEAh22JT5nbRaDca/TYN9+o7vAI3xjrGuxwcn0w3ynye oGCb8Z+vFRQGvHovZVyRfLdBCFW7gdOduYLs6uLk= 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 5.9 059/147] kgdb: Make "kgdbcon" work properly with "kgdb_earlycon" Date: Mon, 26 Oct 2020 19:47:37 -0400 Message-Id: <20201026234905.1022767-59-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026234905.1022767-1-sashal@kernel.org> References: <20201026234905.1022767-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 b16dbc1bf0567..404d6d47a11da 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); @@ -920,6 +912,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