Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp637638pxx; Mon, 26 Oct 2020 17:41:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAKU3gmA7uvBsyaO36ixs3AKheLcOros2PvBlgr/lVtsMnzdP2BhaoAFxw7AAt9NP8k2ct X-Received: by 2002:aa7:c5c4:: with SMTP id h4mr18982892eds.379.1603759316753; Mon, 26 Oct 2020 17:41:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603759316; cv=none; d=google.com; s=arc-20160816; b=myxsjav/C5HTGi5vn15t1YFvDflksLbwqE0LfEHYKMjU9q6ew26KkgU0k579qFmayn NMorOaDTKAOzZAWbrZ7NEfq51HOEM0Q4uJZm7saZ9bc90xYxsz92+JxR2LyUgsGiMfH9 r7TJImm8nLlZ229KK62ykXktNH/YcKwLotJkRBfdfuZwxcH8FCOYxEcEesbhAs02vPup MZRjktpnWmHt0l0hnNSieiUeu//PDdL/VUKy2TmB0vc6RXAuP/ei+3d6CspMtk8Z/WCU VdFbvBHE/4E8cIAWDFjejoZr77+D4DwYS6us6e6UGIG++6v42tUGtU8hDXLFUBGyK//j /IYQ== 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=4IJMl4JY2v9hnZ6ZrCdQz/LpQcLsXYAXjldoYxb9euU=; b=P+etxo+R9JsbPLIqvp7tVQeGOoJXVZXvNkdT7ukFMgVrw+EYXx3BDHTPQhzoZS8KxP y+wyqg4Wsmqjh1Ibwn7VNgQ+QSI0VcOSMDLdNZfmw5u2Ul4lj4nS9lJrV/88bWxYHN0X G+WJxKTXb8fwXTUVBlF4m/MAk7I78OpskFUwqWgJGaGeJ5Sx/tpHEMb1xtwliWjiC2+z HekpttWeCSMoR7B7QTkOlyfNHg8Dtuj0C9GfxKxbLO5O5R16XcxuuUY1gok/2BDIO0+A OE2GBKgOoPQxHDbL5cto4hK4Gi/b3/16HtirWpRCLauCDuHml1sTw6owx/ccpiCezJ5o hsxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gG8KIu8f; 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 a19si8224427ejb.263.2020.10.26.17.41.34; Mon, 26 Oct 2020 17:41:56 -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=gG8KIu8f; 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 S2437639AbgJ0AVb (ORCPT + 99 others); Mon, 26 Oct 2020 20:21:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:34788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2410996AbgJZXzz (ORCPT ); Mon, 26 Oct 2020 19:55:55 -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 50B3220882; Mon, 26 Oct 2020 23:55:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756554; bh=KnBzctQEr+xtU5GkObVedVmESSPZw3mvX0j9hs7UELY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gG8KIu8f6E8x8+e/x4gMvGtLoPwqn5Rxf6VRg2cYR8OnYcTtyOP5+NCxAL8JkkXQx 1oP45L5EF+mOOnoG/U7jl+9sj7F0LTw0r2FXqFjvnmTg8GQRHWb6kuNE437FbLY7E2 WLw+as0CQD3/UbcMa4uos0OJhhpXMQmsernNxaLE= 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.4 31/80] kgdb: Make "kgdbcon" work properly with "kgdb_earlycon" Date: Mon, 26 Oct 2020 19:54:27 -0400 Message-Id: <20201026235516.1025100-31-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026235516.1025100-1-sashal@kernel.org> References: <20201026235516.1025100-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 2222f3225e53d..097ab02989f92 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -96,14 +96,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); @@ -876,6 +868,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