Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5465203rdb; Sat, 16 Sep 2023 20:00:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEL3p8ypgaEa/7d4ozclqeXPAjXlan0gNLcHWQj1Abztl1ibd8jxP3ZIfhb3u75K3R6W1KY X-Received: by 2002:a17:90a:2ac9:b0:26f:392f:f901 with SMTP id i9-20020a17090a2ac900b0026f392ff901mr7122191pjg.14.1694919641819; Sat, 16 Sep 2023 20:00:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694919641; cv=none; d=google.com; s=arc-20160816; b=0LFA3Abb3A6zl6SZBs3K5TQbmWfk9Xfkh6co1Oj8w50cbDx2hOo0X7jeaU/9l4OBZI rTShib76O7dDsHRHXYGj9CyTdLguCUAzAav3Fh6kKli8p/ZG/rnNEOs28qJheT+ujnmB HDASUf6k8qPk/f6aCqN8jAcXCgv/xTtFiLaSbo2Wbj0laQFYUwpPhb5nI7hmnd1u9Wf4 K7+a0JNfiqCsGQybl+mAr6+MrRfDQckcYWF5jDlNrx5MQDRVlQPBOmYprDBavC3dbtma f/WxfkETYB2713FJPbHdtuIAAPimf0fQgbuOscCKrDDJGSPcgKxVtxZ1Y/OUXxzTpXXr jrBg== 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:dkim-signature :dkim-signature:from; bh=jNeRpVHG0OdM83PrKLG+UdCmA4Kb+afHXFf5PMIQJM4=; fh=pKnPKUsir0uEGSsor+4Zc2vgbu+g+ayvUgsdzkuXaoA=; b=yOxfzDuluh7CUszGcBdi3S0e8yayZmKAZRZvGN1Z9DUEc+vwoE+9hYb9LcXZWMV04m /1lkZUrN3mhSdkplN/cLMFCq3cmuJirJ2Kau76NyW7PSdcB/KdMLE4IGw01c9+r1VYsZ Xri3tEvqEUzpefoH7WQRTH+OYKCFW07cvbZ8xuFbRTEGknDWVQO+5vg10aojYsqSad+S FRd9nWNntmkmoR+mGrPrffWt/T41Z82hxYnD/4UFlY10OycOPu2Bmqy/eLOUyf/PZ6mD KR8OQDz6TXFtoxO2GGTRc3TktG8AZ3RqFvbC2RiRhhE+ngSOib5lrfd+xvn2ImtWXJ6n slvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=gCYaR4mw; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="S/EO2UAW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id bs123-20020a632881000000b0057408ac52aasi3910028pgb.381.2023.09.16.20.00.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 20:00:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=gCYaR4mw; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="S/EO2UAW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 82BB083C82E2; Sat, 16 Sep 2023 12:21:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236056AbjIPTUs (ORCPT + 99 others); Sat, 16 Sep 2023 15:20:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233268AbjIPTUV (ORCPT ); Sat, 16 Sep 2023 15:20:21 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDA48139 for ; Sat, 16 Sep 2023 12:20:15 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694892014; 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=jNeRpVHG0OdM83PrKLG+UdCmA4Kb+afHXFf5PMIQJM4=; b=gCYaR4mw1DXja+pAMA92dMbugAw9SHgAKPc2kYUM25FN1CZEqzwusMNJr93nQiL6IeE0IX MoeeuVgNvWN0iRsq3Z5h+/zhpmrconWi966MoyDVIpwYKG0XXpmoDsaKm1W31N4PoZ2F79 TX3fthiVRR3A4rodfrJv/MUQLCyEd0qUTTXr8BSxasGwrA6v4ccNh5f7P3HvVVJtVxxtk3 +jE6MglwAlNMTlNtrhu8V3wYP9FjHUnEFpXOHXlsNfSWUlzDMXecPDFVe/aQKtkrDMIx/k cDNkPKKBX0Py7uschF8NXAo7uXZvJrOTd0NCFyZCQsYrwiXJ2XAeei1unhiNlg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694892014; 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=jNeRpVHG0OdM83PrKLG+UdCmA4Kb+afHXFf5PMIQJM4=; b=S/EO2UAWeoajmNz66txZA9K2MtJwOo6svmZtAgn7nGmF20OaZmyszh/K/hi6gnIPn/fo+c 8n825voFp3YN+vBw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v5 3/8] printk: Make static printk buffers available to nbcon Date: Sat, 16 Sep 2023 21:26:02 +0206 Message-Id: <20230916192007.608398-4-john.ogness@linutronix.de> In-Reply-To: <20230916192007.608398-1-john.ogness@linutronix.de> References: <20230916192007.608398-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INVALID_DATE_TZ_ABSURD, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sat, 16 Sep 2023 12:21:44 -0700 (PDT) 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) { } #endif /* CONFIG_PRINTK */ +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 5f372eaceb29..17def3791bc0 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2846,6 +2846,13 @@ static bool printk_get_next_message(struct printk_message *pmsg, u64 seq, return true; } +/* + * 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. @@ -2863,12 +2870,10 @@ static bool printk_get_next_message(struct printk_message *pmsg, u64 seq, */ static bool console_emit_next_record(struct console *con, bool *handover, int cookie) { - static struct printk_buffers pbufs; - bool is_extended = console_srcu_read_flags(con) & CON_EXTENDED; - char *outbuf = &pbufs.outbuf[0]; + char *outbuf = &printk_shared_pbufs.outbuf[0]; struct printk_message pmsg = { - .pbufs = &pbufs, + .pbufs = &printk_shared_pbufs, }; unsigned long flags; -- 2.39.2