Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1877052lqb; Sun, 26 May 2024 23:41:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVLtNCjm3mP+6nHgy6VO3hGPBPKnxaRTVqejCt4CYvbdVEF3K/7GeR/LfVS8ZUy7TK32FzYY4o7HU8kbQPzW/8CKVZzkY6epajp/xV8+g== X-Google-Smtp-Source: AGHT+IGOfxAERw/aseZND7A6/Yw+I2rhNSw2ANTclcHZsDBg2mDky+HN7UPqiD658QO6LVZPFfpB X-Received: by 2002:a05:6a00:4390:b0:6f4:9fc7:daf2 with SMTP id d2e1a72fcca58-6f8f2c56b72mr9055879b3a.7.1716792109155; Sun, 26 May 2024 23:41:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716792109; cv=pass; d=google.com; s=arc-20160816; b=H9RGAiTeajA3Uz1eOpR22R1Vfm3oafRIDW81az5RuEj5QCWf4TmV1nQVkKZTS9XNZa r6ESrzGiXQESGa2dNetKsYk6TIguwYzd1YBHFmZcpTXDz3P/WdHD55+DHKNvNEuTZhg6 PifYuLlhYKFLqb+W5a9A+e4WVVTThLLnPZmcETNYdBYyLGxOZvc252ogqpOg7lK6KKDE Re/GyxA8PYxKVKhcYw13wBvGKvvU1hQ9jmrS8wC8eWhoqRYqJOVBrUPwXo58mnUzM59U HMbP+0PeOFK+GuFV5tknqpLITwP6d8TPq/RCB/vj1XM0ERpUbnR9e5GdUj/sKuk9EQ+E s24Q== 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=vAfJ0/ArpyBrKdvlxG2JN5Vl00RCt4dDRQpqktRYYBg=; fh=pKnPKUsir0uEGSsor+4Zc2vgbu+g+ayvUgsdzkuXaoA=; b=yVNLxvB6oAlzOejDrBvp9nYQEEkyV9e1rbG0407/DZQrMWfCyciMsCjCTaxh2ILKz/ 8zmN5VNFNspeAO7k42Fuu1R1G2fTVgqzRKDn/RWn7yvj7E0vngG99QJvAc/tBlc7jMN9 pQN+of/c3GOsrgJFL/EXlFs8Ng/7jJhuAvwA3y9hPJQYiWIBp49MLYhhqMgucU1xXTL9 PXpudpBhSXeAvLd2zaLGdfO6Uc9tVd1tUKnhvU33mEm9NU4HPCSQjTPf/NZw0BqP/H1p vJC4Mff/B60xwcrCqLvMsCkVBtzvnjghfH0eCc/pM6OGMUG1h5TEuLMVO/1ubWk+/BMS kDpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=GHuqOGJW; 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-190090-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190090-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-682275b2af2si5928362a12.355.2024.05.26.23.41.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 23:41:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190090-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=GHuqOGJW; 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-190090-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190090-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 508142825C2 for ; Mon, 27 May 2024 06:41:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94E3413AD0A; Mon, 27 May 2024 06:38:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="GHuqOGJW"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="NK4ijYFW" 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 1676E4594D for ; Mon, 27 May 2024 06:38:24 +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=1716791907; cv=none; b=ues1e2eJWLxFI7abIm6LkQUZCbynKfXfsVdQhw2xyictFrnXtn8xTT+Gi0PqSZPnRbZGMInkX436S+6JhfdRCx3jfpJQ4SSRMTS4FbwSbCAmIkaOQ921s1o/XkFGeU06u4bKrIYnhM5zKncFSEjHiZ4dJ1fPXoZPLVb3i/OfbGE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716791907; c=relaxed/simple; bh=4TqYg9C9M7bVyQVBRTlOYVbfQwj4hBnVKOPQn39lBzI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KS1kc8RT9Lhfx9ILfIvXhJWvzSbECPHS/6mcYgCmqsBwx5ON2BRFli+B7u2oEqCoLOuBK9OqSuTpRiFwajvb1cSXhq1KprPfhR5DTAXCDBnP7+1Mj/xgBy+6v6PW6XSlP6bZZLuKRgv4RBk4ejiIjA/aQWJwvOQDF/2srs9TmVU= 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=GHuqOGJW; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=NK4ijYFW; 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=1716791902; 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=vAfJ0/ArpyBrKdvlxG2JN5Vl00RCt4dDRQpqktRYYBg=; b=GHuqOGJWM0mKftTjKcJZFWer07OfurTQzkE2xHi9zx93nnmXVS4hW7PfaXl07TmhDxWjXc lMPDWaSCycf9iIbsh3/lZ+NN5cCuUWKXpqBW49osTb3gffPbTNA0aARqoHAPTyvgvZ+Gqr eoVCxn7oQV4xsOszXIT/qQa2HKhILG3YPcM/8xp3aTwzs9CZvVSSV9FM6AQkcZBc7ugqMH FYBOSqhjIspUcyMpmZV3qnEu51WqN3zmNv88SdPN21dhsBxwDrkN/uuYYpFtG1+7QKzZL7 zT+iqgZ9+AAj2icfNMIHX/z8trqf/8D4W7U3uko3qU5UIBwq6zczM9tdwwtRJg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1716791902; 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=vAfJ0/ArpyBrKdvlxG2JN5Vl00RCt4dDRQpqktRYYBg=; b=NK4ijYFWANDnGQrJZ+jdRFOKCqDon2eMqGJl5Vzuj6lF3XPUvJ2r4BvTb7q2eQNhQJK3HF lhCY06fcUasuigAg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v6 15/30] printk: Make console_is_usable() available to nbcon Date: Mon, 27 May 2024 08:43:34 +0206 Message-Id: <20240527063749.391035-16-john.ogness@linutronix.de> In-Reply-To: <20240527063749.391035-1-john.ogness@linutronix.de> References: <20240527063749.391035-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 Content-Transfer-Encoding: 8bit Move console_is_usable() as-is into internal.h so that it can be used by nbcon printing functions as well. Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- kernel/printk/internal.h | 32 ++++++++++++++++++++++++++++++++ kernel/printk/printk.c | 30 ------------------------------ 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h index 6c1d01eabf3b..339563dd60bb 100644 --- a/kernel/printk/internal.h +++ b/kernel/printk/internal.h @@ -85,6 +85,36 @@ bool nbcon_alloc(struct console *con); void nbcon_init(struct console *con, u64 init_seq); void nbcon_free(struct console *con); +/* + * Check if the given console is currently capable and allowed to print + * records. + * + * Requires the console_srcu_read_lock. + */ +static inline bool console_is_usable(struct console *con) +{ + short flags = console_srcu_read_flags(con); + + if (!(flags & CON_ENABLED)) + return false; + + if ((flags & CON_SUSPENDED)) + return false; + + if (!con->write) + return false; + + /* + * Console drivers may assume that per-cpu resources have been + * allocated. So unless they're explicitly marked as being able to + * cope (CON_ANYTIME) don't call them until this CPU is officially up. + */ + if (!cpu_online(raw_smp_processor_id()) && !(flags & CON_ANYTIME)) + return false; + + return true; +} + #else #define PRINTK_PREFIX_MAX 0 @@ -106,6 +136,8 @@ static inline bool nbcon_alloc(struct console *con) { return false; } static inline void nbcon_init(struct console *con, u64 init_seq) { } static inline void nbcon_free(struct console *con) { } +static inline bool console_is_usable(struct console *con) { return false; } + #endif /* CONFIG_PRINTK */ extern struct printk_buffers printk_shared_pbufs; diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 75f64efaa53c..3947702b7977 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2697,36 +2697,6 @@ int is_console_locked(void) } EXPORT_SYMBOL(is_console_locked); -/* - * Check if the given console is currently capable and allowed to print - * records. - * - * Requires the console_srcu_read_lock. - */ -static inline bool console_is_usable(struct console *con) -{ - short flags = console_srcu_read_flags(con); - - if (!(flags & CON_ENABLED)) - return false; - - if ((flags & CON_SUSPENDED)) - return false; - - if (!con->write) - return false; - - /* - * Console drivers may assume that per-cpu resources have been - * allocated. So unless they're explicitly marked as being able to - * cope (CON_ANYTIME) don't call them until this CPU is officially up. - */ - if (!cpu_online(raw_smp_processor_id()) && !(flags & CON_ANYTIME)) - return false; - - return true; -} - static void __console_unlock(void) { console_locked = 0; -- 2.39.2