Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ajay Kumar Nandam" <ajay.nandam@oss.qualcomm.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 3/3] ASoC: qcom: qdsp6: generalize GPR service domain
Date: Tue, 25 Aug 2026 18:54:51 +0000	[thread overview]
Message-ID: <20260825185451.61A291F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260826-a2a-shikra-vmid-v5-v2-3-c3dc62354eee@oss.qualcomm.com>

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

Pre-existing issues:
- [High] Global pointer `g_apm` is not cleared on driver removal, leading to a Use-After-Free.
- [High] Functions acquire a mutex and allocate memory with `GFP_KERNEL` while holding a spinlock with IRQs disabled.
--

commit bafa8aa7e49a38a568945d982b4109f80964d60c
Author: Ajay Kumar Nandam <ajay.nandam@oss.qualcomm.com>

ASoC: qcom: qdsp6: generalize GPR service domain

This commit generalizes the GPR destination domain in AudioReach to support 
targets where audio is served by the modem DSP instead of the ADSP. It 
updates the packet builders to dynamically stamp the correct domain from 
the device, rather than hardcoding it.

> diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c
> index f167b9dae3fa1..3ec3c5a18c7a2 100644
> --- a/sound/soc/qcom/qdsp6/q6apm.c
> +++ b/sound/soc/qcom/qdsp6/q6apm.c
> @@ -29,11 +29,13 @@ struct apm_graph_mgmt_cmd {
>  
>  static struct q6apm *g_apm;

[Severity: High]
This is a pre-existing issue, but does this code leave a dangling pointer
on driver removal?

The global pointer g_apm is assigned dynamically allocated memory during 
apm_probe(), which is bound to the device's lifecycle. However, apm_remove() 
fails to clear g_apm:

sound/soc/qcom/qdsp6/q6apm.c:apm_remove() {
	of_platform_depopulate(&gdev->dev);
	snd_soc_unregister_component(&gdev->dev);
}

The devres framework will free the apm structure automatically after removal. 
If another subsystem subsequently calls q6apm_is_adsp_ready(), it will 
dereference the freed pointer:

sound/soc/qcom/qdsp6/q6apm.c:q6apm_is_adsp_ready() {
	if (g_apm)
		return q6apm_get_apm_state(g_apm);
}

>  
> -int q6apm_send_cmd_sync(struct q6apm *apm, const struct gpr_pkt *pkt,
> +int q6apm_send_cmd_sync(struct q6apm *apm, struct gpr_pkt *pkt,
>  			uint32_t rsp_opcode)
>  {

[ ... ]

> @@ -502,6 +504,8 @@ int q6apm_write_async(struct q6apm_graph *graph, uint32_t len, uint32_t msw_ts,
>  
>  	mutex_unlock(&graph->lock);
>  
> +	pkt->hdr.dest_domain = audioreach_gpr_dest_domain(graph->apm->gdev);
> +

[Severity: High]
This is a pre-existing issue, but does calling this function result in a 
sleep-in-atomic bug?

Earlier in q6apm_write_async(), it calls audioreach_alloc_pkt(), which 
allocates memory with GFP_KERNEL. It also acquires a sleepable mutex via 
mutex_lock(&graph->lock).

However, callers in sound/soc/qcom/qdsp6/q6apm-dai.c such as 
event_handler_compr() and q6apm_compr_copy() call this while holding an 
IRQ-disabled spinlock:

sound/soc/qcom/qdsp6/q6apm-dai.c:event_handler_compr() {
	...
	guard(spinlock_irqsave)(&prtd->lock);
	...
	q6apm_write_async(prtd->graph, bytes_to_write, 0, 0, wflags);
}

Could this lead to schedule-while-atomic panics or deadlocks during compressed 
audio playback?

>  	return gpr_send_port_pkt(graph->port, pkt);
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260826-a2a-shikra-vmid-v5-v2-0-c3dc62354eee@oss.qualcomm.com?part=3

      reply	other threads:[~2026-08-25 18:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25 18:40 [PATCH v2 0/3] ASoC: qcom: enable audio on stage-2 protected DSPs (mDSP) Ajay Kumar Nandam
2026-08-25 18:40 ` [PATCH v2 1/3] dt-bindings: sound: qcom,q6apm-dai: add stage-2 (SCM/VMID) access model Ajay Kumar Nandam
2026-08-26 22:44   ` Mark Brown
2026-08-27  6:03   ` Krzysztof Kozlowski
2026-08-25 18:40 ` [PATCH v2 2/3] ASoC: qcom: q6apm-dai: add VMID-based SCM assignment for mDSP buffers Ajay Kumar Nandam
2026-08-25 18:57   ` sashiko-bot
2026-08-26 22:52   ` Mark Brown
2026-08-25 18:40 ` [PATCH v2 3/3] ASoC: qcom: qdsp6: generalize GPR service domain Ajay Kumar Nandam
2026-08-25 18: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=20260825185451.61A291F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ajay.nandam@oss.qualcomm.com \
    --cc=conor+dt@kernel.org \
    --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