From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) (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 B78742C21C9 for ; Wed, 14 Jan 2026 14:23:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.68 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768400586; cv=none; b=amjEu6NvA/4f3oKKzrvfDon5C1prouPY2o9g2UecFCht6uJBhKmdKJK8EHnNjIpWLrWbBITxba/+KME8L5Z0HEB25MjnSv8qnoMXw3BUZm5JYDqeGqoodgVv8vE6165jy1uxaXFj1b7LiaYgJ+xAHCEFGxgc+DC3Z7EQMzBia/4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768400586; c=relaxed/simple; bh=DfrdswblHy1q9UZ6D1iDapX7djYN6NrxRY58tdu4Ov8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bjAWIShbQTOt8pFlr6f+G7GO0w/qpP2EJrjBBrDZLfV1DCVsoNAdqx6ba/UEl5wdmt+SrL5EK2jylcDJysqDhpxSprhpwWMKsSI9nvK3hMZ13NEHLVlmDeoB348nmXHgnnBItHtzNw6xuOlJz0NmswkevuF96QftVdySl4V6qH8= 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 (2048-bit key) header.d=suse.com header.i=@suse.com header.b=OqIS36MK; arc=none smtp.client-ip=209.85.221.68 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 (2048-bit key) header.d=suse.com header.i=@suse.com header.b="OqIS36MK" Received: by mail-wr1-f68.google.com with SMTP id ffacd0b85a97d-432d2c7a8b9so4909827f8f.2 for ; Wed, 14 Jan 2026 06:23:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1768400583; x=1769005383; darn=lists.linux-m68k.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=rjJ0doliNf6plVmMYQkV7IlLiBwqr6x+viyB7m/anSs=; b=OqIS36MK4VRRYRJF3JLB9hwqJo96SDmzdOY1iGTYHg98P61ElmeSyVFbUq+ubxCxpZ Bm0AWC4QIW5+zgsw712Lh/zsChDBPixwYDm5z+yeZ88QHUSgaZgnB+D8YdWkSPDTKZpT o0aNoEB4shtVNZSkcqcm1pyTJqIoYGdPkD5oyk33gZIN01bSScNbrtUhGiRWR3xVFSxo y4wCqS5SRqfyvYUZp8qWFyyOaS077+2PIV3B1tCldrz4RH6Ay01Jx6wW2BcU3uYx1R5U xC8i5X5XdWdRgjAW7ld6BHEPcXDDSuRwP0arm7fGeMAWiAKT1BBcE0ZNnCN2/k0Wl2ZQ Nxmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768400583; x=1769005383; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rjJ0doliNf6plVmMYQkV7IlLiBwqr6x+viyB7m/anSs=; b=AuZEyaUFG1BK3anzmENr/2zyzfPCZSagq/70THM+CM/CgZ09qUmAZz/Hpx/vWWazzg deRyOiW57aFHrhhTe20S+fPCF2WYU3gmSlye17DjmdSCCtQqVByW/yD+ZcVieu58JrBk kVtDJoKNXo1CV3rvsWt+lwt5UNap+Co2Gd7GbgIfBR1gKLEqnyP0TDCvi5ansvFo6EIf Int+8xeGZDstGTxLAUlZ7PUHML1I7PsSvQOWshswvKXjzI/Wasn370z/sq+R4bPYFSTV kmQC+iw8u0+rD3a2OpOHMja1W47wXd+YNV+g/D/4xmdYRAwt+nL/c4YluWCiZ/sAff0x /0iA== X-Forwarded-Encrypted: i=1; AJvYcCVRb9/UeEfjYkDg1Guk77HGNqxAnfbVPhgTnpOWmO73dP+EswYskEEBpLQci5FGFj0XM7wvwVm1ieFG@lists.linux-m68k.org X-Gm-Message-State: AOJu0YyImyknNIEmAZmQkiA24V4bflXbz2g4PAt2vKylNiU/GIGC3qeE hkNtNWWikXya1qEwNU2enx1DdUBa788YjJ2wMqVnUSzoieD8b/hsRwpc8tKIXWymJbY= X-Gm-Gg: AY/fxX5SPCQZvVmVszjURtUMcXWsT3h/URCQBEsRVysKBGHGC6OcGRTdZNWKllD9QNr sH3ZkWy8++BUe0G410FwhTHgf1kap5yk7mR9DyWG2oITIltUjgqiRsnA/dNnJcRqLoS5pnsNNR2 wtkOCuYnuVSlL0Z3cGhOc3YehUeABCEWo7qxqh0buIuHLmwvzo9zs1LedOQW8FLPWKihraa3BXz lyBeahMf91xNoimz2rylYRPZB6IRuXJi5YP334yll8QbHfDLOagw52npoP/vrEh3qzbTgM5THzD 844Wgz/DOMlevFuSwkS/GzsLtQioxUWDPpk5XemxDkw7jR7TxDW7pqT8FZ5+FH6mAP0l48piztb NaEpas/LHqYbM6ynKG1y/FFax+q94LLFFBZmpbG97hEklHL6Vxh4fZLeROwir0AiJTDwoi0SdCF dkWFwTu7zSt8deZg== X-Received: by 2002:a05:6000:3105:b0:431:104:6dd5 with SMTP id ffacd0b85a97d-4342c5728e2mr3256518f8f.58.1768400582935; Wed, 14 Jan 2026 06:23:02 -0800 (PST) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-432bd0dacd1sm49446446f8f.4.2026.01.14.06.23.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jan 2026 06:23:02 -0800 (PST) Date: Wed, 14 Jan 2026 15:22:59 +0100 From: Petr Mladek To: Marcos Paulo de Souza Cc: Richard Weinberger , Anton Ivanov , Johannes Berg , Greg Kroah-Hartman , Jason Wessel , Daniel Thompson , Douglas Anderson , Steven Rostedt , John Ogness , Sergey Senozhatsky , Jiri Slaby , Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Geert Uytterhoeven , Kees Cook , Tony Luck , "Guilherme G. Piccoli" , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Andreas Larsson , Alexander Shishkin , Maxime Coquelin , Alexandre Torgue , Jacky Huang , Shan-Chun Hung , Laurentiu Tudor , linux-um@lists.infradead.org, linux-kernel@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org, netdev@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-hardening@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 06/19] printk: Introduce register_console_force Message-ID: References: <20251227-printk-cleanup-part3-v1-0-21a291bcf197@suse.com> <20251227-printk-cleanup-part3-v1-6-21a291bcf197@suse.com> Precedence: bulk X-Mailing-List: linux-m68k@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251227-printk-cleanup-part3-v1-6-21a291bcf197@suse.com> On Sat 2025-12-27 09:16:13, Marcos Paulo de Souza wrote: > The register_console_force function will register a console even if it > wasn't specified on boot. The new function will act like all consoles > being registered were using the CON_ENABLED flag. I am a bit confused by the last sentence. It might be bacause I am not a native speaker. I wonder if the following is more clear: The register_console_force() function will register a console even if it wasn't preferred via the command line, SPCR, or device tree. Currently, certain drivers pre-set the CON_ENABLE flag to achieve this. > The CON_ENABLED flag will be removed in the following patches and the > drivers that use it will migrate to register_console_force instead. > > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -3858,7 +3858,7 @@ static int console_call_setup(struct console *newcon, char *options) > * enabled such as netconsole > */ > static int try_enable_preferred_console(struct console *newcon, > - bool user_specified) > + bool user_specified, bool force) > { > struct console_cmdline *c; > int i, err; > @@ -3896,12 +3896,15 @@ static int try_enable_preferred_console(struct console *newcon, > return 0; > } > > + if (force) > + newcon->flags |= CON_ENABLED; > + This makes sense because the pre-enabled CON_ENABLED flag is handled right below. > /* > * 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 && c->user_specified == user_specified) > + if (newcon->flags & CON_ENABLED && c->user_specified == user_specified) > return 0; But this location was not a good idea in the first place. It hides an unexpected side-effect into this function. It is easy to miss. A good example is the regression caused by the last patch in this patch set, see https://lore.kernel.org/all/89409a0f48e6998ff6dd2245691b9954f0e1e435.camel@suse.com/ I actually have a patch removing this side-effect: >From d24cd6b812967669900f9866f6202e8b0b65325a Mon Sep 17 00:00:00 2001 From: Petr Mladek Date: Mon, 24 Nov 2025 17:34:25 +0100 Subject: [PATCH] printk/console: Do not rely on try_enable_preferred_console() for pre-enabled consoles try_enable_preferred_console() has non-obvious side effects. It returns success for pre-enabled consoles. Move the check for pre-enabled consoles to register_console(). It makes the handling of pre-enabled consoles more obvious. Also it will allow call try_enable_preferred_console() only when there is an entry in preferred_consoles[] array. But it would need some more changes. It is part of the code clean up. It should not change the existing behavior. Signed-off-by: Petr Mladek --- kernel/printk/printk.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index abf1b93de056..d6b1d0a26217 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3826,14 +3826,6 @@ static int try_enable_preferred_console(struct console *newcon, return 0; } - /* - * 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 == user_specified) - return 0; - return -ENOENT; } @@ -4022,6 +4014,14 @@ void register_console(struct console *newcon) if (err == -ENOENT) err = try_enable_preferred_console(newcon, false); + /* + * 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 == -ENOENT && (newcon->flags & CON_ENABLED)) + err = 0; + /* printk() messages are not printed to the Braille console. */ if (err || newcon->flags & CON_BRL) { if (newcon->flags & CON_NBCON) -- 2.52.0 It would be better to do the above change 1st. Then the @force parameter might be checked in __register_console() directly, like: /* * 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 == -ENOENT && (force || newcon->flags & CON_ENABLED)) err = 0; You might just remove the check of CON_ENABLED in the last patch. I think that this should actually fix the regression. It will handle also the case when the console was enabled by try_enable_default_console() and try_enable_preferred_console() returned -ENOENT. Note: I have some more patches which clean up this mess. But they are more complicated because of how the Braille console support is wired. They still need some love. Anyway, the above patch should be good enough for removing CON_ENABLED flag. Best Regards, Petr