Linux Sound subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Zhang Yi" <zhangyi@everest-semi.com>, linux-sound@vger.kernel.org
Subject: Re: [PATCH] ASoC: codecs: ES8389: Modify the startup configuration
Date: Fri, 04 Dec 2026 08:44:51 +0000	[thread overview]
Message-ID: <sashiko-outbox-249424@kernel.org> (raw)
In-Reply-To: <20261204082056.4430-1-zhangyi@everest-semi.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] ASoC: es8389: split wakeup in es8389_set_bias_level() and
  es8389_mute()
- [Medium] ASoC: es8389: es8389_mute() can hold active DAC in reset on
  capture unmute
- [Medium] ASoC: es8389: es8389_mute() wakeup writes race with
  es8389_standby()
- [Low] ASoC: es8389: commit message omits root cause and sequencing
  rationale
--

commit b420db27eff9e9ee2261ee4c28eaded8c91efc65
Author: Zhang Yi <zhangyi@everest-semi.com>

> ASoC: codecs: ES8389: Modify the startup configuration
>
> There is an occasional issue where the audio is silent during playback;
> modify the startup configuration to resolve this issue.
>
> Signed-off-by: Zhang Yi <zhangyi@everest-semi.com>

[Severity: Low]
Could the commit message explain the root cause of the occasional silent
playback and why these register sequencing changes are needed?  The patch
moves wakeup writes out of es8389_set_bias_level(), drops ES8389_HPSW and
ES8389_ANA_CTL1 from es8389_mute(), and adds an ES8389_DAC_RESET write.

> diff --git a/sound/soc/codecs/es8389.c b/sound/soc/codecs/es8389.c
> index 1a8e56506fe3a..040ee141318a1 100644
> --- a/sound/soc/codecs/es8389.c
> +++ b/sound/soc/codecs/es8389.c
> @@ -840,10 +840,6 @@ static int es8389_set_bias_level(struct snd_soc_component *component,
>  
>  		regmap_update_bits(es8389->regmap, ES8389_HPSW, 0x20, 0x20);
>  		regmap_write(es8389->regmap, ES8389_ANA_CTL1, 0xD9);
> -		regmap_write(es8389->regmap, ES8389_ADC_EN, 0x8F);
> -		regmap_write(es8389->regmap, ES8389_CSM_JUMP, 0xE4);
> -		regmap_write(es8389->regmap, ES8389_RESET, 0x01);
> -		regmap_write(es8389->regmap, ES8389_CLK_OFF1, 0xC3);
>  		break;
>  	case SND_SOC_BIAS_PREPARE:
>  		break;

[Severity: High]
Does removing these four writes from SND_SOC_BIAS_ON leave the codec stuck
in standby/reset on wakeup paths that do not call es8389_mute(0)?

es8389_standby() puts those four volatile registers into standby/reset, so
regcache_sync() never restores them.  When an active capture stream resumes
from system suspend, snd_soc_card_resume_deferred() restores bias via DAPM
and only unmutes playback streams, leaving capture stuck in standby/reset.

Separately, dropping ES8389_HPSW and ES8389_ANA_CTL1 from es8389_mute()
while writing the wakeup registers unconditionally breaks codec-to-codec
playback links, where dapm_power_widgets() calls es8389_mute(0) before
SND_SOC_BIAS_ON, enabling digital blocks while mclk and analog bias are off.

> @@ -876,13 +872,12 @@ static int es8389_mute(struct snd_soc_dai *dai, int mute, int direction)
>  	} else {
>  		regmap_read(es8389->regmap, ES8389_CSM_STATE1, &regv);
>  		if (regv != ES8389_STATE_ON) {
> -			regmap_update_bits(es8389->regmap, ES8389_HPSW, 0x20, 0x20);
> -			regmap_write(es8389->regmap, ES8389_ANA_CTL1, 0xD9);
> -			regmap_write(es8389->regmap, ES8389_ADC_EN, 0x8F);
> -			regmap_write(es8389->regmap, ES8389_CSM_JUMP, 0xE4);
> -			regmap_write(es8389->regmap, ES8389_RESET, 0x01);
> -			regmap_write(es8389->regmap, ES8389_CLK_OFF1, 0xC3);
> +			regmap_write(es8389->regmap, ES8389_DAC_RESET, 0X02);
>  		}

[Severity: Medium]
Can unmuting a capture stream hold an active playback DAC in reset?

es8389_mute() writes ES8389_DAC_RESET = 0x02 before checking direction, but
only clears it back to 0x00 on the playback branch when !es8389->version.
At 88.2 or 96 kHz, es8389_pcm_hw_params() writes 0xC0 into bits [7:6] of
ES8389_CSM_STATE1, so an unmasked check on capture unmute silences playback.

> +		regmap_write(es8389->regmap, ES8389_CSM_JUMP, 0xE4);
> +		regmap_write(es8389->regmap, ES8389_RESET, 0x01);
> +		regmap_write(es8389->regmap, ES8389_CLK_OFF1, 0xC3);
> +		regmap_write(es8389->regmap, ES8389_ADC_EN, 0x8F);

[Severity: Medium]
Can these wakeup writes in es8389_mute() race with es8389_standby()?

Previously these writes ran in es8389_set_bias_level(SND_SOC_BIAS_ON) under
card->dapm_mutex.  Now __soc_pcm_prepare() calls es8389_mute(0) under
card->pcm_mutex after snd_soc_dapm_stream_event() releases dapm_mutex,
racing with a concurrent snd_soc_dapm_sync() entering es8389_standby():

CPU0                                    CPU1
soc_pcm_prepare()                       snd_soc_dapm_sync()
  lock(card->pcm_mutex)                   lock(card->dapm_mutex)
  snd_soc_dapm_stream_event()             ...
    /* acquires & releases dapm_mutex */  es8389_standby()
  es8389_mute(0)                            write ES8389_CSM_JUMP = 0xD4
    write ES8389_CSM_JUMP = 0xE4            usleep_range(70000, 72000)
    write ES8389_RESET = 0x01
    write ES8389_CLK_OFF1 = 0xC3
    write ES8389_ADC_EN = 0x8F
                                            write ES8389_ANA_CTL1 = 0x59
                                            write ES8389_ADC_EN = 0x00
                                            write ES8389_CLK_OFF1 = 0x00
                                            write ES8389_RESET = 0x3E
                                          clk_disable_unprepare(mclk)
                                          <-- active stream left in reset

In the reverse order, es8389_mute() re-enables CSM, clocks, digital core,
and ADC after es8389_standby() and clk_disable_unprepare() have powered down
analog bias and mclk.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204082056.4430-1-zhangyi@everest-semi.com?part=1

      reply	other threads:[~2026-12-04  8:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  8:20 [PATCH] ASoC: codecs: ES8389: Modify the startup configuration Zhang Yi
2026-12-04  8:44 ` sashiko-bot [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=sashiko-outbox-249424@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=zhangyi@everest-semi.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