Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp430288iog; Wed, 29 Jun 2022 03:15:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tDZ9pqFHETd82Ggy1+njurCDerfZRVG5bOpWjLTyFVj+Bmg9WTi0zL3HOKC0E6i9843UgK X-Received: by 2002:a05:6402:4386:b0:437:6450:b41f with SMTP id o6-20020a056402438600b004376450b41fmr3201147edc.97.1656497710962; Wed, 29 Jun 2022 03:15:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656497710; cv=none; d=google.com; s=arc-20160816; b=F2/emZ95fjlpXihyIHUr0AxC4cxnQ4Tg+kWUjk9Q8xBp3oZsYL9VlTBKHBcgKRDcdA faLT2nhp46d5v2IrstSP3SAH4qMnRDh9O6HJ6WOKMpvYvXSFMfBfXibX96sY2L2t7Y31 S1sz38ywetzdYJsXfHH50N2m/WkkFfUg/SFpeo3+XPr/np9MhC5qUff2UWnPvG2pCjEU 8GU2QfbCpprQVksJrnqJJiRhCzrwqsrrNZ/lCtHulnDDhwhXds0UXbBRNkf0w5bSYK9P v1Fe4uS1B0ZjeqaRhudUJWDVRrUX+FS8dV0zldX4MMX9+zE5V9AYtpdrs1PeE3sUWA9J ybsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=/ymw0RcxxkgPGwFeKs4TuFbRARIcVmFfJtx6PNr+T0s=; b=e/fZ8DXFlSIHIYz+QbX+IHtmYLitccXCEVTmjRcGfqfsAU2IHpLHu5u8jJWSkmnQNc H7OoIqPfnbal8q2Asvtq4fIHEd+A0ocFg5JEG4SISDbw73m/MqOmtOgQLa3d4xxqw5wv JsmIMRcdjpUF8YOQR0I8fAEYIZQJd+Rrcz8VK/wFHxNpnsaxyeD4QcqT7mM3+cpeNr5W OfmE+Ht+8/fi1+lXUSB628B/XueL2oOO21VsvGC5wm6osazjP0ZQVmW2ud216QJVtVlw 8DwJsckWPkAGgzLoIJD8IdHdoQrxpX3DIiMt8HXADfZmf2cl7TJ/jvB66BmrvTyjQkX9 rx+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mxn0bvKF; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v3-20020aa7d803000000b004359684a3a6si4729643edq.533.2022.06.29.03.14.45; Wed, 29 Jun 2022 03:15:10 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=mxn0bvKF; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232875AbiF2Jbj (ORCPT + 99 others); Wed, 29 Jun 2022 05:31:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232909AbiF2Jba (ORCPT ); Wed, 29 Jun 2022 05:31:30 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 674823A19F; Wed, 29 Jun 2022 02:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656495089; x=1688031089; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=6XgOU8eRPAfaRBGVd2axJoVIivSpVH9so8YeDqxKLnU=; b=mxn0bvKFVN+dp4UHWKausY+tUgEffng06T6tYSAboWOx1KcSMNzZGzYr /TnqFoXjfH+LrsCOeKEdltsZpx03Pmtk3S/1lI4pT8T/R7pMJU/pxStL+ vOJULRYb5fvkzycCJDiE3eKfMnrLFG/xOZKGfkZ15fSBxXWzq8L61lGk/ jZ6AVjhR23bTHhZJALwT5nout0xmznm87U2VXArsUniRGqcufKjiFXVH9 OnUTUp5w86PHdSkdJKugCIgA7DcPyCCObR+SJvFGzpaOh6fzkX9iNxBwj TruOupmHeMBgXrASDva/VXBAOlJwCqSTEZBVXMktO23oupESwR5t5P6Sv A==; X-IronPort-AV: E=McAfee;i="6400,9594,10392"; a="282019383" X-IronPort-AV: E=Sophos;i="5.92,231,1650956400"; d="scan'208";a="282019383" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2022 02:31:28 -0700 X-IronPort-AV: E=Sophos;i="5.92,231,1650956400"; d="scan'208";a="733117286" Received: from dsummer-mobl.ger.corp.intel.com ([10.252.38.121]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2022 02:31:27 -0700 Date: Wed, 29 Jun 2022 12:31:25 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Tony Lindgren cc: Andy Shevchenko , Greg Kroah-Hartman , Jiri Slaby , linux-serial , LKML Subject: Re: [PATCH] serial: 8250: Fix PM usage_count for console handover In-Reply-To: Message-ID: <5548afe5-20aa-9066-37e7-a3b2b26872e1@linux.intel.com> References: <20220628165834.63044-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-2038978736-1656495088=:1529" X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,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 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-2038978736-1656495088=:1529 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT 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. -- i. --8323329-2038978736-1656495088=:1529--