Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Neil Armstrong" <neil.armstrong@linaro.org>
Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 19/19] ASoC: qcom: sc8280xp: allow using the sc8280xp card with lpass-cpu
Date: Fri, 04 Dec 2026 17:54:39 +0000	[thread overview]
Message-ID: <sashiko-outbox-250356@kernel.org> (raw)
In-Reply-To: <20261204-topic-sm8650-el2-v3-19-8384ef0ac751@linaro.org>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] ASoC: qcom: sc8280xp: unreachable DSP bypass branch in
  sc8280xp_add_be_ops()
- [High] ASoC: qcom: common: qcom_snd_wcd_jack_setup() breaks Shikra
  QAIF WCD jack
- [Medium] ASoC: qcom: sc8280xp: missing WCD jack cleanup on DSP Bypass
  link exit
--

commit dace9fcff95da852db0ba7dfceee710b6ccfd008
Author: Neil Armstrong <neil.armstrong@linaro.org>

ASoC: qcom: sc8280xp: allow using the sc8280xp card with lpass-cpu

This commit adds LPASS CPU DAI init and ops callbacks to the sc8280xp
machine driver for non-DPCM DSP bypass links, and extends
qcom_snd_wcd_jack_setup() to attach the WCD headset jack on LPASS TX
codec DMA DAIs.

> diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c
> index 77845d43c2194..4b7cda8070b30 100644
> --- a/sound/soc/qcom/common.c
> +++ b/sound/soc/qcom/common.c

[ ... ]

> @@ -420,26 +421,36 @@ int qcom_snd_wcd_jack_setup(struct snd_soc_pcm_runtime *rtd,
>  	if (rval)
>  		return rval;
>  
> -	switch (cpu_dai->id) {
> -	case LPI_MI2S_RX_0:
> -	case TX_CODEC_DMA_TX_0:
> -	case TX_CODEC_DMA_TX_1:
> -	case TX_CODEC_DMA_TX_2:
> -	case TX_CODEC_DMA_TX_3:
> -	case VA_CODEC_DMA_TX_1:
> -		for_each_rtd_codec_dais(rtd, i, codec_dai) {
> -			rval = snd_soc_component_set_jack(codec_dai->component,
> -							  jack, NULL);
> -			if (rval != 0 && rval != -ENOTSUPP) {
> -				dev_warn(card->dev, "Failed to set jack: %d\n", rval);
> -				return rval;
> -			}
> +	if (qcom_snd_is_dsp_bypass_link(rtd)) {
> +		switch (cpu_dai->id) {
> +		case LPASS_CDC_DMA_TX0 ... LPASS_CDC_DMA_TX3:
> +			break;
> +		default:
> +			return 0;
> +		}
> +	} else {
> +		switch (cpu_dai->id) {
> +		case LPI_MI2S_RX_0:
> +		case TX_CODEC_DMA_TX_0:
> +		case TX_CODEC_DMA_TX_1:
> +		case TX_CODEC_DMA_TX_2:
> +		case TX_CODEC_DMA_TX_3:
> +		case VA_CODEC_DMA_TX_1:
> +			break;
> +		default:
> +			return 0;
>  		}
> +	}
>  
> -		break;
> -	default:
> -		break;
> +	for_each_rtd_codec_dais(rtd, i, codec_dai) {
> +		rval = snd_soc_component_set_jack(codec_dai->component,
> +						  jack, NULL);
> +		if (rval != 0 && rval != -ENOTSUPP) {
> +			dev_warn(card->dev, "Failed to set jack: %d\n", rval);
> +			return rval;
> +		}
>  	}
> +
>  	return 0;
>  }

[Severity: High]
Does splitting on qcom_snd_is_dsp_bypass_link() regress WCD headset jack
setup on Shikra QAIF cards?

qcom_snd_is_dsp_bypass_link() returns true whenever neither no_pcm nor
dynamic is set.  Shikra cards (qcom,shikra-cqm-sndcard and
qcom,shikra-cqs-sndcard) also use plain CPU-to-codec links with no
platform node, so both flags are zero, yet qaif-shikra.c uses Q6DSP DAI
IDs including VA_CODEC_DMA_TX_1 from commit 6d2524f0d360 ("ASoC: qcom:
sc8280xp: add backend handling for Shikra sound cards").  With this
change, VA_CODEC_DMA_TX_1 takes the bypass branch, misses
LPASS_CDC_DMA_TX0 ... LPASS_CDC_DMA_TX3, and returns without calling
snd_soc_component_set_jack(), leaving the headset jack detached.

> diff --git a/sound/soc/qcom/sc8280xp.c b/sound/soc/qcom/sc8280xp.c
> index f655b3ae1d5bf..89f14d4350059 100644
> --- a/sound/soc/qcom/sc8280xp.c
> +++ b/sound/soc/qcom/sc8280xp.c

[ ... ]

> @@ -570,6 +654,10 @@ static void sc8280xp_add_be_ops(struct snd_soc_card *card)
>  			link->exit = sc8280xp_snd_exit;
>  			link->be_hw_params_fixup = sc8280xp_be_hw_params_fixup;
>  			link->ops = &sc8280xp_be_ops;
> +		} else if (!link->dynamic) {
> +			/* DSP Bypass link, neither a DPCM frontend nor a backend */
> +			link->init = sc8280xp_lpass_snd_init;
> +			link->ops = &sc8280xp_lpass_ops;
>  		}
>  	}
>  }

