Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3186933rwb; Tue, 8 Nov 2022 01:22:51 -0800 (PST) X-Google-Smtp-Source: AMsMyM5ioReGuYw3079n/3EtqQeSkTLVG8UL0rrJzJREqE0QGL9BAMT+m3VWWmGTYaDLGQx4qSXO X-Received: by 2002:a17:907:80d:b0:73d:1e3f:3d83 with SMTP id wv13-20020a170907080d00b0073d1e3f3d83mr50303689ejb.372.1667899371591; Tue, 08 Nov 2022 01:22:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667899371; cv=none; d=google.com; s=arc-20160816; b=qGCLxs7dZ4mHKjJhPzTJg0uxItQY3M6ApEjlQ0V5Qh08pvWiN/Aa/DSpDv1Y4sZaGI 1I2QuQklVMvs3Qm1YdKZhXduQobHId6I2Pxd56KIFWfzMbZjl12x38YlWqNczRjRvi29 YBrq/RFtN6GwWgpENE9WA1kEI4pEddgw1ZxW5XTuF1vAysgQEMTzMmg7tXAWDx5zlbc+ GpH8v0vo6JqroOzJuFCX2Ip33ZpxnQuXHcNoNM1ARcPze4VdRvacAmLIZH+Wn2KUqJ/P sOK/VwkqSPCN9vau8cULnwalfwkKMHWG6+fQd1hL5syYT8rd7NXJmdHuFy43nxcPK26Q ltyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=BFaOixIsnZB6xQs+v+v1PC0UnPOGoBPbA99XLP2d//4=; b=HAbZTrO6FL3KxBYQ2mkC+aBkliahm9Ev/SJ7F8Ertjgdc+piCUk+VJwjBqdQEGepT1 3jAQ3NofjOyRW36LpY3YjLaG+x259J9aqix8XYp9N3H0yVVQ/WFvlp+kKOxkto16iumC fOOm7j2jJShpgC4C2pN24F9F8kdaEWB+d9coDx6powvlrtOooxCmZHMdgqnBZJEgSnvn QxW3zsY5YBc06S9EePuZatbqKf3fcQ3dDn5ELQVU8WUjJYCbj8HtR8HfZvnJHMWHAT6Y nhhfAo8j4oIkpsOeSmIhw6NkIlGjI9fDArd/RXXkIYITYlZHW7dJEnWiqecsQOSDyR5Q xhVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs19-20020a170906dc9300b0078bcc872a6esi12534265ejc.360.2022.11.08.01.22.25; Tue, 08 Nov 2022 01:22:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233599AbiKHIqh (ORCPT + 90 others); Tue, 8 Nov 2022 03:46:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232654AbiKHIqf (ORCPT ); Tue, 8 Nov 2022 03:46:35 -0500 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34F886328; Tue, 8 Nov 2022 00:46:35 -0800 (PST) Received: by mail-qk1-f178.google.com with SMTP id g10so8697775qkl.6; Tue, 08 Nov 2022 00:46:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BFaOixIsnZB6xQs+v+v1PC0UnPOGoBPbA99XLP2d//4=; b=r1BvGxGhsEKJ0CtZAyIY3Oklp5eBfkr221XBOxriBIAaTtpe02QtuPCCAdqKVdAZ53 yWTPljVS235e7FYabNmxgpMiD0NbcEtrqPafqan7LVg3S49iOrpVEeacglhPZI1/3rHT VgHw7Yup/AfiPMromzkHAyl+V2DQPIGYRO/qOnIlSpPzMH9ijHCegI3dh2f98na+v6tV D7C5S/vI05Sjvj2KVIW3+VJDpKAeZWPZDQEF7tpaGYyO8xZqvllF1My5ogXU3DX9tDIw TJCDbPx+nxca960kKbmOWbL6oy+QLwXuESG9YVbGofoGiNxP/5VrOtlzAP/dyyc7+Lpx nzcg== X-Gm-Message-State: ANoB5pmjsBapCdT5WEBOh8xpqur8gIJmVoCvKIBnjElbbO/OBTfZCs9T UDAGYO62p5Q5+lFe6zKgQmIARlWQvQf347rV X-Received: by 2002:ae9:f008:0:b0:6fa:d7db:72b4 with SMTP id l8-20020ae9f008000000b006fad7db72b4mr6818918qkg.473.1667897194205; Tue, 08 Nov 2022 00:46:34 -0800 (PST) Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com. [209.85.219.179]) by smtp.gmail.com with ESMTPSA id u12-20020a05620a084c00b006fa4cefccd6sm8643966qku.13.2022.11.08.00.46.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Nov 2022 00:46:32 -0800 (PST) Received: by mail-yb1-f179.google.com with SMTP id 131so12189162ybl.3; Tue, 08 Nov 2022 00:46:31 -0800 (PST) X-Received: by 2002:a05:6902:503:b0:6cf:c510:6a23 with SMTP id x3-20020a056902050300b006cfc5106a23mr34694308ybs.380.1667897191488; Tue, 08 Nov 2022 00:46:31 -0800 (PST) MIME-Version: 1.0 References: <20221107141638.3790965-1-john.ogness@linutronix.de> <20221107141638.3790965-24-john.ogness@linutronix.de> In-Reply-To: <20221107141638.3790965-24-john.ogness@linutronix.de> From: Geert Uytterhoeven Date: Tue, 8 Nov 2022 09:46:20 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH printk v3 23/40] serial_core: replace uart_console_enabled() with uart_console_registered() To: John Ogness Cc: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , Andy Shevchenko , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , Geert Uytterhoeven , Tony Lindgren , Lukas Wunner , linux-serial@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi John, On Mon, Nov 7, 2022 at 3:16 PM John Ogness wrote: > All users of uart_console_enabled() really want to know if a console > is registered. It is not reliable to check for CON_ENABLED in order > to identify if a console is registered. Use console_is_registered() > instead. > > A _locked() variant is provided because uart_set_options() is always > called with the console_list_lock held and must check if a console > is registered in order to synchronize with kgdboc. > > Signed-off-by: John Ogness > --- a/include/linux/serial_core.h > +++ b/include/linux/serial_core.h > @@ -743,9 +743,20 @@ static const bool earlycon_acpi_spcr_enable EARLYCON_USED_OR_UNUSED; > static inline int setup_earlycon(char *buf) { return 0; } > #endif > > -static inline bool uart_console_enabled(struct uart_port *port) > +/* Variant of uart_console_registered() when the console_list_lock is held. */ > +static inline bool uart_console_registered_locked(struct uart_port *port) > { > - return uart_console(port) && (port->cons->flags & CON_ENABLED); > + return uart_console(port) && console_is_registered_locked(port->cons); > +} > + > +static inline bool uart_console_registered(struct uart_port *port) > +{ > + bool ret; > + > + console_list_lock(); > + ret = uart_console_registered_locked(port); > + console_list_unlock(); > + return ret; Perhaps return uart_console(port) && console_is_registered(); to avoid locking the list when the first condition is not true? > } Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds