[{"id":1759449,"web_url":"http://patchwork.ozlabs.org/comment/1759449/","msgid":"<13933269.sbLfAJfmVU@aspire.rjw.lan>","list_archive_url":null,"date":"2017-08-29T15:15:02","subject":"Re: [PATCH v3 1/8] PM / Sleep: Make the runtime PM centric path\n\tknown to the PM core","submitter":{"id":26536,"url":"http://patchwork.ozlabs.org/api/people/26536/","name":"Rafael J. Wysocki","email":"rjw@rjwysocki.net"},"content":"On Tuesday, August 29, 2017 4:56:43 PM CEST Ulf Hansson wrote:\n> The main principle behind the runtime PM centric path, is to re-use the\n> runtime PM callbacks to implement system sleep - and while doing that also\n> achieve a fully optimized behaviour from PM point of view.\n> \n> More precisely, avoid to wake up a device from its low power state during\n> system sleep, unless the device is really needed to be operational. That\n> does not only mean avoiding to waste power, but may also decrease system\n> suspend/resume time for a device.\n> \n> However, using the runtime PM centric path for a device, does put some\n> requirements on the behaviour of the PM core and a potential PM domain that\n> may be attached to the device. So far, these requirements are not being\n> specially considered, except by the generic PM domain.\n> \n> To move forward and to make it possible to deploy the runtime PM centric\n> path for cross SoC drivers, which may have different PM domains attached to\n> its devices depending on the SoC, we must address how to deal with these\n> requirements. This change starts by making some adoptions to the PM core,\n> while other parts, such as the ACPI PM domain needs to be taken care of\n> separately.\n> \n> In the runtime PM centric path, the driver is expected to make use of the\n> pm_runtime_force_suspend|resume() helpers, to deploy system sleep support.\n> More precisely it may assign the system sleep callbacks to these helpers or\n> may call them from its own callbacks, in case it needs to perform\n> additional actions during system sleep.\n> \n> In other words, the PM core must always invoke the system sleep callbacks\n> for the device when they are present, to allow the driver to deal with\n> the system sleep operations.\n> \n> In case the PM core decides to run the direct_complete path for the device,\n> it skips invoking most of the system sleep callbacks, besides\n> ->prepare|complete(). Therefore using the direct_complete path in\n> combination with the runtime PM centric patch for a device, does not play\n> well.\n> \n> To deal with this issue, let's add a flag 'is_rpm_sleep', to the struct\n> dev_pm_info. The driver that deploys the runtime PM centric path, shall set\n> the flag for the device during ->probe(), to inform the PM core about that\n> it must not use the direct_complete path for the device.\n> \n> Note, not allowing the direct_complete path for a device, doesn't implicit\n> need to propagate to the device's parent/suppliers. Therefore make the PM\n> core check this condition in device_suspend(), before it decides to abandon\n> the direct_complete path for parent/suppliers.\n> \n> To make the is_rpm_sleep flag internal to the PM core, let's add two APIs.\n> \t- dev_pm_use_rpm_sleep(): It sets the flag and should be called by\n> \t  the driver during ->probe().\n> \t- dev_pm_is_rpm_sleep(): Makes it possible for users of the device,\n> \t  like a PM domain, to fetch the state of the flag.\n> \n> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>\n> ---\n> \n> Changes in v3:\n> \t- New patch.\n> \t- This replaces the earlier method of adding the no_direct_complete to\n> \tthe ACPI structures, according to comments from Rafael.\n> \t- This change also address the consern Rafael had around that\n> \tdirect_complete should not have to be disabled for parent/suppliers, in\n> \tcase a device use the runtime PM centric path for system sleep.\n> \n> ---\n>  drivers/base/power/main.c    | 49 +++++++++++++++++++++++++++++++++++++++-----\n>  drivers/base/power/runtime.c |  1 +\n>  include/linux/pm.h           |  7 +++++++\n>  3 files changed, 52 insertions(+), 5 deletions(-)\n> \n> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c\n> index ea1732e..865737a 100644\n> --- a/drivers/base/power/main.c\n> +++ b/drivers/base/power/main.c\n> @@ -1549,14 +1549,16 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)\n>  \t\tif (parent) {\n>  \t\t\tspin_lock_irq(&parent->power.lock);\n>  \n> -\t\t\tdev->parent->power.direct_complete = false;\n> +\t\t\tif (!dev->power.is_rpm_sleep)\n> +\t\t\t\tdev->parent->power.direct_complete = false;\n\nThis doesn't look good to me at all.\n\nIt potentially breaks the fundamental assumption of the direct_complete\nmechanism that no devices with that flag set will ever be runtime resumed\nduring system suspend.\n\nWhich can happen with this change if a device with power.is_rpm_sleep is\nresumed causing the parent to be resumed too.\n\n>  \t\t\tif (dev->power.wakeup_path\n>  \t\t\t    && !dev->parent->power.ignore_children)\n>  \t\t\t\tdev->parent->power.wakeup_path = true;\n>  \n>  \t\t\tspin_unlock_irq(&parent->power.lock);\n>  \t\t}\n> -\t\tdpm_clear_suppliers_direct_complete(dev);\n> +\t\tif (!dev->power.is_rpm_sleep)\n> +\t\t\tdpm_clear_suppliers_direct_complete(dev);\n\nAnd same here.\n\n>  \t}\n>  \n>  \tdevice_unlock(dev);\n> @@ -1709,11 +1711,14 @@ static int device_prepare(struct device *dev, pm_message_t state)\n>  \t * A positive return value from ->prepare() means \"this device appears\n>  \t * to be runtime-suspended and its state is fine, so if it really is\n>  \t * runtime-suspended, you can leave it in that state provided that you\n> -\t * will do the same thing with all of its descendants\".  This only\n> -\t * applies to suspend transitions, however.\n> +\t * will do the same thing with all of its descendants\". To allow this,\n> +\t * the is_rpm_sleep flag must not be set, which is default false, but\n> +\t * may have been changed by a driver. This only applies to suspend\n> +\t * transitions, however.\n>  \t */\n>  \tspin_lock_irq(&dev->power.lock);\n> -\tdev->power.direct_complete = ret > 0 && state.event == PM_EVENT_SUSPEND;\n> +\tdev->power.direct_complete = ret > 0 && !dev->power.is_rpm_sleep &&\n> +\t\t\t\tstate.event == PM_EVENT_SUSPEND;\n\nThe only problem addressed by avoiding direct_complete is when runtime PM needs\nto work during __device_suspend() for devices with direct_complete set.  You\nsaid that this was not the case with the i2c designware driver, so I'm not sure\nwhat the purpose of this is.\n\nIt doesn't solve any other problems at all.\n\n>  \tspin_unlock_irq(&dev->power.lock);\n>  \treturn 0;\n>  }\n> @@ -1841,6 +1846,40 @@ void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *))\n>  }\n>  EXPORT_SYMBOL_GPL(dpm_for_each_dev);\n>  \n> +/**\n> + * dev_pm_use_rpm_sleep - use the runtime PM centric sleep path.\n> + * @dev: the device to use the path for.\n> + *\n> + * The runtime PM centric path requires the system sleep callbacks for the\n> + * driver of the device to be invoked. This function sets the is_rpm_sleep flag\n> + * to enable this path to be used, which makes the PM core to adopt to this\n> + * behaviour. More precisely the PM core makes sure to not run the\n> + * direct_complete path for the chosen device during system sleep, when the\n> + * is_rpm_sleep flag is set. A driver using the runtime PM centric path, shall\n> + * use the pm_runtime_force_suspend|resume() helpers, to deploy system sleep\n> + * support and call this function during ->probe().\n> + * The is_rpm_sleep flag is cleared when unbinding/bind-failure of the driver.\n> + */\n> +void dev_pm_use_rpm_sleep(struct device *dev)\n> +{\n> +\tdev->power.is_rpm_sleep = true;\n> +}\n> +EXPORT_SYMBOL_GPL(dev_pm_use_rpm_sleep);\n> +\n> +/**\n> + * dev_pm_is_rpm_sleep - Returns the value of the is_rpm_sleep flag.\n> + * @dev: the device to return the flag for.\n> + *\n> + * The caller of this function is typically a subsystem or a PM domain that\n> + * needs to know if the runtime PM centric path is used for the device. It may\n> + * be invoked during any of the system sleep phases.\n> + */\n> +bool dev_pm_is_rpm_sleep(struct device *dev)\n> +{\n> +\treturn dev->power.is_rpm_sleep;\n> +}\n> +EXPORT_SYMBOL_GPL(dev_pm_is_rpm_sleep);\n> +\n>  static bool pm_ops_is_empty(const struct dev_pm_ops *ops)\n>  {\n>  \tif (!ops)\n> diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c\n> index 7bcf80f..b2ab22c 100644\n> --- a/drivers/base/power/runtime.c\n> +++ b/drivers/base/power/runtime.c\n> @@ -1522,6 +1522,7 @@ void pm_runtime_reinit(struct device *dev)\n>  \t\t\t\tpm_runtime_put(dev->parent);\n>  \t\t}\n>  \t}\n> +\tdev->power.is_rpm_sleep = false;\n>  }\n>  \n>  /**\n> diff --git a/include/linux/pm.h b/include/linux/pm.h\n> index 47ded8a..5bf96d2 100644\n> --- a/include/linux/pm.h\n> +++ b/include/linux/pm.h\n> @@ -559,6 +559,7 @@ struct dev_pm_info {\n>  \tbool\t\t\tis_suspended:1;\t/* Ditto */\n>  \tbool\t\t\tis_noirq_suspended:1;\n>  \tbool\t\t\tis_late_suspended:1;\n> +\tbool\t\t\tis_rpm_sleep:1;\t/* Owned by the PM core */\n\nIt is expected to be set by drivers, so by definition it is *not* owned by the\nPM core.\n\n>  \tbool\t\t\tearly_init:1;\t/* Owned by the PM core */\n>  \tbool\t\t\tdirect_complete:1;\t/* Owned by the PM core */\n>  \tspinlock_t\t\tlock;\n> @@ -716,6 +717,9 @@ extern void __suspend_report_result(const char *function, void *fn, int ret);\n>  extern int device_pm_wait_for_dev(struct device *sub, struct device *dev);\n>  extern void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *));\n>  \n> +extern void dev_pm_use_rpm_sleep(struct device *dev);\n> +extern bool dev_pm_is_rpm_sleep(struct device *dev);\n> +\n>  extern int pm_generic_prepare(struct device *dev);\n>  extern int pm_generic_suspend_late(struct device *dev);\n>  extern int pm_generic_suspend_noirq(struct device *dev);\n> @@ -759,6 +763,9 @@ static inline void dpm_for_each_dev(void *data, void (*fn)(struct device *, void\n>  {\n>  }\n>  \n> +static inline void dev_pm_use_rpm_sleep(struct device *dev) {}\n> +static inline bool dev_pm_is_rpm_sleep(struct device *dev) { return false; }\n> +\n>  #define pm_generic_prepare\t\tNULL\n>  #define pm_generic_suspend_late\t\tNULL\n>  #define pm_generic_suspend_noirq\tNULL\n> \n\nThanks,\nRafael","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"F9XqSjgo\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xhXVS1zvpz9t38\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 01:24:16 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dmiN7-0000DJ-DL; Tue, 29 Aug 2017 15:24:09 +0000","from cloudserver094114.home.net.pl ([79.96.170.134])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dmiN2-0000AI-W7 for linux-arm-kernel@lists.infradead.org;\n\tTue, 29 Aug 2017 15:24:08 +0000","from 79.184.253.199.ipv4.supernova.orange.pl (79.184.253.199) (HELO\n\taspire.rjw.lan)\n\tby serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer\n\t0.82) id e80b735aa4954770; Tue, 29 Aug 2017 17:23:41 +0200"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=UPTAxuLZMY53PbRQRmLMuZ5zy82u4r2HyMyq8i2QbAI=;\n\tb=F9XqSjgoZHlwg/\n\teNNV718DajUq7my5F7ATp2J7ux0Qu82LmDeBDX3quXf6T7P6ggv46T0Zqx7bDLSpNX78PO/n4nkJ8\n\t2OzahDLFKq8X70Gaq+Poyg8YPHkDWd9vqnPWNbbe1O3q/fPFO/oZvqN/mGqbnoIKD8AXozTJy5a5O\n\tYI4v3MbFck8Ofbx6+cJBm0jFSuaJFX36Eii7zIm0VgyCDfGP/oguepL73nnvm+eGINdFw/J3mKbEX\n\tRcizGAqlSFAnhXAR9WnpgmUcHNPNd82/6NssvP/52mqNH55W8tpMog49Nq2/AEcu/yPN28qtn8RdZ\n\tj66AcPV2GijjwZvV2oVA==;","From":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","To":"Ulf Hansson <ulf.hansson@linaro.org>","Subject":"Re: [PATCH v3 1/8] PM / Sleep: Make the runtime PM centric path\n\tknown to the PM core","Date":"Tue, 29 Aug 2017 17:15:02 +0200","Message-ID":"<13933269.sbLfAJfmVU@aspire.rjw.lan>","In-Reply-To":"<1504018610-10822-2-git-send-email-ulf.hansson@linaro.org>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<1504018610-10822-2-git-send-email-ulf.hansson@linaro.org>","MIME-Version":"1.0","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170829_082405_308279_E228B67A ","X-CRM114-Status":"GOOD (  42.13  )","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>, linux-pm@vger.kernel.org,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\tlinux-i2c@vger.kernel.org, linux-acpi@vger.kernel.org,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\tlinux-arm-kernel@lists.infradead.org, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1759467,"web_url":"http://patchwork.ozlabs.org/comment/1759467/","msgid":"<2855684.NY3Ly9PzrE@aspire.rjw.lan>","list_archive_url":null,"date":"2017-08-29T15:27:55","subject":"Re: [PATCH v3 6/8] PM / ACPI: Enable the runtime PM centric approach\n\tfor system sleep","submitter":{"id":26536,"url":"http://patchwork.ozlabs.org/api/people/26536/","name":"Rafael J. Wysocki","email":"rjw@rjwysocki.net"},"content":"On Tuesday, August 29, 2017 4:56:48 PM CEST Ulf Hansson wrote:\n> This change enables the ACPI PM domain to cope with drivers that deploys\n> the runtime PM centric path for system sleep.\n\n[cut]\n\n> @@ -1052,11 +1066,20 @@ EXPORT_SYMBOL_GPL(acpi_subsys_complete);\n>   * @dev: Device to handle.\n>   *\n>   * Follow PCI and resume devices suspended at run time before running their\n> - * system suspend callbacks.\n> + * system suspend callbacks. However, try to avoid it in case the runtime PM\n> + * centric path is used for the device and then trust the driver to do the\n> + * right thing.\n>   */\n>  int acpi_subsys_suspend(struct device *dev)\n>  {\n> -\tpm_runtime_resume(dev);\n> +\tstruct acpi_device *adev = ACPI_COMPANION(dev);\n> +\n> +\tif (!adev)\n> +\t\treturn 0;\n> +\n> +\tif (!dev_pm_is_rpm_sleep(dev) || acpi_dev_needs_resume(dev, adev))\n> +\t\tpm_runtime_resume(dev);\n> +\n>  \treturn pm_generic_suspend(dev);\n>  }\n>  EXPORT_SYMBOL_GPL(acpi_subsys_suspend);\n\nWell, I tried to avoid calling acpi_dev_needs_resume() for multiple times\nand that's why I added the update_state thing.\n\nMoreover, the is_rpm_sleep flag here has to mean not only that\ndirect_complete should not be used with the device, but also that its driver\nis fine with not resuming it.\n\nIMO it is not a good idea to use one flag for these two different things at the\nsame time at all.\n\nThanks,\nRafael","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"lMufYlmF\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xhXnV3tfDz9t33\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 01:37:16 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dmiZd-0006C6-Sc; Tue, 29 Aug 2017 15:37:05 +0000","from cloudserver094114.home.net.pl ([79.96.170.134])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dmiZW-00068i-JH for linux-arm-kernel@lists.infradead.org;\n\tTue, 29 Aug 2017 15:37:03 +0000","from 79.184.253.199.ipv4.supernova.orange.pl (79.184.253.199) (HELO\n\taspire.rjw.lan)\n\tby serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer\n\t0.82) id 944c6b487de22f45; Tue, 29 Aug 2017 17:36:35 +0200"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=bRZVPSkk8s7ndV0O2+jIFUV5LaGWa0eCGrAZL8Fp370=;\n\tb=lMufYlmFgxrEV7\n\tbISCVsJwdF2poCn23E8poopjwI/uokzsqIiva2jdNQ08/iS2DQclAqTwka7gf2Xa5elOpjbPYYsge\n\t1t7Yp1ltnB6VkPr+aSa0t0oK7glk2bUqAkYHQunBx6bViGlSfD2RlDNGKANZIDIkYIAEzBSPgnmHT\n\tXUZZ+i/HgrYbk7vGMqx/NrBSRDcAyG61yWWWBi/fiikQ9ZTqFJY7qcrUyYSi5pKbtSG8dEx5RNR/L\n\t2gEPPpuUfC5ChV140sRpv52Ec4PZtlUqYIexMp9mg77kKJuScEUMdhWkKFbZqndNzqyGNnghhumZ+\n\t+SUcD/7pNdJfOLHX3wDQ==;","From":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","To":"Ulf Hansson <ulf.hansson@linaro.org>","Subject":"Re: [PATCH v3 6/8] PM / ACPI: Enable the runtime PM centric approach\n\tfor system sleep","Date":"Tue, 29 Aug 2017 17:27:55 +0200","Message-ID":"<2855684.NY3Ly9PzrE@aspire.rjw.lan>","In-Reply-To":"<1504018610-10822-7-git-send-email-ulf.hansson@linaro.org>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<1504018610-10822-7-git-send-email-ulf.hansson@linaro.org>","MIME-Version":"1.0","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170829_083658_912628_BEF23022 ","X-CRM114-Status":"GOOD (  14.90  )","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>, linux-pm@vger.kernel.org,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\tlinux-i2c@vger.kernel.org, linux-acpi@vger.kernel.org,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\tlinux-arm-kernel@lists.infradead.org, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1759654,"web_url":"http://patchwork.ozlabs.org/comment/1759654/","msgid":"<1957183.ZU1CWrAZoR@aspire.rjw.lan>","list_archive_url":null,"date":"2017-08-29T20:19:43","subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","submitter":{"id":26536,"url":"http://patchwork.ozlabs.org/api/people/26536/","name":"Rafael J. Wysocki","email":"rjw@rjwysocki.net"},"content":"On Tuesday, August 29, 2017 4:56:42 PM CEST Ulf Hansson wrote:\n> The i2c designware platform driver, drivers/i2c/busses/i2c-designware-platdrv.c,\n> isn't well optimized for system sleep.\n> \n> What makes this driver particularly interesting is because it's a cross-SoC\n> driver, which sometimes means there is an ACPI PM domain attached to the i2c\n> device and sometimes not. The driver is being used on both x86 and ARM.\n> \n> In principle, to optimize the system sleep support in i2c driver, this series\n> enables the proven runtime PM centric path for the i2c driver. However, to do\n> that the ACPI PM domain also have to collaborate and understand this behaviour.\n> From earlier versions, Rafael has also pointed out that also the PM core needs\n> to be involved.\n\nEarlier today I realized that drivers pointing their ->suspend_late and\n->resume_early callbacks, respectively, to pm_runtime_force_suspend() and\npm_runtime_force_resume(), are fundamentally incompatible with any bus type\ndoing nontrivial PM and with almost any nontrivial PM domains, for two reasons.\n\nFirst, it basically requires the bus type or PM domain to expect that its\n->runtime_suspend callback may or may not be indirectly invoked from its\nown ->suspend_late callback, depending on the driver (and analogously\nfor ->runtime_resume and ->resume early), which is insane.\n\nSecond, it is a layering violation, because it makes the driver effectively\noverride the upper layer's decisions about what code to run.\n\nThat's why I'm afraid that we've reached a dead end here. :-(\n\nThanks,\nRafael","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"lIngg5KP\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xhgGW51LXz9sR9\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 06:29:23 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dmn8R-0006wy-UX; Tue, 29 Aug 2017 20:29:20 +0000","from cloudserver094114.home.net.pl ([79.96.170.134])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dmn7x-0006aP-5b for linux-arm-kernel@lists.infradead.org;\n\tTue, 29 Aug 2017 20:28:53 +0000","from 79.184.253.199.ipv4.supernova.orange.pl (79.184.253.199) (HELO\n\taspire.rjw.lan)\n\tby serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer\n\t0.82) id ee08f67d5e0703dd; Tue, 29 Aug 2017 22:28:23 +0200"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=a8LWRgpexQz8A8NlJB1GAq77oZNuMpQhSJtqbz8W13w=;\n\tb=lIngg5KPzFx/3R\n\tY/yA9jSn7IOqPZ+c7khPhKbKTZYjUD8kNOaq3yquHHPp5O3+y32f/SSe3Vg0na3pro/j3+juBU7Uh\n\tgmz5OP2i4Vd8I+ZpbNkdHo7z7AQLuGmBcf1SkowTm0L90a5uHVcSqQgTBiJHLo+cfjoXlp7WTU/LB\n\tJhIp1vnru4QcinXogt88B1ldhiAOe7tIykDNXoZpV6WP7Dhius/YSKghOMtoYS2pGdt0v20jULein\n\tEoQlrZEc7McSQXLxB4+6Ex/M05QB2oEqOkAC/OcD4h8dGDLuVf3jnh8S+gpyn1iq/eox3+77W72dl\n\tHW19kUiMBs5wSGYFnTxg==;","From":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","To":"Ulf Hansson <ulf.hansson@linaro.org>","Subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","Date":"Tue, 29 Aug 2017 22:19:43 +0200","Message-ID":"<1957183.ZU1CWrAZoR@aspire.rjw.lan>","In-Reply-To":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>","MIME-Version":"1.0","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170829_132849_722963_D2D48A2C ","X-CRM114-Status":"GOOD (  10.99  )","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>, linux-pm@vger.kernel.org,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\tlinux-i2c@vger.kernel.org, linux-acpi@vger.kernel.org,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\tlinux-arm-kernel@lists.infradead.org, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1759924,"web_url":"http://patchwork.ozlabs.org/comment/1759924/","msgid":"<CAPDyKFqujAbw9RAxG-kRhgnhEtAZeojBiL=v5F+JS3T9eaxfgQ@mail.gmail.com>","list_archive_url":null,"date":"2017-08-30T07:13:47","subject":"Re: [PATCH v3 1/8] PM / Sleep: Make the runtime PM centric path\n\tknown to the PM core","submitter":{"id":21036,"url":"http://patchwork.ozlabs.org/api/people/21036/","name":"Ulf Hansson","email":"ulf.hansson@linaro.org"},"content":"On 29 August 2017 at 17:15, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:\n> On Tuesday, August 29, 2017 4:56:43 PM CEST Ulf Hansson wrote:\n>> The main principle behind the runtime PM centric path, is to re-use the\n>> runtime PM callbacks to implement system sleep - and while doing that also\n>> achieve a fully optimized behaviour from PM point of view.\n>>\n>> More precisely, avoid to wake up a device from its low power state during\n>> system sleep, unless the device is really needed to be operational. That\n>> does not only mean avoiding to waste power, but may also decrease system\n>> suspend/resume time for a device.\n>>\n>> However, using the runtime PM centric path for a device, does put some\n>> requirements on the behaviour of the PM core and a potential PM domain that\n>> may be attached to the device. So far, these requirements are not being\n>> specially considered, except by the generic PM domain.\n>>\n>> To move forward and to make it possible to deploy the runtime PM centric\n>> path for cross SoC drivers, which may have different PM domains attached to\n>> its devices depending on the SoC, we must address how to deal with these\n>> requirements. This change starts by making some adoptions to the PM core,\n>> while other parts, such as the ACPI PM domain needs to be taken care of\n>> separately.\n>>\n>> In the runtime PM centric path, the driver is expected to make use of the\n>> pm_runtime_force_suspend|resume() helpers, to deploy system sleep support.\n>> More precisely it may assign the system sleep callbacks to these helpers or\n>> may call them from its own callbacks, in case it needs to perform\n>> additional actions during system sleep.\n>>\n>> In other words, the PM core must always invoke the system sleep callbacks\n>> for the device when they are present, to allow the driver to deal with\n>> the system sleep operations.\n>>\n>> In case the PM core decides to run the direct_complete path for the device,\n>> it skips invoking most of the system sleep callbacks, besides\n>> ->prepare|complete(). Therefore using the direct_complete path in\n>> combination with the runtime PM centric patch for a device, does not play\n>> well.\n>>\n>> To deal with this issue, let's add a flag 'is_rpm_sleep', to the struct\n>> dev_pm_info. The driver that deploys the runtime PM centric path, shall set\n>> the flag for the device during ->probe(), to inform the PM core about that\n>> it must not use the direct_complete path for the device.\n>>\n>> Note, not allowing the direct_complete path for a device, doesn't implicit\n>> need to propagate to the device's parent/suppliers. Therefore make the PM\n>> core check this condition in device_suspend(), before it decides to abandon\n>> the direct_complete path for parent/suppliers.\n>>\n>> To make the is_rpm_sleep flag internal to the PM core, let's add two APIs.\n>>       - dev_pm_use_rpm_sleep(): It sets the flag and should be called by\n>>         the driver during ->probe().\n>>       - dev_pm_is_rpm_sleep(): Makes it possible for users of the device,\n>>         like a PM domain, to fetch the state of the flag.\n>>\n>> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>\n>> ---\n>>\n>> Changes in v3:\n>>       - New patch.\n>>       - This replaces the earlier method of adding the no_direct_complete to\n>>       the ACPI structures, according to comments from Rafael.\n>>       - This change also address the consern Rafael had around that\n>>       direct_complete should not have to be disabled for parent/suppliers, in\n>>       case a device use the runtime PM centric path for system sleep.\n>>\n>> ---\n>>  drivers/base/power/main.c    | 49 +++++++++++++++++++++++++++++++++++++++-----\n>>  drivers/base/power/runtime.c |  1 +\n>>  include/linux/pm.h           |  7 +++++++\n>>  3 files changed, 52 insertions(+), 5 deletions(-)\n>>\n>> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c\n>> index ea1732e..865737a 100644\n>> --- a/drivers/base/power/main.c\n>> +++ b/drivers/base/power/main.c\n>> @@ -1549,14 +1549,16 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)\n>>               if (parent) {\n>>                       spin_lock_irq(&parent->power.lock);\n>>\n>> -                     dev->parent->power.direct_complete = false;\n>> +                     if (!dev->power.is_rpm_sleep)\n>> +                             dev->parent->power.direct_complete = false;\n>\n> This doesn't look good to me at all.\n>\n> It potentially breaks the fundamental assumption of the direct_complete\n> mechanism that no devices with that flag set will ever be runtime resumed\n> during system suspend.\n>\n> Which can happen with this change if a device with power.is_rpm_sleep is\n> resumed causing the parent to be resumed too.\n\nDoesn't the exact same problem you describe, already exist prior my change!?\n\nThat is, if the current device is runtime suspended and the\ndirect_complete flag is set for it, then __device_suspend() has\nalready disabled runtime PM for the device, when we reach this point.\nThat means, a following attempts to runtime resume the device will\nfail and thus also to runtime resume its parent.\n\nSo to me, this is a different problem, related how to work out the\ncorrect order of how to suspend devices.\n\n>\n>>                       if (dev->power.wakeup_path\n>>                           && !dev->parent->power.ignore_children)\n>>                               dev->parent->power.wakeup_path = true;\n>>\n>>                       spin_unlock_irq(&parent->power.lock);\n>>               }\n>> -             dpm_clear_suppliers_direct_complete(dev);\n>> +             if (!dev->power.is_rpm_sleep)\n>> +                     dpm_clear_suppliers_direct_complete(dev);\n>\n> And same here.\n\nSee comment above.\n\n>\n>>       }\n>>\n>>       device_unlock(dev);\n>> @@ -1709,11 +1711,14 @@ static int device_prepare(struct device *dev, pm_message_t state)\n>>        * A positive return value from ->prepare() means \"this device appears\n>>        * to be runtime-suspended and its state is fine, so if it really is\n>>        * runtime-suspended, you can leave it in that state provided that you\n>> -      * will do the same thing with all of its descendants\".  This only\n>> -      * applies to suspend transitions, however.\n>> +      * will do the same thing with all of its descendants\". To allow this,\n>> +      * the is_rpm_sleep flag must not be set, which is default false, but\n>> +      * may have been changed by a driver. This only applies to suspend\n>> +      * transitions, however.\n>>        */\n>>       spin_lock_irq(&dev->power.lock);\n>> -     dev->power.direct_complete = ret > 0 && state.event == PM_EVENT_SUSPEND;\n>> +     dev->power.direct_complete = ret > 0 && !dev->power.is_rpm_sleep &&\n>> +                             state.event == PM_EVENT_SUSPEND;\n>\n> The only problem addressed by avoiding direct_complete is when runtime PM needs\n> to work during __device_suspend() for devices with direct_complete set.  You\n> said that this was not the case with the i2c designware driver, so I'm not sure\n> what the purpose of this is.\n\nI should probably work more on my changelog, because I tried to\nexplain it there.\n\nAnyway, let me quote the important parts, and this is not specific for\nthe i2c-designware-driver, but generic to drivers using\npm_runtime_force_suspend|resume().\n\n\"In the runtime PM centric path, the driver is expected to make use of\nthe pm_runtime_force_suspend|resume() helpers, to deploy system sleep\nsupport. More precisely it may assign the system sleep callbacks to\nthese helpers or may call them from its own callbacks, in case it\nneeds to perform additional actions during system sleep.\n\nIn other words, the PM core must always invoke the system sleep\ncallbacks for the device when they are present, to allow the driver to\ndeal with the system sleep operations.\"\n\nA concrete example is drivers/spi/spi-fsl-espi.c, but one can easily find more.\n\n>\n> It doesn't solve any other problems at all.\n>\n>>       spin_unlock_irq(&dev->power.lock);\n>>       return 0;\n>>  }\n>> @@ -1841,6 +1846,40 @@ void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *))\n>>  }\n>>  EXPORT_SYMBOL_GPL(dpm_for_each_dev);\n>>\n>> +/**\n>> + * dev_pm_use_rpm_sleep - use the runtime PM centric sleep path.\n>> + * @dev: the device to use the path for.\n>> + *\n>> + * The runtime PM centric path requires the system sleep callbacks for the\n>> + * driver of the device to be invoked. This function sets the is_rpm_sleep flag\n>> + * to enable this path to be used, which makes the PM core to adopt to this\n>> + * behaviour. More precisely the PM core makes sure to not run the\n>> + * direct_complete path for the chosen device during system sleep, when the\n>> + * is_rpm_sleep flag is set. A driver using the runtime PM centric path, shall\n>> + * use the pm_runtime_force_suspend|resume() helpers, to deploy system sleep\n>> + * support and call this function during ->probe().\n>> + * The is_rpm_sleep flag is cleared when unbinding/bind-failure of the driver.\n>> + */\n>> +void dev_pm_use_rpm_sleep(struct device *dev)\n>> +{\n>> +     dev->power.is_rpm_sleep = true;\n>> +}\n>> +EXPORT_SYMBOL_GPL(dev_pm_use_rpm_sleep);\n>> +\n>> +/**\n>> + * dev_pm_is_rpm_sleep - Returns the value of the is_rpm_sleep flag.\n>> + * @dev: the device to return the flag for.\n>> + *\n>> + * The caller of this function is typically a subsystem or a PM domain that\n>> + * needs to know if the runtime PM centric path is used for the device. It may\n>> + * be invoked during any of the system sleep phases.\n>> + */\n>> +bool dev_pm_is_rpm_sleep(struct device *dev)\n>> +{\n>> +     return dev->power.is_rpm_sleep;\n>> +}\n>> +EXPORT_SYMBOL_GPL(dev_pm_is_rpm_sleep);\n>> +\n>>  static bool pm_ops_is_empty(const struct dev_pm_ops *ops)\n>>  {\n>>       if (!ops)\n>> diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c\n>> index 7bcf80f..b2ab22c 100644\n>> --- a/drivers/base/power/runtime.c\n>> +++ b/drivers/base/power/runtime.c\n>> @@ -1522,6 +1522,7 @@ void pm_runtime_reinit(struct device *dev)\n>>                               pm_runtime_put(dev->parent);\n>>               }\n>>       }\n>> +     dev->power.is_rpm_sleep = false;\n>>  }\n>>\n>>  /**\n>> diff --git a/include/linux/pm.h b/include/linux/pm.h\n>> index 47ded8a..5bf96d2 100644\n>> --- a/include/linux/pm.h\n>> +++ b/include/linux/pm.h\n>> @@ -559,6 +559,7 @@ struct dev_pm_info {\n>>       bool                    is_suspended:1; /* Ditto */\n>>       bool                    is_noirq_suspended:1;\n>>       bool                    is_late_suspended:1;\n>> +     bool                    is_rpm_sleep:1; /* Owned by the PM core */\n>\n> It is expected to be set by drivers, so by definition it is *not* owned by the\n> PM core.\n\nAhh, I see. I didn't quite get those comments, thanks for clarifying.\n\n>\n>>       bool                    early_init:1;   /* Owned by the PM core */\n>>       bool                    direct_complete:1;      /* Owned by the PM core */\n>>       spinlock_t              lock;\n>> @@ -716,6 +717,9 @@ extern void __suspend_report_result(const char *function, void *fn, int ret);\n>>  extern int device_pm_wait_for_dev(struct device *sub, struct device *dev);\n>>  extern void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *));\n>>\n>> +extern void dev_pm_use_rpm_sleep(struct device *dev);\n>> +extern bool dev_pm_is_rpm_sleep(struct device *dev);\n>> +\n>>  extern int pm_generic_prepare(struct device *dev);\n>>  extern int pm_generic_suspend_late(struct device *dev);\n>>  extern int pm_generic_suspend_noirq(struct device *dev);\n>> @@ -759,6 +763,9 @@ static inline void dpm_for_each_dev(void *data, void (*fn)(struct device *, void\n>>  {\n>>  }\n>>\n>> +static inline void dev_pm_use_rpm_sleep(struct device *dev) {}\n>> +static inline bool dev_pm_is_rpm_sleep(struct device *dev) { return false; }\n>> +\n>>  #define pm_generic_prepare           NULL\n>>  #define pm_generic_suspend_late              NULL\n>>  #define pm_generic_suspend_noirq     NULL\n>>\n>\n> Thanks,\n> Rafael\n>\n\nThanks for reviewing!\n\nKind regards\nUffe","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"Qoyd0FjM\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"UxlvsSKz\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xhxZd2y41z9sQl\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 17:14:17 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dmxCX-0007XC-Ut; Wed, 30 Aug 2017 07:14:13 +0000","from mail-it0-x22e.google.com ([2607:f8b0:4001:c0b::22e])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dmxCT-0007IP-EX for linux-arm-kernel@lists.infradead.org;\n\tWed, 30 Aug 2017 07:14:11 +0000","by mail-it0-x22e.google.com with SMTP id 77so3680077itj.1\n\tfor <linux-arm-kernel@lists.infradead.org>;\n\tWed, 30 Aug 2017 00:13:48 -0700 (PDT)","by 10.2.96.38 with HTTP; Wed, 30 Aug 2017 00:13:47 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:\n\tReferences:In-Reply-To:MIME-Version:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=cQARFBnUUmrqRqTWknYYvV9rMvntOUy0PrWDjMJvoa8=;\n\tb=Qoyd0FjMQVnH7s\n\tlDQzOnruAkWD11C1mhBIvSyU7FiT7JIQo6QdNQfDSyIe1Km3Ski8kgU9ZpzQ1dCwx/SufKah/Ps10\n\tijof8+vJBLI1xhGj4tp9dURPysgkR6LwuGemsHQGxqevjBUOFkfygcpohyy/SPEmMwgfcuVPNkvOb\n\tUd7FX8Nh9DWxs2KOrVPuQvm5auolge06t6MIz7nuMLVanJ9OLbkFtOJyJU8nc40AWgVf9Fws66+6o\n\txmsFyGV+PBpOQufLdOk95wH06TaXdg10mGdDzT82zySoMCib41xQosOsZvPpT1KnXC9NQg9x0YOyL\n\t0VYJ1gg4SP18om77i1aA==;","v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=qX4ZAWHD4v7HW+t81YBNqLYgG7aNDSfM+Rbnnt4gAD4=;\n\tb=UxlvsSKzd+M0SFGxgsrTW2mYh6lgBQBUMYW3ecTb/0jr34J486YP/7CVGPC1gk4olX\n\tfB6VGC8PD4b3ZxVyVarIMZrVkTbGQ5sdrU17w+Y7C6+91+sAR7lSNgT41DOVISbi3z7M\n\t+xcZjeTczYCY9Tf1E5d02rSo7aOXNU/u0UPqM="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=qX4ZAWHD4v7HW+t81YBNqLYgG7aNDSfM+Rbnnt4gAD4=;\n\tb=kAWWIwH0DclzKD4pWjFvqevBSV5USQBdex1xS8rOMDJOB5IHC+2O58Yu47TXN38QoY\n\tspZAIRTOHpQM1ag05i4HMyx6t+BubYl1/o2WjcjWrylmw9CjXRmk6zl3yIHdgrbDuBfL\n\tLvn8fUWi2dpGzOjGN7bf85nJ5cJNa6routko/e42uVQeH3yF9itqjofmpKchloJOqxO7\n\tcwzS8W5hx5gqDs8fTalaVX33+sDcaQNbS/I1xSSRa8mCuQsh9Z74du6WdBmBfCjUcZYC\n\t1RotUSsgV99gRJy0hBj5avj2icjg0z7Frk20nzeJzPWZwHOp3qzudpqKJ/t6Vkvmm4R5\n\touSQ==","X-Gm-Message-State":"AHYfb5iIoyDh2H5gX58is5PxbkzGL4XJK/BwVJLCJcGGDgS+AB3RPHJS\n\ttRYcRYwabO9UZVcu+5vHjVUN8C/f17Rb","X-Received":"by 10.36.173.11 with SMTP id c11mr568955itf.106.1504077227872;\n\tWed, 30 Aug 2017 00:13:47 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<13933269.sbLfAJfmVU@aspire.rjw.lan>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<1504018610-10822-2-git-send-email-ulf.hansson@linaro.org>\n\t<13933269.sbLfAJfmVU@aspire.rjw.lan>","From":"Ulf Hansson <ulf.hansson@linaro.org>","Date":"Wed, 30 Aug 2017 09:13:47 +0200","Message-ID":"<CAPDyKFqujAbw9RAxG-kRhgnhEtAZeojBiL=v5F+JS3T9eaxfgQ@mail.gmail.com>","Subject":"Re: [PATCH v3 1/8] PM / Sleep: Make the runtime PM centric path\n\tknown to the PM core","To":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170830_001409_569716_2B892B4D ","X-CRM114-Status":"GOOD (  41.52  )","X-Spam-Score":"-2.7 (--)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-2.7 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/,\n\tlow\n\ttrust [2607:f8b0:4001:c0b:0:0:0:22e listed in] [list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature\n\t0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n\tnot necessarily valid\n\t-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n\tauthor's domain","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1760006,"web_url":"http://patchwork.ozlabs.org/comment/1760006/","msgid":"<CAPDyKFosu8RYUUCiBn7+03b3TNmND-aCTqR=+svcvzCwhxw9+A@mail.gmail.com>","list_archive_url":null,"date":"2017-08-30T09:57:28","subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","submitter":{"id":21036,"url":"http://patchwork.ozlabs.org/api/people/21036/","name":"Ulf Hansson","email":"ulf.hansson@linaro.org"},"content":"On 29 August 2017 at 22:19, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:\n> On Tuesday, August 29, 2017 4:56:42 PM CEST Ulf Hansson wrote:\n>> The i2c designware platform driver, drivers/i2c/busses/i2c-designware-platdrv.c,\n>> isn't well optimized for system sleep.\n>>\n>> What makes this driver particularly interesting is because it's a cross-SoC\n>> driver, which sometimes means there is an ACPI PM domain attached to the i2c\n>> device and sometimes not. The driver is being used on both x86 and ARM.\n>>\n>> In principle, to optimize the system sleep support in i2c driver, this series\n>> enables the proven runtime PM centric path for the i2c driver. However, to do\n>> that the ACPI PM domain also have to collaborate and understand this behaviour.\n>> From earlier versions, Rafael has also pointed out that also the PM core needs\n>> to be involved.\n>\n> Earlier today I realized that drivers pointing their ->suspend_late and\n> ->resume_early callbacks, respectively, to pm_runtime_force_suspend() and\n> pm_runtime_force_resume(), are fundamentally incompatible with any bus type\n> doing nontrivial PM and with almost any nontrivial PM domains, for two reasons.\n>\n> First, it basically requires the bus type or PM domain to expect that its\n> ->runtime_suspend callback may or may not be indirectly invoked from its\n> own ->suspend_late callback, depending on the driver (and analogously\n> for ->runtime_resume and ->resume early), which is insane.\n>\n> Second, it is a layering violation, because it makes the driver effectively\n> override the upper layer's decisions about what code to run.\n\nYou are right that for more complex bus types and PM domains, those\nneeds to play along. So that is what I am trying to implement for the\nACPI PM domain in this series.\n\nThe generic PM domain, is simple in this regards. There is only a\nminor adaptation for the ->runtime_suspend|resume() callbacks, which\navoids validating dev_pm_qos constraints during system sleep. Nothing\nspecial is needed in ->suspend_late|noirq callbacks, etc.\n\nFor most other simple bus types, like the platform bus, spi, i2c,\namba, no particular adoptions is needed at all. Instead those just\ntrust the drivers to do the right thing.\n\nBefore we had the direct_complete path, using the\npm_runtime_force_suspend|resume() helpers, was the only good way for\nthese kind of drivers, to in an optimized manner, deal with system\nsleep when runtime PM also was enabled for their devices. Now this\nmethod has become widely deployed, unfortunate whether you like it or\nnot.\n\nBesides the slightly better optimizations you get when using\npm_runtime_force_suspend|resume(), comparing to the direct_complete\npath - I think it's also worth to consider, how easy it becomes for\ndrivers to deploy system sleep support. In many cases, only two lines\nof code is needed to add system sleep support in a driver.\n\nNow, some complex code always needs to be implemented somewhere. When\nusing the runtime PM centric path, that code consist of the\npm_runtime_force_suspend|resume() helpers itself - and some\nadaptations in buses/PM domains in cases when those needs special\ncare.\n\nMy point is, the runtime PM centric path, allows us to keep the\ncomplex part of the code at a few centralized places, instead of\nhaving it spread/duplicated into drivers.\n\nSo yes, you could consider it insane, but to me and many others, it\nseems to work out quite well.\n\nYeah, and the laying violation is undoubtedly the most controversial\npart of the runtime PM centric path - I agree to that! The\ndirect_complete path don't have this, as you implemented it. :-)\n\nOn the other hand, one could consider that these upper layers, in many\ncases anyway needs to play along with the behavior of the driver. So,\nI guess it depends on how one see it.\n\n>\n> That's why I'm afraid that we've reached a dead end here. :-(\n\nThat's said news. Is was really hoping I could find a way to move this\nforward. You don't have any other ideas on how I can adjust the series\nto make you happy?\n\n>\n> Thanks,\n> Rafael\n>\n\nKind regards\nUffe","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"JL7/klzj\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"jl8hxeK7\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xj1CX14cqz9sNn\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 19:58:00 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dmzky-0000NM-4Z; Wed, 30 Aug 2017 09:57:56 +0000","from mail-io0-x230.google.com ([2607:f8b0:4001:c06::230])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dmzks-00087Q-8X for linux-arm-kernel@lists.infradead.org;\n\tWed, 30 Aug 2017 09:57:53 +0000","by mail-io0-x230.google.com with SMTP id k22so3530020iod.2\n\tfor <linux-arm-kernel@lists.infradead.org>;\n\tWed, 30 Aug 2017 02:57:29 -0700 (PDT)","by 10.2.96.38 with HTTP; Wed, 30 Aug 2017 02:57:28 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:\n\tReferences:In-Reply-To:MIME-Version:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=jJSyOCpYM+iR2hSxQBMJDY0nOYFL1yad8bbL3t/g21o=;\n\tb=JL7/klzj8fRCp3\n\tRCJFYYSO2t5Gn56wvD2jTSAHf5gNVYbEJj20MGTxGM/NpcD2P3uLQFIVoxgx+NTxPgsYsHkdmkNb+\n\tCIWIpDlw+DWWRZ8mpWJbiJ+5wyevhxxgXcYMZ2ngv5KU1TBjYwawt0Ru879YLv4F/OlZr8yAKF61k\n\tF2R4mk0mev7RUfbqIzd4pH88AZHJbtYBvqSAuHnIs3Mh1WQ55BMgV2Iqeki0scmfExt3TzHt6jB5b\n\tHxA9ZksvonSqgAltmpqJmeIbRk2vyg9ik42py+1H1sn5emmE6YRyFv7uJO6FqpLX1SD7dJaLE6WpP\n\tDElapP4EvZDVdZF5JenA==;","v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=oNZ0nFlT/0ox637VDpuaZmezigONBFIUNckEfNpXsu8=;\n\tb=jl8hxeK7ZTpKbOlcuqxhf5bpgB7bnMRdCVavr9BmLL8w69JGDtzEuIFEevvWo+resi\n\tG9IeskK+psUjSYODY1EWWPz5g4aP+zUsXNb/2xaidoRhi+YQ5hTuBqYFo5OUH+8/3jDz\n\tEpDPwXaK2Egn8CtVO0d6XYZKSC7caf1vHlef0="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=oNZ0nFlT/0ox637VDpuaZmezigONBFIUNckEfNpXsu8=;\n\tb=IOaiPF+mSysBb2Ug4akufzuWpnFsjRStkiXHzmoX3ztbSnhBs9Wxtv1ZqOso3wiOGl\n\t9SSIS8yub28tXC1tL4GdHjR7EJctoYGnjP14sTLTpf+00cuSdmmr+4GG0MqpQ7H0UQfQ\n\tKP1GZJw8jgs/I5jroNmajiNq/4wZMKBbTPAAwfI62lVynHZmoQqjDghdPNzoUV6v5HTy\n\tVAZr9jHNyTKKsPrQdngpNwPhPCiLyg/wWH/QYxf4b5jtAHzEgGWGp4RtK5M0A9GqtUXE\n\tdVygxvJmezln8F7li/DV00FqTxMPU6aQ+wtkrbrxFo29kGt7Hu3VKF0Z2IZcMqWqAH02\n\t3+3A==","X-Gm-Message-State":"AHPjjUgOWFxofWNKDStaFSslBOSPaFHaTv1D7AgFZtg9t9gvgh7tx5Ha\n\tZI7MYey9Ky6u5FLKDkxSqrb86dLi/EeCIZLSog==","X-Received":"by 10.107.158.12 with SMTP id h12mr766558ioe.222.1504087049011; \n\tWed, 30 Aug 2017 02:57:29 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<1957183.ZU1CWrAZoR@aspire.rjw.lan>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<1957183.ZU1CWrAZoR@aspire.rjw.lan>","From":"Ulf Hansson <ulf.hansson@linaro.org>","Date":"Wed, 30 Aug 2017 11:57:28 +0200","Message-ID":"<CAPDyKFosu8RYUUCiBn7+03b3TNmND-aCTqR=+svcvzCwhxw9+A@mail.gmail.com>","Subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","To":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170830_025750_440635_2429824C ","X-CRM114-Status":"GOOD (  23.45  )","X-Spam-Score":"-2.0 (--)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-2.0 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature\n\t0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n\tnot necessarily valid\n\t-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n\tauthor's domain","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1760160,"web_url":"http://patchwork.ozlabs.org/comment/1760160/","msgid":"<2403318.HVB4k3qRsK@aspire.rjw.lan>","list_archive_url":null,"date":"2017-08-30T13:37:08","subject":"Re: [PATCH v3 1/8] PM / Sleep: Make the runtime PM centric path\n\tknown to the PM core","submitter":{"id":26536,"url":"http://patchwork.ozlabs.org/api/people/26536/","name":"Rafael J. Wysocki","email":"rjw@rjwysocki.net"},"content":"On Wednesday, August 30, 2017 9:13:47 AM CEST Ulf Hansson wrote:\n> On 29 August 2017 at 17:15, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:\n> > On Tuesday, August 29, 2017 4:56:43 PM CEST Ulf Hansson wrote:\n> >> The main principle behind the runtime PM centric path, is to re-use the\n> >> runtime PM callbacks to implement system sleep - and while doing that also\n> >> achieve a fully optimized behaviour from PM point of view.\n> >>\n> >> More precisely, avoid to wake up a device from its low power state during\n> >> system sleep, unless the device is really needed to be operational. That\n> >> does not only mean avoiding to waste power, but may also decrease system\n> >> suspend/resume time for a device.\n> >>\n> >> However, using the runtime PM centric path for a device, does put some\n> >> requirements on the behaviour of the PM core and a potential PM domain that\n> >> may be attached to the device. So far, these requirements are not being\n> >> specially considered, except by the generic PM domain.\n> >>\n> >> To move forward and to make it possible to deploy the runtime PM centric\n> >> path for cross SoC drivers, which may have different PM domains attached to\n> >> its devices depending on the SoC, we must address how to deal with these\n> >> requirements. This change starts by making some adoptions to the PM core,\n> >> while other parts, such as the ACPI PM domain needs to be taken care of\n> >> separately.\n> >>\n> >> In the runtime PM centric path, the driver is expected to make use of the\n> >> pm_runtime_force_suspend|resume() helpers, to deploy system sleep support.\n> >> More precisely it may assign the system sleep callbacks to these helpers or\n> >> may call them from its own callbacks, in case it needs to perform\n> >> additional actions during system sleep.\n> >>\n> >> In other words, the PM core must always invoke the system sleep callbacks\n> >> for the device when they are present, to allow the driver to deal with\n> >> the system sleep operations.\n> >>\n> >> In case the PM core decides to run the direct_complete path for the device,\n> >> it skips invoking most of the system sleep callbacks, besides\n> >> ->prepare|complete(). Therefore using the direct_complete path in\n> >> combination with the runtime PM centric patch for a device, does not play\n> >> well.\n> >>\n> >> To deal with this issue, let's add a flag 'is_rpm_sleep', to the struct\n> >> dev_pm_info. The driver that deploys the runtime PM centric path, shall set\n> >> the flag for the device during ->probe(), to inform the PM core about that\n> >> it must not use the direct_complete path for the device.\n> >>\n> >> Note, not allowing the direct_complete path for a device, doesn't implicit\n> >> need to propagate to the device's parent/suppliers. Therefore make the PM\n> >> core check this condition in device_suspend(), before it decides to abandon\n> >> the direct_complete path for parent/suppliers.\n> >>\n> >> To make the is_rpm_sleep flag internal to the PM core, let's add two APIs.\n> >>       - dev_pm_use_rpm_sleep(): It sets the flag and should be called by\n> >>         the driver during ->probe().\n> >>       - dev_pm_is_rpm_sleep(): Makes it possible for users of the device,\n> >>         like a PM domain, to fetch the state of the flag.\n> >>\n> >> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>\n> >> ---\n> >>\n> >> Changes in v3:\n> >>       - New patch.\n> >>       - This replaces the earlier method of adding the no_direct_complete to\n> >>       the ACPI structures, according to comments from Rafael.\n> >>       - This change also address the consern Rafael had around that\n> >>       direct_complete should not have to be disabled for parent/suppliers, in\n> >>       case a device use the runtime PM centric path for system sleep.\n> >>\n> >> ---\n> >>  drivers/base/power/main.c    | 49 +++++++++++++++++++++++++++++++++++++++-----\n> >>  drivers/base/power/runtime.c |  1 +\n> >>  include/linux/pm.h           |  7 +++++++\n> >>  3 files changed, 52 insertions(+), 5 deletions(-)\n> >>\n> >> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c\n> >> index ea1732e..865737a 100644\n> >> --- a/drivers/base/power/main.c\n> >> +++ b/drivers/base/power/main.c\n> >> @@ -1549,14 +1549,16 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)\n> >>               if (parent) {\n> >>                       spin_lock_irq(&parent->power.lock);\n> >>\n> >> -                     dev->parent->power.direct_complete = false;\n> >> +                     if (!dev->power.is_rpm_sleep)\n> >> +                             dev->parent->power.direct_complete = false;\n> >\n> > This doesn't look good to me at all.\n> >\n> > It potentially breaks the fundamental assumption of the direct_complete\n> > mechanism that no devices with that flag set will ever be runtime resumed\n> > during system suspend.\n> >\n> > Which can happen with this change if a device with power.is_rpm_sleep is\n> > resumed causing the parent to be resumed too.\n> \n> Doesn't the exact same problem you describe, already exist prior my change!?\n\nNo, it doesn't.\n\n> That is, if the current device is runtime suspended and the\n> direct_complete flag is set for it, then __device_suspend() has\n> already disabled runtime PM for the device, when we reach this point.\n> That means, a following attempts to runtime resume the device will\n> fail and thus also to runtime resume its parent.\n\nThat's because any devices with direct_complete set *cannot* be runtime\nresumed after __device_suspend().  That's intentional and how the thing\nis designed.  It cannot work differently, sorry.\n\n> So to me, this is a different problem, related how to work out the\n> correct order of how to suspend devices.\n\nThe ordering matters here, but it is not the problem.\n\nSetting direct_complete means that PM callbacks for this device won't be\ninvoked going forward.  However, if the state of the device was to change\n(like as a result of runtime PM resume), it would be necessary to run those\ncallbacks after all, but after __device_suspend() it may be too late for\nthat, because the ->suspend callback may have been skipped already.\n\nThe only way to address that is to prevent runtime PM resume of the device\nfrom happening at the point the PM core decides to use direct_complete for it,\nbut that requires runtime PM to be disabled for it.  Moreover, since the\ndevice is now suspended with runtime PM disabled and its children might rely\non it if they were active, the children must be suspended with runtime PM\ndisabled at this point too.  That's why direct_complete can only be set\nfor a device if it is set for the entire hierarchy below it.\n\nSummary: If you allow a device to be runtime resumed during system susped,\ndirect_complete cannot be set for it and it cannot be set for its parent and\nso on.\n\n[cut]\n\n> >> @@ -1709,11 +1711,14 @@ static int device_prepare(struct device *dev, pm_message_t state)\n> >>        * A positive return value from ->prepare() means \"this device appears\n> >>        * to be runtime-suspended and its state is fine, so if it really is\n> >>        * runtime-suspended, you can leave it in that state provided that you\n> >> -      * will do the same thing with all of its descendants\".  This only\n> >> -      * applies to suspend transitions, however.\n> >> +      * will do the same thing with all of its descendants\". To allow this,\n> >> +      * the is_rpm_sleep flag must not be set, which is default false, but\n> >> +      * may have been changed by a driver. This only applies to suspend\n> >> +      * transitions, however.\n> >>        */\n> >>       spin_lock_irq(&dev->power.lock);\n> >> -     dev->power.direct_complete = ret > 0 && state.event == PM_EVENT_SUSPEND;\n> >> +     dev->power.direct_complete = ret > 0 && !dev->power.is_rpm_sleep &&\n> >> +                             state.event == PM_EVENT_SUSPEND;\n> >\n> > The only problem addressed by avoiding direct_complete is when runtime PM needs\n> > to work during __device_suspend() for devices with direct_complete set.  You\n> > said that this was not the case with the i2c designware driver, so I'm not sure\n> > what the purpose of this is.\n> \n> I should probably work more on my changelog, because I tried to\n> explain it there.\n> \n> Anyway, let me quote the important parts, and this is not specific for\n> the i2c-designware-driver, but generic to drivers using\n> pm_runtime_force_suspend|resume().\n> \n> \"In the runtime PM centric path, the driver is expected to make use of\n> the pm_runtime_force_suspend|resume() helpers, to deploy system sleep\n> support. More precisely it may assign the system sleep callbacks to\n> these helpers or may call them from its own callbacks, in case it\n> needs to perform additional actions during system sleep.\n> \n> In other words, the PM core must always invoke the system sleep\n> callbacks for the device when they are present, to allow the driver to\n> deal with the system sleep operations.\"\n> \n> A concrete example is drivers/spi/spi-fsl-espi.c, but one can easily find more.\n\nIn fact, the new flag introduced here means \"assume that that the driver of this\ndevice points ->late_suspend and ->early_resume to pm_runtime_force_suspend()\nand pm_runtime_force_resume(), respectively.\"  Which then implies that\ndirect_complete cannot be used with it and (and with its parent and so on)\nand that it is not necessary to runtime resume it during system suspend.\n\nHowever, there are (or at least there may be) devices that need not be\nruntime resumed during system suspend even though their drivers don't use\n_force_suspend/resume().\n\nAlso there are devices whose drivers don't want direct_complete to be used with\nthem, even though they don't use _force_suspend/resume() and they *do* need\ntheir devices to be runtime resumed during system suspend.\n\nMoreover, some drivers may not mind direct_complete even though their devices\nneed not be runtime resumed during system suspend.  All of that doesn't have\nto be related to using _force_suspend/resume() at all.\n\nSo I don't see any reason whatever for combining all of these three *different*\nconditions under one flag.\n\nThanks,\nRafael","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"aIZDUmHx\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xj6H53sHLz9sN7\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 23:46:25 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dn3K1-0007GS-Qa; Wed, 30 Aug 2017 13:46:21 +0000","from cloudserver094114.home.net.pl ([79.96.170.134])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dn3Jw-0007F4-PS for linux-arm-kernel@lists.infradead.org;\n\tWed, 30 Aug 2017 13:46:19 +0000","from 79.184.253.199.ipv4.supernova.orange.pl (79.184.253.199) (HELO\n\taspire.rjw.lan)\n\tby serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer\n\t0.82) id 950554e770ce4363; Wed, 30 Aug 2017 15:45:49 +0200"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=YSpAVdpnFuI4Au2YdmtXrrfSw+e1NyTIYv2VRWFt05U=;\n\tb=aIZDUmHx2GNw7o\n\t7L46LoAFkV/gTaRy4ChoAWfuhMhYscydAzhRLUD1W8300yxpqx3gk2ivKRXxpt/1/iNosQNqMwwuJ\n\tOjUjPP3WUj9U81OBp+2Rt/0/fKvr9vHm0RoQVZBFGRG8o4f6nVIDvGudtQ/q08x9s5Q1R6lqmt7H/\n\taWBb8TjVBCBRAg/gBWZ1ai5pwfXCg2SBa7VUDsroUDr1QhD/NwvPK9AmvLn+wOrThXweOCx1qn7xN\n\t9FdvJUPYw3JjYGYWiC5q/PSW92iWzKva+oL/rQ3CoO3MsXsK04sIhQDUmAB8zR78cW1zzL2TkA3K0\n\tWRPy7dsuxtLb3gdCgIMg==;","From":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","To":"Ulf Hansson <ulf.hansson@linaro.org>","Subject":"Re: [PATCH v3 1/8] PM / Sleep: Make the runtime PM centric path\n\tknown to the PM core","Date":"Wed, 30 Aug 2017 15:37:08 +0200","Message-ID":"<2403318.HVB4k3qRsK@aspire.rjw.lan>","In-Reply-To":"<CAPDyKFqujAbw9RAxG-kRhgnhEtAZeojBiL=v5F+JS3T9eaxfgQ@mail.gmail.com>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<13933269.sbLfAJfmVU@aspire.rjw.lan>\n\t<CAPDyKFqujAbw9RAxG-kRhgnhEtAZeojBiL=v5F+JS3T9eaxfgQ@mail.gmail.com>","MIME-Version":"1.0","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170830_064617_023347_3B58D694 ","X-CRM114-Status":"GOOD (  45.64  )","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1760584,"web_url":"http://patchwork.ozlabs.org/comment/1760584/","msgid":"<3033151.kbPpEQGlRq@aspire.rjw.lan>","list_archive_url":null,"date":"2017-08-31T00:17:41","subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","submitter":{"id":26536,"url":"http://patchwork.ozlabs.org/api/people/26536/","name":"Rafael J. Wysocki","email":"rjw@rjwysocki.net"},"content":"Disclaimer: I'm falling asleep, so I probably shouldn't reply to email right\nnow, but tomorrow I may not be able to get to email at all, so I'll try anyway.\n\nOn Wednesday, August 30, 2017 11:57:28 AM CEST Ulf Hansson wrote:\n> On 29 August 2017 at 22:19, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:\n> > On Tuesday, August 29, 2017 4:56:42 PM CEST Ulf Hansson wrote:\n> >> The i2c designware platform driver, drivers/i2c/busses/i2c-designware-platdrv.c,\n> >> isn't well optimized for system sleep.\n> >>\n> >> What makes this driver particularly interesting is because it's a cross-SoC\n> >> driver, which sometimes means there is an ACPI PM domain attached to the i2c\n> >> device and sometimes not. The driver is being used on both x86 and ARM.\n> >>\n> >> In principle, to optimize the system sleep support in i2c driver, this series\n> >> enables the proven runtime PM centric path for the i2c driver. However, to do\n> >> that the ACPI PM domain also have to collaborate and understand this behaviour.\n> >> From earlier versions, Rafael has also pointed out that also the PM core needs\n> >> to be involved.\n> >\n> > Earlier today I realized that drivers pointing their ->suspend_late and\n> > ->resume_early callbacks, respectively, to pm_runtime_force_suspend() and\n> > pm_runtime_force_resume(), are fundamentally incompatible with any bus type\n> > doing nontrivial PM and with almost any nontrivial PM domains, for two reasons.\n> >\n> > First, it basically requires the bus type or PM domain to expect that its\n> > ->runtime_suspend callback may or may not be indirectly invoked from its\n> > own ->suspend_late callback, depending on the driver (and analogously\n> > for ->runtime_resume and ->resume early), which is insane.\n> >\n> > Second, it is a layering violation, because it makes the driver effectively\n> > override the upper layer's decisions about what code to run.\n> \n> You are right that for more complex bus types and PM domains, those\n> needs to play along. So that is what I am trying to implement for the\n> ACPI PM domain in this series.\n\nWell, \"play along\" is a bit of an understatement here.\n\nThey would need to turn into horrible mess and that's not going to happen.\n\n> The generic PM domain, is simple in this regards. There is only a\n> minor adaptation for the ->runtime_suspend|resume() callbacks, which\n> avoids validating dev_pm_qos constraints during system sleep. Nothing\n> special is needed in ->suspend_late|noirq callbacks, etc.\n> \n> For most other simple bus types, like the platform bus, spi, i2c,\n> amba, no particular adoptions is needed at all. Instead those just\n> trust the drivers to do the right thing.\n\nThey are the trivial ones.\n\n> Before we had the direct_complete path, using the\n> pm_runtime_force_suspend|resume() helpers, was the only good way for\n> these kind of drivers, to in an optimized manner, deal with system\n> sleep when runtime PM also was enabled for their devices. Now this\n> method has become widely deployed, unfortunate whether you like it or\n> not.\n\nSo can you please remind me why the _force_ wrappers are needed?\n\nIn particular, why can't drivers arrange their callbacks the way I did that\nin https://patchwork.kernel.org/patch/9928583/ ?\n\n> Besides the slightly better optimizations you get when using\n> pm_runtime_force_suspend|resume(), comparing to the direct_complete\n> path - I think it's also worth to consider, how easy it becomes for\n> drivers to deploy system sleep support. In many cases, only two lines\n> of code is needed to add system sleep support in a driver.\n\nYou are doing a wrong comparison here IMO.  You essentially are comparing two\nbandaids with each other and arguing that one of them somehow is better.\n\nWhat about doing something which is not a bandaid instead?\n\n> Now, some complex code always needs to be implemented somewhere. When\n> using the runtime PM centric path, that code consist of the\n> pm_runtime_force_suspend|resume() helpers itself - and some\n> adaptations in buses/PM domains in cases when those needs special\n> care.\n> \n> My point is, the runtime PM centric path, allows us to keep the\n> complex part of the code at a few centralized places, instead of\n> having it spread/duplicated into drivers.\n> \n> So yes, you could consider it insane, but to me and many others, it\n> seems to work out quite well.\n\nBecause it only has been used with trivial middle layer code so far\nand I'm quite disappointed that you don't seem to see a problem here. :-/\n\nI mean something like\n\nPM core => bus type / PM domain ->suspend_late => driver ->suspend_late\n\nis far more straightforward than\n\nPM core => bus type / PM domain ->suspend_late => driver ->suspend_late =>\n\tbus type / PM domain ->runtime_suspend => driver ->runtime_suspend\n\nwith the bus type / PM domain having to figure out somehow at the\n->suspend_late time whether or not its ->runtume_suspend is going to be invoked\nin the middle of it.\n\nApart from this just being aesthetically disgusting to me, which admittedly is\na matter of personal opinion, it makes debugging new driver code harder (if it\nhappens to not work) and reviewing it almost impossible, because now you need\nto take all of the tangling between callbacks into accont and sometimes not\njust for one bus type / PM domain.\n\n> Yeah, and the laying violation is undoubtedly the most controversial\n> part of the runtime PM centric path - I agree to that! The\n> direct_complete path don't have this, as you implemented it. :-)\n> \n> On the other hand, one could consider that these upper layers, in many\n> cases anyway needs to play along with the behavior of the driver. So,\n> I guess it depends on how one see it.\n> \n> >\n> > That's why I'm afraid that we've reached a dead end here. :-(\n> \n> That's said news. Is was really hoping I could find a way to move this\n> forward. You don't have any other ideas on how I can adjust the series\n> to make you happy?\n\nSo to be precise, patches [2-3/8] are basically fine by me.  Patch [4/8]\nsort of works too, but I'd do the splitting slightly differently and I don't\nsee much value in it alone.\n\nThe rest of the ACPI changes is mostly not acceptable to me, mostly because\nof what is done to the PM domain's ->runtime_suspend/resume and\n->suspend_late/->resume_early callbacks.\n\nI guess the only way that could be made work for me would be by not using\n_force_suspend/resume() at all, but that would defeat the point, right?\n\nI don't like the flag too, but that might be worked out.\n\nAlso, when I looked at _force_suspend/resume() again, I got concerned.\nThere is stuff in there that shouldn't be necessary in a driver's\n->late_suspend/->early_resume and some things in there just made me\nscratch my head.\n\nThanks,\nRafael","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"pbFoZ3Q3\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjNV56XJ7z9sNc\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 10:26:53 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dnDJo-0006Om-JE; Thu, 31 Aug 2017 00:26:48 +0000","from cloudserver094114.home.net.pl ([79.96.170.134])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dnDJk-0006ML-Sy for linux-arm-kernel@lists.infradead.org;\n\tThu, 31 Aug 2017 00:26:47 +0000","from 79.184.253.199.ipv4.supernova.orange.pl (79.184.253.199) (HELO\n\taspire.rjw.lan)\n\tby serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer\n\t0.82) id 8f7e48eca07b2e14; Thu, 31 Aug 2017 02:26:22 +0200"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=WfYXH9KWOc0u4NebdFPVynNKi3O+SQnvUFskZrUPEts=;\n\tb=pbFoZ3Q3mHSbMT\n\tLX08XvhJMBPh8ymJetyC+Mke1Uk4gVa72aL2BbuG/wLlA7J/cu+pdzq/t5Tif65oXdoTl+P6YNTkz\n\ty7XfYEKwfbYvTagkVpcavPEMsRBHw84uMvJrvRSvFoEm2eH23P9mx2LcGwoFLdyC8iOnrGQhzqm9p\n\t0pVHzkDTAWB9Rw06okQq+a8X6apK+pnP1B7xnMbN2mh0hlfZdeB56erb7F1S388IIeaZ9B9dCvm6b\n\t/Lb4Le3sg3yCQRd6vOqFw5Jacn9OKxIR3Iq0Y60Y1GlhF8xeD/ImV7UyP0X6Q4WtDkgwWARHWmp3X\n\tRae39gt9UIURHI7e/Asg==;","From":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","To":"Ulf Hansson <ulf.hansson@linaro.org>","Subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","Date":"Thu, 31 Aug 2017 02:17:41 +0200","Message-ID":"<3033151.kbPpEQGlRq@aspire.rjw.lan>","In-Reply-To":"<CAPDyKFosu8RYUUCiBn7+03b3TNmND-aCTqR=+svcvzCwhxw9+A@mail.gmail.com>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<1957183.ZU1CWrAZoR@aspire.rjw.lan>\n\t<CAPDyKFosu8RYUUCiBn7+03b3TNmND-aCTqR=+svcvzCwhxw9+A@mail.gmail.com>","MIME-Version":"1.0","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170830_172645_134870_EC04EC6F ","X-CRM114-Status":"GOOD (  33.72  )","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1760758,"web_url":"http://patchwork.ozlabs.org/comment/1760758/","msgid":"<CAPDyKFoOJzciMNMWkc+ci+Fn2iD8vwsg25TQjcx=xw2ftg5rug@mail.gmail.com>","list_archive_url":null,"date":"2017-08-31T09:06:05","subject":"Re: [PATCH v3 1/8] PM / Sleep: Make the runtime PM centric path\n\tknown to the PM core","submitter":{"id":21036,"url":"http://patchwork.ozlabs.org/api/people/21036/","name":"Ulf Hansson","email":"ulf.hansson@linaro.org"},"content":"[...]\n\n>> >> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c\n>> >> index ea1732e..865737a 100644\n>> >> --- a/drivers/base/power/main.c\n>> >> +++ b/drivers/base/power/main.c\n>> >> @@ -1549,14 +1549,16 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)\n>> >>               if (parent) {\n>> >>                       spin_lock_irq(&parent->power.lock);\n>> >>\n>> >> -                     dev->parent->power.direct_complete = false;\n>> >> +                     if (!dev->power.is_rpm_sleep)\n>> >> +                             dev->parent->power.direct_complete = false;\n>> >\n>> > This doesn't look good to me at all.\n>> >\n>> > It potentially breaks the fundamental assumption of the direct_complete\n>> > mechanism that no devices with that flag set will ever be runtime resumed\n>> > during system suspend.\n>> >\n>> > Which can happen with this change if a device with power.is_rpm_sleep is\n>> > resumed causing the parent to be resumed too.\n>>\n>> Doesn't the exact same problem you describe, already exist prior my change!?\n>\n> No, it doesn't.\n>\n>> That is, if the current device is runtime suspended and the\n>> direct_complete flag is set for it, then __device_suspend() has\n>> already disabled runtime PM for the device, when we reach this point.\n>> That means, a following attempts to runtime resume the device will\n>> fail and thus also to runtime resume its parent.\n>\n> That's because any devices with direct_complete set *cannot* be runtime\n> resumed after __device_suspend().  That's intentional and how the thing\n> is designed.  It cannot work differently, sorry.\n>\n>> So to me, this is a different problem, related how to work out the\n>> correct order of how to suspend devices.\n>\n> The ordering matters here, but it is not the problem.\n>\n> Setting direct_complete means that PM callbacks for this device won't be\n> invoked going forward.  However, if the state of the device was to change\n> (like as a result of runtime PM resume), it would be necessary to run those\n> callbacks after all, but after __device_suspend() it may be too late for\n> that, because the ->suspend callback may have been skipped already.\n>\n> The only way to address that is to prevent runtime PM resume of the device\n> from happening at the point the PM core decides to use direct_complete for it,\n> but that requires runtime PM to be disabled for it.  Moreover, since the\n> device is now suspended with runtime PM disabled and its children might rely\n> on it if they were active, the children must be suspended with runtime PM\n> disabled at this point too.  That's why direct_complete can only be set\n> for a device if it is set for the entire hierarchy below it.\n\nThanks, this was a very nice description of the direct_complete path!\n\n>\n> Summary: If you allow a device to be runtime resumed during system susped,\n> direct_complete cannot be set for it and it cannot be set for its parent and\n> so on.\n\nYes, this is what it seems to boils done to!\n\nPerhaps the ACPI PM domain is special in this case, because in its\n->prepare() callback it asks the ACPI FW about whether the\ndirect_complete path is possible for a device. In other words, the\nACPI FW seems to be capable of providing information about if a device\nmay become runtime resumed during system suspend. But, really, isn't\nthat just a best guess? No?\n\nOn those ARM SoCs I am working on, non-ACPI, the information about\nwhether a device may become runtime resumed during system suspend,\nmost often can't be find out in a deterministic way. That's because\nthis information depends on how a device is being used by other\ndevices, which changes dynamically and from one system suspend\nsequence to another. In cases like the i2c-designware-plat driver used\nin Hikey (ARM64 board), it can't ever know before hand, if someone is\ngoing to request an i2c transfer during system suspend or not.\n\nTo really deal with these devices properly, we have to suspend them in\nthe correct order.\n\nMy point is, doesn't the ordering problem exists also for a device,\nwhich the PM core runs the direct_complete path for, even if the ACPI\nPM domain is attached to the device? Just because runtime PM is\ndisabled for a device, doesn't mean the ordering issue disappears,\nright?\n\n>\n> [cut]\n>\n>> >> @@ -1709,11 +1711,14 @@ static int device_prepare(struct device *dev, pm_message_t state)\n>> >>        * A positive return value from ->prepare() means \"this device appears\n>> >>        * to be runtime-suspended and its state is fine, so if it really is\n>> >>        * runtime-suspended, you can leave it in that state provided that you\n>> >> -      * will do the same thing with all of its descendants\".  This only\n>> >> -      * applies to suspend transitions, however.\n>> >> +      * will do the same thing with all of its descendants\". To allow this,\n>> >> +      * the is_rpm_sleep flag must not be set, which is default false, but\n>> >> +      * may have been changed by a driver. This only applies to suspend\n>> >> +      * transitions, however.\n>> >>        */\n>> >>       spin_lock_irq(&dev->power.lock);\n>> >> -     dev->power.direct_complete = ret > 0 && state.event == PM_EVENT_SUSPEND;\n>> >> +     dev->power.direct_complete = ret > 0 && !dev->power.is_rpm_sleep &&\n>> >> +                             state.event == PM_EVENT_SUSPEND;\n>> >\n>> > The only problem addressed by avoiding direct_complete is when runtime PM needs\n>> > to work during __device_suspend() for devices with direct_complete set.  You\n>> > said that this was not the case with the i2c designware driver, so I'm not sure\n>> > what the purpose of this is.\n>>\n>> I should probably work more on my changelog, because I tried to\n>> explain it there.\n>>\n>> Anyway, let me quote the important parts, and this is not specific for\n>> the i2c-designware-driver, but generic to drivers using\n>> pm_runtime_force_suspend|resume().\n>>\n>> \"In the runtime PM centric path, the driver is expected to make use of\n>> the pm_runtime_force_suspend|resume() helpers, to deploy system sleep\n>> support. More precisely it may assign the system sleep callbacks to\n>> these helpers or may call them from its own callbacks, in case it\n>> needs to perform additional actions during system sleep.\n>>\n>> In other words, the PM core must always invoke the system sleep\n>> callbacks for the device when they are present, to allow the driver to\n>> deal with the system sleep operations.\"\n>>\n>> A concrete example is drivers/spi/spi-fsl-espi.c, but one can easily find more.\n>\n> In fact, the new flag introduced here means \"assume that that the driver of this\n> device points ->late_suspend and ->early_resume to pm_runtime_force_suspend()\n> and pm_runtime_force_resume(), respectively.\"  Which then implies that\n> direct_complete cannot be used with it and (and with its parent and so on)\n> and that it is not necessary to runtime resume it during system suspend.\n>\n> However, there are (or at least there may be) devices that need not be\n> runtime resumed during system suspend even though their drivers don't use\n> _force_suspend/resume().\n>\n> Also there are devices whose drivers don't want direct_complete to be used with\n> them, even though they don't use _force_suspend/resume() and they *do* need\n> their devices to be runtime resumed during system suspend.\n>\n> Moreover, some drivers may not mind direct_complete even though their devices\n> need not be runtime resumed during system suspend.  All of that doesn't have\n> to be related to using _force_suspend/resume() at all.\n>\n> So I don't see any reason whatever for combining all of these three *different*\n> conditions under one flag.\n\nOkay!\n\n>\n> Thanks,\n> Rafael\n>\n\nKind regards\nUffe","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"rRQlAolE\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"Nn+JMQ0H\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjc1n5GC4z9sRW\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 19:06:37 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dnLQm-0004K6-G9; Thu, 31 Aug 2017 09:06:32 +0000","from mail-io0-x22e.google.com ([2607:f8b0:4001:c06::22e])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dnLQh-0004GU-Pw for linux-arm-kernel@lists.infradead.org;\n\tThu, 31 Aug 2017 09:06:30 +0000","by mail-io0-x22e.google.com with SMTP id f99so10947991ioi.3\n\tfor <linux-arm-kernel@lists.infradead.org>;\n\tThu, 31 Aug 2017 02:06:07 -0700 (PDT)","by 10.2.96.38 with HTTP; Thu, 31 Aug 2017 02:06:05 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:\n\tReferences:In-Reply-To:MIME-Version:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=I/uysUnlV3HSxXMwHwTcg91qMdYSXS5WTafJTycsJJw=;\n\tb=rRQlAolEIxJeE2\n\tHf/fZTC9F0+6+GVXydzuhPwXMNJ89nnZ0TFxYn4VKQxgPfekIRev/cvYSp+RZkFhWypEFPoMHug+x\n\tcwCnSoOxIkVfMxnm0bQIa1k2p5+aQSQgW3ieVn7A+BcFJpUSE995W5FxKW99F5LxA5vKF7bbaGtt/\n\tlmUXV7J1g0IKZ6XEH1V7l78YaFlwdrm24Lre5WQHfoApXTv4WpZRd/ncpU2TOWDGgGbCD9y83rDDa\n\tQIG82A4CfYtFPhEkz0VNf+cw2xSZMBFjagTXEgz+SX4OkNMI4ph0jC0mkOrNl/R6I8BHlbRdLLNHo\n\tEchqcKrMydkXShJzd2oA==;","v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=VVsCK1aj3pD2uRWPs14JsAtIjvGaVY7Dt4qRMLjk52I=;\n\tb=Nn+JMQ0HpLxNh+QPN2XJrawQzfvMKFkoWNYpUSyL5Cdgn0ZrZAn5vxgD6TuOqxOhyP\n\tUStRrFvHOJ+hUky57Hbvjc3og0EuFW7PJQBsbgTiKiAryga6IbUlOWPA//4PQUaN3TKf\n\tlkTQ/bFj+D59xm6g0I36JJSe01eWAXuStHXW0="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=VVsCK1aj3pD2uRWPs14JsAtIjvGaVY7Dt4qRMLjk52I=;\n\tb=gLdbI3rBqCrs1Pq5LBykCnhOs1x3iABgqCoqjWzG1olIeYNAs0B1vZ8fAYJ9jzYqL9\n\tVUOrQ/DLX5byXhqrW5RMN2Z7ZoInR52xjZj2czSazcLqRubHRLNABCyNseDPlLB3CWdQ\n\t0+zmKJQ46KEUBtFqt6if25f8HCqdYuj0gtbdVdzqDNcMP12dXMgWR3+O/jpcmpQmc8Dk\n\tgYKIkOfO5EFXAMA7u57DhGYG0sbDjNWj8GKZ+CjxX9jqi55XD8Wa4zAGVG7AsP1EUdpX\n\ti44giIGxBP3MjcUMY1aCkIAfKjb82BLxfYkvkDUWEtCySSd0IcAlWVyTDvFGFJuCX0yB\n\t1YdA==","X-Gm-Message-State":"AHPjjUgGR4kXjSOKUkejcnRjrLuMUoURN9sBS1enJr98vyl9O3to4loe\n\tNHfPoKkumfBS12oPeu8erEhNcYt3gFTF","X-Received":"by 10.107.138.155 with SMTP id c27mr4078391ioj.103.1504170366608;\n\tThu, 31 Aug 2017 02:06:06 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<2403318.HVB4k3qRsK@aspire.rjw.lan>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<13933269.sbLfAJfmVU@aspire.rjw.lan>\n\t<CAPDyKFqujAbw9RAxG-kRhgnhEtAZeojBiL=v5F+JS3T9eaxfgQ@mail.gmail.com>\n\t<2403318.HVB4k3qRsK@aspire.rjw.lan>","From":"Ulf Hansson <ulf.hansson@linaro.org>","Date":"Thu, 31 Aug 2017 11:06:05 +0200","Message-ID":"<CAPDyKFoOJzciMNMWkc+ci+Fn2iD8vwsg25TQjcx=xw2ftg5rug@mail.gmail.com>","Subject":"Re: [PATCH v3 1/8] PM / Sleep: Make the runtime PM centric path\n\tknown to the PM core","To":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170831_020628_041221_A0A187BF ","X-CRM114-Status":"GOOD (  39.01  )","X-Spam-Score":"-2.7 (--)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-2.7 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/,\n\tlow\n\ttrust [2607:f8b0:4001:c06:0:0:0:22e listed in] [list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature\n\t0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n\tnot necessarily valid\n\t-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n\tauthor's domain","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1761516,"web_url":"http://patchwork.ozlabs.org/comment/1761516/","msgid":"<CAPDyKFq5ic+bAVRoEC58oSO-8VTGnfipJndLmR6YLXgEhZ+RWw@mail.gmail.com>","list_archive_url":null,"date":"2017-09-01T08:27:05","subject":"Re: [PATCH v3 6/8] PM / ACPI: Enable the runtime PM centric approach\n\tfor system sleep","submitter":{"id":21036,"url":"http://patchwork.ozlabs.org/api/people/21036/","name":"Ulf Hansson","email":"ulf.hansson@linaro.org"},"content":"On 29 August 2017 at 17:27, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:\n> On Tuesday, August 29, 2017 4:56:48 PM CEST Ulf Hansson wrote:\n>> This change enables the ACPI PM domain to cope with drivers that deploys\n>> the runtime PM centric path for system sleep.\n>\n> [cut]\n>\n>> @@ -1052,11 +1066,20 @@ EXPORT_SYMBOL_GPL(acpi_subsys_complete);\n>>   * @dev: Device to handle.\n>>   *\n>>   * Follow PCI and resume devices suspended at run time before running their\n>> - * system suspend callbacks.\n>> + * system suspend callbacks. However, try to avoid it in case the runtime PM\n>> + * centric path is used for the device and then trust the driver to do the\n>> + * right thing.\n>>   */\n>>  int acpi_subsys_suspend(struct device *dev)\n>>  {\n>> -     pm_runtime_resume(dev);\n>> +     struct acpi_device *adev = ACPI_COMPANION(dev);\n>> +\n>> +     if (!adev)\n>> +             return 0;\n>> +\n>> +     if (!dev_pm_is_rpm_sleep(dev) || acpi_dev_needs_resume(dev, adev))\n>> +             pm_runtime_resume(dev);\n>> +\n>>       return pm_generic_suspend(dev);\n>>  }\n>>  EXPORT_SYMBOL_GPL(acpi_subsys_suspend);\n>\n> Well, I tried to avoid calling acpi_dev_needs_resume() for multiple times\n> and that's why I added the update_state thing.\n>\n> Moreover, the is_rpm_sleep flag here has to mean not only that\n> direct_complete should not be used with the device, but also that its driver\n> is fine with not resuming it.\n\nLet me try to explain this better. I realize the changelog is\nmisleading around this particular section! Huh, apologize for that!\n\nFirst, patch1 makes the PM core treat the is_rpm_sleep flag as the\ndirect_complete isn't allowed for the device.\n\nFor that reason, when the is_rpm_sleep is set, there is no point\ncalling acpi_dev_needs_resume() from acpi_subsys_prepare(), but\ninstead that can be deferred to acpi_subsys_suspend() - because it\ndoesn't matter if acpi_subsys_prepare() returns 0 or 1, in either case\nthe acpi_subsys_suspend() will be called. That's really what goes on\nhere.\n\nThe end result is the same. If the acpi_dev_needs_resume() thinks that\nthe device needs to be runtime resumed, pm_runtime_resume() is called\nfor the device in acpi_subsys_suspend().\n\nSo, this has nothing to do with whether the driver \"is fine with not\nresuming it\" thing.\n\n>\n> IMO it is not a good idea to use one flag for these two different things at the\n> same time at all.\n\nYeah, I guess my upper comment addresses your immediate concern here?\n\nHowever, there is one other thing the is_rpm_flag means. That is that\nthe driver has informed the ACPI PM domain, to trust the driver to\ndeal with system sleep, via re-using the runtime PM callbacks.\nSo the flag does still have two meanings, but that we can change - of course.\n\n>\n> Thanks,\n> Rafael\n>\n\nKind regards\nUffe","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"QWdjfY7/\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"LhEn1DvD\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xkC6H1Np4z9t1t\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 18:27:35 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dnhIZ-0001Zs-Q9; Fri, 01 Sep 2017 08:27:31 +0000","from mail-io0-x22f.google.com ([2607:f8b0:4001:c06::22f])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dnhIV-0001Y2-SD for linux-arm-kernel@lists.infradead.org;\n\tFri, 01 Sep 2017 08:27:29 +0000","by mail-io0-x22f.google.com with SMTP id d78so12350998ioe.4\n\tfor <linux-arm-kernel@lists.infradead.org>;\n\tFri, 01 Sep 2017 01:27:07 -0700 (PDT)","by 10.2.96.38 with HTTP; Fri, 1 Sep 2017 01:27:05 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:\n\tReferences:In-Reply-To:MIME-Version:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=ZXFE8jxAwtRESqfEMHBS9wwJEDgapsmAeFSMNrBodzg=;\n\tb=QWdjfY7/sVYKoH\n\t7h3VgFwt1JiUGYOQCDskc0JETptPVJw0TYAG2ebcG5fubYHybSPDgv9bNSwp1in6MNSNc55du7S4I\n\twlB3eiylonaV0UJQmote1YeQDTdaWjVxntqRO2oRYAFOwJ0HoM2lDNz32CRPQuIPwJ0C6v27VlF62\n\tDY5QP88tOc0mmNisss83JvZoy9ZsppibEZCLs+1g8QqL1rdWBnHdwkPmbmiiqdrHvFXwkqcrIT7fg\n\t/F6PkCaV3Upq+QagtCUq5b1UbVqxjqNhJxXFI7ch9WvUFG8loRicD0tj9Vtvlr9nVwtx9RA4IpuWt\n\te1T2aCjV7nudNEvxtSJA==;","v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=5ixv3x7gqEIQVDxuc1U5Pyyn0lgxF/p6HRlCDu6LsiU=;\n\tb=LhEn1DvDO4xLeWbajOMmxCf7AX2qT/s6En+BhcQS03NfjFeVQ1DR/C/80Qby00TQB7\n\tZNLICgFvAEGn1r+yxmSLv1mdM2eGGjo579eHcEx2r2oZ9ohsJ3UBXpF+AZQa1plQiHa9\n\txuL+F7qORz/C0tJSBfMQ0YJz/ZEpA0JUxiwvk="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=5ixv3x7gqEIQVDxuc1U5Pyyn0lgxF/p6HRlCDu6LsiU=;\n\tb=FS/IkqN8wLUqwdVItcUK6a2NEbzru383rqpYS7UfHyioddM9D9VJyu+vJ10OkgwxOF\n\thRGbsd5mTNhHIkm1KdaTlI5nyVv+T47FFrPBk8w0Ga66YT/eADeMRG+s/yhUpZHqwjBA\n\teSCnW8rjXWiejiPsY1NJ3koSOribhPSd6xwJQL1k1U9RqDd0DLlzqB0TMrYeFkVNofSN\n\tUIOhFwZK8NuhiRc+8GNwMhu1AqecgDg9maLYs8jTpDTbOUP2e12ke05sWNM8sg7RXwDD\n\tOBcRouLm497tMbI3xWQpnLZmDH3deCx6mKHBrwvn+BeVRXi/0/JRYwmUM+OhTz76woFl\n\tqTwQ==","X-Gm-Message-State":"AHPjjUhfVm8eulwYhw5vzVI0QUOqfioefPh9bfcxeITzSVZjMrqblmHl\n\tGUgOeftorbMYRRKz69xIbTcRniW53+FI","X-Google-Smtp-Source":"ADKCNb4NSgGmoy41O0tiW2uN7wuXzUMi7/3YAhc5FvNLuSh4hd/ivZbz2K+g3PXU967tBHm6XzCALhAHapjednk37ag=","X-Received":"by 10.107.15.10 with SMTP id x10mr970302ioi.45.1504254426423;\n\tFri, 01 Sep 2017 01:27:06 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<2855684.NY3Ly9PzrE@aspire.rjw.lan>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<1504018610-10822-7-git-send-email-ulf.hansson@linaro.org>\n\t<2855684.NY3Ly9PzrE@aspire.rjw.lan>","From":"Ulf Hansson <ulf.hansson@linaro.org>","Date":"Fri, 1 Sep 2017 10:27:05 +0200","Message-ID":"<CAPDyKFq5ic+bAVRoEC58oSO-8VTGnfipJndLmR6YLXgEhZ+RWw@mail.gmail.com>","Subject":"Re: [PATCH v3 6/8] PM / ACPI: Enable the runtime PM centric approach\n\tfor system sleep","To":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170901_012727_956219_5A0E83CE ","X-CRM114-Status":"GOOD (  21.30  )","X-Spam-Score":"-2.7 (--)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-2.7 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/,\n\tlow\n\ttrust [2607:f8b0:4001:c06:0:0:0:22f listed in] [list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature\n\t0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n\tnot necessarily valid\n\t-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n\tauthor's domain","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1761580,"web_url":"http://patchwork.ozlabs.org/comment/1761580/","msgid":"<CAPDyKFqAqiDcdwEOwEu1m7icnP8MijYf4UNrMqN9YhNbug_upg@mail.gmail.com>","list_archive_url":null,"date":"2017-09-01T10:42:35","subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","submitter":{"id":21036,"url":"http://patchwork.ozlabs.org/api/people/21036/","name":"Ulf Hansson","email":"ulf.hansson@linaro.org"},"content":"On 31 August 2017 at 02:17, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:\n> Disclaimer: I'm falling asleep, so I probably shouldn't reply to email right\n> now, but tomorrow I may not be able to get to email at all, so I'll try anyway.\n>\n> On Wednesday, August 30, 2017 11:57:28 AM CEST Ulf Hansson wrote:\n>> On 29 August 2017 at 22:19, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:\n>> > On Tuesday, August 29, 2017 4:56:42 PM CEST Ulf Hansson wrote:\n>> >> The i2c designware platform driver, drivers/i2c/busses/i2c-designware-platdrv.c,\n>> >> isn't well optimized for system sleep.\n>> >>\n>> >> What makes this driver particularly interesting is because it's a cross-SoC\n>> >> driver, which sometimes means there is an ACPI PM domain attached to the i2c\n>> >> device and sometimes not. The driver is being used on both x86 and ARM.\n>> >>\n>> >> In principle, to optimize the system sleep support in i2c driver, this series\n>> >> enables the proven runtime PM centric path for the i2c driver. However, to do\n>> >> that the ACPI PM domain also have to collaborate and understand this behaviour.\n>> >> From earlier versions, Rafael has also pointed out that also the PM core needs\n>> >> to be involved.\n>> >\n>> > Earlier today I realized that drivers pointing their ->suspend_late and\n>> > ->resume_early callbacks, respectively, to pm_runtime_force_suspend() and\n>> > pm_runtime_force_resume(), are fundamentally incompatible with any bus type\n>> > doing nontrivial PM and with almost any nontrivial PM domains, for two reasons.\n>> >\n>> > First, it basically requires the bus type or PM domain to expect that its\n>> > ->runtime_suspend callback may or may not be indirectly invoked from its\n>> > own ->suspend_late callback, depending on the driver (and analogously\n>> > for ->runtime_resume and ->resume early), which is insane.\n>> >\n>> > Second, it is a layering violation, because it makes the driver effectively\n>> > override the upper layer's decisions about what code to run.\n>>\n>> You are right that for more complex bus types and PM domains, those\n>> needs to play along. So that is what I am trying to implement for the\n>> ACPI PM domain in this series.\n>\n> Well, \"play along\" is a bit of an understatement here.\n>\n> They would need to turn into horrible mess and that's not going to happen.\n\nI absolutely agree, there must be no mess what so ever!\n\nBut, I don't want to give up yet, I still believe I can make this\nseries into a nice couple of changes for the ACPI PM domain.\nEspecially if you continue giving me your guidance.\n\n>\n>> The generic PM domain, is simple in this regards. There is only a\n>> minor adaptation for the ->runtime_suspend|resume() callbacks, which\n>> avoids validating dev_pm_qos constraints during system sleep. Nothing\n>> special is needed in ->suspend_late|noirq callbacks, etc.\n>>\n>> For most other simple bus types, like the platform bus, spi, i2c,\n>> amba, no particular adoptions is needed at all. Instead those just\n>> trust the drivers to do the right thing.\n>\n> They are the trivial ones.\n\nYes.\n\nHowever, the platform bus is also very commonly used in kernel. I\nthink that's an important thing to consider.\n\n>\n>> Before we had the direct_complete path, using the\n>> pm_runtime_force_suspend|resume() helpers, was the only good way for\n>> these kind of drivers, to in an optimized manner, deal with system\n>> sleep when runtime PM also was enabled for their devices. Now this\n>> method has become widely deployed, unfortunate whether you like it or\n>> not.\n>\n> So can you please remind me why the _force_ wrappers are needed?\n\nSee below.\n\n>\n> In particular, why can't drivers arrange their callbacks the way I did that\n> in https://patchwork.kernel.org/patch/9928583/ ?\n\nI was preparing a reply to that patch, but let me summarize that here instead.\n\nLet me be clear, the patch is an improvement of the behavior of the\ndriver and it addresses the issues you point out in the change log.\nRe-using the runtime PM callbacks for system sleep, is nice as it\navoids open coding, which is of curse also one of the reason of using\npm_runtime_force_suspend|resume().\n\nStill there are a couple of things I am worried about in this patch.\n*)\nTo be able to re-use the same callbacks for system sleep and runtime\nPM, some boilerplate code is added to the driver, as to cope with the\ndifferent conditions inside the callbacks. That pattern would become\nrepeated to many drivers dealing with similar issues.\n\n**)\nThe ->resume_early() callback powers on the device, in case it was\nruntime resumed when the ->suspend_late() callback was invoked. That\nis in many cases completely unnecessary, causing us to waste power and\nincrease system resume time, for absolutely no reason. However, I\nunderstand the patch didn't try to address this, but to really fix\nthis, there has to be an even closer collaboration between runtime PM\nand the system sleep callbacks.\n\nSo, to remind you why the pm_runtime_force_suspend|resume() helpers is\npreferred, that's because both of the above two things becomes taken\ncare of.\n\n>\n>> Besides the slightly better optimizations you get when using\n>> pm_runtime_force_suspend|resume(), comparing to the direct_complete\n>> path - I think it's also worth to consider, how easy it becomes for\n>> drivers to deploy system sleep support. In many cases, only two lines\n>> of code is needed to add system sleep support in a driver.\n>\n> You are doing a wrong comparison here IMO.  You essentially are comparing two\n> bandaids with each other and arguing that one of them somehow is better.\n\nI just wanted to compare against something...\n\n>\n> What about doing something which is not a bandaid instead?\n\nI don't have a problem working on something new, but I am not sure\nwhat that should be.\n\nUnless you re-consider moving forward in some form, with the current\nsuggested approach for the ACPI PM domain, can you give me some\npointers on what you have in mind?\n\nTo remind you of my current view, the direct_complete path is useful\nfor PM domains, like the ACPI PM domain as it impacts all its devices.\nUsing pm_runtime_force_suspend|resume() offers the next steps to\nachieve a fully optimized behavior of a device during system sleep, as\nalready been proven by now. It would be great to both options\nsupported by the ACPI PM domain.\n\nAnother related thing that is causing lots of problems during system\nsleep of devices, but not related to optimizations, is to have the\ncorrect order of how to suspend/resume the devices. We have talked\nabout this, but it's a separate problem and it's rather a deployment\nissue, than having to implements something entirely new (we have\nsupplies/consumers links you invented for this).\n\n>\n>> Now, some complex code always needs to be implemented somewhere. When\n>> using the runtime PM centric path, that code consist of the\n>> pm_runtime_force_suspend|resume() helpers itself - and some\n>> adaptations in buses/PM domains in cases when those needs special\n>> care.\n>>\n>> My point is, the runtime PM centric path, allows us to keep the\n>> complex part of the code at a few centralized places, instead of\n>> having it spread/duplicated into drivers.\n>>\n>> So yes, you could consider it insane, but to me and many others, it\n>> seems to work out quite well.\n>\n> Because it only has been used with trivial middle layer code so far\n> and I'm quite disappointed that you don't seem to see a problem here. :-/\n>\n> I mean something like\n>\n> PM core => bus type / PM domain ->suspend_late => driver ->suspend_late\n>\n> is far more straightforward than\n>\n> PM core => bus type / PM domain ->suspend_late => driver ->suspend_late =>\n>         bus type / PM domain ->runtime_suspend => driver ->runtime_suspend\n>\n> with the bus type / PM domain having to figure out somehow at the\n> ->suspend_late time whether or not its ->runtume_suspend is going to be invoked\n> in the middle of it.\n>\n> Apart from this just being aesthetically disgusting to me, which admittedly is\n> a matter of personal opinion, it makes debugging new driver code harder (if it\n> happens to not work) and reviewing it almost impossible, because now you need\n> to take all of the tangling between callbacks into accont and sometimes not\n> just for one bus type / PM domain.\n\nI am wondering that perhaps you may be overlooking some of the\ninternals of runtime PM. Or maybe not? :-)\n\nI mean, the hole thing is build upon that anyone can call runtime PM\nfunctions to runtime resume/suspend a device. Doing that, makes the\nhierarchy of the runtime PM callbacks being walked and invoked, of\ncourse properly managed by the runtime PM core.\n\nMy point is that, the runtime PM core still controls this behavior,\neven when the pm_runtime_force_suspend|resume() helpers are being\ninvoked. The only difference is that it allows runtime PM for the\ndevice to be disabled, and still correctly invoked the callbacks. That\nis what it is all about.\n\n>\n>> Yeah, and the laying violation is undoubtedly the most controversial\n>> part of the runtime PM centric path - I agree to that! The\n>> direct_complete path don't have this, as you implemented it. :-)\n>>\n>> On the other hand, one could consider that these upper layers, in many\n>> cases anyway needs to play along with the behavior of the driver. So,\n>> I guess it depends on how one see it.\n>>\n>> >\n>> > That's why I'm afraid that we've reached a dead end here. :-(\n>>\n>> That's said news. Is was really hoping I could find a way to move this\n>> forward. You don't have any other ideas on how I can adjust the series\n>> to make you happy?\n>\n> So to be precise, patches [2-3/8] are basically fine by me.  Patch [4/8]\n> sort of works too, but I'd do the splitting slightly differently and I don't\n> see much value in it alone.\n>\n> The rest of the ACPI changes is mostly not acceptable to me, mostly because\n> of what is done to the PM domain's ->runtime_suspend/resume and\n> ->suspend_late/->resume_early callbacks.\n>\n> I guess the only way that could be made work for me would be by not using\n> _force_suspend/resume() at all, but that would defeat the point, right?\n\nYes, it would.\n\n>\n> I don't like the flag too, but that might be worked out.\n\nYeah, I am open to any suggestion.\n\n>\n> Also, when I looked at _force_suspend/resume() again, I got concerned.\n> There is stuff in there that shouldn't be necessary in a driver's\n> ->late_suspend/->early_resume and some things in there just made me\n> scratch my head.\n\nYes, there are some complexity in there, I will be happy to answer any\nspecific question about it.\n\nThe main thing is, that it tries to conform to the regular rules set\nby the runtime PM core when runtime PM is enabled for the device - and\nthen apply those to the device when runtime PM has been disabled for\nit.\n\nAgain, thanks for being patient and reviewing!\n\nKind regards\nUffe","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"sYAG1Ri/\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"Dm/gAG0s\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xkG6d5h3Pz9t32\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 20:43:05 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dnjPi-0006QT-Bh; Fri, 01 Sep 2017 10:43:02 +0000","from mail-io0-x231.google.com ([2607:f8b0:4001:c06::231])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dnjPd-0006OB-9K for linux-arm-kernel@lists.infradead.org;\n\tFri, 01 Sep 2017 10:43:00 +0000","by mail-io0-x231.google.com with SMTP id d78so13828689ioe.4\n\tfor <linux-arm-kernel@lists.infradead.org>;\n\tFri, 01 Sep 2017 03:42:37 -0700 (PDT)","by 10.2.96.38 with HTTP; Fri, 1 Sep 2017 03:42:35 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:\n\tReferences:In-Reply-To:MIME-Version:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=PSnjddXmOJCphZ8DTEG3GTCzGC4EIftp8OWKvc5/7Mg=;\n\tb=sYAG1Ri/vOHx6R\n\tBgP8TdshkxSceDPZol7LfD3/RTi49Ez9anjXSnhc329tv2i37vKGIO0qUa7b916gTgaxbGdHeNCwb\n\tkRpBzR0cFDTzadkJHtlLHg6WS8SXqXm9wgZ9R6D8CSXLGvtcvH177pIgqRHmi5anLwilg30Zfm8qs\n\tnqy6p6Bk4ZrNz/tOhfG76R9XJKUfM4IW58GUspm+7o/sfV0Hj2hEGgfPi1yZuSIQpfEmr7Mo+H/oW\n\tjLERoBPfdOrzVRyd1FS5JuZClHSlPTuhgwhjygBSpRofV3GcTUWTmIpfaIZ1F+ABAaxcziEv94Vf9\n\tcJjEqzQU29rQ4hG8oJFw==;","v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=mdFwhCaj9YvvcSznbjyqtrmatZCiI6HvZcMs3glZ6to=;\n\tb=Dm/gAG0s7nhu9/sbX0AlxavXlRBefrfCYLYZKXbyJACybj78HHK15AINCgu0+d58Eo\n\tJvoM8/lADyWXCOCN0jqtddbyzTV2FL97+0RLalybp+KAUNeecXMKz3BKwZWUQmySqvAc\n\t5iPMWEvEdWFngAaOWd2PxhTDAIER+yMwyr4ew="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=mdFwhCaj9YvvcSznbjyqtrmatZCiI6HvZcMs3glZ6to=;\n\tb=bmE1TpfZMo3cWDjPwHij44q/3cCquBciPV1RrxadFONqCMSde5TUn6shCRssfvXLFK\n\tbcJYWcfNbhWXUD2sIkmH0iiS/VsHkOBb0Hf0GYJUfgRM3nf2xVMigxJYFouulEkevnS+\n\twGGNn+ULhq2dK5wQSGtA9JyYiBDPZDiNn7/ucVtlBJYfXCnnDSkIukEd/M3oWhHd/u+U\n\tm0/bmKkA4h8EEZnxky4uc3MbKSoO/SZirWDgmu0IbIrlgC/L2AKfyKyPJ47oN5Sb2szu\n\tSwoAx6Y3UzwFp1X1U2A1FpcKWLXXRx4kuY0NeX7PkjrZCGtw9IJRz8kYcZU+VcoviKWs\n\tyGWA==","X-Gm-Message-State":"AHPjjUglQFqR3hc68eTi7hurFHMutBseLHFeykHc8B8YmgmoH51YflcB\n\tS4jSdJzRjtTw5/LYAb1oIHpICkMCTINF","X-Google-Smtp-Source":"ADKCNb4/2d8NpMz1byBo1BPM112p1cM1mCgEupDS7/RTuoH6DxD6N97/7KgFstN9yj5Zj4jBQ0SbMn8R4xFVQsVYCVc=","X-Received":"by 10.107.138.155 with SMTP id c27mr1037849ioj.103.1504262556195;\n\tFri, 01 Sep 2017 03:42:36 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<3033151.kbPpEQGlRq@aspire.rjw.lan>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<1957183.ZU1CWrAZoR@aspire.rjw.lan>\n\t<CAPDyKFosu8RYUUCiBn7+03b3TNmND-aCTqR=+svcvzCwhxw9+A@mail.gmail.com>\n\t<3033151.kbPpEQGlRq@aspire.rjw.lan>","From":"Ulf Hansson <ulf.hansson@linaro.org>","Date":"Fri, 1 Sep 2017 12:42:35 +0200","Message-ID":"<CAPDyKFqAqiDcdwEOwEu1m7icnP8MijYf4UNrMqN9YhNbug_upg@mail.gmail.com>","Subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","To":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170901_034257_575744_9AC47CA4 ","X-CRM114-Status":"GOOD (  47.82  )","X-Spam-Score":"-2.0 (--)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-2.0 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature\n\t0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n\tnot necessarily valid\n\t-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n\tauthor's domain","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1762132,"web_url":"http://patchwork.ozlabs.org/comment/1762132/","msgid":"<1702559.yU4llTGfcI@aspire.rjw.lan>","list_archive_url":null,"date":"2017-09-02T14:48:26","subject":"Re: [PATCH v3 1/8] PM / Sleep: Make the runtime PM centric path\n\tknown to the PM core","submitter":{"id":26536,"url":"http://patchwork.ozlabs.org/api/people/26536/","name":"Rafael J. Wysocki","email":"rjw@rjwysocki.net"},"content":"On Thursday, August 31, 2017 11:06:05 AM CEST Ulf Hansson wrote:\n> [...]\n> \n> >> >> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c\n> >> >> index ea1732e..865737a 100644\n> >> >> --- a/drivers/base/power/main.c\n> >> >> +++ b/drivers/base/power/main.c\n> >> >> @@ -1549,14 +1549,16 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)\n> >> >>               if (parent) {\n> >> >>                       spin_lock_irq(&parent->power.lock);\n> >> >>\n> >> >> -                     dev->parent->power.direct_complete = false;\n> >> >> +                     if (!dev->power.is_rpm_sleep)\n> >> >> +                             dev->parent->power.direct_complete = false;\n> >> >\n> >> > This doesn't look good to me at all.\n> >> >\n> >> > It potentially breaks the fundamental assumption of the direct_complete\n> >> > mechanism that no devices with that flag set will ever be runtime resumed\n> >> > during system suspend.\n> >> >\n> >> > Which can happen with this change if a device with power.is_rpm_sleep is\n> >> > resumed causing the parent to be resumed too.\n> >>\n> >> Doesn't the exact same problem you describe, already exist prior my change!?\n> >\n> > No, it doesn't.\n> >\n> >> That is, if the current device is runtime suspended and the\n> >> direct_complete flag is set for it, then __device_suspend() has\n> >> already disabled runtime PM for the device, when we reach this point.\n> >> That means, a following attempts to runtime resume the device will\n> >> fail and thus also to runtime resume its parent.\n> >\n> > That's because any devices with direct_complete set *cannot* be runtime\n> > resumed after __device_suspend().  That's intentional and how the thing\n> > is designed.  It cannot work differently, sorry.\n> >\n> >> So to me, this is a different problem, related how to work out the\n> >> correct order of how to suspend devices.\n> >\n> > The ordering matters here, but it is not the problem.\n> >\n> > Setting direct_complete means that PM callbacks for this device won't be\n> > invoked going forward.  However, if the state of the device was to change\n> > (like as a result of runtime PM resume), it would be necessary to run those\n> > callbacks after all, but after __device_suspend() it may be too late for\n> > that, because the ->suspend callback may have been skipped already.\n> >\n> > The only way to address that is to prevent runtime PM resume of the device\n> > from happening at the point the PM core decides to use direct_complete for it,\n> > but that requires runtime PM to be disabled for it.  Moreover, since the\n> > device is now suspended with runtime PM disabled and its children might rely\n> > on it if they were active, the children must be suspended with runtime PM\n> > disabled at this point too.  That's why direct_complete can only be set\n> > for a device if it is set for the entire hierarchy below it.\n> \n> Thanks, this was a very nice description of the direct_complete path!\n> \n> >\n> > Summary: If you allow a device to be runtime resumed during system susped,\n> > direct_complete cannot be set for it and it cannot be set for its parent and\n> > so on.\n> \n> Yes, this is what it seems to boils done to!\n> \n> Perhaps the ACPI PM domain is special in this case, because in its\n> ->prepare() callback it asks the ACPI FW about whether the\n> direct_complete path is possible for a device. In other words, the\n> ACPI FW seems to be capable of providing information about if a device\n> may become runtime resumed during system suspend. But, really, isn't\n> that just a best guess? No?\n\nI wouldn't call it a guess, but it may go too far.\n\nThe part that the ACPI PM domain can figure out is whether or not the power\nstate of the device needs to be updated due to differences between runtime\nPM and system suspend configuration requirements.  If it doesn't need to be\nupdated, acpi_subsys_prepare() returns 1 which may me overoptimistic.\n\nFor many devices that works, because the only possible reason why they may\nneed to be accessed during system suspend is to update their power state.\n\nIt may not work for some devices, though, because there may be other reasons\nfor accessing them during system suspend and that's where some opt-out way\nis needed.\n\n> On those ARM SoCs I am working on, non-ACPI, the information about\n> whether a device may become runtime resumed during system suspend,\n> most often can't be find out in a deterministic way. That's because\n> this information depends on how a device is being used by other\n> devices, which changes dynamically and from one system suspend\n> sequence to another. In cases like the i2c-designware-plat driver used\n> in Hikey (ARM64 board), it can't ever know before hand, if someone is\n> going to request an i2c transfer during system suspend or not.\n\nWell, I2C is somewhat special in that respect, because dependencies between\ndevices in there are not tracked AFAICS. \n\n> To really deal with these devices properly, we have to suspend them in\n> the correct order.\n\nRight, but in order to achieve that the right ordering actually needs\nto be known.  If it is not known, there is no way to get that right in\ngeneral. :-)\n\nThe problem basically is that during system suspend you need to disable\nthe controller at one point, sooner or later, and keep it disabled from\nthat point on.   Of course, that should happen when it is guaranteed that\nthere won't be any new transactions going forward, but you cannot actually\nguaranee that without knowing that all of its \"consumers\" have already\nbeen suspended.\n\n> My point is, doesn't the ordering problem exists also for a device,\n> which the PM core runs the direct_complete path for, even if the ACPI\n> PM domain is attached to the device? Just because runtime PM is\n> disabled for a device, doesn't mean the ordering issue disappears,\n> right?\n\nThe ordering issue is there if there are dependencies between devices the\nPM core doesn't know about.  Otherwise, the rule that direct_complete can\nonly be used for a given device if it also is used for the entire hierarchy\nbelow it (and for all of the device's \"consumers\" and everything that depends\non them too for that matter) makes it go away (it serves as a guarantee that\nall of the device's \"consumers\" have already been suspended).\n\nThanks,\nRafael","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"mXEaOriK\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xkzk90nLyz9t0F\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tSun,  3 Sep 2017 00:57:49 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1do9rj-0004gd-Tw; Sat, 02 Sep 2017 14:57:43 +0000","from cloudserver094114.home.net.pl ([79.96.170.134])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1do9rf-0004eU-BW for linux-arm-kernel@lists.infradead.org;\n\tSat, 02 Sep 2017 14:57:42 +0000","from 79.184.253.199.ipv4.supernova.orange.pl (79.184.253.199) (HELO\n\taspire.rjw.lan)\n\tby serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer\n\t0.82) id 35890705de9269f4; Sat, 2 Sep 2017 16:57:10 +0200"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=o+e8LGR+UbyJduyZGWB/gEe/qRmFi3kNRZ6zSERx6pM=;\n\tb=mXEaOriK75TExm\n\tx1I7PB6LB6AwNeqeaub+bHvtW2H2azgwy2LxedQGqssHYV7NsZOgXX/WuF2UIEkklMNwEqIIb4Vcc\n\thXY/p4o0LkPc0yI4y/a8LuSkltNhEJMxocxMX+JRFp4F7PBKpMFMYuixH9MBH3tjapeauB+bc2UIg\n\trcvnmV5z7qddmCJRer0+xJQsHIMAg3aTslvnvd03Rh0bYVww381NOfsWfmYgLHD9bV+usNzznspaD\n\tsAE0Ocui11TpyiphQkmtl0ec/catloWOKVc5qsw9DXL1kljPEzoPwLbuJtOdIRp7mm6kApg/JjMYB\n\t64SoiNDqBxWTOHwURhNw==;","From":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","To":"Ulf Hansson <ulf.hansson@linaro.org>","Subject":"Re: [PATCH v3 1/8] PM / Sleep: Make the runtime PM centric path\n\tknown to the PM core","Date":"Sat, 02 Sep 2017 16:48:26 +0200","Message-ID":"<1702559.yU4llTGfcI@aspire.rjw.lan>","In-Reply-To":"<CAPDyKFoOJzciMNMWkc+ci+Fn2iD8vwsg25TQjcx=xw2ftg5rug@mail.gmail.com>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<2403318.HVB4k3qRsK@aspire.rjw.lan>\n\t<CAPDyKFoOJzciMNMWkc+ci+Fn2iD8vwsg25TQjcx=xw2ftg5rug@mail.gmail.com>","MIME-Version":"1.0","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170902_075739_677416_86F19F87 ","X-CRM114-Status":"GOOD (  36.52  )","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1762143,"web_url":"http://patchwork.ozlabs.org/comment/1762143/","msgid":"<2209426.5Z3u1iKN4i@aspire.rjw.lan>","list_archive_url":null,"date":"2017-09-02T15:38:04","subject":"Re: [PATCH v3 6/8] PM / ACPI: Enable the runtime PM centric approach\n\tfor system sleep","submitter":{"id":26536,"url":"http://patchwork.ozlabs.org/api/people/26536/","name":"Rafael J. Wysocki","email":"rjw@rjwysocki.net"},"content":"On Friday, September 1, 2017 10:27:05 AM CEST Ulf Hansson wrote:\n> On 29 August 2017 at 17:27, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:\n> > On Tuesday, August 29, 2017 4:56:48 PM CEST Ulf Hansson wrote:\n> >> This change enables the ACPI PM domain to cope with drivers that deploys\n> >> the runtime PM centric path for system sleep.\n> >\n> > [cut]\n> >\n> >> @@ -1052,11 +1066,20 @@ EXPORT_SYMBOL_GPL(acpi_subsys_complete);\n> >>   * @dev: Device to handle.\n> >>   *\n> >>   * Follow PCI and resume devices suspended at run time before running their\n> >> - * system suspend callbacks.\n> >> + * system suspend callbacks. However, try to avoid it in case the runtime PM\n> >> + * centric path is used for the device and then trust the driver to do the\n> >> + * right thing.\n> >>   */\n> >>  int acpi_subsys_suspend(struct device *dev)\n> >>  {\n> >> -     pm_runtime_resume(dev);\n> >> +     struct acpi_device *adev = ACPI_COMPANION(dev);\n> >> +\n> >> +     if (!adev)\n> >> +             return 0;\n> >> +\n> >> +     if (!dev_pm_is_rpm_sleep(dev) || acpi_dev_needs_resume(dev, adev))\n> >> +             pm_runtime_resume(dev);\n> >> +\n> >>       return pm_generic_suspend(dev);\n> >>  }\n> >>  EXPORT_SYMBOL_GPL(acpi_subsys_suspend);\n> >\n> > Well, I tried to avoid calling acpi_dev_needs_resume() for multiple times\n> > and that's why I added the update_state thing.\n> >\n> > Moreover, the is_rpm_sleep flag here has to mean not only that\n> > direct_complete should not be used with the device, but also that its driver\n> > is fine with not resuming it.\n> \n> Let me try to explain this better. I realize the changelog is\n> misleading around this particular section! Huh, apologize for that!\n> \n> First, patch1 makes the PM core treat the is_rpm_sleep flag as the\n> direct_complete isn't allowed for the device.\n> \n> For that reason, when the is_rpm_sleep is set, there is no point\n> calling acpi_dev_needs_resume() from acpi_subsys_prepare(), but\n> instead that can be deferred to acpi_subsys_suspend() - because it\n> doesn't matter if acpi_subsys_prepare() returns 0 or 1, in either case\n> the acpi_subsys_suspend() will be called. That's really what goes on\n> here.\n> \n> The end result is the same. If the acpi_dev_needs_resume() thinks that\n> the device needs to be runtime resumed, pm_runtime_resume() is called\n> for the device in acpi_subsys_suspend().\n> \n> So, this has nothing to do with whether the driver \"is fine with not\n> resuming it\" thing.\n\nNo, sorry.\n\nIf is_rpm_sleep was not set, the ACPI PM domain would resume the device in\nacpi_subsys_suspend() regardless of the acpi_dev_needs_resume() return value.\nThat's what's there in the patch.  So clearly, setting is_rpm_sleep means\n\"this device does not need to be resumed in acpi_subsys_suspend() unless\nacpi_dev_needs_resume() returns true\".  Which clearly means that the driver\n*is* fine with not resuming it, because if is_rpm_sleep is set, the device\nin fact may not be resumed and then the driver will need to cope with that.\n\nAnd note that this meaning of is_rpm_sleep is different from what it is\nexpected to mean to the core.\n\n> >\n> > IMO it is not a good idea to use one flag for these two different things at the\n> > same time at all.\n> \n> Yeah, I guess my upper comment addresses your immediate concern here?\n\nNo, they don't.\n\n> However, there is one other thing the is_rpm_flag means. That is that\n> the driver has informed the ACPI PM domain, to trust the driver to\n> deal with system sleep, via re-using the runtime PM callbacks.\n> So the flag does still have two meanings, but that we can change - of course.\n\nI guess that you are referring to the use of dev_pm_is_rpm_sleep() in\nacpi_subsys_suspend_late()?  That's the third thing this flag means ...\n\nThanks,\nRafael","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"Y2BxdqEU\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xl0qB17xlz9sQl\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tSun,  3 Sep 2017 01:47:18 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1doAde-0004Rm-Rk; Sat, 02 Sep 2017 15:47:14 +0000","from cloudserver094114.home.net.pl ([79.96.170.134])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1doAda-0004KI-Pk for linux-arm-kernel@lists.infradead.org;\n\tSat, 02 Sep 2017 15:47:12 +0000","from 79.184.253.199.ipv4.supernova.orange.pl (79.184.253.199) (HELO\n\taspire.rjw.lan)\n\tby serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer\n\t0.82) id e2a649d0fff84b71; Sat, 2 Sep 2017 17:46:48 +0200"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=Lhn4dEYqIP6a9kgcw4rSKbn40hK13SxBlku84RYI0K4=;\n\tb=Y2BxdqEUnII+8a\n\t89iqynBF6AQRaAHj2jYg0l9A+E4Wl1v9T/uj5Nu7N1CosyF4tmTYZy754tpUE4rqQlsu2heaoTYXN\n\tf0DkXEgrT+JQ1n5tpOHj6h2ogi5tDHbYIVMb38pwyDtZoIOs/CQNYRNKRLWLOlOYa6PJMrGtUZBRG\n\t658CeUeFfj3VCOFcHYkt/60SZ7EuvARujjlmdn2KI5czk4a4KPtxuhcWsedo/o9NhRCutNMe8D8WP\n\tcPC0QXVkBDZtLt9IUSq57RjYABekqWzWWsUp2eVkcy2ZrVxEp4PXmkYN140gVRkGIggk0eQ0Z32gI\n\tgeWWiGCBdB72l2s9POvQ==;","From":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","To":"Ulf Hansson <ulf.hansson@linaro.org>","Subject":"Re: [PATCH v3 6/8] PM / ACPI: Enable the runtime PM centric approach\n\tfor system sleep","Date":"Sat, 02 Sep 2017 17:38:04 +0200","Message-ID":"<2209426.5Z3u1iKN4i@aspire.rjw.lan>","In-Reply-To":"<CAPDyKFq5ic+bAVRoEC58oSO-8VTGnfipJndLmR6YLXgEhZ+RWw@mail.gmail.com>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<2855684.NY3Ly9PzrE@aspire.rjw.lan>\n\t<CAPDyKFq5ic+bAVRoEC58oSO-8VTGnfipJndLmR6YLXgEhZ+RWw@mail.gmail.com>","MIME-Version":"1.0","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170902_084711_075383_71869700 ","X-CRM114-Status":"GOOD (  27.08  )","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1762361,"web_url":"http://patchwork.ozlabs.org/comment/1762361/","msgid":"<1668277.7DWLdgHGid@aspire.rjw.lan>","list_archive_url":null,"date":"2017-09-04T00:17:21","subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","submitter":{"id":26536,"url":"http://patchwork.ozlabs.org/api/people/26536/","name":"Rafael J. Wysocki","email":"rjw@rjwysocki.net"},"content":"On Friday, September 1, 2017 12:42:35 PM CEST Ulf Hansson wrote:\n> On 31 August 2017 at 02:17, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:\n> > Disclaimer: I'm falling asleep, so I probably shouldn't reply to email right\n> > now, but tomorrow I may not be able to get to email at all, so I'll try anyway.\n> >\n> > On Wednesday, August 30, 2017 11:57:28 AM CEST Ulf Hansson wrote:\n> >> On 29 August 2017 at 22:19, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:\n> >> > On Tuesday, August 29, 2017 4:56:42 PM CEST Ulf Hansson wrote:\n> >> >> The i2c designware platform driver, drivers/i2c/busses/i2c-designware-platdrv.c,\n> >> >> isn't well optimized for system sleep.\n> >> >>\n> >> >> What makes this driver particularly interesting is because it's a cross-SoC\n> >> >> driver, which sometimes means there is an ACPI PM domain attached to the i2c\n> >> >> device and sometimes not. The driver is being used on both x86 and ARM.\n> >> >>\n> >> >> In principle, to optimize the system sleep support in i2c driver, this series\n> >> >> enables the proven runtime PM centric path for the i2c driver. However, to do\n> >> >> that the ACPI PM domain also have to collaborate and understand this behaviour.\n> >> >> From earlier versions, Rafael has also pointed out that also the PM core needs\n> >> >> to be involved.\n> >> >\n> >> > Earlier today I realized that drivers pointing their ->suspend_late and\n> >> > ->resume_early callbacks, respectively, to pm_runtime_force_suspend() and\n> >> > pm_runtime_force_resume(), are fundamentally incompatible with any bus type\n> >> > doing nontrivial PM and with almost any nontrivial PM domains, for two reasons.\n> >> >\n> >> > First, it basically requires the bus type or PM domain to expect that its\n> >> > ->runtime_suspend callback may or may not be indirectly invoked from its\n> >> > own ->suspend_late callback, depending on the driver (and analogously\n> >> > for ->runtime_resume and ->resume early), which is insane.\n> >> >\n> >> > Second, it is a layering violation, because it makes the driver effectively\n> >> > override the upper layer's decisions about what code to run.\n> >>\n> >> You are right that for more complex bus types and PM domains, those\n> >> needs to play along. So that is what I am trying to implement for the\n> >> ACPI PM domain in this series.\n> >\n> > Well, \"play along\" is a bit of an understatement here.\n> >\n> > They would need to turn into horrible mess and that's not going to happen.\n> \n> I absolutely agree, there must be no mess what so ever!\n> \n> But, I don't want to give up yet, I still believe I can make this\n> series into a nice couple of changes for the ACPI PM domain.\n\nWell, as far as I'm concerned, this is not going to get any further.\n\n> Especially if you continue giving me your guidance.\n> \n> >\n> >> The generic PM domain, is simple in this regards. There is only a\n> >> minor adaptation for the ->runtime_suspend|resume() callbacks, which\n> >> avoids validating dev_pm_qos constraints during system sleep. Nothing\n> >> special is needed in ->suspend_late|noirq callbacks, etc.\n> >>\n> >> For most other simple bus types, like the platform bus, spi, i2c,\n> >> amba, no particular adoptions is needed at all. Instead those just\n> >> trust the drivers to do the right thing.\n> >\n> > They are the trivial ones.\n> \n> Yes.\n> \n> However, the platform bus is also very commonly used in kernel. I\n> think that's an important thing to consider.\n\nWell, so is ACPI, and PCI.\n\nAnd the platform bus doesn't do any kind of PM handling by itself,\nwhereas the above do.  Therefore trying to look at the platform bus as\nan example to follow by them is rather not useful IMO.\n\n> >\n> >> Before we had the direct_complete path, using the\n> >> pm_runtime_force_suspend|resume() helpers, was the only good way for\n> >> these kind of drivers, to in an optimized manner, deal with system\n> >> sleep when runtime PM also was enabled for their devices. Now this\n> >> method has become widely deployed, unfortunate whether you like it or\n> >> not.\n> >\n> > So can you please remind me why the _force_ wrappers are needed?\n> \n> See below.\n> \n> >\n> > In particular, why can't drivers arrange their callbacks the way I did that\n> > in https://patchwork.kernel.org/patch/9928583/ ?\n> \n> I was preparing a reply to that patch, but let me summarize that here instead.\n> \n> Let me be clear, the patch is an improvement of the behavior of the\n> driver and it addresses the issues you point out in the change log.\n> Re-using the runtime PM callbacks for system sleep, is nice as it\n> avoids open coding, which is of curse also one of the reason of using\n> pm_runtime_force_suspend|resume().\n> \n> Still there are a couple of things I am worried about in this patch.\n> *)\n> To be able to re-use the same callbacks for system sleep and runtime\n> PM, some boilerplate code is added to the driver, as to cope with the\n> different conditions inside the callbacks. That pattern would become\n> repeated to many drivers dealing with similar issues.\n\nI'm not worried about that as long as there are good examples and\ndocumented best practices.\n\nThere aren't any right now, which is a problem, but that certainly is\nfixable.\n\n> **)\n> The ->resume_early() callback powers on the device, in case it was\n> runtime resumed when the ->suspend_late() callback was invoked. That\n> is in many cases completely unnecessary, causing us to waste power and\n> increase system resume time, for absolutely no reason. However, I\n> understand the patch didn't try to address this, but to really fix\n> this, there has to be an even closer collaboration between runtime PM\n> and the system sleep callbacks.\n\nI don't quite agree and here's why.\n\nIf a device was not runtime-suspended right before system suspend, then quite\nlikely it was in use then.  Therefore it is quite likely to be resumed\nimmediately after system resume anyway.\n\nNow, if that's just one device, it probably doesn't matter, but if there are\nmore devices like that, they will be resumed after system suspend when they\nare accessed and quite likely they will be accessed one-by-one rather than in\nparallel with each other, so the latencies related to that will add up.  In\nthat case it is better to resume them upfront during system resume as they will\nbe resumed in parallel with each other then.  And that also is *way* simpler.\n\nThis means that the benefit from avoiding to resume devices during system\nresume is not quite so obvious and the whole point above is highly\nquestionable.\n\n> \n> So, to remind you why the pm_runtime_force_suspend|resume() helpers is\n> preferred, that's because both of the above two things becomes taken\n> care of.\n\nAnd that is why there is this stuff about parents and usage counters, right?\n\nI'm not liking it at all.\n\n> \n> >\n> >> Besides the slightly better optimizations you get when using\n> >> pm_runtime_force_suspend|resume(), comparing to the direct_complete\n> >> path - I think it's also worth to consider, how easy it becomes for\n> >> drivers to deploy system sleep support. In many cases, only two lines\n> >> of code is needed to add system sleep support in a driver.\n> >\n> > You are doing a wrong comparison here IMO.  You essentially are comparing two\n> > bandaids with each other and arguing that one of them somehow is better.\n> \n> I just wanted to compare against something...\n> \n> >\n> > What about doing something which is not a bandaid instead?\n> \n> I don't have a problem working on something new, but I am not sure\n> what that should be.\n> \n> Unless you re-consider moving forward in some form, with the current\n> suggested approach for the ACPI PM domain, can you give me some\n> pointers on what you have in mind?\n\nYes.\n\nDo what was indended from the start and make drivers re-use runtime\nPM callbacks for ->suspend_late and ->resume_early.\n\nFirst, that can be done.\n\nSecond, it is *conceptually* much more straightforward than things like\n_force_suspend/resume().\n\nNext, the drivers have full control on what they do in that case and\ncan be made work with any middle-layer core easily enough.\n\nNo layering violations, no insane callback chains.\n\n> To remind you of my current view, the direct_complete path is useful\n> for PM domains, like the ACPI PM domain as it impacts all its devices.\n> Using pm_runtime_force_suspend|resume() offers the next steps to\n\nI completely disagree at this point.\n\nSo to be clear, the invocation of moddle-layer callbacks instead of\n*driver* callbacks in pm_runtime_force_suspend|resume() is a grave mistake.\nThey would have been almost possible to work with had they just invoke\ndriver callbacks.\n\nOTOH I'm starting to think that direct_complete is only theoretically useful\nand may not be actually set very often in practice, whereas it adds significant\ncomplexity to the code, so I'm not sure about it any more.\n\n> achieve a fully optimized behavior of a device during system sleep, as\n> already been proven by now. It would be great to both options\n> supported by the ACPI PM domain.\n\nNo.\n\n> Another related thing that is causing lots of problems during system\n> sleep of devices, but not related to optimizations, is to have the\n> correct order of how to suspend/resume the devices. We have talked\n> about this, but it's a separate problem and it's rather a deployment\n> issue, than having to implements something entirely new (we have\n> supplies/consumers links you invented for this).\n\nYes, that is a separate issue.\n\n> >\n> >> Now, some complex code always needs to be implemented somewhere. When\n> >> using the runtime PM centric path, that code consist of the\n> >> pm_runtime_force_suspend|resume() helpers itself - and some\n> >> adaptations in buses/PM domains in cases when those needs special\n> >> care.\n> >>\n> >> My point is, the runtime PM centric path, allows us to keep the\n> >> complex part of the code at a few centralized places, instead of\n> >> having it spread/duplicated into drivers.\n> >>\n> >> So yes, you could consider it insane, but to me and many others, it\n> >> seems to work out quite well.\n> >\n> > Because it only has been used with trivial middle layer code so far\n> > and I'm quite disappointed that you don't seem to see a problem here. :-/\n> >\n> > I mean something like\n> >\n> > PM core => bus type / PM domain ->suspend_late => driver ->suspend_late\n> >\n> > is far more straightforward than\n> >\n> > PM core => bus type / PM domain ->suspend_late => driver ->suspend_late =>\n> >         bus type / PM domain ->runtime_suspend => driver ->runtime_suspend\n> >\n> > with the bus type / PM domain having to figure out somehow at the\n> > ->suspend_late time whether or not its ->runtume_suspend is going to be invoked\n> > in the middle of it.\n> >\n> > Apart from this just being aesthetically disgusting to me, which admittedly is\n> > a matter of personal opinion, it makes debugging new driver code harder (if it\n> > happens to not work) and reviewing it almost impossible, because now you need\n> > to take all of the tangling between callbacks into accont and sometimes not\n> > just for one bus type / PM domain.\n> \n> I am wondering that perhaps you may be overlooking some of the\n> internals of runtime PM. Or maybe not? :-)\n> \n> I mean, the hole thing is build upon that anyone can call runtime PM\n> functions to runtime resume/suspend a device.\n\nWell, right in general, except that _force_suspend/resume() invoke\n*callbacks* and *not* runtime PM functions.\n\n> Doing that, makes the\n> hierarchy of the runtime PM callbacks being walked and invoked, of\n> course properly managed by the runtime PM core.\n> \n> My point is that, the runtime PM core still controls this behavior,\n> even when the pm_runtime_force_suspend|resume() helpers are being\n> invoked. The only difference is that it allows runtime PM for the\n> device to be disabled, and still correctly invoked the callbacks. That\n> is what it is all about.\n\nSo why is it even useful to call ->runtime_suspend from a middle layer\nin pm_runtime_force_suspend(), for example?\n\n> >\n> >> Yeah, and the laying violation is undoubtedly the most controversial\n> >> part of the runtime PM centric path - I agree to that! The\n> >> direct_complete path don't have this, as you implemented it. :-)\n> >>\n> >> On the other hand, one could consider that these upper layers, in many\n> >> cases anyway needs to play along with the behavior of the driver. So,\n> >> I guess it depends on how one see it.\n> >>\n> >> >\n> >> > That's why I'm afraid that we've reached a dead end here. :-(\n> >>\n> >> That's said news. Is was really hoping I could find a way to move this\n> >> forward. You don't have any other ideas on how I can adjust the series\n> >> to make you happy?\n> >\n> > So to be precise, patches [2-3/8] are basically fine by me.  Patch [4/8]\n> > sort of works too, but I'd do the splitting slightly differently and I don't\n> > see much value in it alone.\n> >\n> > The rest of the ACPI changes is mostly not acceptable to me, mostly because\n> > of what is done to the PM domain's ->runtime_suspend/resume and\n> > ->suspend_late/->resume_early callbacks.\n> >\n> > I guess the only way that could be made work for me would be by not using\n> > _force_suspend/resume() at all, but that would defeat the point, right?\n> \n> Yes, it would.\n> \n> >\n> > I don't like the flag too, but that might be worked out.\n> \n> Yeah, I am open to any suggestion.\n> \n> >\n> > Also, when I looked at _force_suspend/resume() again, I got concerned.\n> > There is stuff in there that shouldn't be necessary in a driver's\n> > ->late_suspend/->early_resume and some things in there just made me\n> > scratch my head.\n> \n> Yes, there are some complexity in there, I will be happy to answer any\n> specific question about it.\n\nOK\n\nOf course they require runtime PM to be enabled by drivers using them as\ntheir callbacks, but I suppose that you realize that.\n\nWhy to disabe/renable runtime PM in there in the first place?  That should\nhave been done by the core when these functions are intended to be called.\n\nSecond, why to use RPM_GET_CALLBACK in there?\n\nNext, how is the parent actually runtime-resumed by pm_runtime_force_resume()\nwhich the comment in pm_runtime_force_suspend() talks about?\n\n> \n> The main thing is, that it tries to conform to the regular rules set\n> by the runtime PM core when runtime PM is enabled for the device - and\n> then apply those to the device when runtime PM has been disabled for\n> it.\n\nSorry, I'm not sure what this means really ...\n\n> Again, thanks for being patient and reviewing!\n\nWell, no problem.\n\nThanks,\nRafael","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"Y+OJoh/N\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xlrJ36J8cz9s8J\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tMon,  4 Sep 2017 10:26:43 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dofDs-00041W-KV; Mon, 04 Sep 2017 00:26:40 +0000","from cloudserver094114.home.net.pl ([79.96.170.134])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dofDn-0003ym-D9 for linux-arm-kernel@lists.infradead.org;\n\tMon, 04 Sep 2017 00:26:38 +0000","from 79.184.253.199.ipv4.supernova.orange.pl (79.184.253.199) (HELO\n\taspire.rjw.lan)\n\tby serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer\n\t0.82) id 977448f64dceb8fe; Mon, 4 Sep 2017 02:26:06 +0200"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=mXowxcvzYBLPtvh1W+YGPWquTPLo2fsCWrTXyMDxJQ0=;\n\tb=Y+OJoh/NsRotRq\n\tLmYUAh4SKD/rZ8sLoHK+ECQilylCEQNwATt4z/iQKeQw8DI9718wFRxRqje9BWWQo1frqzxI9Anig\n\t4FIX2vpuucspg0d0BuQ80Do16U8brtel4AXhWznA021IxxJHrclQXuxr9XfBvaMUUXBX+NYcS0qP8\n\t28JW9p8bLAUpkX8GiJ31+szmPfmsjcOM6/biEfZWTAUTwt7lt1Vmz6DC4dP+KaKzrjnXeKiphnHz3\n\tfQSIFIYxVAaCA33DvbjLIbQKlUICikAj1BbkecLS4EduC8oXQgrCr2s9HEGgk08J+oxA6/0AIL4YO\n\tfwVkcamQBRoNHJ5Vs3Uw==;","From":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","To":"Ulf Hansson <ulf.hansson@linaro.org>","Subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","Date":"Mon, 04 Sep 2017 02:17:21 +0200","Message-ID":"<1668277.7DWLdgHGid@aspire.rjw.lan>","In-Reply-To":"<CAPDyKFqAqiDcdwEOwEu1m7icnP8MijYf4UNrMqN9YhNbug_upg@mail.gmail.com>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<3033151.kbPpEQGlRq@aspire.rjw.lan>\n\t<CAPDyKFqAqiDcdwEOwEu1m7icnP8MijYf4UNrMqN9YhNbug_upg@mail.gmail.com>","MIME-Version":"1.0","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170903_172635_812917_FF828EDE ","X-CRM114-Status":"GOOD (  57.77  )","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1762429,"web_url":"http://patchwork.ozlabs.org/comment/1762429/","msgid":"<20170904054637.GA23707@wunner.de>","list_archive_url":null,"date":"2017-09-04T05:46:37","subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","submitter":{"id":68499,"url":"http://patchwork.ozlabs.org/api/people/68499/","name":"Lukas Wunner","email":"lukas@wunner.de"},"content":"On Mon, Sep 04, 2017 at 02:17:21AM +0200, Rafael J. Wysocki wrote:\n> OTOH I'm starting to think that direct_complete is only theoretically\n> useful and may not be actually set very often in practice, whereas it\n> adds significant complexity to the code, so I'm not sure about it any\n> more.\n\nThat makes me come out of the woodwork as a direct_complete fan:\n\nRuntime resuming a discrete GPU on a modern dual GPU laptop takes about\n1.5 sec, runtime resuming Thunderbolt controllers more than 2 sec.\nA discrete GPU easily consumes 10W, a Thunderbolt controller 2W.\n\nSo not having direct_complete would noticeably delay system suspend and\nresume as well as reduce battery life.\n\nLukas","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"CCIaVHfS\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xlzQ12Vhcz9s7M\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tMon,  4 Sep 2017 15:47:21 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dokE6-0008NA-HS; Mon, 04 Sep 2017 05:47:14 +0000","from mailout2.hostsharing.net ([83.223.90.233])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dokE2-0008D6-Hm for linux-arm-kernel@lists.infradead.org;\n\tMon, 04 Sep 2017 05:47:12 +0000","from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby mailout2.hostsharing.net (Postfix) with ESMTPS id 26DF1101712DC;\n\tMon,  4 Sep 2017 07:46:38 +0200 (CEST)","by h08.hostsharing.net (Postfix, from userid 100393)\n\tid E7D8C7C35F9; Mon,  4 Sep 2017 07:46:37 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:\n\tMessage-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=LDoiFaDLOfmEVX8aeNNSA5tiPCxcHLB69TknHgvXxY4=;\n\tb=CCIaVHfStzQkG+\n\tI+N+bGDUl20xM5HohxwTAaMEi5IuMlVh60Drz/A/RfGf+STZbWwZZPE13Iarm2lL5Lx3NdxuXb7o4\n\tyej3H0NES7UTmwJCBm2iDByDPd9OQx8pLLC+mEiD2QrGofmcfHGZrzv9zpSpvXG1vM2InSAvNkn0K\n\taq43GdMeCFfu9z+Byv24V1xIreBoGpUNqKRiMU6xnAC2KsfAwsVEvJuB8FUnQ5cxkKYSXz8QIxdn5\n\tqDqxYFqkt3tX8pquTFy7m2dkd4wmKp94GsCv/FJA/tFvDeamNV4yWI/Us2KQd9Ev4z89E/Utul1zW\n\tfRr742xZlbzgfjlAX0Iw==;","Date":"Mon, 4 Sep 2017 07:46:37 +0200","From":"Lukas Wunner <lukas@wunner.de>","To":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","Subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","Message-ID":"<20170904054637.GA23707@wunner.de>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<3033151.kbPpEQGlRq@aspire.rjw.lan>\n\t<CAPDyKFqAqiDcdwEOwEu1m7icnP8MijYf4UNrMqN9YhNbug_upg@mail.gmail.com>\n\t<1668277.7DWLdgHGid@aspire.rjw.lan>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<1668277.7DWLdgHGid@aspire.rjw.lan>","User-Agent":"Mutt/1.5.23 (2014-03-12)","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170903_224710_769285_76F9239A ","X-CRM114-Status":"UNSURE (   9.91  )","X-CRM114-Notice":"Please train this message.","X-Spam-Score":"-2.6 (--)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-2.6 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/,\n\tlow trust [83.223.90.233 listed in list.dnswl.org]\n\t-0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay\n\tdomain\n\t0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level\n\tmail domains are different\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Ulf Hansson <ulf.hansson@linaro.org>,\n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\tJohannes Stezenbach <js@sig21.net>,\n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1762553,"web_url":"http://patchwork.ozlabs.org/comment/1762553/","msgid":"<3410095.RTqPGnhnfq@aspire.rjw.lan>","list_archive_url":null,"date":"2017-09-04T10:04:58","subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","submitter":{"id":26536,"url":"http://patchwork.ozlabs.org/api/people/26536/","name":"Rafael J. Wysocki","email":"rjw@rjwysocki.net"},"content":"On Monday, September 4, 2017 7:46:37 AM CEST Lukas Wunner wrote:\n> On Mon, Sep 04, 2017 at 02:17:21AM +0200, Rafael J. Wysocki wrote:\n> > OTOH I'm starting to think that direct_complete is only theoretically\n> > useful and may not be actually set very often in practice, whereas it\n> > adds significant complexity to the code, so I'm not sure about it any\n> > more.\n> \n> That makes me come out of the woodwork as a direct_complete fan:\n> \n> Runtime resuming a discrete GPU on a modern dual GPU laptop takes about\n> 1.5 sec, runtime resuming Thunderbolt controllers more than 2 sec.\n> A discrete GPU easily consumes 10W, a Thunderbolt controller 2W.\n> \n> So not having direct_complete would noticeably delay system suspend and\n> resume as well as reduce battery life.\n\nWell, that's a good reason for having it. :-)\n\nThanks,\nRafael","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"aSY0ePsG\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xm5L621pZz9s82\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tMon,  4 Sep 2017 20:14:22 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dooOY-0004au-FE; Mon, 04 Sep 2017 10:14:18 +0000","from cloudserver094114.home.net.pl ([79.96.170.134])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dooOP-0004Vq-Pg for linux-arm-kernel@lists.infradead.org;\n\tMon, 04 Sep 2017 10:14:16 +0000","from 79.184.253.199.ipv4.supernova.orange.pl (79.184.253.199) (HELO\n\taspire.rjw.lan)\n\tby serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer\n\t0.82) id 195fe62584e15445; Mon, 4 Sep 2017 12:13:45 +0200"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=rw0g7jefPqTPKKcuNp0nTS9GJgqdNUzhUMjVjemUq8c=;\n\tb=aSY0ePsG9YeYbS\n\ti3jovggPa2xOAZyYs8HSefLeX+uCIqCbCGjCRA3nH/zTIEui5xJBDHKGkHtZMrDBB3XozvtJX+pll\n\t91mWz6ekfG7ITvjRwjK++ehh1fJLM+takvKA6xmpAcYQdOtIr39IZMBbEXZA1NQTU0nhqgyRhn6zP\n\towYrtwXjELUQRV9U+wgBpbVeKZB1vKe+3s6xSjlkN/eAUFga3lxfFhMXGIv3cFvereb3SyaJCgH+h\n\t2S93/F06brHp5TJ06TjVMSUiI02p3zs2SpVkaK1B56wJ52SiQLXb9q1jgJySnkPnDulHY41IZJNHD\n\tno2ly4mhmbOPSv/EKNQA==;","From":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","To":"Lukas Wunner <lukas@wunner.de>","Subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","Date":"Mon, 04 Sep 2017 12:04:58 +0200","Message-ID":"<3410095.RTqPGnhnfq@aspire.rjw.lan>","In-Reply-To":"<20170904054637.GA23707@wunner.de>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<1668277.7DWLdgHGid@aspire.rjw.lan>\n\t<20170904054637.GA23707@wunner.de>","MIME-Version":"1.0","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170904_031410_021833_EE226FF7 ","X-CRM114-Status":"UNSURE (   9.04  )","X-CRM114-Notice":"Please train this message.","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Ulf Hansson <ulf.hansson@linaro.org>,\n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\tJohannes Stezenbach <js@sig21.net>,\n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1762608,"web_url":"http://patchwork.ozlabs.org/comment/1762608/","msgid":"<CAPDyKFpX3Owk4H=0SqgfspXZd9TmdL_ANOZftXRq6HPjrT2ctQ@mail.gmail.com>","list_archive_url":null,"date":"2017-09-04T12:55:37","subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","submitter":{"id":21036,"url":"http://patchwork.ozlabs.org/api/people/21036/","name":"Ulf Hansson","email":"ulf.hansson@linaro.org"},"content":"[...]\n\n>> > So can you please remind me why the _force_ wrappers are needed?\n>>\n>> See below.\n>>\n>> >\n>> > In particular, why can't drivers arrange their callbacks the way I did that\n>> > in https://patchwork.kernel.org/patch/9928583/ ?\n>>\n>> I was preparing a reply to that patch, but let me summarize that here instead.\n>>\n>> Let me be clear, the patch is an improvement of the behavior of the\n>> driver and it addresses the issues you point out in the change log.\n>> Re-using the runtime PM callbacks for system sleep, is nice as it\n>> avoids open coding, which is of curse also one of the reason of using\n>> pm_runtime_force_suspend|resume().\n>>\n>> Still there are a couple of things I am worried about in this patch.\n>> *)\n>> To be able to re-use the same callbacks for system sleep and runtime\n>> PM, some boilerplate code is added to the driver, as to cope with the\n>> different conditions inside the callbacks. That pattern would become\n>> repeated to many drivers dealing with similar issues.\n>\n> I'm not worried about that as long as there are good examples and\n> documented best practices.\n>\n> There aren't any right now, which is a problem, but that certainly is\n> fixable.\n>\n>> **)\n>> The ->resume_early() callback powers on the device, in case it was\n>> runtime resumed when the ->suspend_late() callback was invoked. That\n>> is in many cases completely unnecessary, causing us to waste power and\n>> increase system resume time, for absolutely no reason. However, I\n>> understand the patch didn't try to address this, but to really fix\n>> this, there has to be an even closer collaboration between runtime PM\n>> and the system sleep callbacks.\n>\n> I don't quite agree and here's why.\n>\n> If a device was not runtime-suspended right before system suspend, then quite\n> likely it was in use then.  Therefore it is quite likely to be resumed\n> immediately after system resume anyway.\n\nUnfortunate, to always make that assumption, leads to a non-optimized\nbehavior of system sleep. I think we can do better than that!\n\nLet me give you a concrete example, where the above assumption would\nlead to an non-optimized behavior.\n\nTo put an MMC card into low power state during system suspend\n(covering eMMC, SD, SDIO) the mmc core needs to send a couple of\ncommands over the MMC interface to the card, as to conform with the\n(e)MMC/SD/SDIO spec. To do this, the mmc driver for the mmc controller\nmust runtime resume its device, as to be able to send the commands\nover the interface.\n\nNow, when the system resumes, there is absolutely no reason to runtime\nresume the device for the MMC controller, just because it was runtime\nresumed during system suspend. Instead that is better to be postponed\nto when the MMC card is really needed and thus via runtime PM instead.\n\nThis scenario shouldn't be specific to only MMC controllers/cards, but\nshould apply to any external devices/controllers that needs some\nspecial treatment to be put into low power state during system\nsuspend. Particularly also when those external devices may be left in\nthat low power state until those are really needed. A couple of cases\nI know of pops up in my head, WiFi chips, persistent storage devices,\netc. There should be plenty.\n\nAnother common case, is when a subsystem core layer flushes a request\nqueue during system suspend, which may cause a controller device to be\nruntime resumed. Making the assumption that, because flushing the\nqueue was done during system suspend, we must also power up the\ncontroller during system resume, again would lead to a non-optimized\nbehavior.\n\n>\n> Now, if that's just one device, it probably doesn't matter, but if there are\n> more devices like that, they will be resumed after system suspend when they\n> are accessed and quite likely they will be accessed one-by-one rather than in\n> parallel with each other, so the latencies related to that will add up.  In\n> that case it is better to resume them upfront during system resume as they will\n> be resumed in parallel with each other then.  And that also is *way* simpler.\n>\n> This means that the benefit from avoiding to resume devices during system\n> resume is not quite so obvious and the whole point above is highly\n> questionable.\n\nI hope my reasoning above explains why I think it shouldn't be\nconsidered as questionable.\n\nIf you like, I can also provide some real data/logs - showing you\nwhat's happening.\n\n>\n>>\n>> So, to remind you why the pm_runtime_force_suspend|resume() helpers is\n>> preferred, that's because both of the above two things becomes taken\n>> care of.\n>\n> And that is why there is this stuff about parents and usage counters, right?\n\nCorrect. Perhaps this commit tells you a little more.\n\ncommit 1d9174fbc55ec99ccbfcafa3de2528ef78a849aa\nAuthor: Ulf Hansson <ulf.hansson@linaro.org>\nDate:   Thu Oct 13 16:58:54 2016 +0200\n\n    PM / Runtime: Defer resuming of the device in pm_runtime_force_resume()\n\n[...]\n\n>> >\n>> > PM core => bus type / PM domain ->suspend_late => driver ->suspend_late\n>> >\n>> > is far more straightforward than\n>> >\n>> > PM core => bus type / PM domain ->suspend_late => driver ->suspend_late =>\n>> >         bus type / PM domain ->runtime_suspend => driver ->runtime_suspend\n>> >\n>> > with the bus type / PM domain having to figure out somehow at the\n>> > ->suspend_late time whether or not its ->runtume_suspend is going to be invoked\n>> > in the middle of it.\n>> >\n>> > Apart from this just being aesthetically disgusting to me, which admittedly is\n>> > a matter of personal opinion, it makes debugging new driver code harder (if it\n>> > happens to not work) and reviewing it almost impossible, because now you need\n>> > to take all of the tangling between callbacks into accont and sometimes not\n>> > just for one bus type / PM domain.\n>>\n>> I am wondering that perhaps you may be overlooking some of the\n>> internals of runtime PM. Or maybe not? :-)\n>>\n>> I mean, the hole thing is build upon that anyone can call runtime PM\n>> functions to runtime resume/suspend a device.\n>\n> Well, right in general, except that _force_suspend/resume() invoke\n> *callbacks* and *not* runtime PM functions.\n\nI am considering pm_runtime_force_suspend|resume() being a part of the\nruntime PM API, except that those may be called only during system\nsleep.\n\nComparing a call to pm_runtime_resume(); this may trigger rpm_resume()\nto invoke the callbacks. To me, the difference is that the conditions\nlooked at in rpm_resume(), when runtime PM is enabled, becomes\ndifferent for system sleep when runtime PM is disabled - and that is\ntaken care of in pm_runtime_force_suspend|resume().\n\n>\n>> Doing that, makes the\n>> hierarchy of the runtime PM callbacks being walked and invoked, of\n>> course properly managed by the runtime PM core.\n>>\n>> My point is that, the runtime PM core still controls this behavior,\n>> even when the pm_runtime_force_suspend|resume() helpers are being\n>> invoked. The only difference is that it allows runtime PM for the\n>> device to be disabled, and still correctly invoked the callbacks. That\n>> is what it is all about.\n>\n> So why is it even useful to call ->runtime_suspend from a middle layer\n> in pm_runtime_force_suspend(), for example?\n\nPerhaps I don't understand the question correctly.\n\nAnyway, the answer I think of, is probably because of the same reason\nto why the runtime PM core invokes it, when it runs rpm_suspend() for\na device. My point is, we want the similar behavior.\n\n[...]\n\n>> >\n>> > Also, when I looked at _force_suspend/resume() again, I got concerned.\n>> > There is stuff in there that shouldn't be necessary in a driver's\n>> > ->late_suspend/->early_resume and some things in there just made me\n>> > scratch my head.\n>>\n>> Yes, there are some complexity in there, I will be happy to answer any\n>> specific question about it.\n>\n> OK\n>\n> Of course they require runtime PM to be enabled by drivers using them as\n> their callbacks, but I suppose that you realize that.\n>\n> Why to disabe/renable runtime PM in there in the first place?  That should\n> have been done by the core when these functions are intended to be called.\n\nThe reason is because we didn't want to re-strict them to be used only\nin ->suspend_late() and ->resume_early(), but also for ->suspend() and\n->resume(), which is when runtime PM still is enabled.\n\n>\n> Second, why to use RPM_GET_CALLBACK in there?\n\nTo follow the same rules/hierarchy, as being done in rpm_suspend|resume().\n\n>\n> Next, how is the parent actually runtime-resumed by pm_runtime_force_resume()\n> which the comment in pm_runtime_force_suspend() talks about?\n\nI think the relevant use case here is when a parent and a child, both\nhave subsystems/drivers using pm_runtime_force_suspend|resume(). If\nthat isn't the case, we expect that the parent is always resumed\nduring system resume. It's a bit fragile approach, so we perhaps we\nshould deal with it, even if the hole thing is used as opt-in.\n\nAnyway, let's focus on the case which I think is most relevant to your question:\n\nA couple of conditions to start with.\n*) The PM core system suspends a child prior a parent, which leads to\npm_runtime_force_suspend() being called for the child first.\n**) The PM core system resumes a parents before a child, thus\npm_runtime_force_resume() is called for the parent first.\n\nIn case a child don't need to be resumed when\npm_runtime_force_resume() is called for it, likely doesn't its parent.\nHowever, to control that, in system suspend the\npm_runtime_force_suspend() increases the usage counter for the parent,\nas to indicate if it needs to be resumed when\npm_runtime_force_resume() is called for it.\n\nFinally, when the child becomes resumed in pm_runtime_force_resume(),\npm_runtime_set_active() is called for it. This verifies that the\nparent also has been resumed properly.\n\n[...]\n\nKind regards\nUffe","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"gVOB/Vdr\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"c4AGTNOT\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xm8wp5wvjz9sNr\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tMon,  4 Sep 2017 22:56:09 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1doqv7-0002gO-ER; Mon, 04 Sep 2017 12:56:05 +0000","from mail-it0-x236.google.com ([2607:f8b0:4001:c0b::236])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1doqv2-0002MB-G3 for linux-arm-kernel@lists.infradead.org;\n\tMon, 04 Sep 2017 12:56:02 +0000","by mail-it0-x236.google.com with SMTP id c13so2524797itb.0\n\tfor <linux-arm-kernel@lists.infradead.org>;\n\tMon, 04 Sep 2017 05:55:39 -0700 (PDT)","by 10.2.96.38 with HTTP; Mon, 4 Sep 2017 05:55:37 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:\n\tReferences:In-Reply-To:MIME-Version:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=Gg3cSYanf3t0Y1w66GhWIzmJpTLW8C0MQyah2+C7yV4=;\n\tb=gVOB/VdrUEG77U\n\tPsWx6+g2+UGQAzYgCv/MgebYY/2mbXXlT6q2Wu0h9g85hTB5nSMhiEkepVy9Wz6apG/mtH0YA/yV1\n\tUKU3P10V9fmkYM4ujKwfh3CBHsqQ6TqiPmEwG74mYSNncXAC2BsB3zGWvqpweghszVf5QuCrNFIWB\n\tZAiIkgK7rOFnXhRBPVJxJ6rKaErnUSsAUpNLMw+a0TqSB69+xB4eq6R92rcTVSW5DGdJvk8I09Nuu\n\tdVk3KPTRiiXwHhhCcZtLBKLXK6DY/dZIyyPDdTNRvKnducNmTj5bqYaCFEIFlaPCCqFSES9+QUZjK\n\tDLY4ZEUP+EZzJ6SrX3zw==;","v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=yjxnPDpLCf2yCjcd0ZoCpKX4Y5FapV/v3zxDTSipIys=;\n\tb=c4AGTNOT5kODFukoYUuQHFMsGA5nES0B9wSeLxKLnZyUFPFXDKQgLqhFObJdInjMFX\n\tNV6tE1S4oBziWGQ75mjqjTlPIaw6y63nRAiHoKJmpi7gm5Oo110bpFVAdd5o1V8fkUX1\n\tcccxJv7MwNS7U9IdyO9QCUSDvPJ73p9cPoxew="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=yjxnPDpLCf2yCjcd0ZoCpKX4Y5FapV/v3zxDTSipIys=;\n\tb=ZbRcjM7/oRyKo62HSaKU0cRXadWJH7MJcl4DmNs6PlTCIvAUMjQyRuRLprF9wu6Sa+\n\thLiefHucmV2CXrhezv7HR2yPqGimnEClp6wcME3rN2G+F5KItF57JVTD/Xx+MRECiiNc\n\t9/WZXrI4gopXRgFhemj37SrOUir9EeIeC4jJGULwr6rDWERlbtI2TtaOunpidzTtAJxy\n\tWtqJh1kIqwhqaS3TJThSAZiMfK/BOu+A7JrgS8bZs57ZSt7DN3SEIDvK70wBKbj6rmxC\n\tD5o9A8DX+0GO1To4OW8CyRxNs857GkzAf0D+BJEPXYttf2GSBWwTIiHRFSwjWeF+Wk7X\n\tYxzg==","X-Gm-Message-State":"AHPjjUjt2/p/gBmUDB5MlqqXGnjjCXZ8R99vPJPN7wNP/Bp44tIvViSX\n\tsvqD+Y0rTd82ixfz1q+V2eyq1FA6a0tm","X-Google-Smtp-Source":"ADKCNb7RtD7/MHb0knWGMAgxtiVjBTXHV3QmKwMx1yyNIWuwN0xewI3MY9DcPtT9WPMWa/QXjvNQ9/gGxMsv4WAGUgU=","X-Received":"by 10.36.192.69 with SMTP id u66mr706090itf.25.1504529738713;\n\tMon, 04 Sep 2017 05:55:38 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<1668277.7DWLdgHGid@aspire.rjw.lan>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<3033151.kbPpEQGlRq@aspire.rjw.lan>\n\t<CAPDyKFqAqiDcdwEOwEu1m7icnP8MijYf4UNrMqN9YhNbug_upg@mail.gmail.com>\n\t<1668277.7DWLdgHGid@aspire.rjw.lan>","From":"Ulf Hansson <ulf.hansson@linaro.org>","Date":"Mon, 4 Sep 2017 14:55:37 +0200","Message-ID":"<CAPDyKFpX3Owk4H=0SqgfspXZd9TmdL_ANOZftXRq6HPjrT2ctQ@mail.gmail.com>","Subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","To":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170904_055600_621434_E2B1CBD3 ","X-CRM114-Status":"GOOD (  40.77  )","X-Spam-Score":"-2.7 (--)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-2.7 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/,\n\tlow\n\ttrust [2607:f8b0:4001:c0b:0:0:0:236 listed in] [list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature\n\t0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n\tnot necessarily valid\n\t-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n\tauthor's domain","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1762632,"web_url":"http://patchwork.ozlabs.org/comment/1762632/","msgid":"<CAPDyKFoTz3fFJwpJgmmwLfHQTzmWpyZL+NcVPY8D254nR2Mzag@mail.gmail.com>","list_archive_url":null,"date":"2017-09-04T13:21:15","subject":"Re: [PATCH v3 6/8] PM / ACPI: Enable the runtime PM centric approach\n\tfor system sleep","submitter":{"id":21036,"url":"http://patchwork.ozlabs.org/api/people/21036/","name":"Ulf Hansson","email":"ulf.hansson@linaro.org"},"content":"On 2 September 2017 at 17:38, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:\n> On Friday, September 1, 2017 10:27:05 AM CEST Ulf Hansson wrote:\n>> On 29 August 2017 at 17:27, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:\n>> > On Tuesday, August 29, 2017 4:56:48 PM CEST Ulf Hansson wrote:\n>> >> This change enables the ACPI PM domain to cope with drivers that deploys\n>> >> the runtime PM centric path for system sleep.\n>> >\n>> > [cut]\n>> >\n>> >> @@ -1052,11 +1066,20 @@ EXPORT_SYMBOL_GPL(acpi_subsys_complete);\n>> >>   * @dev: Device to handle.\n>> >>   *\n>> >>   * Follow PCI and resume devices suspended at run time before running their\n>> >> - * system suspend callbacks.\n>> >> + * system suspend callbacks. However, try to avoid it in case the runtime PM\n>> >> + * centric path is used for the device and then trust the driver to do the\n>> >> + * right thing.\n>> >>   */\n>> >>  int acpi_subsys_suspend(struct device *dev)\n>> >>  {\n>> >> -     pm_runtime_resume(dev);\n>> >> +     struct acpi_device *adev = ACPI_COMPANION(dev);\n>> >> +\n>> >> +     if (!adev)\n>> >> +             return 0;\n>> >> +\n>> >> +     if (!dev_pm_is_rpm_sleep(dev) || acpi_dev_needs_resume(dev, adev))\n>> >> +             pm_runtime_resume(dev);\n>> >> +\n>> >>       return pm_generic_suspend(dev);\n>> >>  }\n>> >>  EXPORT_SYMBOL_GPL(acpi_subsys_suspend);\n>> >\n>> > Well, I tried to avoid calling acpi_dev_needs_resume() for multiple times\n>> > and that's why I added the update_state thing.\n>> >\n>> > Moreover, the is_rpm_sleep flag here has to mean not only that\n>> > direct_complete should not be used with the device, but also that its driver\n>> > is fine with not resuming it.\n>>\n>> Let me try to explain this better. I realize the changelog is\n>> misleading around this particular section! Huh, apologize for that!\n>>\n>> First, patch1 makes the PM core treat the is_rpm_sleep flag as the\n>> direct_complete isn't allowed for the device.\n>>\n>> For that reason, when the is_rpm_sleep is set, there is no point\n>> calling acpi_dev_needs_resume() from acpi_subsys_prepare(), but\n>> instead that can be deferred to acpi_subsys_suspend() - because it\n>> doesn't matter if acpi_subsys_prepare() returns 0 or 1, in either case\n>> the acpi_subsys_suspend() will be called. That's really what goes on\n>> here.\n>>\n>> The end result is the same. If the acpi_dev_needs_resume() thinks that\n>> the device needs to be runtime resumed, pm_runtime_resume() is called\n>> for the device in acpi_subsys_suspend().\n>>\n>> So, this has nothing to do with whether the driver \"is fine with not\n>> resuming it\" thing.\n>\n> No, sorry.\n>\n> If is_rpm_sleep was not set, the ACPI PM domain would resume the device in\n> acpi_subsys_suspend() regardless of the acpi_dev_needs_resume() return value.\n\nYes, I believe I forgot about one scenario, when the direct_complete\npath has been abandoned by the PM core, because a child device was\nsuspend before and it couldn't run the direct_complete path for it?\n\nJust to be sure, that's the case you also had in mind?\n\n> That's what's there in the patch.  So clearly, setting is_rpm_sleep means\n> \"this device does not need to be resumed in acpi_subsys_suspend() unless\n> acpi_dev_needs_resume() returns true\".  Which clearly means that the driver\n> *is* fine with not resuming it, because if is_rpm_sleep is set, the device\n> in fact may not be resumed and then the driver will need to cope with that.\n\nYes, I understand your concern, because we may break the default\nbehavior of the ACPI PM domain.\n\nSo, *if* there will be a next version, I will make sure to be better\nsafe than sorry, and add one flag per use case.\n\n>\n> And note that this meaning of is_rpm_sleep is different from what it is\n> expected to mean to the core.\n>\n>> >\n>> > IMO it is not a good idea to use one flag for these two different things at the\n>> > same time at all.\n>>\n>> Yeah, I guess my upper comment addresses your immediate concern here?\n>\n> No, they don't.\n>\n>> However, there is one other thing the is_rpm_flag means. That is that\n>> the driver has informed the ACPI PM domain, to trust the driver to\n>> deal with system sleep, via re-using the runtime PM callbacks.\n>> So the flag does still have two meanings, but that we can change - of course.\n>\n> I guess that you are referring to the use of dev_pm_is_rpm_sleep() in\n> acpi_subsys_suspend_late()?  That's the third thing this flag means ...\n\nYes.\n\nKind regards\nUffe","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"Vii52szl\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"C9sX9awi\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xm9VJ1KJfz9sR9\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tMon,  4 Sep 2017 23:21:44 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dorJt-00060i-Fq; Mon, 04 Sep 2017 13:21:41 +0000","from mail-io0-x233.google.com ([2607:f8b0:4001:c06::233])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dorJp-0005oT-FE for linux-arm-kernel@lists.infradead.org;\n\tMon, 04 Sep 2017 13:21:39 +0000","by mail-io0-x233.google.com with SMTP id b2so1442623iof.1\n\tfor <linux-arm-kernel@lists.infradead.org>;\n\tMon, 04 Sep 2017 06:21:17 -0700 (PDT)","by 10.2.96.38 with HTTP; Mon, 4 Sep 2017 06:21:15 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:\n\tReferences:In-Reply-To:MIME-Version:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=lD6HV/762h9/387+UcnfQb9hDA27Y7sVZYfUTyfFVYc=;\n\tb=Vii52szlWl82oD\n\tCyuBesIM4BZGnVTC9rntaSjHS/XynsEgI2VPlglwOBYNVtYofWBEA2g/gExxnhPd4CXbKDRCmB7vD\n\tiV8s00zg9L2nHeyATp2rCybWZPnnkAsuBEVSixW5lcbQkt5Hk6ZAC3k+JDNULDbIhseQdvedrJYeQ\n\tavOQjl5rGwOdiky5ghz0/4rF4zulmjpVGUiFalH7NOjHDjwRRJluf6jIqLTPy0S/M7A+YoDwFuZtP\n\t4iWTS+rLxpiELH4/dlMGkpgL1lwoyX4fcF9QWZ4mtU3PC9TOaz8cqsjtX8jQQCDPN4TE7pb85ybSu\n\tpCFHZAWEiUMUOHP/azMA==;","v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=bzQvUPQY0HRl5qQZDEazRF6l6srRl4eS0XAryhYBKbc=;\n\tb=C9sX9awi72n8VJGnyIExPun7dBoq9LX9YqyQ8eWpRyE8w6WNLpFX2KEPS9vnjr/uhB\n\tQ7Og01RAxuiKjUXfS3WI2gggJaplaZFipMBD7oCrY+4KbTqIyo0RRgxiOiq1n9ghNSVa\n\tCNdrh0CQzh5+QV8fY2QaNHE0dttjxsStATeb0="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=bzQvUPQY0HRl5qQZDEazRF6l6srRl4eS0XAryhYBKbc=;\n\tb=OPiyC8Vwpi7Ryty93kbGOfHLRV9kSrj5yARRjorPCIuW4BDADPaWMZDEgsu54dQdIF\n\toP87JbuEYZiMmH1e3TLqvXR+LAbbDOaHv6DTi92kYTK2wod9ToOBKnpPdJiGD0fu3pOV\n\tJISVeN/8eEGX8Rt3cdkR5/F+1Bn7rrk37na5wbvHWMllIez/RN6AvrZ8jXR+kSPw+IQS\n\ttGxhDzeysGaPTc6MNdvAWryglxEKMIoaHxDkxifZgmnZKj8FlG4nofpa7E81BxnMfvS8\n\tr2ePn6s+BBb7NufvJ0a2t+/prDeU0+uOxCyWg3+scI+JPOC9Q669n49FZA4Ua8dsy+w6\n\tmslA==","X-Gm-Message-State":"AHPjjUiPqiZCoACkgcZKmhEsR+4VfnO+0uRVDoIbavFROFMdVyfFCRDp\n\tOSBljaMSrXpyzToNzMls79QzV+BwIVnp","X-Google-Smtp-Source":"ADKCNb6vf3eoJgYszW8/UUqkUXRFa5aZZNX023es8RmCUDRmiB9PzUOrw6oWkTGbJgx7JaeG90f/R1Ej8F9xKNHaOV8=","X-Received":"by 10.107.26.198 with SMTP id a189mr573809ioa.223.1504531276439; \n\tMon, 04 Sep 2017 06:21:16 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<2209426.5Z3u1iKN4i@aspire.rjw.lan>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<2855684.NY3Ly9PzrE@aspire.rjw.lan>\n\t<CAPDyKFq5ic+bAVRoEC58oSO-8VTGnfipJndLmR6YLXgEhZ+RWw@mail.gmail.com>\n\t<2209426.5Z3u1iKN4i@aspire.rjw.lan>","From":"Ulf Hansson <ulf.hansson@linaro.org>","Date":"Mon, 4 Sep 2017 15:21:15 +0200","Message-ID":"<CAPDyKFoTz3fFJwpJgmmwLfHQTzmWpyZL+NcVPY8D254nR2Mzag@mail.gmail.com>","Subject":"Re: [PATCH v3 6/8] PM / ACPI: Enable the runtime PM centric approach\n\tfor system sleep","To":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170904_062137_559232_3E8E5A46 ","X-CRM114-Status":"GOOD (  29.13  )","X-Spam-Score":"-2.7 (--)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-2.7 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/,\n\tlow\n\ttrust [2607:f8b0:4001:c06:0:0:0:233 listed in] [list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature\n\t0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n\tnot necessarily valid\n\t-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n\tauthor's domain","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1763734,"web_url":"http://patchwork.ozlabs.org/comment/1763734/","msgid":"<28965959.lSjY1gHxkl@aspire.rjw.lan>","list_archive_url":null,"date":"2017-09-06T00:02:41","subject":"Re: [PATCH v3 6/8] PM / ACPI: Enable the runtime PM centric approach\n\tfor system sleep","submitter":{"id":26536,"url":"http://patchwork.ozlabs.org/api/people/26536/","name":"Rafael J. Wysocki","email":"rjw@rjwysocki.net"},"content":"On Monday, September 4, 2017 3:21:15 PM CEST Ulf Hansson wrote:\n> On 2 September 2017 at 17:38, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:\n> > On Friday, September 1, 2017 10:27:05 AM CEST Ulf Hansson wrote:\n> >> On 29 August 2017 at 17:27, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:\n> >> > On Tuesday, August 29, 2017 4:56:48 PM CEST Ulf Hansson wrote:\n> >> >> This change enables the ACPI PM domain to cope with drivers that deploys\n> >> >> the runtime PM centric path for system sleep.\n> >> >\n> >> > [cut]\n> >> >\n> >> >> @@ -1052,11 +1066,20 @@ EXPORT_SYMBOL_GPL(acpi_subsys_complete);\n> >> >>   * @dev: Device to handle.\n> >> >>   *\n> >> >>   * Follow PCI and resume devices suspended at run time before running their\n> >> >> - * system suspend callbacks.\n> >> >> + * system suspend callbacks. However, try to avoid it in case the runtime PM\n> >> >> + * centric path is used for the device and then trust the driver to do the\n> >> >> + * right thing.\n> >> >>   */\n> >> >>  int acpi_subsys_suspend(struct device *dev)\n> >> >>  {\n> >> >> -     pm_runtime_resume(dev);\n> >> >> +     struct acpi_device *adev = ACPI_COMPANION(dev);\n> >> >> +\n> >> >> +     if (!adev)\n> >> >> +             return 0;\n> >> >> +\n> >> >> +     if (!dev_pm_is_rpm_sleep(dev) || acpi_dev_needs_resume(dev, adev))\n> >> >> +             pm_runtime_resume(dev);\n> >> >> +\n> >> >>       return pm_generic_suspend(dev);\n> >> >>  }\n> >> >>  EXPORT_SYMBOL_GPL(acpi_subsys_suspend);\n> >> >\n> >> > Well, I tried to avoid calling acpi_dev_needs_resume() for multiple times\n> >> > and that's why I added the update_state thing.\n> >> >\n> >> > Moreover, the is_rpm_sleep flag here has to mean not only that\n> >> > direct_complete should not be used with the device, but also that its driver\n> >> > is fine with not resuming it.\n> >>\n> >> Let me try to explain this better. I realize the changelog is\n> >> misleading around this particular section! Huh, apologize for that!\n> >>\n> >> First, patch1 makes the PM core treat the is_rpm_sleep flag as the\n> >> direct_complete isn't allowed for the device.\n> >>\n> >> For that reason, when the is_rpm_sleep is set, there is no point\n> >> calling acpi_dev_needs_resume() from acpi_subsys_prepare(), but\n> >> instead that can be deferred to acpi_subsys_suspend() - because it\n> >> doesn't matter if acpi_subsys_prepare() returns 0 or 1, in either case\n> >> the acpi_subsys_suspend() will be called. That's really what goes on\n> >> here.\n> >>\n> >> The end result is the same. If the acpi_dev_needs_resume() thinks that\n> >> the device needs to be runtime resumed, pm_runtime_resume() is called\n> >> for the device in acpi_subsys_suspend().\n> >>\n> >> So, this has nothing to do with whether the driver \"is fine with not\n> >> resuming it\" thing.\n> >\n> > No, sorry.\n> >\n> > If is_rpm_sleep was not set, the ACPI PM domain would resume the device in\n> > acpi_subsys_suspend() regardless of the acpi_dev_needs_resume() return value.\n> \n> Yes, I believe I forgot about one scenario, when the direct_complete\n> path has been abandoned by the PM core, because a child device was\n> suspend before and it couldn't run the direct_complete path for it?\n> \n> Just to be sure, that's the case you also had in mind?\n\nYes.\n\nThanks,\nRafael","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"JEc47Al7\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xn3tL457gz9sNr\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tWed,  6 Sep 2017 10:12:10 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dpNwt-0004jJ-5X; Wed, 06 Sep 2017 00:12:07 +0000","from cloudserver094114.home.net.pl ([79.96.170.134])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dpNwp-0004cR-FT for linux-arm-kernel@lists.infradead.org;\n\tWed, 06 Sep 2017 00:12:05 +0000","from 79.184.253.199.ipv4.supernova.orange.pl (79.184.253.199) (HELO\n\taspire.rjw.lan)\n\tby serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer\n\t0.82) id 8c472b82d51be5ca; Wed, 6 Sep 2017 02:11:29 +0200"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=7fyHicZtPBkfv3Ig0r/7Ac5FbqAz71QCWJ/lvRoVO64=;\n\tb=JEc47Al7B+sJkq\n\tv53E/WO8I79uVFTNPnt1eU0NqNmQ3NoJSHm1SFYjsjlUpB2cQo8daZszFvwUc6hqnh8fa473rfv5V\n\tr2XushqTMqJhbCBP/OTuUjb27m3qxLIOx5G+7X2Idqb/HWYXNS3z/ndStRx4z/uG4Yy00CWluzF+7\n\t8FzU6xFvScFyQfuy/aOpo4ExBOnHEBe8AuAMMUTfbqQtl4zFL/TNP7lecHcnYlqLVSdkFBsU3BY1r\n\tRAq6O859+J+JDeP5BFyaQ7ev167bQ/tR2gjEzT0G5xommPn7SYlNYS6dzd/ulBugY9TjCsOsej8Py\n\txZRZIco5ZP2z+4gnpUMA==;","From":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","To":"Ulf Hansson <ulf.hansson@linaro.org>","Subject":"Re: [PATCH v3 6/8] PM / ACPI: Enable the runtime PM centric approach\n\tfor system sleep","Date":"Wed, 06 Sep 2017 02:02:41 +0200","Message-ID":"<28965959.lSjY1gHxkl@aspire.rjw.lan>","In-Reply-To":"<CAPDyKFoTz3fFJwpJgmmwLfHQTzmWpyZL+NcVPY8D254nR2Mzag@mail.gmail.com>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<2209426.5Z3u1iKN4i@aspire.rjw.lan>\n\t<CAPDyKFoTz3fFJwpJgmmwLfHQTzmWpyZL+NcVPY8D254nR2Mzag@mail.gmail.com>","MIME-Version":"1.0","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170905_171203_710852_37488E03 ","X-CRM114-Status":"GOOD (  24.80  )","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1763756,"web_url":"http://patchwork.ozlabs.org/comment/1763756/","msgid":"<1883292.VFru06qUYG@aspire.rjw.lan>","list_archive_url":null,"date":"2017-09-06T00:52:59","subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","submitter":{"id":26536,"url":"http://patchwork.ozlabs.org/api/people/26536/","name":"Rafael J. Wysocki","email":"rjw@rjwysocki.net"},"content":"On Monday, September 4, 2017 2:55:37 PM CEST Ulf Hansson wrote:\n> [...]\n> \n> >> > So can you please remind me why the _force_ wrappers are needed?\n> >>\n> >> See below.\n> >>\n> >> >\n> >> > In particular, why can't drivers arrange their callbacks the way I did that\n> >> > in https://patchwork.kernel.org/patch/9928583/ ?\n> >>\n> >> I was preparing a reply to that patch, but let me summarize that here instead.\n> >>\n> >> Let me be clear, the patch is an improvement of the behavior of the\n> >> driver and it addresses the issues you point out in the change log.\n> >> Re-using the runtime PM callbacks for system sleep, is nice as it\n> >> avoids open coding, which is of curse also one of the reason of using\n> >> pm_runtime_force_suspend|resume().\n> >>\n> >> Still there are a couple of things I am worried about in this patch.\n> >> *)\n> >> To be able to re-use the same callbacks for system sleep and runtime\n> >> PM, some boilerplate code is added to the driver, as to cope with the\n> >> different conditions inside the callbacks. That pattern would become\n> >> repeated to many drivers dealing with similar issues.\n> >\n> > I'm not worried about that as long as there are good examples and\n> > documented best practices.\n> >\n> > There aren't any right now, which is a problem, but that certainly is\n> > fixable.\n> >\n> >> **)\n> >> The ->resume_early() callback powers on the device, in case it was\n> >> runtime resumed when the ->suspend_late() callback was invoked. That\n> >> is in many cases completely unnecessary, causing us to waste power and\n> >> increase system resume time, for absolutely no reason. However, I\n> >> understand the patch didn't try to address this, but to really fix\n> >> this, there has to be an even closer collaboration between runtime PM\n> >> and the system sleep callbacks.\n> >\n> > I don't quite agree and here's why.\n> >\n> > If a device was not runtime-suspended right before system suspend, then quite\n> > likely it was in use then.  Therefore it is quite likely to be resumed\n> > immediately after system resume anyway.\n> \n> Unfortunate, to always make that assumption, leads to a non-optimized\n> behavior of system sleep. I think we can do better than that!\n> \n> Let me give you a concrete example, where the above assumption would\n> lead to an non-optimized behavior.\n> \n> To put an MMC card into low power state during system suspend\n> (covering eMMC, SD, SDIO) the mmc core needs to send a couple of\n> commands over the MMC interface to the card, as to conform with the\n> (e)MMC/SD/SDIO spec. To do this, the mmc driver for the mmc controller\n> must runtime resume its device, as to be able to send the commands\n> over the interface.\n> \n> Now, when the system resumes, there is absolutely no reason to runtime\n> resume the device for the MMC controller, just because it was runtime\n> resumed during system suspend. Instead that is better to be postponed\n> to when the MMC card is really needed and thus via runtime PM instead.\n\nYes, in this particular case it makes more sense to defer the resume of\nthe device, but there also are cases in which doing that leads to\nsuboptimal behavior.\n\n> This scenario shouldn't be specific to only MMC controllers/cards, but\n> should apply to any external devices/controllers that needs some\n> special treatment to be put into low power state during system\n> suspend. Particularly also when those external devices may be left in\n> that low power state until those are really needed. A couple of cases\n> I know of pops up in my head, WiFi chips, persistent storage devices,\n> etc. There should be plenty.\n> \n> Another common case, is when a subsystem core layer flushes a request\n> queue during system suspend, which may cause a controller device to be\n> runtime resumed. Making the assumption that, because flushing the\n> queue was done during system suspend, we must also power up the\n> controller during system resume, again would lead to a non-optimized\n> behavior.\n\nI understand that.\n\nHowever, from a driver perspective, the most straightforward thing to do\nis to restore the previous state of the device during system resume,\nbecause that guarantees correctness.  Anything else is tricky and need to\nbe done with extra care.  Drivers *must* know what they are doing when\nthey are doing such things.\n\n> >\n> > Now, if that's just one device, it probably doesn't matter, but if there are\n> > more devices like that, they will be resumed after system suspend when they\n> > are accessed and quite likely they will be accessed one-by-one rather than in\n> > parallel with each other, so the latencies related to that will add up.  In\n> > that case it is better to resume them upfront during system resume as they will\n> > be resumed in parallel with each other then.  And that also is *way* simpler.\n> >\n> > This means that the benefit from avoiding to resume devices during system\n> > resume is not quite so obvious and the whole point above is highly\n> > questionable.\n> \n> I hope my reasoning above explains why I think it shouldn't be\n> considered as questionable.\n> \n> If you like, I can also provide some real data/logs - showing you\n> what's happening.\n> \n\nThat's not necessary, this behavior can be useful and there are arguments for\ndoing it in *some* cases, but all of this argumentation applies to devices\nthat aren't going to be used right after system resume.  If they *are* going\nto be used then, it very well may be better to resume them as part of\nsystem resume instead of deferring that.\n\nThe tricky part is that at the point the resume callbacks run it is not known\nwhether or not the device is going to be accessed shortly and the decision made\neither way may be suboptimal.\n\n[Note: I know that people mostly care about seeing the screen on, but in fact\nthey should *also* care about the touch panel being ready to respond to\ntouches, for example.  If it isn't ready and the system suspends again\nafter a while because of that, the experience is somehwat less than fantastic.]\n\n> >>\n> >> So, to remind you why the pm_runtime_force_suspend|resume() helpers is\n> >> preferred, that's because both of the above two things becomes taken\n> >> care of.\n> >\n> > And that is why there is this stuff about parents and usage counters, right?\n> \n> Correct. Perhaps this commit tells you a little more.\n> \n> commit 1d9174fbc55ec99ccbfcafa3de2528ef78a849aa\n> Author: Ulf Hansson <ulf.hansson@linaro.org>\n> Date:   Thu Oct 13 16:58:54 2016 +0200\n> \n>     PM / Runtime: Defer resuming of the device in pm_runtime_force_resume()\n> \n> [...]\n> \n> >> >\n> >> > PM core => bus type / PM domain ->suspend_late => driver ->suspend_late\n> >> >\n> >> > is far more straightforward than\n> >> >\n> >> > PM core => bus type / PM domain ->suspend_late => driver ->suspend_late =>\n> >> >         bus type / PM domain ->runtime_suspend => driver ->runtime_suspend\n> >> >\n> >> > with the bus type / PM domain having to figure out somehow at the\n> >> > ->suspend_late time whether or not its ->runtume_suspend is going to be invoked\n> >> > in the middle of it.\n> >> >\n> >> > Apart from this just being aesthetically disgusting to me, which admittedly is\n> >> > a matter of personal opinion, it makes debugging new driver code harder (if it\n> >> > happens to not work) and reviewing it almost impossible, because now you need\n> >> > to take all of the tangling between callbacks into accont and sometimes not\n> >> > just for one bus type / PM domain.\n> >>\n> >> I am wondering that perhaps you may be overlooking some of the\n> >> internals of runtime PM. Or maybe not? :-)\n> >>\n> >> I mean, the hole thing is build upon that anyone can call runtime PM\n> >> functions to runtime resume/suspend a device.\n> >\n> > Well, right in general, except that _force_suspend/resume() invoke\n> > *callbacks* and *not* runtime PM functions.\n> \n> I am considering pm_runtime_force_suspend|resume() being a part of the\n> runtime PM API, except that those may be called only during system\n> sleep.\n> \n> Comparing a call to pm_runtime_resume(); this may trigger rpm_resume()\n> to invoke the callbacks. To me, the difference is that the conditions\n> looked at in rpm_resume(), when runtime PM is enabled, becomes\n> different for system sleep when runtime PM is disabled - and that is\n> taken care of in pm_runtime_force_suspend|resume().\n\nSo actually invoking runtime PM from a *driver* ->suspend callback for the\nsame device it was called for is fishy at best and may be a bug.  I'm not\nsure why I had been thinking that it might have been fine at all.  It isn't.\n\nThe reason why is because runtime PM *potentially* involves invoking middle\nlayer callbacks an they generally may look like\n\n->runtime_resume:\n\t(1) do A\n\t(2) call driver ->runtime_resume\n\t(3) do B\n\nNow, a middle layer ->suspend callback generally may look like this:\n\n->suspend:\n\t(1) do C\n\t(2) call driver ->suspend\n\t(3) do D\n\nand if you stick the middle layer ->runtime_suspend invocation into the\ndriver ->suspend (which effectively is what running runtime PM in there means),\nyou get something like\n\ndo C\n...\ndo A\ncall driver ->runtime_resume\ndo B\n...\ndo D\n\nand there's no guarantee whatever that \"do C\" can go before \"do A\" and\n\"do B\" can go before \"do D\".  That depends on how the middle layer is designed\nand there may be good reasons for how it works.\n\n> >\n> >> Doing that, makes the\n> >> hierarchy of the runtime PM callbacks being walked and invoked, of\n> >> course properly managed by the runtime PM core.\n> >>\n> >> My point is that, the runtime PM core still controls this behavior,\n> >> even when the pm_runtime_force_suspend|resume() helpers are being\n> >> invoked. The only difference is that it allows runtime PM for the\n> >> device to be disabled, and still correctly invoked the callbacks. That\n> >> is what it is all about.\n> >\n> > So why is it even useful to call ->runtime_suspend from a middle layer\n> > in pm_runtime_force_suspend(), for example?\n> \n> Perhaps I don't understand the question correctly.\n> \n> Anyway, the answer I think of, is probably because of the same reason\n> to why the runtime PM core invokes it, when it runs rpm_suspend() for\n> a device. My point is, we want the similar behavior.\n\nNot really.  The context is different, so why to expect the behavior to be\nthe same?\n\n> [...]\n> \n> >> >\n> >> > Also, when I looked at _force_suspend/resume() again, I got concerned.\n> >> > There is stuff in there that shouldn't be necessary in a driver's\n> >> > ->late_suspend/->early_resume and some things in there just made me\n> >> > scratch my head.\n> >>\n> >> Yes, there are some complexity in there, I will be happy to answer any\n> >> specific question about it.\n> >\n> > OK\n> >\n> > Of course they require runtime PM to be enabled by drivers using them as\n> > their callbacks, but I suppose that you realize that.\n> >\n> > Why to disabe/renable runtime PM in there in the first place?  That should\n> > have been done by the core when these functions are intended to be called.\n> \n> The reason is because we didn't want to re-strict them to be used only\n> in ->suspend_late() and ->resume_early(), but also for ->suspend() and\n> ->resume(), which is when runtime PM still is enabled.\n\nWell, that means disabling runtime PM for some devices earlier which isn't\nparticularly consistent overall.\n\n> >\n> > Second, why to use RPM_GET_CALLBACK in there?\n> \n> To follow the same rules/hierarchy, as being done in rpm_suspend|resume().\n\nNo, you don't use the same hierarchy, which is the key point of my objection.\n\nYou run *already* in the context of a middle layer PM callback, so by very\ndefinition it is *not* the same situation as running runtime PM elsewhere.\n\nThis is the second or maybe even the third time I have repeated this point\nand I'm not going to do so again.\n\n> >\n> > Next, how is the parent actually runtime-resumed by pm_runtime_force_resume()\n> > which the comment in pm_runtime_force_suspend() talks about?\n> \n> I think the relevant use case here is when a parent and a child, both\n> have subsystems/drivers using pm_runtime_force_suspend|resume(). If\n> that isn't the case, we expect that the parent is always resumed\n> during system resume.\n\nWhy?\n\n> It's a bit fragile approach, so we perhaps we\n> should deal with it, even if the hole thing is used as opt-in.\n> \n> Anyway, let's focus on the case which I think is most relevant to your question:\n> \n> A couple of conditions to start with.\n> *) The PM core system suspends a child prior a parent, which leads to\n> pm_runtime_force_suspend() being called for the child first.\n> **) The PM core system resumes a parents before a child, thus\n> pm_runtime_force_resume() is called for the parent first.\n> \n> In case a child don't need to be resumed when\n> pm_runtime_force_resume() is called for it, likely doesn't its parent.\n> However, to control that, in system suspend the\n> pm_runtime_force_suspend() increases the usage counter for the parent,\n> as to indicate if it needs to be resumed when\n> pm_runtime_force_resume() is called for it.\n\nOK, I see.\n\nWhy is usage_count > 1 used as the condition to trigger this behavior?\n\nThanks,\nRafael","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"nZFD8YUg\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xn50C0VHhz9sP3\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tWed,  6 Sep 2017 11:02:19 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dpOjP-0002gf-Vv; Wed, 06 Sep 2017 01:02:15 +0000","from cloudserver094114.home.net.pl ([79.96.170.134])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dpOjK-0002QU-Cw for linux-arm-kernel@lists.infradead.org;\n\tWed, 06 Sep 2017 01:02:13 +0000","from 79.184.253.199.ipv4.supernova.orange.pl (79.184.253.199) (HELO\n\taspire.rjw.lan)\n\tby serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer\n\t0.82) id 504d7c0833a68916; Wed, 6 Sep 2017 03:01:48 +0200"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=tfgqErchdvWBokzAY3AX5FuZ5hQo2rR2s+mFZIA4ww0=;\n\tb=nZFD8YUgPbZSjw\n\twIRNIf0OniWXr4roXXV1xPvAL6zHymObQRwOt6caOGC6HrXoqLVJRLkwT+xYTcvQvQ5a0w9caY/4A\n\t6DoS7Z8RxV/DpBMSbwA6tTXNwC9jDeFrYp2Y9ExfLy3GHWOQeRpL52LHUDVOnOviliXK23pHU7PYV\n\tNGJahMo3+qGKcAfGT2boI0thZgjtJcm3243fRhYzQV5rAgtawYrKA4GHf5m+1uZhwj82EJwttailA\n\tPYUsIUrtSYRmU/p/8U31QYLdmeT2nF3E9JhLaayLMKbr3l+JqeLEYOcsKB3FMcTMq3iiovDeU4GUn\n\tHGdHCsap8nwyHTUyMHqA==;","From":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","To":"Ulf Hansson <ulf.hansson@linaro.org>","Subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","Date":"Wed, 06 Sep 2017 02:52:59 +0200","Message-ID":"<1883292.VFru06qUYG@aspire.rjw.lan>","In-Reply-To":"<CAPDyKFpX3Owk4H=0SqgfspXZd9TmdL_ANOZftXRq6HPjrT2ctQ@mail.gmail.com>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<1668277.7DWLdgHGid@aspire.rjw.lan>\n\t<CAPDyKFpX3Owk4H=0SqgfspXZd9TmdL_ANOZftXRq6HPjrT2ctQ@mail.gmail.com>","MIME-Version":"1.0","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170905_180210_822694_1703753D ","X-CRM114-Status":"GOOD (  55.04  )","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1764001,"web_url":"http://patchwork.ozlabs.org/comment/1764001/","msgid":"<8456507.jc97SKmauk@aspire.rjw.lan>","list_archive_url":null,"date":"2017-09-06T10:46:34","subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","submitter":{"id":26536,"url":"http://patchwork.ozlabs.org/api/people/26536/","name":"Rafael J. Wysocki","email":"rjw@rjwysocki.net"},"content":"On Wednesday, September 6, 2017 2:52:59 AM CEST Rafael J. Wysocki wrote:\n> On Monday, September 4, 2017 2:55:37 PM CEST Ulf Hansson wrote:\n> > [...]\n\nI guess I can wrap it up, because all of the points seem to have been stated\nand repeating them would not be useful.\n\nMy summary of the discussion is as follows.\n\nIt only is valid to use pm_runtime_force_suspend/resume() as *driver*\ncallbacks for system suspend/resume if both the driver itself and all of\nthe middle layers it has to work with carry out the same sequence of\noperations in order to suspend the device both in runtime PM and for\nsystem sleep (and analogously for resuming).  [The middle layers need\nto meet additional conditions, but that's less relevant.]\n\nUnfortunately, for the ACPI PM domain and the PCI bus type the situation is\ndifferent, because they generally need to do different things to suspend\ndevices for system sleep than they do for runtime PM (which mostly is\nrelated to the handling of ACPI-defined sleep states and device/system\nwakeup, but not limited to that).  This clearly means that drivers needing\nto work with the ACPI PM domain and PCI drivers cannot use\npm_runtime_force_suspend/resume() as their PM callbacks for system\nsuspend/resume (quite fundamentally).\n\n[Note that for i2c-designware-platdrv the situation is even more complicated,\nbecause on some platforms it has to work with the ACPI PM domain (or the\nACPI LPSS driver), on some platforms its parent is a PCI device and on\nsome other platforms there's none of them.]\n\nHowever, for drivers that need to work with the ACPI PM domain and\nPCI drivers the differences in the device handling between runtime PM and\nsystem suspend/resume are *very* often (even though not always) covered\nentirely by the middle layer code.  Then, the driver itself actually\nalways carries out the same sequence of operations in order to suspend\nthe device (or to resume it, analogously).  The driver then can re-use\nits runtime PM callbacks for system suspend/resume (but at the driver\nlevel only) and it would be good to make that easy (or easier) for these\ndrivers somehow.\n\nThanks,\nRafael","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"lSo0qv21\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xnL9838yzz9s0g\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tWed,  6 Sep 2017 20:55:56 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dpXzs-0001Zp-Iv; Wed, 06 Sep 2017 10:55:52 +0000","from cloudserver094114.home.net.pl ([79.96.170.134])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dpXzo-0001WC-LE for linux-arm-kernel@lists.infradead.org;\n\tWed, 06 Sep 2017 10:55:50 +0000","from 79.184.253.199.ipv4.supernova.orange.pl (79.184.253.199) (HELO\n\taspire.rjw.lan)\n\tby serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer\n\t0.82) id cf015b5817f578cb; Wed, 6 Sep 2017 12:55:22 +0200"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=z5PD26dzWQOFzby6Nc2IMUUEx4dpw88Zt2258iXxu1o=;\n\tb=lSo0qv21PZn5gC\n\tARH86xJMs+cY1xLJhxthJpqg5wxrxDiRFuXe4hk+XAIkIh0SZw951dm7jIID9A9ZwpolSRjOADJqh\n\tGIkd2Ws1fs7OWDvaEKP0Flqcc7CSywB1bJmyUMu7QmsB2jnml6mfGZ860sOUxPxYWhUU23IFmVSXD\n\tnQKbcHNpd//Qs/wCkpKRuwb8R6Z1gqmvJCu1hrqxo9EPRNGScthaYVmyy2hcPLojn5kqGcYznElmc\n\twDToB6j0iiRONNjEeMzr0ktOMrJ491exLfpDA4WbpKgMxhCmGzvmkzyPl8quZ4qQltFiq7tsEfo1F\n\tc5ZoABXvtOtuqBjK20EA==;","From":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","To":"Ulf Hansson <ulf.hansson@linaro.org>","Subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","Date":"Wed, 06 Sep 2017 12:46:34 +0200","Message-ID":"<8456507.jc97SKmauk@aspire.rjw.lan>","In-Reply-To":"<1883292.VFru06qUYG@aspire.rjw.lan>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<CAPDyKFpX3Owk4H=0SqgfspXZd9TmdL_ANOZftXRq6HPjrT2ctQ@mail.gmail.com>\n\t<1883292.VFru06qUYG@aspire.rjw.lan>","MIME-Version":"1.0","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170906_035548_888991_B70050C0 ","X-CRM114-Status":"UNSURE (   9.30  )","X-CRM114-Notice":"Please train this message.","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1764118,"web_url":"http://patchwork.ozlabs.org/comment/1764118/","msgid":"<CAPDyKFr8jEBf9YRUQGOwFi0q7V70f-fTGbOW6q2L1yB85JQn1w@mail.gmail.com>","list_archive_url":null,"date":"2017-09-06T13:54:06","subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","submitter":{"id":21036,"url":"http://patchwork.ozlabs.org/api/people/21036/","name":"Ulf Hansson","email":"ulf.hansson@linaro.org"},"content":"[...]\n\n>\n>> >\n>> > Now, if that's just one device, it probably doesn't matter, but if there are\n>> > more devices like that, they will be resumed after system suspend when they\n>> > are accessed and quite likely they will be accessed one-by-one rather than in\n>> > parallel with each other, so the latencies related to that will add up.  In\n>> > that case it is better to resume them upfront during system resume as they will\n>> > be resumed in parallel with each other then.  And that also is *way* simpler.\n>> >\n>> > This means that the benefit from avoiding to resume devices during system\n>> > resume is not quite so obvious and the whole point above is highly\n>> > questionable.\n>>\n>> I hope my reasoning above explains why I think it shouldn't be\n>> considered as questionable.\n>>\n>> If you like, I can also provide some real data/logs - showing you\n>> what's happening.\n>>\n>\n> That's not necessary, this behavior can be useful and there are arguments for\n> doing it in *some* cases, but all of this argumentation applies to devices\n> that aren't going to be used right after system resume.  If they *are* going\n> to be used then, it very well may be better to resume them as part of\n> system resume instead of deferring that.\n>\n> The tricky part is that at the point the resume callbacks run it is not known\n> whether or not the device is going to be accessed shortly and the decision made\n> either way may be suboptimal.\n\nYou have a point and it seems like this is what everything boils done\nto, except for the reasons about that you dislike how\npm_runtime_force_suspend|resume() is being used by drivers.\n\nTo clarify, let me bring up yet another typical scenario, observed\noften in cases when pm_runtime_force_suspend|resume is not used.\n\nDuring system resume the device gets resumed, then shortly after the\nsystem resume sequence has completed, it become runtime suspened,\nbecause pm_runtime_put() is called in device_complete(). Then, soon\nafter the system has resumed, the device becomes runtime resumed\nagain, which is because there is a request for it to really be used.\n\nThis means we end up resuming the device, suspending it then and\nresuming it again, all within a very short time frame. I guess this is\nalso one of those tricky cases you refer to above, because one just\ncan know how long after the system has resumed it takes for the device\nto be requested to be used again, thus we end up runtime suspending\nthe device in-between.\n\nTo me, spending lot of time in the world of embedded battery driven\ndevices, this behavior isn't good enough, because it increases system\nresume time and may waste some power. Apologize if you find me\nrepeating myself.\n\nAnyway, this leads to my final question, do you want this behavior to\nbe better addressed by the ACPI PM domain, if it can be solved nicely,\nor are you fine with how works today?\n\n>\n> [Note: I know that people mostly care about seeing the screen on, but in fact\n> they should *also* care about the touch panel being ready to respond to\n> touches, for example.  If it isn't ready and the system suspends again\n> after a while because of that, the experience is somehwat less than fantastic.]\n>\n\nYep!\n\n[...]\n\n>> Comparing a call to pm_runtime_resume(); this may trigger rpm_resume()\n>> to invoke the callbacks. To me, the difference is that the conditions\n>> looked at in rpm_resume(), when runtime PM is enabled, becomes\n>> different for system sleep when runtime PM is disabled - and that is\n>> taken care of in pm_runtime_force_suspend|resume().\n>\n> So actually invoking runtime PM from a *driver* ->suspend callback for the\n> same device it was called for is fishy at best and may be a bug.  I'm not\n> sure why I had been thinking that it might have been fine at all.  It isn't.\n\nHuh, now you lost me. :-)\n\n>\n> The reason why is because runtime PM *potentially* involves invoking middle\n> layer callbacks an they generally may look like\n>\n> ->runtime_resume:\n>         (1) do A\n>         (2) call driver ->runtime_resume\n>         (3) do B\n>\n> Now, a middle layer ->suspend callback generally may look like this:\n>\n> ->suspend:\n>         (1) do C\n>         (2) call driver ->suspend\n>         (3) do D\n>\n> and if you stick the middle layer ->runtime_suspend invocation into the\n> driver ->suspend (which effectively is what running runtime PM in there means),\n> you get something like\n>\n> do C\n> ...\n> do A\n> call driver ->runtime_resume\n> do B\n> ...\n> do D\n>\n> and there's no guarantee whatever that \"do C\" can go before \"do A\" and\n> \"do B\" can go before \"do D\".  That depends on how the middle layer is designed\n> and there may be good reasons for how it works.\n\nFor ARM SoCs, not using the ACPI PM domain, many drivers needs to be\nable to use runtime PM during system suspend, simply because the PM\ndomain/middle layer, has no knowledge of what the driver needs to put\nits device into low power state during system suspend.\n\nFor many of the simple cases, the PM domain/middle layer act\ntransparent to this, which means leaving what needs to be done to the\ndriver (platform, spi, i2c, amba, genpd etc).\n\nI understand there may be some cases where the situation becomes more\ncomplex and interaction between the driver and the PM domain/middle\nlayer is required, like what it seems for in ACPI PM domain and PCI,\nbut is that a reason turn the world upside down for everybody else?\n\nOr perhaps I don't understand what your are suggesting here.\n\n[...]\n\n>\n>> I think the relevant use case here is when a parent and a child, both\n>> have subsystems/drivers using pm_runtime_force_suspend|resume(). If\n>> that isn't the case, we expect that the parent is always resumed\n>> during system resume.\n>\n> Why?\n\nBecause the child may rely on that for it to be resumed.\n\nMoreover, the expectation is that the parent likely doesn't support\nruntime PM, or that it not yet supports the optimized method of using\npm_runtime_force_suspend|resume() during system sleep, and will thus\nresume its device always during system resume.\n\n>\n>> It's a bit fragile approach, so we perhaps we\n>> should deal with it, even if the hole thing is used as opt-in.\n>>\n>> Anyway, let's focus on the case which I think is most relevant to your question:\n>>\n>> A couple of conditions to start with.\n>> *) The PM core system suspends a child prior a parent, which leads to\n>> pm_runtime_force_suspend() being called for the child first.\n>> **) The PM core system resumes a parents before a child, thus\n>> pm_runtime_force_resume() is called for the parent first.\n>>\n>> In case a child don't need to be resumed when\n>> pm_runtime_force_resume() is called for it, likely doesn't its parent.\n>> However, to control that, in system suspend the\n>> pm_runtime_force_suspend() increases the usage counter for the parent,\n>> as to indicate if it needs to be resumed when\n>> pm_runtime_force_resume() is called for it.\n>\n> OK, I see.\n>\n> Why is usage_count > 1 used as the condition to trigger this behavior?\n\nIt takes into account that the PM core increases the usage count in\ndevice_prepare(), but which isn't because it needs the device to be\noperational.\n\nKind regards\nUffe","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"uvud8Zxt\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"Rc1/y6Ga\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xnQ7M3Nhtz9s9Y\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tWed,  6 Sep 2017 23:54:39 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dpamp-000625-T1; Wed, 06 Sep 2017 13:54:35 +0000","from mail-it0-x229.google.com ([2607:f8b0:4001:c0b::229])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dpami-0005wG-Uk for linux-arm-kernel@lists.infradead.org;\n\tWed, 06 Sep 2017 13:54:33 +0000","by mail-it0-x229.google.com with SMTP id p6so10358003itb.1\n\tfor <linux-arm-kernel@lists.infradead.org>;\n\tWed, 06 Sep 2017 06:54:08 -0700 (PDT)","by 10.2.96.38 with HTTP; Wed, 6 Sep 2017 06:54:06 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:\n\tReferences:In-Reply-To:MIME-Version:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=XDOavbLPXLXbV+f3/Oi8iihLUYdE1xwf1iPzB2bG0L8=;\n\tb=uvud8ZxthUZKM8\n\tnbMT9PSM2S0vSQj1djBJIAaqK8zOA1XXb30nD457P7BuJtkbsRlqMtKqfrObWDax1zcUZevnnD/uB\n\tWurtRZyRr4VoF1/ZNS+rOpqNc+AC9qkgVeK64jBzRufPl7FCuR9oOfvrvaSH57WGWz119+DcWNDbk\n\trZphhr2nZ5F2YRjDSzCQCM1IDGANSgpcWWryc6TB8z7Xfl74eyRu690S6boHi9RLP2O1no3UxOp6K\n\tSm0HM2IM/IHSq3YHCnMfbVfao+C+MS9Hi3rat5QByIiX6T3P9YtRxWhRVGHVUwMhJkRarWJ1rFZNw\n\tRAWZsVjlWp1ZvPcDrl/g==;","v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=M+SkkJacXOxWso9B22opU1xKDGhm37Lfl1WsIk4eGr4=;\n\tb=Rc1/y6Gag2Czdd2UDNm2hJjjcu2EP4myIL/gY7yKMQcjOofYHAIcfxN8huLftEMeJj\n\tyWhGui9IgUIQo3FkDEdnlTmtiEbcG8iyuTJ/5HqIQ8v19wcPmZu5mj5PB1Zwcqn9Xn3S\n\t7q3ScKSPH2Z8OIw2zYFN3+Xde4LJ2bzQE9w1A="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=M+SkkJacXOxWso9B22opU1xKDGhm37Lfl1WsIk4eGr4=;\n\tb=Bvx0v5dn3Sp9KPHdx1EP0aYLaHsedn9QInL8r+sH/l5FmotlPGhsI1lmaTw5dqkEbq\n\t9aAxDJ7iqpp2dsvmoeOKQ54JqeBrXmT2D/II2zCaqWv+RQf7J6D/HNi9omQO1stzbaJX\n\tSpRhg5vbT6yXrTCUVXIke3rooHSuC2I5gnPvZL6krTgGsTdgsqzZbxdLfJR9mU1gvTps\n\tMaKlymaL5KtS1ELWKFY9/7da0YvRXtTumBwXC9mZmgm5rYQ7cEmte6Icy9VkabhextOn\n\tJ4pjpVPrNExigvrTFJbH2NhH2UtbcGfNKEacaXQNbPNZzshsBEMSwTN0EW9wVNX/B0ZJ\n\td1zg==","X-Gm-Message-State":"AHPjjUi9yLG7iCOMav6dvM1g2zk6cuBPgxZTymEMmKAf9SUKopVcpE2o\n\tVs6HeafPQ8PSqE2OHWnR6gkR1V3HEfuw","X-Google-Smtp-Source":"ADKCNb4pxQEDvXr5g2ftNGDRAKUexXJ1jxMdUz03haf/o7uGHzI6255sAOxolbG2lkUknEo3kjn+JS9jZOX93mN6oHU=","X-Received":"by 10.36.44.200 with SMTP id i191mr3067457iti.136.1504706047319; \n\tWed, 06 Sep 2017 06:54:07 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<1883292.VFru06qUYG@aspire.rjw.lan>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<1668277.7DWLdgHGid@aspire.rjw.lan>\n\t<CAPDyKFpX3Owk4H=0SqgfspXZd9TmdL_ANOZftXRq6HPjrT2ctQ@mail.gmail.com>\n\t<1883292.VFru06qUYG@aspire.rjw.lan>","From":"Ulf Hansson <ulf.hansson@linaro.org>","Date":"Wed, 6 Sep 2017 15:54:06 +0200","Message-ID":"<CAPDyKFr8jEBf9YRUQGOwFi0q7V70f-fTGbOW6q2L1yB85JQn1w@mail.gmail.com>","Subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","To":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170906_065429_214392_7473760C ","X-CRM114-Status":"GOOD (  35.35  )","X-Spam-Score":"-2.0 (--)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-2.0 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature\n\t0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n\tnot necessarily valid\n\t-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n\tauthor's domain","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1764126,"web_url":"http://patchwork.ozlabs.org/comment/1764126/","msgid":"<CAPDyKFr0hV=m=TumYKLoYC57mTht9_185vR5ynP_3oi7rauRbg@mail.gmail.com>","list_archive_url":null,"date":"2017-09-06T13:59:16","subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","submitter":{"id":21036,"url":"http://patchwork.ozlabs.org/api/people/21036/","name":"Ulf Hansson","email":"ulf.hansson@linaro.org"},"content":"On 6 September 2017 at 12:46, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:\n> On Wednesday, September 6, 2017 2:52:59 AM CEST Rafael J. Wysocki wrote:\n>> On Monday, September 4, 2017 2:55:37 PM CEST Ulf Hansson wrote:\n>> > [...]\n>\n> I guess I can wrap it up, because all of the points seem to have been stated\n> and repeating them would not be useful.\n>\n> My summary of the discussion is as follows.\n>\n> It only is valid to use pm_runtime_force_suspend/resume() as *driver*\n> callbacks for system suspend/resume if both the driver itself and all of\n> the middle layers it has to work with carry out the same sequence of\n> operations in order to suspend the device both in runtime PM and for\n> system sleep (and analogously for resuming).  [The middle layers need\n> to meet additional conditions, but that's less relevant.]\n>\n> Unfortunately, for the ACPI PM domain and the PCI bus type the situation is\n> different, because they generally need to do different things to suspend\n> devices for system sleep than they do for runtime PM (which mostly is\n> related to the handling of ACPI-defined sleep states and device/system\n> wakeup, but not limited to that).  This clearly means that drivers needing\n> to work with the ACPI PM domain and PCI drivers cannot use\n> pm_runtime_force_suspend/resume() as their PM callbacks for system\n> suspend/resume (quite fundamentally).\n>\n> [Note that for i2c-designware-platdrv the situation is even more complicated,\n> because on some platforms it has to work with the ACPI PM domain (or the\n> ACPI LPSS driver), on some platforms its parent is a PCI device and on\n> some other platforms there's none of them.]\n\nThat is also why it makes it really interesting. I am guessing we will\nbe seeing more of these cases sooner or later.\n\nTo make it even more complex, I can guess we can expect cases when\ngenpd is mixed with the ACPI PM domain.\n\n>\n> However, for drivers that need to work with the ACPI PM domain and\n> PCI drivers the differences in the device handling between runtime PM and\n> system suspend/resume are *very* often (even though not always) covered\n> entirely by the middle layer code.  Then, the driver itself actually\n> always carries out the same sequence of operations in order to suspend\n> the device (or to resume it, analogously).  The driver then can re-use\n> its runtime PM callbacks for system suspend/resume (but at the driver\n> level only) and it would be good to make that easy (or easier) for these\n> drivers somehow.\n\nThis is a very nice summary so far, thanks for putting it together.\n\nKind regards\nUffe","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"GcF0j6rS\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"GYovbC4v\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xnQFG5l7wz9t2R\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tWed,  6 Sep 2017 23:59:46 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dparn-0000tC-BK; Wed, 06 Sep 2017 13:59:43 +0000","from mail-io0-x22f.google.com ([2607:f8b0:4001:c06::22f])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dpari-0000o7-8d for linux-arm-kernel@lists.infradead.org;\n\tWed, 06 Sep 2017 13:59:40 +0000","by mail-io0-x22f.google.com with SMTP id i14so4936970ioe.2\n\tfor <linux-arm-kernel@lists.infradead.org>;\n\tWed, 06 Sep 2017 06:59:17 -0700 (PDT)","by 10.2.96.38 with HTTP; Wed, 6 Sep 2017 06:59:16 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:\n\tReferences:In-Reply-To:MIME-Version:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=ZvkwWCB6ewLyULACegkkS44grfagnStB2gErpRM0pdU=;\n\tb=GcF0j6rSXwmg4M\n\t8jMNDidyOquSJigli169oaKihhYOfXXn5fU+PPgw5AmF3+VBcGC8BVby+gX/CBpH2f2ibQ56daaF5\n\t0TCEqBo/ohugCUbmWqQHcP00phQcyqmuuJ3h+eSxZsYO63dNrm7wAsH9kslmQiog3hWxOHAcFXzPA\n\tVVwMzqld14BVMhD6XLwb0YHwQxBZRrhVilyBkkTp5bW3vkYQe6YAvZ9WecMl/4rxDlkeiK6iwEgZ3\n\t2XeFRdn1+QTIeaC/R9meV03jpuz695bThBD3O3PFeQBtvj18ZH0JWRcKfSlRPz1h8B/BNS2FWPCXG\n\tL53pL+3P4YZSIO2Fuxkw==;","v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=Txb81XLQVtpJGB1IaFy4nzgUbqfK3rasyh6LBqEt334=;\n\tb=GYovbC4vHxnAuDftgqdv6syAx9MQUVNtpk2u7oqWlQvLcqzOq8VES70uv7N91OzOjb\n\tBH8EF6n1EkT7Y1r+jeCMf3Qsk1DyR2kfSawzgcCJyFc+8CRZlAWmNLoxr4vYA8584vP5\n\tIwJc60LXnUk9YeKw2G3dUaO0tdDu60q9fSKdo="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=Txb81XLQVtpJGB1IaFy4nzgUbqfK3rasyh6LBqEt334=;\n\tb=DccKChQEZCqtvpPFfjAyGsHSxgaw7Ge9aqj5D+kATnUkSTW21yf0xh9ywoyLZIgQeu\n\tZPzu0zCMLUErqG8pY2cUNNFgk8lZhZ4LAGP1NCOIyFkRL6dn4XX2ofIYC+N7lFaXtuU2\n\t+eF1ghKz8OIs4DnL8FQdLVBc0DM4R06hsWbizMn7wN2cRLmWLAvAUReQ0O2cd6Lg0jsl\n\t5KfZ+T6DVdVVT8F0Va0YDI5P1F4osj4dGrrIquctqiLT7+4VxvUtxSXTNpRN/XXn7GPT\n\tdWdms7EbK6tT6K5PWbi1mBfVS2v3b+BoIeSqtCsL2tNoCEoWacHrTHvQWfd9bA0jGXkI\n\t8FFA==","X-Gm-Message-State":"AHPjjUhKznfUIRDuNu2MgrX7qYtaXkOdw4FeQnJjkpag4l+Hgz69H9tY\n\t8l7GbyU4wXaW1geJy8kB2HF2Ejotev2g","X-Google-Smtp-Source":"AOwi7QADsZGm8+mKJmeu5+OZBnBVWeiAnImimDzzcFhfX3KutBdfrUGSCvOTc1pHJFuuArEvUt5U33Jv+8zLTcvOrbs=","X-Received":"by 10.107.68.16 with SMTP id r16mr3064643ioa.34.1504706357254;\n\tWed, 06 Sep 2017 06:59:17 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<8456507.jc97SKmauk@aspire.rjw.lan>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<CAPDyKFpX3Owk4H=0SqgfspXZd9TmdL_ANOZftXRq6HPjrT2ctQ@mail.gmail.com>\n\t<1883292.VFru06qUYG@aspire.rjw.lan>\n\t<8456507.jc97SKmauk@aspire.rjw.lan>","From":"Ulf Hansson <ulf.hansson@linaro.org>","Date":"Wed, 6 Sep 2017 15:59:16 +0200","Message-ID":"<CAPDyKFr0hV=m=TumYKLoYC57mTht9_185vR5ynP_3oi7rauRbg@mail.gmail.com>","Subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","To":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170906_065938_388726_A0DA7F6E ","X-CRM114-Status":"GOOD (  19.36  )","X-Spam-Score":"-2.7 (--)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-2.7 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/,\n\tlow\n\ttrust [2607:f8b0:4001:c06:0:0:0:22f listed in] [list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]\n\t-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature\n\t0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n\tnot necessarily valid\n\t-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n\tauthor's domain","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}},{"id":1764402,"web_url":"http://patchwork.ozlabs.org/comment/1764402/","msgid":"<7722016.zqrrHyr8aS@aspire.rjw.lan>","list_archive_url":null,"date":"2017-09-06T21:39:01","subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","submitter":{"id":26536,"url":"http://patchwork.ozlabs.org/api/people/26536/","name":"Rafael J. Wysocki","email":"rjw@rjwysocki.net"},"content":"On Wednesday, September 6, 2017 3:59:16 PM CEST Ulf Hansson wrote:\n> On 6 September 2017 at 12:46, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:\n> > On Wednesday, September 6, 2017 2:52:59 AM CEST Rafael J. Wysocki wrote:\n> >> On Monday, September 4, 2017 2:55:37 PM CEST Ulf Hansson wrote:\n> >> > [...]\n> >\n> > I guess I can wrap it up, because all of the points seem to have been stated\n> > and repeating them would not be useful.\n> >\n> > My summary of the discussion is as follows.\n> >\n> > It only is valid to use pm_runtime_force_suspend/resume() as *driver*\n> > callbacks for system suspend/resume if both the driver itself and all of\n> > the middle layers it has to work with carry out the same sequence of\n> > operations in order to suspend the device both in runtime PM and for\n> > system sleep (and analogously for resuming).  [The middle layers need\n> > to meet additional conditions, but that's less relevant.]\n> >\n> > Unfortunately, for the ACPI PM domain and the PCI bus type the situation is\n> > different, because they generally need to do different things to suspend\n> > devices for system sleep than they do for runtime PM (which mostly is\n> > related to the handling of ACPI-defined sleep states and device/system\n> > wakeup, but not limited to that).  This clearly means that drivers needing\n> > to work with the ACPI PM domain and PCI drivers cannot use\n> > pm_runtime_force_suspend/resume() as their PM callbacks for system\n> > suspend/resume (quite fundamentally).\n> >\n> > [Note that for i2c-designware-platdrv the situation is even more complicated,\n> > because on some platforms it has to work with the ACPI PM domain (or the\n> > ACPI LPSS driver), on some platforms its parent is a PCI device and on\n> > some other platforms there's none of them.]\n> \n> That is also why it makes it really interesting. I am guessing we will\n> be seeing more of these cases sooner or later.\n> \n> To make it even more complex, I can guess we can expect cases when\n> genpd is mixed with the ACPI PM domain.\n> \n> >\n> > However, for drivers that need to work with the ACPI PM domain and\n> > PCI drivers the differences in the device handling between runtime PM and\n> > system suspend/resume are *very* often (even though not always) covered\n> > entirely by the middle layer code.  Then, the driver itself actually\n> > always carries out the same sequence of operations in order to suspend\n> > the device (or to resume it, analogously).  The driver then can re-use\n> > its runtime PM callbacks for system suspend/resume (but at the driver\n> > level only) and it would be good to make that easy (or easier) for these\n> > drivers somehow.\n> \n> This is a very nice summary so far, thanks for putting it together.\n\nNo problem.\n\nI actually have an idea on how to move forward, but let me start a new thread\nfor discussing that.\n\nThanks,\nRafael","headers":{"Return-Path":"<linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming-imx@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming-imx@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.infradead.org\n\t(client-ip=65.50.211.133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org\n\theader.b=\"ofTTnlM3\"; dkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xncf64FbDz9s8J\n\tfor <incoming-imx@patchwork.ozlabs.org>;\n\tThu,  7 Sep 2017 07:48:30 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dpiBO-00025Z-Er; Wed, 06 Sep 2017 21:48:26 +0000","from cloudserver094114.home.net.pl ([79.96.170.134])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1dpiBJ-00021h-Iv for linux-arm-kernel@lists.infradead.org;\n\tWed, 06 Sep 2017 21:48:23 +0000","from 79.184.253.199.ipv4.supernova.orange.pl (79.184.253.199) (HELO\n\taspire.rjw.lan)\n\tby serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer\n\t0.82) id 7883038369968e14; Wed, 6 Sep 2017 23:47:50 +0200"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=/k5vAau/2pv7ecLDD/Qug0xIYRAkvmdoeS2j0PZw8Ts=;\n\tb=ofTTnlM3bQWqnk\n\thAJ8bmfSUosGxiJ6+jZguV5LM5wnbjz4lMa19vGhUwrRnrPrZg9/k/IAHuDIurecF/ZbNFo0gfmC+\n\tGPr+Qrk3WHmxWPoOu9NjlzumshAuTf6AL+xCx3P3axuHyP55K/X2Wo+rKYj/TXRi1OY6nT/OYURW0\n\tG5XiQXACBjF69kx1c37GgCyVcMNbrK+FHwGAJQ1KAkiMv9erxlNNCU6mAV3O/tbEkAqVNnBg9cWn7\n\tX7TUt3xozhN5GQZ+EQBorATj7dfnKI1VOW9UKQw6TE1zTvqIa5G9L/rMW2m/HNVfIpoIKfvWFFD0X\n\tZzLW+y8byBaSlWlTW6CQ==;","From":"\"Rafael J. Wysocki\" <rjw@rjwysocki.net>","To":"Ulf Hansson <ulf.hansson@linaro.org>","Subject":"Re: [PATCH v3 0/8] PM / ACPI / i2c: Deploy runtime PM centric path\n\tfor system sleep","Date":"Wed, 06 Sep 2017 23:39:01 +0200","Message-ID":"<7722016.zqrrHyr8aS@aspire.rjw.lan>","In-Reply-To":"<CAPDyKFr0hV=m=TumYKLoYC57mTht9_185vR5ynP_3oi7rauRbg@mail.gmail.com>","References":"<1504018610-10822-1-git-send-email-ulf.hansson@linaro.org>\n\t<8456507.jc97SKmauk@aspire.rjw.lan>\n\t<CAPDyKFr0hV=m=TumYKLoYC57mTht9_185vR5ynP_3oi7rauRbg@mail.gmail.com>","MIME-Version":"1.0","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20170906_144821_815481_A76C8A9A ","X-CRM114-Status":"GOOD (  20.66  )","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","X-BeenThere":"linux-arm-kernel@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-arm-kernel/>","List-Post":"<mailto:linux-arm-kernel@lists.infradead.org>","List-Help":"<mailto:linux-arm-kernel-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>,\n\t<mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe>","Cc":"Jisheng Zhang <jszhang@marvell.com>, Johannes Stezenbach <js@sig21.net>, \n\tGuodong Xu <guodong.xu@linaro.org>,\n\t\"linux-pm@vger.kernel.org\" <linux-pm@vger.kernel.org>,\n\tWolfram Sang <wsa@the-dreams.de>, Kevin Hilman <khilman@kernel.org>, \n\t\"linux-i2c@vger.kernel.org\" <linux-i2c@vger.kernel.org>,\n\tACPI Devel Maling List <linux-acpi@vger.kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohn Stultz <john.stultz@linaro.org>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\t\"linux-arm-kernel@lists.infradead.org\"\n\t<linux-arm-kernel@lists.infradead.org>, Len Brown <lenb@kernel.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-arm-kernel\" <linux-arm-kernel-bounces@lists.infradead.org>","Errors-To":"linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org","List-Id":"linux-imx-kernel.lists.patchwork.ozlabs.org"}}]