From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:53936 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751604AbdLFR0j (ORCPT ); Wed, 6 Dec 2017 12:26:39 -0500 Subject: Patch "PM / Domains: Fix genpd to deal with drivers returning 1 from ->prepare()" has been added to the 4.14-stable tree To: ulf.hansson@linaro.org, alexander.levin@verizon.com, gregkh@linuxfoundation.org, rafael.j.wysocki@intel.com Cc: , From: Date: Wed, 06 Dec 2017 18:26:24 +0100 Message-ID: <1512581184152249@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled PM / Domains: Fix genpd to deal with drivers returning 1 from ->prepare() to the 4.14-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: pm-domains-fix-genpd-to-deal-with-drivers-returning-1-from-prepare.patch and it can be found in the queue-4.14 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >>From foo@baz Wed Dec 6 18:04:41 CET 2017 From: Ulf Hansson Date: Wed, 8 Nov 2017 10:11:02 +0100 Subject: PM / Domains: Fix genpd to deal with drivers returning 1 from ->prepare() From: Ulf Hansson [ Upstream commit 5241ab40f6e742f8a1631f8826faf6dc6412b3b5 ] During system-wide PM, genpd relies on its PM callbacks to be invoked for all its attached devices, as to deal with powering off/on the PM domain. In other words, genpd is not compatible with the direct_complete path, if executed by the PM core for any of its attached devices. However, when genpd's ->prepare() callback invokes pm_generic_prepare(), it does not take into account that it may return 1. Instead it treats that as an error internally and expects the PM core to abort the prepare phase and roll back. This leads to genpd not properly powering on/off the PM domain, because its internal counters gets wrongly balanced. To fix the behaviour, allow drivers to return 1 from their ->prepare() callbacks, but let's return 0 from genpd's ->prepare() callback in such case, as that prevents the PM core from running the direct_complete path for the device. Signed-off-by: Ulf Hansson Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/base/power/domain.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -921,7 +921,7 @@ static int pm_genpd_prepare(struct devic genpd_unlock(genpd); ret = pm_generic_prepare(dev); - if (ret) { + if (ret < 0) { genpd_lock(genpd); genpd->prepared_count--; @@ -929,7 +929,8 @@ static int pm_genpd_prepare(struct devic genpd_unlock(genpd); } - return ret; + /* Never return 1, as genpd don't cope with the direct_complete path. */ + return ret >= 0 ? 0 : ret; } /** Patches currently in stable-queue which might be from ulf.hansson@linaro.org are queue-4.14/mmc-tmio-check-mmc_regulator_get_supply-return-value.patch queue-4.14/pm-domains-fix-genpd-to-deal-with-drivers-returning-1-from-prepare.patch queue-4.14/mmc-sdhci-msm-fix-issue-with-power-irq.patch