mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Maxime Douailin <maxime.douailin@gmail.com>
Cc: Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	patches@opensource.cirrus.com, alsa-devel@alsa-project.org,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] ASoC: wm8962: Do not clear SYSCLK_ENA owned by DAPM in configure_bclk()
Date: Wed, 9 Sep 2026 10:58:31 +0100	[thread overview]
Message-ID: <aqEtx/wIwdo+D3tl@opensource.cirrus.com> (raw)
In-Reply-To: <20260908175802.604262-1-maxime.douailin@gmail.com>

On Tue, Sep 08, 2026 at 07:58:02PM +0200, Maxime Douailin wrote:
> +	int sysclk;
> +	bool sysclk_was_ena;
>  
>  	if (!wm8962->sysclk_rate) {
>  		dev_dbg(component->dev, "No SYSCLK configured\n");
> @@ -2504,8 +2506,19 @@ static void wm8962_configure_bclk(struct snd_soc_component *component)
>  	/* DSPCLK_DIV can be only generated correctly after enabling SYSCLK.
>  	 * So we here provisionally enable it and then disable it afterward
>  	 * if current bias_level hasn't reached SND_SOC_BIAS_ON.
> +	 *
> +	 * SYSCLK_ENA is owned by the "SYSCLK" DAPM supply widget, which may
> +	 * already have it set even below SND_SOC_BIAS_ON: wm8962_mic_detect()
> +	 * force-enables that pin, so on boards using it (the Tegra machine
> +	 * driver) the bit is set once at card init and DAPM never writes it
> +	 * again. If we unconditionally clear it here, SYSCLK stays off for
> +	 * every stream, DAPM still believes it is on, and the codec is
> +	 * silent with "DC servo timed out" errors. Only undo what we did.
>  	 */
> -	if (snd_soc_dapm_get_bias_level(dapm) != SND_SOC_BIAS_ON)
> +	sysclk = snd_soc_component_read(component, WM8962_CLOCKING2);

Probably should error out if we fail the read here.

> +	sysclk_was_ena = sysclk >= 0 && (sysclk & WM8962_SYSCLK_ENA);
> +	if (!sysclk_was_ena &&
> +	    snd_soc_dapm_get_bias_level(dapm) != SND_SOC_BIAS_ON)

Do we still need the get_bias_level here? I feel like it was just
a proxy for if the sysclk is enabled so can just be replaced now.

>  		snd_soc_component_update_bits(component, WM8962_CLOCKING2,
>  				WM8962_SYSCLK_ENA_MASK, WM8962_SYSCLK_ENA);
>  
> @@ -2519,7 +2532,8 @@ static void wm8962_configure_bclk(struct snd_soc_component *component)
>  	usleep_range(500, 1000);
>  	dspclk = snd_soc_component_read(component, WM8962_CLOCKING1);
>  
> -	if (snd_soc_dapm_get_bias_level(dapm) != SND_SOC_BIAS_ON)
> +	if (!sysclk_was_ena &&
> +	    snd_soc_dapm_get_bias_level(dapm) != SND_SOC_BIAS_ON)

Ditto here, just restore the original state. In fact, probably a
neater way to do the whole thing would be to store the original
state, unconditionally enable the sysclk, then restore the
original state.

Also do we need to hold the dapm mutex across the call to call to
wm8962_configure_bclk() in hw_params? I would worry slightly that
can race with a DAPM sequence.

Thanks,
Charles

      reply	other threads:[~2026-09-09  9:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 17:58 Maxime Douailin
2026-09-09  9:58 ` Charles Keepax [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aqEtx/wIwdo+D3tl@opensource.cirrus.com \
    --to=ckeepax@opensource.cirrus.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.douailin@gmail.com \
    --cc=patches@opensource.cirrus.com \
    --cc=perex@perex.cz \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®