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 09/19] ASoC: qcom: lpass: add support for optional WSA interface
Date: Fri, 04 Dec 2026 16:49:49 +0000 [thread overview]
Message-ID: <sashiko-outbox-250234@kernel.org> (raw)
In-Reply-To: <20261204-topic-sm8650-el2-v3-9-8384ef0ac751@linaro.org>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] ASoC: qcom: lpass: race between lpass_platform_wsaif_irq() and
close()
- [Medium] ASoC: qcom: lpass: missing wsa_lpaif_map regcache sync on
suspend/resume
- [Low] ASoC: qcom: lpass: missing regmap name in
lpass_wsa_regmap_config
- [Low] ASoC: qcom: lpass: lpass_platform_wsa_hardware duplicates rxtx
struct
--
commit be7127fbdf093a9c69f87b524efb6d872b0f934c
Author: Neil Armstrong <neil.armstrong@linaro.org>
ASoC: qcom: lpass: add support for optional WSA interface
This commit adds optional WSA LPAIF regmap, DMA control, IRQ, and PCM
platform support for the Qualcomm LPASS codec DMA driver.
> diff --git a/sound/soc/qcom/lpass-cpu.c b/sound/soc/qcom/lpass-cpu.c
> index 3089107442231..db7a0752edb2f 100644
> --- a/sound/soc/qcom/lpass-cpu.c
> +++ b/sound/soc/qcom/lpass-cpu.c
[ ... ]
> @@ -984,6 +1076,16 @@ static struct regmap_config lpass_va_regmap_config = {
> .cache_type = REGCACHE_FLAT,
> };
>
> +static struct regmap_config lpass_wsa_regmap_config = {
> + .reg_bits = 32,
> + .reg_stride = 4,
> + .val_bits = 32,
> + .writeable_reg = lpass_wsa_regmap_writeable,
> + .readable_reg = lpass_wsa_regmap_readable,
> + .volatile_reg = lpass_wsa_regmap_volatile,
> + .cache_type = REGCACHE_FLAT,
> +};
[Severity: Low]
Should lpass_wsa_regmap_config set .name (for example "lpass_wsa"), like
lpass_cpu_regmap_config and lpass_hdmi_regmap_config do?
Because drvdata->wsa_lpaif_map is registered on the same platform device as
the earlier unnamed drvdata->rxtx_lpaif_map, regmap_debugfs_init() collides
on the bare device name and fails with -EEXIST, leaving the WSA regmap
unexposed in debugfs when CONFIG_DEBUG_FS is enabled.
[ ... ]
> @@ -1143,6 +1254,18 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
> if (IS_ERR(drvdata->va_lpaif_map))
> return PTR_ERR(drvdata->va_lpaif_map);
>
> + if (drvdata->wsa_enable) {
> + lpass_wsa_regmap_config.max_register = LPAIF_CDC_WSA_WRDMAPER_REG(variant,
> + variant->wsa_wrdma_channels +
> + variant->wsa_wrdma_channel_start,
> + LPASS_CDC_DMA_WSA_TX0);
> +
> + drvdata->wsa_lpaif_map = devm_regmap_init_mmio(dev, drvdata->wsa_lpaif,
> + &lpass_wsa_regmap_config);
> + if (IS_ERR(drvdata->wsa_lpaif_map))
> + return PTR_ERR(drvdata->wsa_lpaif_map);
> + }
[Severity: Medium]
Does drvdata->wsa_lpaif_map need to be handled in
lpass_platform_pcmops_suspend() and lpass_platform_pcmops_resume() alongside
lpaif_map and hdmiif_map?
lpass_wsa_regmap_config uses REGCACHE_FLAT and lpass_platform_wsa_hardware
advertises SNDRV_PCM_INFO_RESUME, so resuming a suspended stream runs
TRIGGER_RESUME without re-running prepare(). If the WSA LPAIF loses state
across suspend, DMA base, buffer, and period registers are never restored.
For a stream left in PREPARED state across suspend, the unsynced flat cache
can also return a stale cached dmactl->enable value and cause
regmap_fields_write() to skip writing to hardware.
> diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c
> index 7dfcae4e6fdaa..902c13c6f2e66 100644
> --- a/sound/soc/qcom/lpass-platform.c
> +++ b/sound/soc/qcom/lpass-platform.c
> @@ -97,6 +97,30 @@ static const struct snd_pcm_hardware lpass_platform_va_hardware = {
> .fifo_size = 0,
> };
>
> +static const struct snd_pcm_hardware lpass_platform_wsa_hardware = {
> + .info = SNDRV_PCM_INFO_MMAP |
> + SNDRV_PCM_INFO_MMAP_VALID |
> + SNDRV_PCM_INFO_INTERLEAVED |
> + SNDRV_PCM_INFO_PAUSE |
> + SNDRV_PCM_INFO_RESUME,
> + .formats = SNDRV_PCM_FMTBIT_S16 |
> + SNDRV_PCM_FMTBIT_S24 |
> + SNDRV_PCM_FMTBIT_S32,
> + .rates = SNDRV_PCM_RATE_8000_192000,
> + .rate_min = 8000,
> + .rate_max = 192000,
> + .channels_min = 1,
> + .channels_max = 8,
> + .buffer_bytes_max = LPASS_RXTX_CDC_DMA_LPM_BUFF_SIZE,
> + .period_bytes_max = LPASS_RXTX_CDC_DMA_LPM_BUFF_SIZE /
> + LPASS_PLATFORM_PERIODS,
> + .period_bytes_min = LPASS_RXTX_CDC_DMA_LPM_BUFF_SIZE /
> + LPASS_PLATFORM_PERIODS,
> + .periods_min = LPASS_PLATFORM_PERIODS,
> + .periods_max = LPASS_PLATFORM_PERIODS,
> + .fifo_size = 0,
> +};
[Severity: Low]
Can WSA reuse lpass_platform_rxtx_hardware directly instead of duplicating
it? Every field in lpass_platform_wsa_hardware is identical to
lpass_platform_rxtx_hardware, including the LPASS_RXTX_CDC_DMA_LPM_BUFF_SIZE
buffer and period sizes.
[ ... ]
> @@ -1117,6 +1235,35 @@ static irqreturn_t lpass_platform_vaif_irq(int irq, void *data)
> return IRQ_HANDLED;
> }
>
> +static irqreturn_t lpass_platform_wsaif_irq(int irq, void *data)
> +{
> + struct lpass_data *drvdata = data;
> + const struct lpass_variant *v = drvdata->variant;
> + unsigned int irqs;
> + irqreturn_t rv;
> + int chan;
> +
> + rv = regmap_read(drvdata->wsa_lpaif_map,
> + LPAIF_WSA_IRQSTAT_REG(v, LPAIF_IRQ_PORT_HOST), &irqs);
> + if (rv) {
> + pr_err("error reading from wsa irqstat reg: %d\n", rv);
> + return IRQ_NONE;
> + }
> +
> + /* Handle per channel interrupts */
> + for (chan = 0; chan < LPASS_MAX_CDC_DMA_CHANNELS; chan++) {
> + if (irqs & LPAIF_IRQ_ALL(chan) && drvdata->wsa_substream[chan]) {
> + rv = lpass_dma_interrupt_handler(
> + drvdata->wsa_substream[chan],
> + drvdata, chan, irqs);
> + if (rv != IRQ_HANDLED)
> + return rv;
> + }
> + }
> +
> + return IRQ_HANDLED;
> +}
[Severity: High]
Can lpass_platform_wsaif_irq() race with lpass_platform_pcmops_close() and
cause a use-after-free of substream->runtime?
lpass_platform_pcmops_trigger(STOP) only masks the interrupt, and neither
lpass_platform_pcmops_close() nor a .sync_stop callback calls
synchronize_irq(drvdata->wsaif_irq) before snd_pcm_detach_substream() frees
runtime:
CPU0 CPU1
lpass_platform_wsaif_irq() snd_pcm_release_substream()
load drvdata->wsa_substream[chan] lpass_platform_pcmops_trigger(STOP)
lpass_platform_pcmops_close()
drvdata->wsa_substream[ch] = NULL
snd_pcm_detach_substream()
kfree(runtime)
lpass_dma_interrupt_handler(...)
snd_pcm_period_elapsed(substream)
... dereference runtime <-- use-after-free
In addition, drvdata->wsa_substream[chan] is read twice without locking or
READ_ONCE(), so clearing it between the check and the call can pass NULL to
lpass_dma_interrupt_handler() and trigger a NULL pointer dereference in
hardirq context.
Calling synchronize_irq(drvdata->wsaif_irq) after clearing the slot in
lpass_platform_pcmops_close() (or implementing .sync_stop) and loading the
substream pointer once with READ_ONCE() would close both windows.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-topic-sm8650-el2-v3-0-8384ef0ac751@linaro.org?part=9
next prev parent reply other threads:[~2026-12-04 16:49 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 [this message]
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
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-250234@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