Re: [PATCH v1 3/4] ASoC: codecs: pm4125: Keep the micbias reference count balanced
From: Mohammad Rafi Shaik
Date: Mon Nov 02 2026 - 06:01:52 EST
On 10/16/2026 12:33 AM, Mark Brown wrote:
On Thu, Oct 15, 2026 at 07:43:11PM +0530, Mohammad Rafi Shaik wrote:
The analog master bias is shared between the microphone bias supplies
and the playback and capture paths, so pm4125_global_mbias_enable() and
pm4125_global_mbias_disable() reference count it and only touch
PM4125_ANA_MBIAS_EN for the first user and the last one.
MICB_DISABLE clamps the per-supply reference count at zero but then
evaluates the enable and pull-up counts regardless, so a release that
has no matching request still reaches pm4125_global_mbias_disable() and
drops a reference it never took. The MBHC framework issues exactly such
a release: it takes MIC_BIAS_2 once when it starts detecting a plug
type and releases it both at the end of the correction work and again
from wcd_micbias_disable(). Inserting a jack while a stream is running
therefore switches the analog master bias off underneath it, leaving
the path up but silent, and it stays silent until another stream takes
the first reference again.
Return early when there is nothing to release, so the hardware is only
touched for a request that was actually made.
This feels like a bodge for poor reference counting elsewhere - in
particular the MBHC seems to be fairly clearly double freeing. The fix
here just silently eats double frees AFAICT?
Hi Mark,
Good catch. I’ll check this and fix it in the next revision.
Sorry for the delayed response. I was away for a few days.
Best Regards.
Rafi.