diff mbox series

[3/4] PM / Domains: Respect errors from genpd's ->power_off() callback

Message ID 1490005163-28633-4-git-send-email-ulf.hansson@linaro.org
State Accepted
Commit 1c14967c6ea0deb3db4a974b1de519f5a5593ef4
Headers show
Series PM / Domains: Add support for always on PM domains in genpd | expand

Commit Message

Ulf Hansson March 20, 2017, 10:19 a.m. UTC
The current code in genpd_sync_power_off(), doesn't care about potential
errors being returned from genpd's ->power_off() callback.

Obviously this behaviour could lead to problems, such as incorrectly
setting the genpd's status to GPD_STATE_POWER_OFF, but also to incorrectly
decrease the subdomain count for the masters, which potentially allows them
to be powered off in the next recursive call to genpd_sync_power_off().

Let's fix this behaviour by bailing out when the ->power_off() callback
returns an error code.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

---
 drivers/base/power/domain.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.7.4

Comments

Viresh Kumar March 20, 2017, 11:11 a.m. UTC | #1
On 20-03-17, 11:19, Ulf Hansson wrote:
> The current code in genpd_sync_power_off(), doesn't care about potential

> errors being returned from genpd's ->power_off() callback.

> 

> Obviously this behaviour could lead to problems, such as incorrectly

> setting the genpd's status to GPD_STATE_POWER_OFF, but also to incorrectly

> decrease the subdomain count for the masters, which potentially allows them

> to be powered off in the next recursive call to genpd_sync_power_off().

> 

> Let's fix this behaviour by bailing out when the ->power_off() callback

> returns an error code.

> 

> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

> ---

>  drivers/base/power/domain.c | 3 ++-

>  1 file changed, 2 insertions(+), 1 deletion(-)

> 

> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c

> index e63712d..8a2bfc8 100644

> --- a/drivers/base/power/domain.c

> +++ b/drivers/base/power/domain.c

> @@ -767,7 +767,8 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock,

>  

>  	/* Choose the deepest state when suspending */

>  	genpd->state_idx = genpd->state_count - 1;

> -	_genpd_power_off(genpd, false);

> +	if (_genpd_power_off(genpd, false))

> +		return;

>  

>  	genpd->status = GPD_STATE_POWER_OFF;


Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>


-- 
viresh
Geert Uytterhoeven March 20, 2017, 11:58 a.m. UTC | #2
On Mon, Mar 20, 2017 at 11:19 AM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> The current code in genpd_sync_power_off(), doesn't care about potential

> errors being returned from genpd's ->power_off() callback.

>

> Obviously this behaviour could lead to problems, such as incorrectly

> setting the genpd's status to GPD_STATE_POWER_OFF, but also to incorrectly

> decrease the subdomain count for the masters, which potentially allows them

> to be powered off in the next recursive call to genpd_sync_power_off().

>

> Let's fix this behaviour by bailing out when the ->power_off() callback

> returns an error code.

>

> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>


Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>


Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Bartlomiej Zolnierkiewicz March 20, 2017, 5:14 p.m. UTC | #3
On Monday, March 20, 2017 11:19:22 AM Ulf Hansson wrote:
> The current code in genpd_sync_power_off(), doesn't care about potential

> errors being returned from genpd's ->power_off() callback.

> 

> Obviously this behaviour could lead to problems, such as incorrectly

> setting the genpd's status to GPD_STATE_POWER_OFF, but also to incorrectly

> decrease the subdomain count for the masters, which potentially allows them

> to be powered off in the next recursive call to genpd_sync_power_off().

> 

> Let's fix this behaviour by bailing out when the ->power_off() callback

> returns an error code.

> 

> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>


Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>


Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
diff mbox series

Patch

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index e63712d..8a2bfc8 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -767,7 +767,8 @@  static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock,
 
 	/* Choose the deepest state when suspending */
 	genpd->state_idx = genpd->state_count - 1;
-	_genpd_power_off(genpd, false);
+	if (_genpd_power_off(genpd, false))
+		return;
 
 	genpd->status = GPD_STATE_POWER_OFF;