From nobody Sun Feb 8 18:49:23 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 434522DAFBD for ; Fri, 6 Feb 2026 16:50:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770396646; cv=none; b=bQ6fywDYb/ZohoTQmnFu4gb87FkFKep6lzAZmlwacM/7QNh9ch0vICC1FJRLzW18L7qMh10XY5thYJqUZlVGEsvOuR9Lu19FhDRDnuuvRK3gbuGjB4h9YPxKyDC4+XiqTXnD9Sj7fIyOQ4kD/3vV7kRKDwqFt1tSPA1CjsGKr74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770396646; c=relaxed/simple; bh=p6b0pYVV8naHmIggxWi1jtulo49jTimZbmMBRKZgDdM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S5GCUPlKc3ZMumCs/P2vAVoLXn8TwNZWGZ5zVTsu43nELk47Wy2Pr5cSSX577LymEngYu666yLPjQnLzOBbyhoXZdMnwNXGOe4BsUc8cSlzJAq4V1VfUTBr9w5JEFpzq+znUekPngXbdBfehm37tJ/9voGO4EgVY57jw33IiLtY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=agJV4Dhm; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=agJV4Dhm; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="agJV4Dhm"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="agJV4Dhm" Received: from pathway.suse.cz (unknown [IPv6:2a07:de40:b2bf:1b::12bd]) by smtp-out1.suse.de (Postfix) with ESMTP id 704473E6D1; Fri, 6 Feb 2026 16:50:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770396644; h=from:from:reply-to: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=dxw47kxMhMVDr/xDNlT8DbsgBhrYS6i+o0FBGaNAC+w=; b=agJV4DhmBQMP2OWQCdqcPgi17iv3O52F6Q0LSx42ij9y5w2wNsFoRrdd0g9kLpsigjkvvK qq1tMsgNF5UpxaLWlzonrBJFYLuKiJIxO5/w2h4/1Lsu61yultM1fSN9t961y6fcPI3KjI WHHPqDgQ4CoYSvK0HbOq496cJ4LtWq4= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=agJV4Dhm DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770396644; h=from:from:reply-to: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=dxw47kxMhMVDr/xDNlT8DbsgBhrYS6i+o0FBGaNAC+w=; b=agJV4DhmBQMP2OWQCdqcPgi17iv3O52F6Q0LSx42ij9y5w2wNsFoRrdd0g9kLpsigjkvvK qq1tMsgNF5UpxaLWlzonrBJFYLuKiJIxO5/w2h4/1Lsu61yultM1fSN9t961y6fcPI3KjI WHHPqDgQ4CoYSvK0HbOq496cJ4LtWq4= From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Marcos Paulo de Souza , Chris Down , linux-kernel@vger.kernel.org, Petr Mladek Subject: [PATCH 7/8] printk: Handle pre-enabled consoles directly in register_console() Date: Fri, 6 Feb 2026 17:50:01 +0100 Message-ID: <20260206165002.496724-8-pmladek@suse.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260206165002.496724-1-pmladek@suse.com> References: <20260206165002.496724-1-pmladek@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 16.67 X-Spamd-Result: default: False [16.67 / 50.00]; SPAM_FLAG(5.00)[]; NEURAL_SPAM_LONG(3.50)[1.000]; BAYES_HAM(-3.00)[100.00%]; NEURAL_SPAM_SHORT(2.98)[0.994]; HFILTER_HOSTNAME_UNKNOWN(2.50)[]; RDNS_NONE(2.00)[]; ONCE_RECEIVED(1.20)[]; HFILTER_HELO_IP_A(1.00)[pathway.suse.cz]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; HFILTER_HELO_NORES_A_OR_MX(0.30)[pathway.suse.cz]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b2bf:1b::12bd:from]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b2bf:1b::12bd:from]; RCVD_COUNT_ZERO(0.00)[0]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:dkim,suse.com:mid,suse.com:email,pathway.suse.cz:helo]; DIRECT_TO_MX(0.00)[git-send-email 2.52.0]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RLgy8oz5x7j7it6a73zx4uugbi)]; DKIM_TRACE(0.00)[suse.com:+]; RCPT_COUNT_SEVEN(0.00)[7] X-Rspamd-Action: add header X-Rspamd-Queue-Id: 704473E6D1 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Level: **************** X-Spamd-Bar: ++++++++++++++++ X-Spam-Flag: YES X-Spam: Yes Content-Type: text/plain; charset="utf-8" The function try_enable_preferred_console() currently has the non-obvious side effect of returning success for consoles that are already pre-enabled. This obscures the logic flow during console registration. Move the check for pre-enabled consoles directly into register_console(). This change makes the handling of pre-enabled consoles explicit and easier to follow. Furthermore, this separation lays the groundwork for future cleanups where try_enable_preferred_console() can be restricted to cases where an entry actually exists in the preferred_consoles[] array. Possible behavior change: try_enable_preferred_console() will newly be called also with @user_specified parameter set to "false" when it failed with the "true" variant. But it looks like the right way to do. It will allow to call newcon->setup() when the console was preferred by some platform specific code. Signed-off-by: Petr Mladek --- kernel/printk/printk.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index eb224eaace64..db91be780de9 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3913,9 +3913,6 @@ static int console_call_setup(struct console *newcon,= char *options) * the newly registered console with any of the ones selected * by either the command line or add_preferred_console() and * setup/enable it. - * - * Care need to be taken with consoles that are statically - * enabled such as netconsole */ static int __try_enable_preferred_console(struct console *newcon, bool user_specified, @@ -3963,14 +3960,6 @@ static int __try_enable_preferred_console(struct con= sole *newcon, return 0; } =20 - /* - * Some consoles, such as pstore and netconsole, can be enabled even - * without matching. Accept the pre-enabled consoles only when match() - * and setup() had a chance to be called. - */ - if (newcon->flags & CON_ENABLED && pc->user_specified =3D=3D user_specifi= ed) - return 0; - return -ENOENT; } =20 @@ -4178,6 +4167,14 @@ void register_console(struct console *newcon) if (err =3D=3D -ENOENT) err =3D try_enable_preferred_console(newcon, false); =20 + /* + * Some consoles, such as pstore and netconsole, can be enabled even + * without matching. Accept them at this stage when they had a chance + * to match() and call setup(). + */ + if (err =3D=3D -ENOENT && (newcon->flags & CON_ENABLED)) + err =3D 0; + if (err) goto unlock_free; =20 --=20 2.52.0