[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aae92260-5169-4af1-97b0-48f364612dca@oss.qualcomm.com>
Date: Mon, 28 Jul 2025 18:06:48 +0530
From: Mohammad Rafi Shaik <mohammad.rafi.shaik@....qualcomm.com>
To: Krzysztof Kozlowski <krzk@...nel.org>,
Srinivas Kandagatla <srini@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley
<conor+dt@...nel.org>, Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>, Philipp Zabel <p.zabel@...gutronix.de>,
Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>
Cc: linux-arm-msm@...r.kernel.org, linux-sound@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-gpio@...r.kernel.org, quic_pkumpatl@...cinc.com,
kernel@....qualcomm.com
Subject: Re: [PATCH v3 2/3] ASoC: codecs: wsa883x: Add devm action to safely
disable regulator on device removal
On 7/27/2025 3:00 PM, Krzysztof Kozlowski wrote:
> On 27/07/2025 10:31, Mohammad Rafi Shaik wrote:
>> To prevent potential warnings from _regulator_put() during device
>
> Warning is either there or not. Either you fix real, specific issue or
> not. The code looks correct at first glance, so please describe exactly
> how these warnings happen or how what is the bug being fixed.
>
The current wsa883x codec driver manually enables and disables
regulators during probe and remove.
In patch v3-0003, reset functionality was added using
devm_reset_control_get_optional_shared_deasserted() for shared gpios.
However, during cleanup, this led to a warning:
"WARNING: CPU: 2 PID: 195 at drivers/regulator/core.c:2450
_regulator_put+0x50/0x58"
This occurs because the regulator is still enabled/released when the
devm-managed cleanup path attempts to release it.
To resolve this, remove the manual regulator disable logic and instead
register a devm-managed cleanup action using devm_add_action_or_reset().
This ensures proper cleanup and avoids regulator misuse warnings.
For reference, the wsa884x codec driver already follows this approach by
using devm actions for regulator management.
>> removal, register a devm-managed cleanup action using
>> devm_add_action_or_reset() to safely disable the regulator
>> associated with the WSA883x codec, ensuring that the regulator
>> is properly disabled when the device is removed, even if the
>
> Device cannot be removed/unloaded, AFAIK, because of suppressed bind.
> Regulator is already disabled during error paths, so that part of above
> sentences is just misleading.
>
> How can one trigger the warnings?
>
The warning in _regulator_put() can be triggered by applying patch
v3-0003, which introduces reset functionality using
devm_reset_control_get_optional_shared_deasserted().
Since the existing driver handles regulator enable/disable manually, the
devm-managed reset cleanup path may attempt to release regulators that
are still enabled, leading to the warning.
This issue highlights the need to replace manual regulator handling with
devm_add_action_or_reset() to ensure proper cleanup and avoid such warnings.
>
>> probe fails or the driver is unloaded unexpectedly.
>
> How driver can be unloaded unexpectedly?
>
"Unloaded" might not be the most accurate term here. What I meant is
that the driver’s probe can fail due to an error—such as missing
resources or improper regulator handling.
Thanks & Regards,
Rafi.
> Best regards,
> Krzysztof
Powered by blists - more mailing lists