Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Zhang Yi" <zhangyi@everest-semi.com>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 2/7] ASoC: codecs: ES8389: Fix the issue about mclk_src
Date: Tue, 09 Jun 2026 07:36:12 +0000	[thread overview]
Message-ID: <20260609073613.1549D1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260609071732.20939-3-zhangyi@everest-semi.com>

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

Pre-existing issues:
- [High] Incorrect BCLK calculation for MCLK derivation
- [High] Missing check on the return value of regmap_read() during resume
- [High] Resource Leak: Regulators enabled during component probe are leaked on removal
--

commit 81fe94b62642e618ad9d244bb25b737cbe5017dd
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.

> 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 does this incorrectly calculate the
physical BCLK frequency?

Using params_width() returns the sample data width instead of the physical
slot width on the wire. When mclk_src is set, es8389->sysclk acts as the MCLK
derived from SCLK.

By under-calculating the physical SCLK, the get_coeff() function is provided
with an incorrect MCLK frequency assumption, which can lead to the selection
of wrong internal clock dividers and distorted or missing audio.

Could the physical BCLK be calculated using snd_soc_params_to_bclk(params)
instead?

>  	}

Additionally, I noticed a few other pre-existing issues in this driver:

[Severity: High]
This isn't a bug introduced by this patch, but is there a missing check on the
return value of regmap_read() during resume?

In es8389_resume():

static int es8389_resume(struct snd_soc_component *component)
{
	...
	unsigned int regv;

	regcache_cache_only(es8389->regmap, false);
	regcache_cache_bypass(es8389->regmap, true);
	regmap_read(es8389->regmap, ES8389_RESET, &regv);

	if (regv == 0xff)
	...
}

If the I2C read fails during resume, the stack variable regv is left
uninitialized and evaluated against 0xff. Could this introduce undefined
behavior and lead to incorrect skipping or triggering of the hardware
re-initialization?


[Severity: High]
This isn't a bug introduced by this patch, but are the regulators enabled
during probe leaked on removal?

es8389_probe() successfully enables core regulators:

static int es8389_probe(struct snd_soc_component *component)
{
	...
	ret = regulator_bulk_enable(ARRAY_SIZE(es8389_core_supplies),
				    es8389->core_supply);
	...
}

However, es8389_remove() does not call the corresponding
regulator_bulk_disable().

Since devm_regulator_bulk_get() only automatically frees the handles but does
not implicitly disable the regulators, this leaks the regulator enable
reference count. Could this cause the power domains to remain permanently on
even when the module is unbound or removed?

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

  reply	other threads:[~2026-06-09  7:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-09  7:17 [PATCH 0/7] ASoC: codecs: ES8389: Modify the ES8389 driver Zhang Yi
2026-06-09  7:17 ` [PATCH 1/7] ASoC: codecs: ES8389: Modify volatile_register Zhang Yi
2026-06-09  7:32   ` sashiko-bot
2026-06-09  7:17 ` [PATCH 2/7] ASoC: codecs: ES8389: Fix the issue about mclk_src Zhang Yi
2026-06-09  7:36   ` sashiko-bot [this message]
2026-06-09  7:17 ` [PATCH 3/7] ASoC: codecs: ES8389: Modify the clock table Zhang Yi
2026-06-09  7:29   ` sashiko-bot
2026-06-09  7:17 ` [PATCH 4/7] ASoC: codecs: ES8389: Modify the initial configuration Zhang Yi
2026-06-09  7:26   ` sashiko-bot
2026-06-09  7:17 ` [PATCH 5/7] ASoC: codecs: ES8389: Add private members related to HPF Zhang Yi
2026-06-09  7:30   ` sashiko-bot
2026-06-09  7:17 ` [PATCH 6/7] ASoC: codecs: ES8389: Add INPUTL MUX and INPUTR MUX Zhang Yi
2026-06-09  7:17 ` [PATCH 7/7] ASoC: dt-bindings: ES8389: Add members about HPF and clock Zhang Yi
  -- strict thread matches above, loose matches on Subject: below --
2026-06-09  3:06 [PATCH 0/7] ASoC: codecs: ES8389: Modify the ES8389 driver Zhang Yi
2026-06-09  3:06 ` [PATCH 2/7] ASoC: codecs: ES8389: Fix the issue about mclk_src Zhang Yi
2026-06-09  3:20   ` sashiko-bot
2026-06-09  7:34   ` Krzysztof Kozlowski
2026-06-09  2:55 [PATCH 0/7] ASoC: codecs: ES8389: Modify the ES8389 driver Zhang Yi
2026-06-09  2:56 ` [PATCH 2/7] ASoC: codecs: ES8389: Fix the issue about mclk_src Zhang Yi
2026-06-09  3:11   ` sashiko-bot

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=20260609073613.1549D1F00893@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