Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp447138iog; Wed, 29 Jun 2022 03:37:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uscosGuKZlKSd80rYgp9kF6H/KUJennL8jaOQTTqTmo/DfrWu822qO3XRC87rWWJGqPWuO X-Received: by 2002:a17:907:8a05:b0:726:e8f2:d539 with SMTP id sc5-20020a1709078a0500b00726e8f2d539mr2596487ejc.429.1656499067289; Wed, 29 Jun 2022 03:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656499067; cv=none; d=google.com; s=arc-20160816; b=jXVhNJGFeAdntzu9ILGnCWK/Mzh6d3KM6y0CVu+D/Hk8YTAurM5IhR5Q3U3nk9ChTd 7NmqlkpKxc6NpaDCc8b3uB5Uct8KuaaCWSYBQzHrwsKmbkaegVJQA9pb7ZFMkZmZrp0v YUuOrchLqT1TIbshRgU+TpKwNBJe8Fkx0aGDHbuTam/xC9Wb8d/A8EoELxqvw6Lwj/y5 t2EclnIaxN6gmnC7u8AUKsndd6aeV6exoZ4lvjpGPNTaY7WpbdnI6DkEzRI8HecHtcjK XZPCWcp+LIhQcGsK0jHP5FfdJjxkptW0TAfNTfh6uZCiADjBGWWR2wYDW9ZdKvJ14c4+ xUYg== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=X7JbLEfaULCaMHM3Tbih8b9Kxd6da/TlT2pE1v0dlIY=; b=B8tud1UGKd+X14GZGzhMGB2k8a31cr5kDMjpExeEmdierJBWBVW31IN9TLElFAGzxg D0ft0wml11xVVLY+0FVldrQXGwrsWFQRNr+hJU0mv8G6di6andNYyEpNnBIVjVYp7Ee/ C+oQcKRRYVeImW38djHPaNjI/zb54o2clFjZGQMFjF8nSgQGgZyimKtdblgbxBYWE/wB JBZeyQAF7uE7EyeF+ndyIPCegdQgr/SnR45mahKsLWvKxYyduqlK8eeArd0ixL29av56 sTiA+aubkY+NM8THCQFsU93qhcgpJmcdzHEAxT7G3hqeYMFieWHI0edFvO+XjERBXfKF 5uqw== 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 p3-20020a170906a00300b007165339eb13si17487146ejy.624.2022.06.29.03.37.21; Wed, 29 Jun 2022 03:37:47 -0700 (PDT) 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 S231786AbiF2JlV (ORCPT + 99 others); Wed, 29 Jun 2022 05:41:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229824AbiF2JlU (ORCPT ); Wed, 29 Jun 2022 05:41:20 -0400 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D0C6039825; Wed, 29 Jun 2022 02:41:19 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTPS id 9BC6380CD; Wed, 29 Jun 2022 09:36:04 +0000 (UTC) Date: Wed, 29 Jun 2022 12:41:17 +0300 From: Tony Lindgren To: Ilpo =?utf-8?B?SsOkcnZpbmVu?= Cc: Andy Shevchenko , Greg Kroah-Hartman , Jiri Slaby , linux-serial , LKML Subject: Re: [PATCH] serial: 8250: Fix PM usage_count for console handover Message-ID: References: <20220628165834.63044-1-ilpo.jarvinen@linux.intel.com> <5548afe5-20aa-9066-37e7-a3b2b26872e1@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5548afe5-20aa-9066-37e7-a3b2b26872e1@linux.intel.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 * Ilpo Järvinen [220629 09:26]: > On Wed, 29 Jun 2022, Tony Lindgren wrote: > > > * Andy Shevchenko [220628 21:09]: > > > On Tue, Jun 28, 2022 at 07:58:34PM +0300, Ilpo Järvinen wrote: > > > > When console is enabled, univ8250_console_setup() calls > > > > serial8250_console_setup() before .dev is set to uart_port. Therefore, > > > > it will not call pm_runtime_get_sync(). Later, when the actual driver > > > > is going to take over univ8250_console_exit() is called. As .dev is > > > > already set, serial8250_console_exit() makes pm_runtime_put_sync() call > > > > with usage count being zero triggering PM usage count warning > > > > (extra debug for univ8250_console_setup(), univ8250_console_exit(), and > > > > serial8250_register_ports()): > > > > Hmm so serial8250_console_setup() calls pm_runtime_get_sync() if dev > > exists.. > > > > > > diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c > > > > index 57e86133af4f..2e83e7367441 100644 > > > > --- a/drivers/tty/serial/8250/8250_core.c > > > > +++ b/drivers/tty/serial/8250/8250_core.c > > > > @@ -23,6 +23,7 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > #include > > > > #include > > > > #include > > > > @@ -558,6 +559,9 @@ serial8250_register_ports(struct uart_driver *drv, struct device *dev) > > > > > > > > up->port.dev = dev; > > > > > > > > + if (uart_console_enabled(&up->port)) > > > > + pm_runtime_get_sync(up->port.dev); > > > > + > > > > serial8250_apply_quirks(up); > > > > uart_add_one_port(drv, &up->port); > > > > } > > > > ..and now we also call it here. Are there now cases where pm_runtime_get_sync() > > gets called twice potentially or does uart_console_enabled() ensure that is > > not the case already? > > The code in serial8250_register_ports() right before that context block is > this: > > if (up->port.dev) > continue; > > If serial8250_console_setup() already saw .dev != NULL, we take that > continue and pm_runtime_get_sync() will not get called again here. OK thanks. Looks good to me: Reviewed-by: Tony Lindgren Tested-by: Tony Lindgren