Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp124897rdb; Tue, 31 Oct 2023 02:48:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvLa1wzl/eDRRj4ozmTIqXkZh6HMN2+vafu0Ad9YIwVnE5yq+CkFwiRkcRevomDcmkoFgm X-Received: by 2002:a05:6a00:3a08:b0:6be:5367:211b with SMTP id fj8-20020a056a003a0800b006be5367211bmr10538939pfb.3.1698745710769; Tue, 31 Oct 2023 02:48:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698745710; cv=none; d=google.com; s=arc-20160816; b=XxSuuPLxndEfgjDXWAqBO4hWOVd6DIBouYotBVVNSZrh0j2TbOISh4KZ6iyPUTq/Ej DOOSEcOUjgfEGzaTSZzPV4NdzCuiU926pUhCHrRDBMB9X8J51DPvsCOa0iR7ksogCKVq MbNGHZBflkzm4vsM8atDXiV3RZlucVQrj7fSDbG/kZlx4AFADiGSphTKMO3o5Cxj/IgR q57lILkDrrjgW/AjoFxrEYDXWW0JLtl/0Hj60+3PlCvLvdhHk5PwtLr+FG+iKecrwbgO 2GTZ+WpWlQoFrdtB/6L175zZ16V0yYhoLxO+Co6FaCHECFb2LIoUQsBrQ/niKXP2CN96 tI+w== 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=cjnG9M0N5AJssB5f4/UZOIeO7ygdSV2NSpSnJwhZuPE=; fh=8sbPN7xiaeth6cIjS6gbltf0yAr/EdzR+RKPJYlqB+Y=; b=nGQzgyOxeo7br0LJc3k5udFBRKrZbpUjWPAfWFRxP4sqQzzneMDlsw+LudlMStW2MF HshcJBG/yCE1a8Gv0P8g6gFu6po+MkTddlu+b9+J2LcfekBmEQMGkEszmV1LjA5gexlB N/4695svZ6mMzWXvZ1d9nsc4NjgDZlLiqZkKV7eqH8nJ5A5Qhjc0eXrAh7xnCDOy0tW1 NelFvKK3Harxf9mnfac3jDYyZE4y/xoAfVSBpVsHV1FChwopI/iYSNoFpyhn9h9GPYIM haioghUyQGqrbvwFsGZGQlIUHCWrGaBH6XkdH1mP8Q4A3IcVlm7r15Aa40bbOY+RCujm aoTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="BW0jS6/L"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id e20-20020aa79814000000b006bf6287097csi761213pfl.213.2023.10.31.02.48.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 02:48:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="BW0jS6/L"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 5B4B780BA6B5; Tue, 31 Oct 2023 02:48:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230464AbjJaJsV (ORCPT + 99 others); Tue, 31 Oct 2023 05:48:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230264AbjJaJsT (ORCPT ); Tue, 31 Oct 2023 05:48:19 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2557ED8; Tue, 31 Oct 2023 02:48:17 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E787C433C8; Tue, 31 Oct 2023 09:48:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1698745696; bh=sM1Wv4trc5rYZHu5HPyjKmqhgM0mXr3pLbPOECiZojA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BW0jS6/LBpKeo8eSNpHnM0lI92BdOehwUWDCNEqNAwtKgSgNv49mXuO0AYlgO8v3M H7b5YRXO1CESFmn6lcM8v9y1DLYWYPDuRhwMpfS0ZfmMm7gwqkv6ALrjoR+0w5nj72 KS2x/XljH6UXfgQmWSQaUn1mHjNIHlimwKpCRYyM= Date: Tue, 31 Oct 2023 10:48:13 +0100 From: Greg KH To: Guan-Yu Lin Cc: rafael@kernel.org, len.brown@intel.com, pavel@ucw.cz, stern@rowland.harvard.edu, heikki.krogerus@linux.intel.com, mkl@pengutronix.de, hadess@hadess.net, mailhol.vincent@wanadoo.fr, ivan.orlov0322@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, pumahsu@google.com, raychi@google.com, albertccwang@google.com Subject: Re: [PATCH] rpm: pm: enable PM_RPM_EXCEPTION config flag Message-ID: <2023103133-kelp-copartner-8e9c@gregkh> References: <20231031093921.755204-1-guanyulin@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231031093921.755204-1-guanyulin@google.com> X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 31 Oct 2023 02:48:28 -0700 (PDT) On Tue, Oct 31, 2023 at 05:38:55PM +0800, Guan-Yu Lin wrote: > Introducing PM_RPM_EXCEPTION config flag, which may alter the priority > between system power management and runtime power management. In > suspend-to-idle flow, PM core will suspend all devices to avoid device > interact with the system. However, chances are devices might be used by > other systems rather than a single system. In this case, PM core shouldn't > suspend the devices. One may use PM_RPM_EXCEPTION config flag to mark > such exception, and determine the power state of a device with runtime > power management rather than system power management. > > Signed-off-by: Guan-Yu Lin > --- > drivers/usb/core/generic.c | 6 ++++++ > drivers/usb/core/usb.h | 16 ++++++++++++++++ > kernel/power/Kconfig | 8 ++++++++ > 3 files changed, 30 insertions(+) > > diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c > index 740342a2812a..bb0dfcfc9764 100644 > --- a/drivers/usb/core/generic.c > +++ b/drivers/usb/core/generic.c > @@ -266,6 +266,9 @@ int usb_generic_driver_suspend(struct usb_device *udev, pm_message_t msg) > { > int rc; > > + if (usb_runtime_pm_exception(udev)) > + return 0; > + > /* Normal USB devices suspend through their upstream port. > * Root hubs don't have upstream ports to suspend, > * so we have to shut down their downstream HC-to-USB > @@ -294,6 +297,9 @@ int usb_generic_driver_resume(struct usb_device *udev, pm_message_t msg) > { > int rc; > > + if (usb_runtime_pm_exception(udev)) > + return 0; > + > /* Normal USB devices resume/reset through their upstream port. > * Root hubs don't have upstream ports to resume or reset, > * so we have to start up their downstream HC-to-USB > diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h > index 60363153fc3f..14a054f814a2 100644 > --- a/drivers/usb/core/usb.h > +++ b/drivers/usb/core/usb.h > @@ -90,6 +90,22 @@ extern void usb_major_cleanup(void); > extern int usb_device_supports_lpm(struct usb_device *udev); > extern int usb_port_disable(struct usb_device *udev); > > +#ifdef CONFIG_PM_RPM_EXCEPTION > + > +static inline int usb_runtime_pm_exception(struct usb_device *udev) > +{ > + return atomic_read(&udev->dev.power.usage_count); > +} > + > +#else > + > +static inline int usb_runtime_pm_exception(struct usb_device *udev) > +{ > + return 0; > +} > + > +#endif > + > #ifdef CONFIG_PM > > extern int usb_suspend(struct device *dev, pm_message_t msg); > diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig > index 4b31629c5be4..beba7a0f3947 100644 > --- a/kernel/power/Kconfig > +++ b/kernel/power/Kconfig > @@ -193,6 +193,14 @@ config PM > responsible for the actual handling of device suspend requests and > wake-up events. > > +config PM_RPM_EXCEPTION > + bool "Prioritize Runtime Power Management more than Power Management" > + default n The default is always 'n' so no need to specify it. > + help > + Provides a way to prioritize Runtime Power Management more than Power > + Management. This way system can suspnd with maintaining specific > + components in operation. This really doesn't give me a good description of why someone would ever want to enable this at all. And why does this have to be a build option? That feels very heavy, why not make it changable at runtime? If this is a build option, how are you going to get all the distros and all of the Android/ChromeOS systems in the world to enable it? thanks, greg k-h