Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp659465rwb; Thu, 10 Nov 2022 06:00:47 -0800 (PST) X-Google-Smtp-Source: AMsMyM7vR9WSmebpsRFB4ldHdQLjr/aogNdWox8O9vKagm1s401WZuRYUxALxQa4HzQgQ29Plg2m X-Received: by 2002:a17:906:4fcf:b0:7ad:8f6f:8079 with SMTP id i15-20020a1709064fcf00b007ad8f6f8079mr60478626ejw.646.1668088847576; Thu, 10 Nov 2022 06:00:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668088847; cv=none; d=google.com; s=arc-20160816; b=DS6JnAwdc31AnkzTc4OjRctGS10NVNiVjCx+SSL+Rm5ahl9UGmMO3hvn5xLSQDDnTY WvlT7Wcn7ofSxTMSKOp6ouJUXD8pOT0PMfvwdeYwPTcUsYOqvTT94gafYE0COJDq7DHq 7SgABsecmKF3wcDWv2CXIouU+0SUUX6kZhPtWt2oVuqw8q9gAeqaDjvQ2cfczvMo/Phv bAf7qC95QBdFIzh5D1wggrSQKjUHi+zDIncCA4YylCGaSLLyv/pvKPKcygCrLBe2UwRf 1kE73c8NDl5iWIq4I+ILZjTrufYrrBlvgBFhl3Q3jxZoU/LLPzq2Gkt9YZ8X8kVqLDEl H6Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=naQhJVICUVfgZMKK27G/LnTrwDheWqZju3P+B9fWRRY=; b=USuHRUrgFyKrg8anmTROPoDki3AMZhyqQ6Ss9FElQj+gbrY3FpblDXn9ma1ZwMrG5f CD4xQQ3HObyLV5fw9VzASeDpqSuP/cAgZ16cwbNIwVHORZwmIqdTUIP+FI8SGT8Os4V4 Wt6pux3UvSYNP0z8z9qsyCJ9UWT6/vJ4rAPD7BVAbWAyYGJWkA0KQ9EQIbAQxUa8nMpt 4Z1sXrrA8EbFJCrJxOXRH0DXv1wCwS4491hLft7WDjbdZkPU+E7GT+gL5VayyoI0zESj n8Xdzivflp+10c/WM1pl0gQ4EN1eZttOYbgl4ivWYvrupvlwVKE86mLH/e0fMceNoADu 1lkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=YPUrf8Q2; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt8-20020a170907728800b0078b2fed72b9si13852044ejc.111.2022.11.10.06.00.23; Thu, 10 Nov 2022 06:00:47 -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; dkim=pass header.i=@suse.com header.s=susede1 header.b=YPUrf8Q2; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230386AbiKJNYl (ORCPT + 93 others); Thu, 10 Nov 2022 08:24:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230364AbiKJNYj (ORCPT ); Thu, 10 Nov 2022 08:24:39 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE8D5B4E; Thu, 10 Nov 2022 05:24:38 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 89CA41FADE; Thu, 10 Nov 2022 13:24:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1668086677; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=naQhJVICUVfgZMKK27G/LnTrwDheWqZju3P+B9fWRRY=; b=YPUrf8Q2PdghD/r6NdSQuVDxLuzuPxEhsCRs6KbXaLps+bE8Mpp1mAPRwPBrxo63y0igTW NWpQeYYp3GABdwM9w0YFJANcKEzEyYuJhjsUstSKBv2luZZX9deOCjbSzmzqMZvdm+cpjA zOQSpKAeqqszBsrWntBw7ZJEAuwGt+c= Received: from suse.cz (unknown [10.100.201.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 708352C141; Thu, 10 Nov 2022 13:24:36 +0000 (UTC) Date: Thu, 10 Nov 2022 14:24:36 +0100 From: Petr Mladek To: Geert Uytterhoeven Cc: John Ogness , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , Andy Shevchenko , Ilpo =?iso-8859-1?Q?J=E4rvinen?= , Geert Uytterhoeven , Tony Lindgren , Lukas Wunner , linux-serial@vger.kernel.org Subject: Re: [PATCH printk v3 23/40] serial_core: replace uart_console_enabled() with uart_console_registered() Message-ID: References: <20221107141638.3790965-1-john.ogness@linutronix.de> <20221107141638.3790965-24-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 On Tue 2022-11-08 09:46:20, Geert Uytterhoeven wrote: > 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? I do not have strong opinion on this. It is true that the code duplication is trivial but it is a code duplication. Either way would work for me. The reset of the code looks good. Feel free to use: Reviewed-by: Petr Mladek Best Regards, Petr