Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp431149iog; Wed, 29 Jun 2022 03:15:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vYHdPDCuRsT90SKF/sGHxGWMruzSKs38Tzs/fFdIHkLE9tUWI/N98Yjm6fy3N8n/WyPS0X X-Received: by 2002:a05:6402:2790:b0:437:6843:cf1a with SMTP id b16-20020a056402279000b004376843cf1amr3218153ede.170.1656497753231; Wed, 29 Jun 2022 03:15:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656497753; cv=none; d=google.com; s=arc-20160816; b=epvVcX+KvttD0OFttcIbfL0fZJfemiFMImgqH30GS0dKYEcmeqmanSG7dMI0uUBOSj NV+wfQZu9eoMeKpmkj6SoWGJHRnSzz21saD67NmQmowxj4TwEpsL7rrYi2/mcrGb2+Yf YiTZEpjWtUrGl2z1t6vmVf4tRQBOCn7Tq4SU5W4BdjRvbgJo05b9+wI4QmAS1SD6oL4T IuewugA4XRiR0KE09j3G0J5e1edy6YAo2OUGiu/gumOVhbrfX0OC78VmHgKYAn2hGtOE iXAiRASg9bVMrqztt6hfGdpUitpyRYX0ue3DEKU+hNdQQzsYrXGqRm+q80S/3OY+ufbI Ua7A== 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=o/arp7DTIKNxOkly04awm5u39rEb/C2cPhFSqH5ScIs=; b=0YJ+MXOjKgxARr65DhxhlRl843CQyqalnz4qbAt8hIrYdmi94PS3Q5WWvX7WYPRFVb 3HfgWlCrfddpM8lZWCeXCVo1InMiE5wbkpXidj3hVx60OewykHXJmkjv/gN5qoUxD1Q7 Rmdp0mfbPpCmwdG7xzXREYdLBbfqAwjVXU8myZzSnbk2d8uWXtURZ6dDZ8rxwBU8m7ft BIgol+8GhZKg1rQ7E2bLAWSLIBUkQKIyhPS4nkFiVFH+riOZ2T8MiTOVBhAUpld2zaIm pPoFFnLoY2E21gYzY2xuzm6I4LbnkhBahHsxh0JyKTjcwUGMaxNNnmot/UQ7yTjdYmN7 wHlg== 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 y3-20020a170906448300b006e87a109539si17831890ejo.204.2022.06.29.03.15.27; Wed, 29 Jun 2022 03:15:53 -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 S232238AbiF2JVZ (ORCPT + 99 others); Wed, 29 Jun 2022 05:21:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229846AbiF2JVY (ORCPT ); Wed, 29 Jun 2022 05:21:24 -0400 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DE9BD369CE; Wed, 29 Jun 2022 02:21:22 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTPS id 15F3A80CD; Wed, 29 Jun 2022 09:16:08 +0000 (UTC) Date: Wed, 29 Jun 2022 12:21:21 +0300 From: Tony Lindgren To: Andy Shevchenko Cc: Ilpo =?utf-8?B?SsOkcnZpbmVu?= , Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] serial: 8250: Fix PM usage_count for console handover Message-ID: References: <20220628165834.63044-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 * 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? Regards, Tony