From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 B862231D371 for ; Thu, 23 Apr 2026 13:02:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776949351; cv=none; b=U4EjAOgEWib9wG7TMnyKMndALnwV579P/Sdn/L76hF/HdMZB0vgnfu4q4lwtTxPWOgII9jj8gSUSgPQLBe5QjQkwSEIv+rOGiadmSN+PuKRmpxhPqPOZriBn3K4DlSRZOuNy0+Hd9CpYV93EAvodzWaLSyRjn8dZl+loTKqY2hM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776949351; c=relaxed/simple; bh=Z1emXjID8GZwhNL1lS/g+f7c8Z3yF1l3LJ/LE/EP2qY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XeLtPl7TQA8JzcgSIo4hEWDbyr0Nta59snj/VV3mzbrttCpivYpWN8QM1y31ysimQHOmThUhI9P5WhLMGPRa5TJitJaprWWOaUgZK8wWo2pRxeqRElKc5qHMBRmdqeWKNW9m76XJUyuDf0puKtqtDe/GDwq9wj1jXTJDvd+qzuw= 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=e6eL27yM; arc=none smtp.client-ip=209.85.128.48 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="e6eL27yM" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4891c00e7aeso42610795e9.2 for ; Thu, 23 Apr 2026 06:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1776949348; x=1777554148; 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=l87ZLddebUWdjXvuZeXUUisBg2RinkONT9hW90ee0fM=; b=e6eL27yMaBvl4eBEcGkHcHr/eGdC17ubmzGPn8LlHTzJyeAcf5gq7eTF5sM8mxAgqI gTmuZXiFpI9pWysARvfqrj91gbMKl3wMTP2VjtUotKVXaP4ca/VTKgB6jLoSBrhXZna5 zD31UvaUqI1TNIekpqCeV3sQS4bgFzHE9Lu8LEQdrgOUQ8IoBBwsGJ4LxvhQpv2YmzJX 5wqhQfDE2clgSg+Gk9gydmmANkeS4+MQfv38eoRnM/Qwz1oAQwlDQfMaeYA1VsFeM6GF ydnGobWIdMRNC02UmPcO/dMf6o1DU0w63PrrP0f/V30LQfB63jjp42CUpWopX5pktDG6 JNFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776949348; x=1777554148; 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=l87ZLddebUWdjXvuZeXUUisBg2RinkONT9hW90ee0fM=; b=Kwz5iG5PVTm4l9yydIwL9QvA2VVbuPiPTwDWIZHuG16Q6EXAIM/QQKgtPkt0/ONrrs GBmj6W0yFJjjuN23SkIFfQULOYoEsridCSviruUaOoQUJnJgw4Nsz/sW9VGixjXcfokF MqDlNnAgLzrw9lowGNFkYJU5mSpad4K+r7kYCAPR9DhOKfV7WsvNmxp2paZFegfTZzjp 65sELKw7EipTjL6qmNvWZ+Zm4/O/MXNqG0PWsBKhgGN5dJ/Qtt03A1PlAK+YOvVUUjpS m0CcYjblLqLULk7OMoAvc0C6IAO3AEqI/YRB40VBM+ksUNZo9w40MCxaaPliOh+yOLq6 sqYQ== X-Forwarded-Encrypted: i=1; AFNElJ9n5fpbrf8WsoMGWZwbtNICgQaTYljqtdYcdgn9wiaynawjMGkS2nC0+0n8vIRn2UPL6Z0pX+Et0T1EAoI=@vger.kernel.org X-Gm-Message-State: AOJu0Yzs6RypFREzffPm2nanBK+MGI7v2jPxIRXUC4SJ/mk3wGZeQzHP 8ndnVxE5EG4EdiLm+ZAFUMQtt8PtGELkbIcK1HqkMNv2zGAYQ6v7WJhRQ00WNVFpvJs= X-Gm-Gg: AeBDieuT7W78LVAb9GihDbT8Rv5cBwqsl7/2D+gtxrzicfoHMpDobPTfz4QnHferZvG ZcDH9trAfkciEEgsuzz1gD9iw3uFTKgwmlESdXwF2Lc3ftrO26N2EayhpNMwYmNdXWZsARBdiY2 24BiTwCGVzok3HI4XzWxPgjbsxwMwo8BkUGmYnH3TgXXbZT0k/Co9FKs5OoFfYQ0mLkzrDKw6v6 s67VWTLF6bH4gNL70jstz0Mi3JhvU/6+Oz7SsumoUHoJSy56jf4ELoX1vvi/VhzeEt0yha/GRqE 6CeukqjQWN/174kJit5l1YHJK5xcPAzHzBD6H7VqTLi+9Msvk2SZunGjzRJwFIBVYFRzBfpKXVc xNYt8nDCVJXb4QlppmHJ7vf3natxEeTFbfmiJElv36UFXM+NlbhSXtUiINJ9RNgYpZZOni9C+27 GuGn9TMF4Ht6vwNYiikFuGU/YpkMLxn6b9jHBR X-Received: by 2002:a05:600c:5285:b0:48a:5333:811e with SMTP id 5b1f17b1804b1-48a53338269mr225529235e9.15.1776949343463; Thu, 23 Apr 2026 06:02:23 -0700 (PDT) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4412150a071sm18249756f8f.21.2026.04.23.06.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2026 06:02:23 -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 v2 8/9] printk: Handle pre-enabled consoles in the top-level try_enable_console() Date: Thu, 23 Apr 2026 15:00:13 +0200 Message-ID: <20260423130015.85175-9-pmladek@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260423130015.85175-1-pmladek@suse.com> References: <20260423130015.85175-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 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 the top-level try_enable_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 | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 9143a050c289..91c3be6843bc 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3988,9 +3988,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, @@ -4043,14 +4040,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; } @@ -4130,7 +4119,19 @@ static int try_enable_console(struct console *newcon) return err; /* If not, try to match against the platform default(s) */ - return try_enable_preferred_console(newcon, false); + 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 + * to match() and call setup(). + */ + if (newcon->flags & CON_ENABLED) + err = 0; + + return err; } /* Return the starting sequence number for a newly registered console. */ -- 2.53.0