From nobody Fri Dec 19 04:01:59 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 200D0EEB562 for ; Fri, 8 Sep 2023 18:51:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241385AbjIHSvy (ORCPT ); Fri, 8 Sep 2023 14:51:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbjIHSvx (ORCPT ); Fri, 8 Sep 2023 14:51:53 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EB9C19BC for ; Fri, 8 Sep 2023 11:51:18 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694199012; 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=ZN61Yy4XSz9CP6DFAbMX5JI5My6PbyQNjYXE4FEmNGo=; b=YHEupqhklhm8R/QAhZK9ScmnErHg9LEyYAlTnnnN90vZPgN7SpKF3fGxOZbF5trtDarXVZ +1r2oxC4p3ICWejXGwxTwZpktKFhDORm2TVsya4vh8FfSPaRI3BQg2IasV5YmIoe12MrSU NvnoSUtq0wPu0aiXSIs+RfQO92nF6MloFcrgcZKvLPh0Xg7yMx7D/JleiOv93K4iSIoDcA 5kTC3hJ7FZLiS1e4SvIypSBx+7Qt+xDKTFTaZwLb3zl4G/nUbACiy4ozu8j3TVHfMaUVVy eOMj2/hLWFaZEihcVBIdg9kVj9l9/fIs+fx0iNe/ubtz/Akbt5xwJrk2zN3TcA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694199012; 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=ZN61Yy4XSz9CP6DFAbMX5JI5My6PbyQNjYXE4FEmNGo=; b=31OH1/qaNXMWm4TVF2X5SrE+xp20PFUhRf6u6fh4PARwj8J/3eg4/E6ipgCWHgPFIxLdVZ 3gstFOM77rUx0LDw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v4 3/8] printk: Make static printk buffers available to nbcon Date: Fri, 8 Sep 2023 20:56:03 +0206 Message-Id: <20230908185008.468566-4-john.ogness@linutronix.de> In-Reply-To: <20230908185008.468566-1-john.ogness@linutronix.de> References: <20230908185008.468566-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The nbcon boot consoles also need printk buffers that are available very early. Since the nbcon boot consoles will also be serialized by the console_lock, they can use the same static printk buffers that the legacy consoles are using. Make the legacy static printk buffers available outside of printk.c so they can be used by nbcon.c. Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- kernel/printk/internal.h | 2 ++ kernel/printk/printk.c | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h index 2ca0ab78802c..7199d60bfc25 100644 --- a/kernel/printk/internal.h +++ b/kernel/printk/internal.h @@ -86,6 +86,8 @@ static inline void nbcon_cleanup(struct console *con) { } =20 #endif /* CONFIG_PRINTK */ =20 +extern struct printk_buffers printk_shared_pbufs; + /** * struct printk_buffers - Buffers to read/format/output printk messages. * @outbuf: After formatting, contains text to output. diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index c0246093ea41..9a2ddab16abe 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2844,6 +2844,13 @@ static bool printk_get_next_message(struct printk_me= ssage *pmsg, u64 seq, return true; } =20 +/* + * Used as the printk buffers for non-panic, serialized console printing. + * This is for legacy (!CON_NBCON) as well as all boot (CON_BOOT) consoles. + * Its usage requires the console_lock held. + */ +struct printk_buffers printk_shared_pbufs; + /* * Print one record for the given console. The record printed is whatever * record is the next available record for the given console. @@ -2861,12 +2868,10 @@ static bool printk_get_next_message(struct printk_m= essage *pmsg, u64 seq, */ static bool console_emit_next_record(struct console *con, bool *handover, = int cookie) { - static struct printk_buffers pbufs; - bool is_extended =3D console_srcu_read_flags(con) & CON_EXTENDED; - char *outbuf =3D &pbufs.outbuf[0]; + char *outbuf =3D &printk_shared_pbufs.outbuf[0]; struct printk_message pmsg =3D { - .pbufs =3D &pbufs, + .pbufs =3D &printk_shared_pbufs, }; unsigned long flags; =20 --=20 2.39.2