[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdWCGFWfvRDi3HWvrZWzgum8dFFf5cUVKjpjMy8mybh1Uw@mail.gmail.com>
Date: Mon, 1 Dec 2025 17:04:26 +0100
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Biju Das <biju.das.jz@...renesas.com>
Cc: Uwe Kleine-König <ukleinek@...nel.org>,
"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 Biju,
On Mon, 1 Dec 2025 at 16:50, Biju Das <biju.das.jz@...renesas.com> wrote:
> > From: Uwe Kleine-König <ukleinek@...nel.org>
> > 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.
>
> OK, what about for making balanced usage count for suspend()/resume() to avoid resource
> like below
>
> static int myresume(...)
> {
> ret = enable_some_resource(...);
> ret |= enable_some_other_resource(...);
>
> return ret;
> }
>
> static int mysuspend(...)
> {
> disable_some_resource(...);
> disable_some_other_resource(...)
What do you do when one of the disabling fails? See also
https://lore.kernel.org/CAMuHMdWDGpqdhCsA0MJqoL1JAiyVR-TA2YqDe+-S9Xf6c5O-gA@mail.gmail.com
> return 0;
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-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
Powered by blists - more mailing lists