[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID:
<TY3PR01MB11346D4CD14B8953747C859BE86A4A@TY3PR01MB11346.jpnprd01.prod.outlook.com>
Date: Sat, 6 Dec 2025 10:06:42 +0000
From: Biju Das <biju.das.jz@...renesas.com>
To: Uwe Kleine-König <ukleinek@...nel.org>
CC: biju.das.au <biju.das.au@...il.com>, Philipp Zabel
<p.zabel@...gutronix.de>, "linux-pwm@...r.kernel.org"
<linux-pwm@...r.kernel.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, Geert Uytterhoeven <geert+renesas@...der.be>,
Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@...renesas.com>,
"linux-renesas-soc@...r.kernel.org" <linux-renesas-soc@...r.kernel.org>,
"linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>
Subject: RE: [PATCH v3 6/8] pwm: rzg2l-gpt: Add suspend/resume support
Hi Uwe,
> -----Original Message-----
> From: Uwe Kleine-König <ukleinek@...nel.org>
> Sent: 01 December 2025 15:29
> Subject: Re: [PATCH v3 6/8] pwm: rzg2l-gpt: Add suspend/resume support
>
> Hello Biju,
>
> On Mon, Dec 01, 2025 at 03:04:08PM +0000, Biju Das wrote:
> > You mean to avoid unbalance between suspend()/resume(), we should not
> > do error handling in resume()??
>
> Consider the following resume function:
>
> static int myresume(...)
> {
> ret = enable_some_resource(...);
> if (ret)
> return ret;
>
> ret = enable_some_other_resource(...)
> if (ret) {
> disable_some_resource();
> return ret;
>
> }
>
> return 0;
> }
>
> If disable_some_resource() can fail it might happen that the first call to myresume() is left with
> some_resource enabled and some_other_resource disabled (i.e. if both enable_some_other_resource() and
> disable_some_resource() fail). Now if the resume is retried some_resource is enabled a second time
> without being tracked and a later suspend (or remove) won't bring the enable count to 0 and thus leak
> a resource.
There is no cleanup function can guarantee, it will succeed next time in myresume().
If in myresume() any of the call fails, we will try to put the device into low power state
(clk off, reset asserted) to save the power assuming there is high chance that all the cleanup
function for low power state succeeds. Also, caller will get error code and it know the device
resume failed.
If in mysuspend() any call fails, we will try to put the device into resume() state
So that it will report failure and next time it can retry for suspend() assuming
high chance that all the cleanup function succeeded during the failed suspend().
Please let me know your thoughts.
Cheers,
Biju
Powered by blists - more mailing lists