Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "David Heidelberg" <david@ixit.cz>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH RFC v2 3/6] ASoC: qcom: sdm845: Use per-speaker RX masks for TDM slot assignment
Date: Thu, 03 Sep 2026 18:41:47 +0000	[thread overview]
Message-ID: <20260903184147.85C091F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260903-pixel3-audio-v2-3-7c22ed915291@ixit.cz>

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

Pre-existing issues:
- [High] Potential NULL pointer dereference when calling strcmp() on an unchecked codec_dai->component->name_prefix.
- [High] Improper reuse of the speaker playback mask (`SPK_TDM_RX_MASK`) for the CPU capture mask, causing dropped speaker feedback.
--

commit fc9c3ae11318fad7d402ab1b0d3e9652106e6e97
Author: David Heidelberg <david@ixit.cz>

ASoC: qcom: sdm845: Use per-speaker RX masks for TDM slot assignment
    
Both Left and Right codec DAIs were passing the same SPK_TDM_RX_MASK,
both speakers ended up on slot 0, breaking the one speaker in
configuration such as on Pixel 3.

> diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c
> index d1cc825fc5cdc..59cfa3b26cd4d 100644
> --- a/sound/soc/qcom/sdm845.c
> +++ b/sound/soc/qcom/sdm845.c
> @@ -157,7 +157,7 @@ static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream,
>  		if (!strcmp(codec_dai->component->name_prefix, "Left")) {

[Severity: High]
This isn't a regression introduced by this patch, but can this cause a kernel
panic if a device tree is missing the optional sound-name-prefix property?

If a local user opens the ALSA PCM device, it triggers
sdm845_tdm_snd_hw_params() which unconditionally passes
codec_dai->component->name_prefix to strcmp().

If the property is missing, name_prefix will be NULL. Can this strcmp()
dereference the NULL pointer and cause a panic?

This same unchecked dereference also occurs during PCM startup:

sound/soc/qcom/sdm845.c:sdm845_snd_startup() {
    ...
    for_each_rtd_codec_dais(rtd, j, codec_dai) {
        if (!strcmp(codec_dai->component->name_prefix, "Left")) {
            ...
        if (!strcmp(codec_dai->component->name_prefix, "Right")) {
    ...
}

>  			ret = snd_soc_dai_set_tdm_slot(
>  					codec_dai, LEFT_SPK_TDM_TX_MASK,
> -					SPK_TDM_RX_MASK, NUM_TDM_SLOTS,
> +					LEFT_SPK_TDM_RX_MASK, NUM_TDM_SLOTS,
>  					slot_width);
>  			if (ret < 0) {
>  				dev_err(rtd->dev,
> @@ -169,7 +169,7 @@ static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream,
>  		if (!strcmp(codec_dai->component->name_prefix, "Right")) {

[Severity: High]
This is the same pre-existing regression as above, but does this code
similarly panic if the sound-name-prefix property is missing for the right
codec?

>  			ret = snd_soc_dai_set_tdm_slot(
>  					codec_dai, RIGHT_SPK_TDM_TX_MASK,
> -					SPK_TDM_RX_MASK, NUM_TDM_SLOTS,
> +					RIGHT_SPK_TDM_RX_MASK, NUM_TDM_SLOTS,
>  					slot_width);
>  			if (ret < 0) {
>  				dev_err(rtd->dev,

[Severity: High]
This is a pre-existing regression cemented by an earlier patch in this series,
but does the CPU DAI capture configuration miss the speaker TX slots?

When a capture stream is opened, sdm845_tdm_snd_hw_params() configures the
capture mask:

sound/soc/qcom/sdm845.c:sdm845_tdm_snd_hw_params() {
    ...
    } else {
        ret = snd_soc_dai_set_tdm_slot(cpu_dai,
                                       SPK_TDM_RX_MASK |
                                       MIC_TDM_RX_MASK, 0,
                                       NUM_TDM_SLOTS, slot_width);
    ...
}

Because it uses SPK_TDM_RX_MASK | MIC_TDM_RX_MASK, it captures from slots 0-3.

This completely ignores LEFT_SPK_TDM_TX_MASK and RIGHT_SPK_TDM_TX_MASK. Does
this break the TDM routing for speaker IV sense feedback data transmitted on
slots 4-7?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260903-pixel3-audio-v2-0-7c22ed915291@ixit.cz?part=3

  reply	other threads:[~2026-09-03 18:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 18:26 [PATCH RFC v2 0/6] Speakers for Pixel 3 / 3 XL David Heidelberg via B4 Relay
2026-09-03 18:26 ` [PATCH RFC v2 1/6] ASoC: qcom: sdm845: Demystify TDM masks a bit David Heidelberg via B4 Relay
2026-09-03 18:40   ` sashiko-bot
2026-09-03 18:26 ` [PATCH RFC v2 2/6] ASoC: qcom: sdm845: use DSP_A format for TDM codec DAIs David Heidelberg via B4 Relay
2026-09-03 18:26 ` [PATCH RFC v2 3/6] ASoC: qcom: sdm845: Use per-speaker RX masks for TDM slot assignment David Heidelberg via B4 Relay
2026-09-03 18:41   ` sashiko-bot [this message]
2026-09-03 18:26 ` [PATCH RFC v2 4/6] ASoC: qcom: sdm845: Set codec dai and component sysclk during startup David Heidelberg via B4 Relay
2026-09-03 18:40   ` sashiko-bot
2026-09-03 18:26 ` [PATCH RFC v2 5/6] ASoC: cs35l36: Implement set_tdm_slot to program RX and TX slots David Heidelberg via B4 Relay
2026-09-03 18:40   ` sashiko-bot
2026-09-04  8:22   ` Konrad Dybcio
2026-09-04  9:26     ` Charles Keepax
2026-09-04  9:23   ` Charles Keepax
2026-09-03 18:26 ` [PATCH RFC v2 6/6] arm64: dts: qcom: sdm845-google: Add basic audio support David Heidelberg via B4 Relay

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=20260903184147.85C091F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=david@ixit.cz \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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