[Severity: High]
Is this new else if (!link->dynamic) branch unreachable dead code?

The preceding condition in sc8280xp_add_be_ops() already matches every
link where !link->dynamic is true:

sound/soc/qcom/sc8280xp.c:sc8280xp_add_be_ops() {
	...
		if (link->no_pcm == 1 || !link->dynamic) {
			link->init = sc8280xp_snd_init;
			link->exit = sc8280xp_snd_exit;
			link->be_hw_params_fixup = sc8280xp_be_hw_params_fixup;
			link->ops = &sc8280xp_be_ops;
		} else if (!link->dynamic) {
	...
}

Because sc8280xp_lpass_snd_init() and sc8280xp_lpass_ops are never
attached, lpass-cpu links keep using sc8280xp_snd_init() and
sc8280xp_be_ops.  Due to overlapping DAI IDs, LPASS_CDC_DMA_TX0..TX3
collide with PRIMARY_MI2S_RX ... QUATERNARY_MI2S_TX in
sc8280xp_snd_hw_params() and fail hw_params with -ENOTSUPP when
mi2s_mclk_enable or mi2s_bclk_enable is set (lpass-cdc-dma DAIs have no
set_sysclk), while LPASS_CDC_DMA_WSA_RX0..1 skip the speaker volume
limits and LPASS_DP_RX skips DP jack setup.

Simply dropping || !link->dynamic from the first if would regress Shikra
QAIF cards from commit 6d2524f0d360 ("ASoC: qcom: sc8280xp: add backend
handling for Shikra sound cards"), which also have !no_pcm && !dynamic
links using Q6DSP DAI IDs, so lpass-cpu links need to be distinguished
from qaif-cpu links explicitly.

[Severity: Medium]
Can omitting link->exit for DSP bypass links cause a use-after-free on
data->jack.jack after card unbind and rebind?

sc8280xp_snd_data is devm-allocated on the card platform device, so
data->jack and data->jack_setup survive snd_soc_card_unbind() and
snd_soc_card_rebind() (for example on component unregister/re-register or
bind rollback).  During unbind, snd_card_free() frees data->jack.jack
through snd_jack_dev_free(), while data->jack_setup stays true because no
link->exit callback resets it (and sc8280xp_snd_exit() only clears it for
SC8280XP_JACK_SETUP_CODEC).

When the card rebinds, sc8280xp_lpass_snd_init() ->
qcom_snd_wcd_jack_setup() -> qcom_snd_headset_jack_init() skips
recreating data->jack.jack because data->jack_setup is still true, and
re-attaches the dangling &data->jack to the WCD codec.  The next headset
jack event in snd_soc_jack_report() -> snd_jack_report() then
dereferences the freed struct snd_jack.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-topic-sm8650-el2-v3-0-8384ef0ac751@linaro.org?part=19

      reply	other threads:[~2026-12-04 17:54 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 15:53 [PATCH v3 00/19] arm64: qcom: enable SM8650 audio without ADSP firmware Neil Armstrong
2026-12-04 15:53 ` [PATCH v3 01/19] ASoC: qcom: lpass-cpu: fix RXTX WRDMA current address register readability Neil Armstrong
2026-12-04 15:53 ` [PATCH v3 02/19] ASoC: qcom: lpass-platform: disable the RXTX & VA DMA interrupts on stop Neil Armstrong
2026-12-04 15:53 ` [PATCH v3 03/19] ASoC: dt-bindings: qcom,lpass: add Senary & Septenary MI2S ids Neil Armstrong
2026-12-04 15:53 ` [PATCH v3 04/19] ASoC: dt-bindings: qcom,lpass: add WSA RX and TX channels ids Neil Armstrong
2026-12-04 15:53 ` [PATCH v3 05/19] ASoC: dt-bindings: qcom,lpass-*-macro: document less clock when ADSP is not used Neil Armstrong
2026-12-04 16:20   ` sashiko-bot
2026-12-04 15:53 ` [PATCH v3 06/19] ASoC: dt-bindings: qcom,lpass-cpu: document the SM8650 LPASS Neil Armstrong
2026-12-04 15:53 ` [PATCH v3 07/19] ASoC: codecs: lpass-wsa-macro: handle the macro & dcodec power domains Neil Armstrong
2026-12-04 15:53 ` [PATCH v3 08/19] ASoC: qcom: lpass-cpu: get the optional codec_mem3 clock Neil Armstrong
2026-12-04 15:53 ` [PATCH v3 09/19] ASoC: qcom: lpass: add support for optional WSA interface Neil Armstrong
2026-12-04 16:49   ` sashiko-bot
2026-12-04 15:53 ` [PATCH v3 10/19] ASoC: qcom: lpass-cdc-dma: add support for WSA codec DMA Neil Armstrong
2026-12-04 16:47   ` sashiko-bot
2026-12-04 15:53 ` [PATCH v3 11/19] ASoC: qcom: lpass: prepare to handle multiple lpaifs for i2s Neil Armstrong
2026-12-04 15:53 ` [PATCH v3 12/19] ASoC: qcom: lpass: add support for MI2S_SENARY & MI2S_SEPTENARY Neil Armstrong
2026-12-04 15:53 ` [PATCH v3 13/19] ASoC: qcom: lpass: support mapping I2S ports to multiple LPAIFs Neil Armstrong
2026-12-04 17:10   ` sashiko-bot
2026-12-04 15:53 ` [PATCH v3 14/19] ASoC: qcom: lpass: support LPM memory type for I2S LPAIFs Neil Armstrong
2026-12-04 17:08   ` sashiko-bot
2026-12-04 15:53 ` [PATCH v3 15/19] ASoC: qcom: lpass: allocate LPM buffer memory to DAIs Neil Armstrong
2026-12-04 17:33   ` sashiko-bot
2026-12-04 15:53 ` [PATCH v3 16/19] ASoC: qcom: lpass: enable the right codec_mem clock when usin LPM memory Neil Armstrong
2026-12-04 17:28   ` sashiko-bot
2026-12-04 15:53 ` [PATCH v3 17/19] ASoC: qcom: add SM8650 LPASS CPU driver Neil Armstrong
2026-12-04 17:42   ` sashiko-bot
2026-12-04 15:53 ` [PATCH v3 18/19] ASoC: qcom: sdw: allow LPASS_CDC_DMA_WSA_RX0 as soundwire dai Neil Armstrong
2026-12-04 17:52   ` sashiko-bot
2026-12-04 15:53 ` [PATCH v3 19/19] ASoC: qcom: sc8280xp: allow using the sc8280xp card with lpass-cpu Neil Armstrong
2026-12-04 17:54   ` 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-250356@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=neil.armstrong@linaro.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