linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PM: Fix bug in the error handling of async suspend
@ 2016-12-07 14:40 Sahitya Tummala
  2016-12-08  0:18 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Sahitya Tummala @ 2016-12-07 14:40 UTC (permalink / raw)
  To: Rafael J. Wysocki", Pavel Machek, Len Brown,
	Greg Kroah-Hartman, linux-pm, linux-kernel
  Cc: Sahitya Tummala

If async_suspend is enabled for parent and child devices, then
PM framework has to ensure that parent's async suspend gets called
only after child's async suspend is done. In case if child's async
suspend fails with error, then parent's async suspend must not be
invoked. The current code uses async_error to ensure this but there
is a problem with it in __device_suspend(). This function notifies
the completion of child's async suspend before updating its error
via async_error variable. As a result, parent's async suspend gets
invoked even though it's child suspend has failed. Fix this bug by
updating the async_error before notifying the child's completion.

Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
---
 drivers/base/power/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index e44944f4be77..f733f50f8321 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1460,9 +1460,9 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
 	dpm_watchdog_clear(&wd);
 
  Complete:
-	complete_all(&dev->power.completion);
 	if (error)
 		async_error = error;
+	complete_all(&dev->power.completion);
 
 	TRACE_SUSPEND(error);
 	return error;
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] PM: Fix bug in the error handling of async suspend
  2016-12-07 14:40 [PATCH] PM: Fix bug in the error handling of async suspend Sahitya Tummala
@ 2016-12-08  0:18 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2016-12-08  0:18 UTC (permalink / raw)
  To: Sahitya Tummala
  Cc: Rafael J. Wysocki", Pavel Machek, Len Brown,
	Greg Kroah-Hartman, linux-pm, linux-kernel

On Wednesday, December 07, 2016 08:10:32 PM Sahitya Tummala wrote:
> If async_suspend is enabled for parent and child devices, then
> PM framework has to ensure that parent's async suspend gets called
> only after child's async suspend is done. In case if child's async
> suspend fails with error, then parent's async suspend must not be
> invoked. The current code uses async_error to ensure this but there
> is a problem with it in __device_suspend(). This function notifies
> the completion of child's async suspend before updating its error
> via async_error variable. As a result, parent's async suspend gets
> invoked even though it's child suspend has failed. Fix this bug by
> updating the async_error before notifying the child's completion.
> 
> Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
> ---
>  drivers/base/power/main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
> index e44944f4be77..f733f50f8321 100644
> --- a/drivers/base/power/main.c
> +++ b/drivers/base/power/main.c
> @@ -1460,9 +1460,9 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
>  	dpm_watchdog_clear(&wd);
>  
>   Complete:
> -	complete_all(&dev->power.completion);
>  	if (error)
>  		async_error = error;
> +	complete_all(&dev->power.completion);
>  
>  	TRACE_SUSPEND(error);
>  	return error;

Good catch!

I'm queuing this one up (with some whitespace rearrangements).

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-12-08  0:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-07 14:40 [PATCH] PM: Fix bug in the error handling of async suspend Sahitya Tummala
2016-12-08  0:18 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).