From patchwork Sun Feb 18 18:57:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 202848 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp912682dyc; Sun, 18 Feb 2024 11:01:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXMNi4GW4bQIVuhRAw7hqx1bXVGpmnauLDWRiytbOKwdrJLOJ8OD+Njl7Hc6E9YOJpwtx+xYIEGnt7Rz7BQt9QXoFRuig== X-Google-Smtp-Source: AGHT+IFh5Vm21LgFubVuWjFoHUMl4vYGbS8cGX3/8M8BZYoi8QG5hJeegvucRwo0TD8i7s6V7lxe X-Received: by 2002:a17:906:4a10:b0:a3e:8bd8:b711 with SMTP id w16-20020a1709064a1000b00a3e8bd8b711mr823353eju.37.1708282908203; Sun, 18 Feb 2024 11:01:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708282908; cv=pass; d=google.com; s=arc-20160816; b=QyEo7LtJq4Yn2uH76xveM2U2oA8bQqC/X+jfCyFegCkz3NYsWttiwO4gKT2BJBqKGa DAVKI+BMcrkRMr1bDQ4E5BSShAdLqjqd3E3nl78MCtTmck1PunpwCRG+eWfgSR7gCS/2 N2PztAaGP5MKdmMOlVlZ8x8G6mgl/SS7Wyoaxt3oc3KWnd7s832BfbSogMwcondZwrtK fbnbUmQOj4pVsnXRfswGlic3biEhZxydxgCoBrkp4pA0+xZnM+aMBDdnmNW1nyKtXOU5 gnthNhzhLSlAny9bL2jGwHkNRYzytWqqZo0vXcBi0t5uFHjBRAQtTuJ5g1w0YlwUy143 gHrw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:dkim-signature:dkim-signature:from; bh=5fJ6yqWdSDvmc7d434BHASreaek3tLpIi1BkLTUqxi8=; fh=pKnPKUsir0uEGSsor+4Zc2vgbu+g+ayvUgsdzkuXaoA=; b=aALzvLiynOp9y7MZXATBpo290Zc+/KXCv+vaAKUFtA+Kuwd6R6lsX76kfpG814xShn fa+fHlOctgT6+Kd5MoYD5XvCI3JKnL0VtBAn2860lF/vnmq9vfPhbJDXN1aDjYE69AxR 9xezVstXgpn3gJW9XfEzHNyKlfQlfxmlng+r1Chgdt96ZuHfPuBGDLVDVK1hDR7pQTHU sqcPJ8reNNmutGQ4YKm6lgboKGqhzSlkrjGKnC2zVG+qjxPRClkHKraBhfO+Sv5Ec6v2 RDkbt6C0n5a/n3ouSru0yVP1Bwiu/aJJXrPnoBIBVk3CdeBg6PU4ksMX2Nq483uV5cG4 T33g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kipOVu39; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-70512-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70512-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g16-20020a1709067c5000b00a3e69ff13bdsi736103ejp.854.2024.02.18.11.01.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 11:01:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70512-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kipOVu39; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-70512-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70512-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9ECE41F21097 for ; Sun, 18 Feb 2024 19:01:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9303768E5; Sun, 18 Feb 2024 18:58:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="kipOVu39"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="zcuQRKgf" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53A3371B45 for ; Sun, 18 Feb 2024 18:57:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708282678; cv=none; b=Bg/vGaOrKCNhSMJ2HEMBNBcVoKU6OpMxpmcc+diADPFoN/4om3Wbh7NhiJsd/n50Kmgrkb0gEL5uUWCP021BM9kY0QoJO/gqwIhIrk+ldpMVPB7TzQTGA3b4tyYPEwVDdvbCynKj5/wctxvUXAJZ/66z0uTGEHn+ZojTKFwEKIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708282678; c=relaxed/simple; bh=QdXwnt6+PhX0aD+AlOZp4u+/7nviebzBO5H0/vlodlw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Oslzbae/biHzS/wfmzj74Fj8vOEaCia7Thx97rh2mEVhNKp3y1gdo7c7/hVAKF5zT47thNzWKYKIXAYQcSycRp34BNIVaykEBp//W0l2IcfY1TCJW1/wH66ZmmP1fwwy/YZ4dyNjmZ52IwNGglkEz4cQTNJZOQI+xqVPydW4cMk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=kipOVu39; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=zcuQRKgf; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708282674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5fJ6yqWdSDvmc7d434BHASreaek3tLpIi1BkLTUqxi8=; b=kipOVu39ofseUoqPTQoCnM23+6kBri5ZY2eBYwv/o+FNAIZUzfw4DtLwp8jDymOfwfi2Pe 4hma6CyBwf2rY4nROH7z1tKEDIcig9XMyk0V+3kCWjCIev9z7q94K6jKZEwgEmANmkgtQ0 bS/5Lwdwmv2ns+NDsy19ux3NkvtqWruYfwTMeQjERAbsIcJigtdYrR0Y4hkaiA3YjLIUsO DUJlz+LqYzQ/w3nKk53Hx1EoymeoDaYPowaeN/AJn1sJwzWPYuKlX5k+OChheaPDPp6VLV 3SHQCtyqROdOxNvNM5LBsbIUXqd54/bZq1/bqjvyzP+MWwhrSn66ePh15T16OA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708282674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5fJ6yqWdSDvmc7d434BHASreaek3tLpIi1BkLTUqxi8=; b=zcuQRKgfxpNNB2OuJJiAlo1opLefEjxr6MexZJu4AsBTFQoMR2c3u1HnqC6qtG9R/LOa+M kOMUfgdZJyWjKTAQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v2 20/26] printk: Track nbcon consoles Date: Sun, 18 Feb 2024 20:03:20 +0106 Message-Id: <20240218185726.1994771-21-john.ogness@linutronix.de> In-Reply-To: <20240218185726.1994771-1-john.ogness@linutronix.de> References: <20240218185726.1994771-1-john.ogness@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791264458752703329 X-GMAIL-MSGID: 1791264458752703329 Add a global flag @have_nbcon_console to identify if any nbcon consoles are registered. This will be used in follow-up commits to preserve legacy behavior when no nbcon consoles are registered. Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- kernel/printk/printk.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 336dad179b99..2c4ab717c110 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -470,6 +470,13 @@ static DEFINE_MUTEX(syslog_lock); */ bool have_legacy_console; +/* + * Specifies if an nbcon console is registered. If nbcon consoles are present, + * synchronous printing of legacy consoles will not occur during panic until + * the backtrace has been stored to the ringbuffer. + */ +static bool have_nbcon_console; + /* * Specifies if a boot console is registered. If boot consoles are present, * nbcon consoles cannot print simultaneously and must be synchronized by @@ -3522,6 +3529,7 @@ void register_console(struct console *newcon) console_init_seq(newcon, bootcon_registered); if (newcon->flags & CON_NBCON) { + have_nbcon_console = true; nbcon_init(newcon); } else { have_legacy_console = true; @@ -3583,6 +3591,7 @@ EXPORT_SYMBOL(register_console); static int unregister_console_locked(struct console *console) { bool found_legacy_con = false; + bool found_nbcon_con = false; bool found_boot_con = false; struct console *c; int res; @@ -3639,13 +3648,18 @@ static int unregister_console_locked(struct console *console) for_each_console(c) { if (c->flags & CON_BOOT) found_boot_con = true; - if (!(c->flags & CON_NBCON)) + + if (c->flags & CON_NBCON) + found_nbcon_con = true; + else found_legacy_con = true; } if (!found_boot_con) have_boot_console = false; if (!found_legacy_con) have_legacy_console = false; + if (!found_nbcon_con) + have_nbcon_console = false; return res; }