From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 EE1DC22D7B5 for ; Tue, 2 Jun 2026 08:55:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780390522; cv=none; b=qH2dPUSlB84cPf/lJ8DYDyBp8TQeM+e/ruOOMTcB1faxdEgXzmipjWEhqqh9O+WsmSZP1r2F2t4979vDCsBvAf2Vw1E/hYbr3fPEkOUE9JD9wupwEEHoV1sPLJ2YabR1GaiKoBTCbaJubZcZyQvjDq5N+Bj3U2Z/ACwcy62kxOg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780390522; c=relaxed/simple; bh=jGkvL8etaBzyJWE1YCKdlI5DAJzYmJX1S4keeQJe5pE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Mpyqlt85vb7l7DIa02fu89ryGZ2umuEOlXpCAb5M2lQ2nzQ3hg90KDLxm4qiaAde1j5m8eY5fPdDsgcFbrKkWy2mwUSNsaoLs9PrIaI8m1b7aM63S6LeG956UWJs8K1zXDfDKGn537OMRW2+RMUQXU3igg7oB9WVNLpkwW1NdZw= 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=QEa11p3G; arc=none smtp.client-ip=209.85.128.45 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="QEa11p3G" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-490a7678b2dso19851775e9.2 for ; Tue, 02 Jun 2026 01:55:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1780390519; x=1780995319; 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=oVL4jOZ//PvW9R/mRISI1v0jCG0a8V/9Y3FuFcbG2Uo=; b=QEa11p3G8upVkwHYQ5efdNg9goPaP7VasoBz3ipVhzFnzVH2zajG2SrEaR5k8BHVLx 9MeKQJTcxHlko9JDux76h+KquAo+6S9uQYYAuGzapBsdZ54tPs9oNfg3JiJ+Hrw/Wydy zdCe5pwmJ4V1XPgainriRweE8kWdNtxr83MudeJGqy7p28ymvcYcfnFTsCslfGnKYr4p KaLVtPZn/TpvN6Lc623HYLrxu57POn07iy1OVOqknu72xmGyKlBqiexni8OTRMBIAd/9 uPdzomtq5Kz9uM1tZDk0re9BjVaTTIrNfEAV1jQlm8g+EPSiRM3v0KuBeiCkkt7Us3Ww FmyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780390519; x=1780995319; 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=oVL4jOZ//PvW9R/mRISI1v0jCG0a8V/9Y3FuFcbG2Uo=; b=DD1P7lfU/ORtwBntVFU98/WgcoVC8Ib2QS+lWDKInu6Hi7bKsz10FI1Sx5c9Ho8LhY DS0h6TH5EgTXHX2vpzS0DVZUn2amrtpDSFYWmrI3QWC6EM7XE9bkiTMbFnbkwjhtZGZP KSwy1qzJGsRlEnJRRk438w6A0TbNQgBrMM2jQel/C9r6GH2IElCbml4Wn07F7hrid0sN AyBXcY7gE1rbGrU0y1h1AfQoLolaslm/YHMS078AXZPUGznwpHLQOBm8UiD9m3c7mPQO seQtoSmT1T8+6hBSKSJCzO0bpClIoNQkuvsl5K3z0Ku1qCDsob4+d7iYKcYIXskZ2E6O BZHw== X-Forwarded-Encrypted: i=1; AFNElJ9VlOL+qoBmyJG8CfFajmlK874WBRROplgM3Uz0BV7CCkjioZdOjl3rj0fs1XNZKPHn09xXtXCgfKlJEII=@vger.kernel.org X-Gm-Message-State: AOJu0YxVd8TZGyopvTe/L0NjzpYEZXkebw4GNKPvYyeUwvZTu6dEuYsN xnmz3Y2973cvzfZt287Iwx9xi9wTcrKyrE1pJLHSuEZWSLImWmvvmV5mqqa6p3qsS9Y= X-Gm-Gg: Acq92OHKoxgRnDE/gwuQISnq3WwcTfkpnbxoVVmh7DCCng+z0wf2FX907ShAaz0pA2l t7PEZ992XpyHLNsKnvsQ3RDiNMNC8Hb9ULc/P/CCa4bi3dhqcV6e2geNNG2h7t8OpSdlYiXEce8 /OGqXqFJWS1gvtPHdVXCnZMFU8Kk+QaWHVZ0mxytwUP7BWd3X1feWJ58GBNRQvIcMAkUY6Y0kgg mIIC5wnemyPvwbi3uoPLO1YlxEB4klZio0Fn1yiXTqvMxN5W9Or+3lzQYndzfXMOSrsizUdkVDx Rq7PxhhTGwqHlSnGXIHpdshRe/P5R7PAONRXJzMwmEw93gX9sVG0N20+ENNU8JJNt+gqA79Yt62 2uoEpH9x+nmLLCNqWSosKiPQozznxWMrdrsKDvJs6ePUxvll2+SARj3kdEZy99zY6Cej9R5vlcu 2nx0q4Dt/cpG5dOI4XxZRr+9hNnrAOAceWMRmj X-Received: by 2002:a05:600c:a012:b0:490:9d5b:d721 with SMTP id 5b1f17b1804b1-490a292f9dbmr262836485e9.16.1780390519481; Tue, 02 Jun 2026 01:55:19 -0700 (PDT) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4909c10376asm95064055e9.23.2026.06.02.01.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 01:55:18 -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 09/11] printk: Handle pre-enabled consoles in the top-level try_enable_console() Date: Tue, 2 Jun 2026 10:53:10 +0200 Message-ID: <20260602085312.228251-10-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 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 97327c27436a..a4eaf157cece 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3993,9 +3993,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, @@ -4048,14 +4045,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; } @@ -4135,7 +4124,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.54.0