Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp772144rdb; Sun, 18 Feb 2024 10:59:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXg7ID7QArBH0kRamycnxOhonASf0bbCwwskv+qOSnERFiQZgu08c8r2r8Iqiv+Be63CZ89mlwU+zX9DZWb4SkXp5pmYeYM2KwVZ54eWg== X-Google-Smtp-Source: AGHT+IFdcAY5N/usWDonhOGTWuZ2XEmZazkB2BlOcIiCoLhqtJlA9Ra3aAkEz1z44S4X1jySy94v X-Received: by 2002:a17:906:4e8d:b0:a3e:8634:88d with SMTP id v13-20020a1709064e8d00b00a3e8634088dmr926543eju.64.1708282756239; Sun, 18 Feb 2024 10:59:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708282756; cv=pass; d=google.com; s=arc-20160816; b=GG63MK1xYoHhyX9bPqSt46oBi2sGuhMGSb1kmkZpHV8nGL9j1W1KUAAG/AG+a9NC7a bQQx56Rw5oEctJvCuSqSdcUE2CvY+8VY6855V01IZagF++w7B5tClmcVQj9KHA7wAbhP Ua10JpNsTrtpsIuHc7mlBbxqYMy+OcBbRnc+Zg8U3+wWK/E0eoQLzVT7ZDp34MBoR+wF JdilSmTe2Hc3jroMal1c3jmkpwvvXOQ2+QtpcE4gnpsH7RdDsj3JiGR9iUQ6ZhB7yWVS byCWaOAl3iVpf+QDSg5ik2zQZ58A8T295nn8/whlUvsnV06+Uerv59K6Nhled58R1i8r x8Ug== 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=n24MWmzqzOOOOZwEfqW/0eRQt3f3jgwSF64cWTce6J0=; fh=pKnPKUsir0uEGSsor+4Zc2vgbu+g+ayvUgsdzkuXaoA=; b=syLYlQN4lq5LirjzHcwG/+PznjIIpDmGos8qlEyG/NizvPEB7+RuvtF3RPMajhVSLf Y/nlIu+XirwI+h74b22Z77fso+uN57qhx8atPTb5UL+9LjI/J2C7qvBYi1XBtcvIC2K/ HMApUrhM3cWcHM7fyFVntYLcC6GFDyziSiL0hz38CIBUsrs4Yv1x7BjQdsafUZGMX0zM nhPg+9T1Gy9SoxMJBdBjob+DfbQUSMXVyGNOOUbNEsfNjKqBPyh607Tbg1qFYThhbtLW BibbqscVRaENHF6N2g5qEAEtXHL3bSNYwQT39mB+e8AJWq2Ngt0lPAHDWibbOaVQcwCd vcaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=QMSBU7jD; 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-70507-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70507-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id kl9-20020a170907994900b00a3d2e0d30fesi1737626ejc.658.2024.02.18.10.59.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 10:59:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70507-linux.lists.archive=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=QMSBU7jD; 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-70507-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70507-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 am.mirrors.kernel.org (Postfix) with ESMTPS id CBA961F22A9E for ; Sun, 18 Feb 2024 18:59:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5DC7E7319C; Sun, 18 Feb 2024 18:57:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="QMSBU7jD"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Y+6u7iXO" 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 B37606F09F for ; Sun, 18 Feb 2024 18:57:53 +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=1708282675; cv=none; b=dcVoXcTLsiI0pCnIrd1jBsohAEkEfIfI4+L5IZ9PdOpQ+v+XHY2FQbmWdm2PJVPHzzOdfFNBpaFDo85UFWEWQEUJ271725C638SbUrLART7jGaP1syYn58bTBdMgBvbuz/tQjlzs2pitC14QJ4avMMCIJQ+uXo6QKWmk5j2ITmU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708282675; c=relaxed/simple; bh=Gn+uo9q8su4/qFeCC4JeId6lrhn6gSNTkrfRmi156Nw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZTySrhhER/jtyP0qo2schzyNrPGMWwf59Lftqb7SJ1vv61+KKTqNemRmGjzXAi8TFjs1lg0f7r9Wx2Fv8WF7ecpil3m4NIYg7QvDxCY5rKMlNqM8vmOGJ8kERzo7UTXVbMpl8j88TLGZ/72Pkqk05b2BB9GM7OBjdsQSVbbhuBg= 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=QMSBU7jD; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Y+6u7iXO; 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=1708282672; 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=n24MWmzqzOOOOZwEfqW/0eRQt3f3jgwSF64cWTce6J0=; b=QMSBU7jD94Yh/o3DcWTZjh0a8JGG9Yx9WNZg5k4O77UQ4qID8e+4cRj1MXJ3SVvOAmVn2/ h2OKdZDfsKW916dakuJrYuN8Y3JU/PeeaGWdkRV/DNOoyrO1GZcHFOFGjRRPpxmAQtqwG+ Ewg+eeiAXtrsH5wjUJmkovot03PxpfwzMmJaE+Dq99ru3fkcTZgAtlnTbcXrnlgdR2iZ/T JwSdJL8smlJrWZc4SL7jk+c8UTfaTaswB08nQdr5MjdYXm7qxU1ooTR9SchSIR+StZT7xx Pw9TdcOnef41ejCiw9jH+vbIcdc7QkmT6p6JpXFPkBRSFwzjl8EF9vT9UrVZwQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708282672; 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=n24MWmzqzOOOOZwEfqW/0eRQt3f3jgwSF64cWTce6J0=; b=Y+6u7iXOgtAwwO99mk362rIMqX3U2eCm3OiQleJuLdrhHEE5dahThYSucQl6FvoXuqDPcY 9Y+H+7HsP4PVEvBQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v2 11/26] printk: Make console_is_usable() available to nbcon Date: Sun, 18 Feb 2024 20:03:11 +0106 Message-Id: <20240218185726.1994771-12-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 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 6c2afee5ef62..6e8c1b02adae 100644 --- a/kernel/printk/internal.h +++ b/kernel/printk/internal.h @@ -78,6 +78,36 @@ bool nbcon_alloc(struct console *con); void nbcon_init(struct console *con); 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 @@ -99,6 +129,8 @@ static inline bool nbcon_alloc(struct console *con) { return false; } static inline void nbcon_init(struct console *con) { } 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 b75ca383683d..ecb50590815c 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2694,36 +2694,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