From patchwork Sun Feb 18 18:57:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 202843 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp912035dyc; Sun, 18 Feb 2024 11:00:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWkY5eiQuX2xhVnHWk0TF1o7vTaDpXUQCT+HGGx9Q18LQBKkpO0F689y6pwLqesgmIrZ1uodBsLFx+085fyVN0muaG4Sg== X-Google-Smtp-Source: AGHT+IECctD7aJMlHjzzWqkRaQCsz72zRCVADQc52TlW95UZ9uQMyVEwF8g9IirdbhVBWKWPUHds X-Received: by 2002:a17:902:f78e:b0:1db:92e1:2e50 with SMTP id q14-20020a170902f78e00b001db92e12e50mr12331907pln.43.1708282839053; Sun, 18 Feb 2024 11:00:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708282839; cv=pass; d=google.com; s=arc-20160816; b=yx1CPZgZt16xGmbhWYdoDFwdMwULQgPnlS+SKeqikkKzb+GRt2+JK6ccruJMKzT01b J7A8lyg7LQ9ynwXgrnT/3rqFJ9/D8IB769ANP7+2JhqYXOfaJ8Yc1HKk9vFJi64L3SPo 9VgHT3N9Nk3nS7diVRcxJdo+1G2PmCk0XI492IWuAfOp1FpF+Fa7hyoj3Z0riSQ7h3L3 0iJsWebtJr2mY99z8M0pFzGs8EmgU6NeMVb0Wx/Q8CefB3PsJLPob3CdzS7ShW52I1gJ hXCR10UEn4UEe2w4ScjE3GXzgRQa7t+zG0NJRYA7JQeLOXjXOkXLbNGGhx8TFEnW14Rk /E1g== 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 header.b=Y+6u7iXO; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70507-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id iz14-20020a170902ef8e00b001d9fcd34721si3215933plb.119.2024.02.18.11.00.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 11:00:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70507-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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 header.b=Y+6u7iXO; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70507-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 74567B20F59 for ; Sun, 18 Feb 2024 19:00:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB99276037; Sun, 18 Feb 2024 18:58:00 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791264385908043494 X-GMAIL-MSGID: 1791264385908043494 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;