[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAD=FV=VH5_i5uVcaXQrrHQWF0=ffnqFpZkmexpqoEFr7RFn_3Q@mail.gmail.com>
Date: Fri, 19 Aug 2022 13:03:31 -0700
From: Doug Anderson <dianders@...omium.org>
To: Andrew Halaney <ahalaney@...hat.com>
Cc: Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
LKML <linux-kernel@...r.kernel.org>, bmasney@...hat.com
Subject: Re: [PATCH] regulator: core: Clean up on enable failure
Hi,
On Fri, Aug 19, 2022 at 12:44 PM Andrew Halaney <ahalaney@...hat.com> wrote:
>
> If regulator_enable() fails, enable_count is incremented still.
> A consumer, assuming no matching regulator_disable() is necessary on
> failure, will then get this error message upon regulator_put()
> since enable_count is non-zero:
>
> [ 1.277418] WARNING: CPU: 3 PID: 1 at drivers/regulator/core.c:2304 _regulator_put.part.0+0x168/0x170
>
> The consumer could try to fix this in their driver by cleaning up on
> error from regulator_enable() (i.e. call regulator_disable()), but that
> results in the following since regulator_enable() failed and didn't
> increment user_count:
>
> [ 1.258112] unbalanced disables for vreg_l17c
> [ 1.262606] WARNING: CPU: 4 PID: 1 at drivers/regulator/core.c:2899 _regulator_disable+0xd4/0x190
>
> Fix this by decrementing enable_count upon failure to enable.
>
> With this in place, just the reason for failure to enable is printed
> as expected and developers can focus on the root cause of their issue
> instead of thinking their usage of the regulator consumer api is
> incorrect. For example, in my case:
>
> [ 1.240426] vreg_l17c: invalid input voltage found
>
> Fixes: 5451781dadf8 ("regulator: core: Only count load for enabled consumers")
> Signed-off-by: Andrew Halaney <ahalaney@...hat.com>
> ---
>
> I'm new to using the regulator framework, but I _believe_ this is a
> cosmetic bug that's fixed by this patch. I went down a bit of a rabbit
> hole because of the original WARN() message, so I'm trying to prevent
> others from doing the same :)
>
> Please let me know what you think, I tested on the misconfigured system
> and on a working system and things seemed to work as expected.
>
> Thanks,
> Andrew
>
> drivers/regulator/core.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
This looks right to me. Thanks!
Reviewed-by: Douglas Anderson <dianders@...omium.org>
Powered by blists - more mailing lists