From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 01CA431B80E for ; Tue, 2 Jun 2026 08:55:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780390535; cv=none; b=trikOppLiut+8yDzCsgvpbpkKq6x/wUYMWgNzeJ+cxyuxDfTLcr3pC7wfDS9M8pEFm/AXatSo1DXCBopThZurm/lq0icKol7gsnrEl5N7MOoOeAcItuC8z1A3bhvwnAfPZk2LojUuQh5LzNpsMuHJ9TQux5FBm+B8g2lNzm6tkA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780390535; c=relaxed/simple; bh=e0AoXs/6FD9FCUQRAd9/tP/d4AOU1jbUQld9ovhylz4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MjxamaSdozyYUNOoyxjIKR34xumGgFx7v4NEuiwi9ZJHhVCN7foY7SQalbjUGy0jxosNkF3dH7q4cqjQeYwMsLer8gTzJ/2vGSXCwRJmJAWdNecsIW56X9v+xeryk21JlwvkaEpNME5jnriIGcbXRVDp/cV4QZaDcqWKY0ny58o= 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=CoPgLVsO; arc=none smtp.client-ip=209.85.128.44 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="CoPgLVsO" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-490b1bbcf3aso4057105e9.1 for ; Tue, 02 Jun 2026 01:55:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1780390532; x=1780995332; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jP023VEDqnXhAI7yeQ0FG7GdS1GrrxF3UPmb8MSuyUk=; b=CoPgLVsO5Qp0XBb0SYDqcgPwRZLWG+YMT0oKnr+TIHoXK2tcBBicESQ1fmnzR9WOZN QXAfugtFj3PW10ofk6avcOi5lstJSeo95iCbiysPa6Qs7PAeuACO3inDC58tb/P6hJLN IyM9NVfP6pRipmeJ+akK6qFbocndYbBIDjaAU7flg07TkhteDjPjJg06c6/Pc/E3b6xc OQdAvgTmvGiXJK1xdM2FzZjFJlKu1/AhNf7HumDPnitcwuj1RYp5CFghTaKvYj1xmdIx Kv0TdKJEn1EfEjQJw9h+J05jcIx4YRd+EKici+m/XwUH9sOUceZCd/aDOv09lrsNx5L5 2F5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780390532; x=1780995332; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jP023VEDqnXhAI7yeQ0FG7GdS1GrrxF3UPmb8MSuyUk=; b=cj/6BYL3ySyVq9x+LsqKlM0gi/h405UQH4Ggq5Wk00g0Py2k6F+DTOab5ftq5Faic9 YRV6WNcNpOhVc+k4pJfcgPs2digU2dh1dC2iFMGO2OW+uOr932VVUQxINcMB0EgyzsjA jNnlaTxppjnzvnBbeBVzDm7k63cdOROGhtttPl23BMVPMAMOJKJIOm5nBVMVxB3tR4s6 ucyPx3oY2N+ILY317VJehWXK7QxmBwPNamWLgqutM1EoZhInp9ICPxxU2Hrgc+Fj6/Le ZBcdG/c8Xlkse4qnPlCN6/+aTyO4z8DtrP62GQz6Q0dcrGHkwnMAhvJ0XSujvq/J5y+9 AeQw== X-Forwarded-Encrypted: i=1; AFNElJ/psK7MQBN/e0UAW6DiDNhnm4xeeYYL64OrmuK23VDCZzOFiWygtXEbhBF79mOv+abA0Q4e/9C9ckzvPKc=@vger.kernel.org X-Gm-Message-State: AOJu0YyI7uBJQtQWCeRKHAjWLzds6fq96Ps4LueIOoiXe6b3rdJ0rini 9EqUY7qpYtaDX4gUawUfVr721PFiZuYXHtxxfvGfPFe5i/cP5R3G2firs6r/6WZmRF8= X-Gm-Gg: Acq92OHtlo2Fy7kPax25uIBe6eFBB/PtPFPdLODZj11L3OOZqEbmJoHjzgsm8Z6lZCC gbmwfrEU9zDsOcc1NyHxWGQuL6IYfR4slzeQOPM89vHidh+uia7BxoGnKQbw2yuwtpHdwPe/0Lm vrjxB/KgGvfkZEYnqGAzaFiLYvGJ10s1U5IzJ45pD3yuaUztj93up+9cUX2jGM9v8J2e2BOOgt2 SKT6SpchyyMc0xvmI67yP2Qiv++Mg8wCHPmxyLnYQiGRcHrFMDpJZRGBmQ8mPnIitA5SHPY0Vt2 vVwOzxmVu4PiBnpXoV04yszjzehyM3ibrMHuz2lKGwIttxSAXqetTB4IDLyq6tKfyxWMIougBu1 mgBbSdR6ucQRn+D0ez0xEb+4FveiS375L5rl71HUwQSzkcbsVvuXqVqXK1bYqt6ylkSkIr3oLCm zxigjRj/vg2lAHXVU+MGFyMbh7oPdCCFjKT4mfruCiNCPXHac= X-Received: by 2002:a05:600c:c492:b0:490:9d1b:f088 with SMTP id 5b1f17b1804b1-490a29e4383mr256190585e9.2.1780390532358; Tue, 02 Jun 2026 01:55:32 -0700 (PDT) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b0e823f7sm57545805e9.13.2026.06.02.01.55.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 01:55:31 -0700 (PDT) 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 v3 10/11] printk: Try enable preferred consoles only when there are any Date: Tue, 2 Jun 2026 10:53:11 +0200 Message-ID: <20260602085312.228251-11-pmladek@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260602085312.228251-1-pmladek@suse.com> References: <20260602085312.228251-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: 8bit try_enable_preferred_console() used to be always called because it had several hidden effects, namely: - enabled Braille consoles which were ignored by "preferred_dev_console" because they were not associated with /dev/console. - returned success when a console was pre-enabled using CON_ENABLED flag. - returned success when a console was enabled by default because try_enable_default_console() did not return success. The first two hidden effects were removed in previous patches. The 2nd fix actually helps even the 3rd case. try_enable_default_console() sets CON_ENABLED flag on success and is later handled as pre-enabled. Prevent any future hidden effects and call try_enable_preferred_console() only when some console is preferred. No behavior change. Signed-off-by: Petr Mladek --- kernel/printk/printk.c | 46 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index a4eaf157cece..d62901a13bf7 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -4099,35 +4099,35 @@ static int try_enable_console(struct console *newcon) return err; } - /* - * See if we want to enable this console driver by default. - * - * Nope when a console is preferred by the command line, device - * tree, or SPCR. - * - * The first real console with tty binding (driver) wins. More - * consoles might get enabled before the right one is found. - * - * Note that a console with tty binding will have CON_CONSDEV - * flag set and will be first in the list. - */ - if (preferred_dev_console < 0) { + if (preferred_dev_console >= 0) { + /* See if this console matches one we selected on the command line */ + err = try_enable_preferred_console(newcon, true); + if (err != -ENOENT) + return err; + + /* If not, try to match against the platform default(s) */ + err = try_enable_preferred_console(newcon, false); + if (err != -ENOENT) + return err; + } else { + /* + * See if we want to enable this console driver by default. + * + * Nope when a console is preferred by the command line, device + * tree, or SPCR. + * + * The first real console with tty binding (driver) wins. More + * consoles might get enabled before the right one is found. + * + * Note that a console with tty binding will have CON_CONSDEV + * flag set and will be first in the list. + */ if (hlist_empty(&console_list) || !console_first()->device || console_first()->flags & CON_BOOT) { try_enable_default_console(newcon); } } - /* See if this console matches one we selected on the command line */ - err = try_enable_preferred_console(newcon, true); - if (err != -ENOENT) - return err; - - /* If not, try to match against the platform default(s) */ - err = try_enable_preferred_console(newcon, false); - if (err != -ENOENT) - return err; - /* * Some consoles, such as pstore and netconsole, can be enabled even * without matching. Accept them at this stage when they had a chance -- 2.54.0