Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Zhang Yi" <zhangyi@everest-semi.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v1 3/7] ASoC: codecs: ES8389: Fix the issue about mclk_src
Date: Thu, 11 Jun 2026 03:32:43 +0000	[thread overview]
Message-ID: <20260611033243.62FE21F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260611031824.4628-4-zhangyi@everest-semi.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing symmetric constraints for channels and sample bits allows concurrent streams to corrupt shared clock configuration.
- [High] Concurrent `hw_params` calls can race, leading to corrupted internal state and interleaved register writes.
--

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

ASoC: codecs: ES8389: Fix the issue about mclk_src
    
Fix the issue with incorrect modifications to mclk_src when configuring
the system to use MCLK from the SCLK pin. Changes the mclk_src member
from u8 to bool to better represent its purpose.

> diff --git a/sound/soc/codecs/es8389.c b/sound/soc/codecs/es8389.c
> index be7a36f17083f..886069be1535f 100644
> --- a/sound/soc/codecs/es8389.c
> +++ b/sound/soc/codecs/es8389.c

[ ... ]

> @@ -607,9 +607,9 @@ static int es8389_pcm_hw_params(struct snd_pcm_substream *substream,
>  	regmap_update_bits(es8389->regmap, ES8389_ADC_FORMAT_MUTE, ES8389_DATA_LEN_MASK, state);
>  	regmap_update_bits(es8389->regmap, ES8389_DAC_FORMAT_MUTE, ES8389_DATA_LEN_MASK, state);
>  
> -	if (es8389->mclk_src == ES8389_SCLK_PIN) {
> +	if (es8389->mclk_src) {
>  		regmap_update_bits(es8389->regmap, ES8389_MASTER_CLK,
> -					ES8389_MCLK_SOURCE, es8389->mclk_src);
> +					ES8389_MCLK_MASK, ES8389_MCLK_FROM_SCLK);
>  		es8389->sysclk = params_channels(params) * params_width(params) * params_rate(params);

[Severity: High]
This is a pre-existing issue, but I noticed the driver dynamically calculates
a shared internal clock (es8389->sysclk) based on the stream parameters here.

Since the es8389_dai definition doesn't set .symmetric_channels = 1 or
.symmetric_sample_bits = 1, couldn't user-space concurrently open playback
and capture streams with different channel counts or bit widths?

Would the second stream silently recalculate and overwrite the hardware clock
registers, breaking the already-running stream?

[Severity: High]
This is also a pre-existing issue, but does this function need locking to
protect against concurrent execution?

ALSA's PCM core does not serialize hw_params calls between separate playback
and capture substreams on the same DAI. If playback and capture streams
execute hw_params simultaneously, couldn't they race when updating shared
driver state like es8389->sysclk and es8389->vddd?

Later in this function, there's a sequence of about 20 non-atomic regmap_write
operations to clock control registers:

    regmap_write(es8389->regmap, ES8389_CLK_DIV1, coeff_div[coeff].Reg0x04);
    regmap_write(es8389->regmap, ES8389_CLK_MUL, coeff_div[coeff].Reg0x05);
    ...

Could concurrent execution interleave these hardware register writes and
potentially leave the codec's clocking tree in an invalid state?

>  	}
>

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

  reply	other threads:[~2026-06-11  3:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-11  3:18 [PATCH v1 0/7] ASoC: codecs: ES8389: Modify the ES8389 driver Zhang Yi
2026-06-11  3:18 ` [PATCH v1 1/7] ASoC: dt-bindings: ES8389: Add members about HPF and clock Zhang Yi
2026-06-11  3:28   ` sashiko-bot
2026-06-11  3:18 ` [PATCH v1 2/7] ASoC: codecs: ES8389: Modify volatile_register Zhang Yi
2026-06-11  3:31   ` sashiko-bot
2026-06-11  3:18 ` [PATCH v1 3/7] ASoC: codecs: ES8389: Fix the issue about mclk_src Zhang Yi
2026-06-11  3:32   ` sashiko-bot [this message]
2026-06-11  3:18 ` [PATCH v1 4/7] ASoC: codecs: ES8389: Modify the clock table Zhang Yi
2026-06-11  3:27   ` sashiko-bot
2026-06-11  3:18 ` [PATCH v1 5/7] ASoC: codecs: ES8389: Modify the initial configuration Zhang Yi
2026-06-11  3:26   ` sashiko-bot
2026-06-11  3:18 ` [PATCH v1 6/7] ASoC: codecs: ES8389: Add private members related to HPF Zhang Yi
2026-06-11  3:18 ` [PATCH v1 7/7] ASoC: codecs: ES8389: Add INPUTL MUX and INPUTR MUX Zhang Yi

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=20260611033243.62FE21F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@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