* [PATCH 1/2] ASoC: qcom: q6apm: Guard callbacks until probe data is ready
2026-10-22 14:41 [PATCH 0/2] Fix GPR callback registration race during probe Mohit Sharma
@ 2026-10-22 14:41 ` Mohit Sharma
2026-10-22 14:41 ` [PATCH 2/2] soc: qcom: apr: Publish GPR callback before client probe Mohit Sharma
2026-11-02 22:38 ` (subset) [PATCH 0/2] Fix GPR callback registration race during probe Mark Brown
2 siblings, 0 replies; 5+ messages in thread
From: Mohit Sharma @ 2026-10-22 14:41 UTC (permalink / raw)
To: Srinivas Kandagatla, Bjorn Andersson, Mark Brown
Cc: Ajay Kumar Nandam, Liam Girdwood, Konrad Dybcio, Jaroslav Kysela,
Takashi Iwai, Krzysztof Kozlowski, linux-sound, linux-arm-msm,
linux-kernel, Mohit Sharma, stable
The GPR bus needs to make response callbacks available before invoking a
client probe because clients can issue synchronous commands from probe.
This creates a short interval where a callback can run before the client
has published its private data.
Make q6apm publish its driver data only after all callback-visible state
has been initialized. Have the q6apm and q6prm callbacks ignore packets
received before driver data is available.
Fixes: ec1471a898cc ("soc: qcom: apr: Add GPR support")
Cc: stable@vger.kernel.org
Co-developed-by: Ajay Kumar Nandam <ajay.nandam@oss.qualcomm.com>
Signed-off-by: Ajay Kumar Nandam <ajay.nandam@oss.qualcomm.com>
Signed-off-by: Mohit Sharma <mohit.sharma@oss.qualcomm.com>
---
sound/soc/qcom/qdsp6/q6apm.c | 6 ++++--
sound/soc/qcom/qdsp6/q6prm.c | 3 +++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c
index 3ec3c5a18c7a..dbebb643cd5e 100644
--- a/sound/soc/qcom/qdsp6/q6apm.c
+++ b/sound/soc/qcom/qdsp6/q6apm.c
@@ -872,8 +872,6 @@ static int apm_probe(gpr_device_t *gdev)
if (!apm)
return -ENOMEM;
- dev_set_drvdata(dev, apm);
-
mutex_init(&apm->lock);
apm->dev = dev;
apm->gdev = gdev;
@@ -887,6 +885,7 @@ static int apm_probe(gpr_device_t *gdev)
idr_init(&apm->modules_idr);
+ dev_set_drvdata(dev, apm);
g_apm = apm;
q6apm_get_apm_state(apm);
@@ -930,6 +929,9 @@ static int apm_callback(const struct gpr_resp_pkt *data, void *priv, int op)
const struct gpr_hdr *hdr = &data->hdr;
int graph_id, is_pos_buf;
+ if (!apm)
+ return 0;
+
result = data->payload;
switch (hdr->opcode) {
diff --git a/sound/soc/qcom/qdsp6/q6prm.c b/sound/soc/qcom/qdsp6/q6prm.c
index 2042ff1e8ff1..5c927ebd81f4 100644
--- a/sound/soc/qcom/qdsp6/q6prm.c
+++ b/sound/soc/qcom/qdsp6/q6prm.c
@@ -194,6 +194,9 @@ static int prm_callback(const struct gpr_resp_pkt *data, void *priv, int op)
const struct gpr_ibasic_rsp_result_t *result;
const struct gpr_hdr *hdr = &data->hdr;
+ if (!prm)
+ return 0;
+
switch (hdr->opcode) {
case PRM_CMD_RSP_REQUEST_HW_RSC:
case PRM_CMD_RSP_RELEASE_HW_RSC:
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 2/2] soc: qcom: apr: Publish GPR callback before client probe
2026-10-22 14:41 [PATCH 0/2] Fix GPR callback registration race during probe Mohit Sharma
2026-10-22 14:41 ` [PATCH 1/2] ASoC: qcom: q6apm: Guard callbacks until probe data is ready Mohit Sharma
@ 2026-10-22 14:41 ` Mohit Sharma
2026-11-14 15:25 ` Shawn Guo
2026-11-02 22:38 ` (subset) [PATCH 0/2] Fix GPR callback registration race during probe Mark Brown
2 siblings, 1 reply; 5+ messages in thread
From: Mohit Sharma @ 2026-10-22 14:41 UTC (permalink / raw)
To: Srinivas Kandagatla, Bjorn Andersson, Mark Brown
Cc: Ajay Kumar Nandam, Liam Girdwood, Konrad Dybcio, Jaroslav Kysela,
Takashi Iwai, Krzysztof Kozlowski, linux-sound, linux-arm-msm,
linux-kernel, Mohit Sharma, stable
A GPR service driver can issue synchronous commands from its probe path,
or populate child devices which issue commands before the parent probe
returns. The APR/GPR bus currently installs the GPR service callback only
after the service driver's probe has completed.
If a response arrives while the client probe is still running, GPR finds
the destination service but cannot dispatch the response because the
service callback is NULL. The client waiting for the response eventually
times out.
This was observed intermittently on Qualcomm Lemans and Monaco platforms
when q6apm child probing sent an APM shared-memory map command before the
parent probe returned. The failure has the following signature:
qcom-apm ... CMD timeout for [100100c] opcode
q6apm-dai ... Audio Start: Buffer Allocation failed rc = -110
snd-sc8280xp ... ASoC: can't create pcm MultiMedia1 Playback :-110
Install the GPR callback before invoking the client probe so responses to
probe-time commands can be dispatched. Clear the callback again if probe
fails, and preserve the existing callback ordering for APR clients.
Fixes: ec1471a898cc ("soc: qcom: apr: Add GPR support")
Cc: stable@vger.kernel.org
Co-developed-by: Ajay Kumar Nandam <ajay.nandam@oss.qualcomm.com>
Signed-off-by: Ajay Kumar Nandam <ajay.nandam@oss.qualcomm.com>
Signed-off-by: Mohit Sharma <mohit.sharma@oss.qualcomm.com>
---
drivers/soc/qcom/apr.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/soc/qcom/apr.c b/drivers/soc/qcom/apr.c
index ea7f83916d8d..829e5c8fdf98 100644
--- a/drivers/soc/qcom/apr.c
+++ b/drivers/soc/qcom/apr.c
@@ -365,13 +365,24 @@ static int apr_device_probe(struct device *dev)
{
struct apr_device *adev = to_apr_device(dev);
struct apr_driver *adrv = to_apr_driver(dev->driver);
+ struct packet_router *apr = dev_get_drvdata(dev->parent);
int ret;
+ if (apr->type == PR_TYPE_GPR)
+ adev->svc.callback = adrv->gpr_callback;
+
ret = adrv->probe(adev);
- if (!ret)
+ if (ret) {
+ if (apr->type == PR_TYPE_GPR)
+ adev->svc.callback = NULL;
+
+ return ret;
+ }
+
+ if (apr->type != PR_TYPE_GPR)
adev->svc.callback = adrv->gpr_callback;
- return ret;
+ return 0;
}
static void apr_device_remove(struct device *dev)
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 2/2] soc: qcom: apr: Publish GPR callback before client probe
2026-10-22 14:41 ` [PATCH 2/2] soc: qcom: apr: Publish GPR callback before client probe Mohit Sharma
@ 2026-11-14 15:25 ` Shawn Guo
0 siblings, 0 replies; 5+ messages in thread
From: Shawn Guo @ 2026-11-14 15:25 UTC (permalink / raw)
To: Mohit Sharma
Cc: Srinivas Kandagatla, Bjorn Andersson, Mark Brown,
Ajay Kumar Nandam, Liam Girdwood, Konrad Dybcio, Jaroslav Kysela,
Takashi Iwai, Krzysztof Kozlowski, linux-sound, linux-arm-msm,
linux-kernel, stable
On Thu, Oct 22, 2026 at 08:11:30PM +0530, Mohit Sharma wrote:
> A GPR service driver can issue synchronous commands from its probe path,
> or populate child devices which issue commands before the parent probe
> returns. The APR/GPR bus currently installs the GPR service callback only
> after the service driver's probe has completed.
>
> If a response arrives while the client probe is still running, GPR finds
> the destination service but cannot dispatch the response because the
> service callback is NULL. The client waiting for the response eventually
> times out.
>
> This was observed intermittently on Qualcomm Lemans and Monaco platforms
> when q6apm child probing sent an APM shared-memory map command before the
> parent probe returned. The failure has the following signature:
>
> qcom-apm ... CMD timeout for [100100c] opcode
> q6apm-dai ... Audio Start: Buffer Allocation failed rc = -110
> snd-sc8280xp ... ASoC: can't create pcm MultiMedia1 Playback :-110
>
> Install the GPR callback before invoking the client probe so responses to
> probe-time commands can be dispatched. Clear the callback again if probe
> fails, and preserve the existing callback ordering for APR clients.
>
> Fixes: ec1471a898cc ("soc: qcom: apr: Add GPR support")
> Cc: stable@vger.kernel.org
> Co-developed-by: Ajay Kumar Nandam <ajay.nandam@oss.qualcomm.com>
> Signed-off-by: Ajay Kumar Nandam <ajay.nandam@oss.qualcomm.com>
> Signed-off-by: Mohit Sharma <mohit.sharma@oss.qualcomm.com>
Thanks for the patch, Mohit! It fixes a 5s timeout with audio card probe
on Nord platform.
Without the patch:
[ 4.483213] qcom,apr 4c00000.remoteproc:glink-edge.adsp_apps.-1.-1: Adding APR/GPR dev: gprsvc:service:2:1
[ 4.483249] qcom,apr 4c00000.remoteproc:glink-edge.adsp_apps.-1.-1: Adding APR/GPR dev: gprsvc:service:2:2
[ 4.491115] platform 4c00000.remoteproc:glink-edge:fastrpc:compute-cb@3: Adding to iommu group 5
[ 4.492141] platform 4c00000.remoteproc:glink-edge:fastrpc:compute-cb@4: Adding to iommu group 6
[ 4.492727] platform 4c00000.remoteproc:glink-edge:fastrpc:compute-cb@5: Adding to iommu group 7
[ 4.493313] platform 4c00000.remoteproc:glink-edge:fastrpc:compute-cb@6: Adding to iommu group 8
[ 9.623909] qcom-apm gprsvc:service:2:1: CMD timeout for [1001021] opcode
[ 9.624571] platform 4c00000.remoteproc:glink-edge:gpr:service@1:dais: Adding to iommu group 61
[ 9.675293] snd-sc8280xp sound: ASoC: Parent card not yet available, widget card binding deferred
[ 9.678425] ALSA: Control name 'stream0.vol_ctrl0 MultiMedia1 Playback Volume' truncated to 'stream0.vol_ctrl0 MultiMedia1 Playback Volu'
With the patch:
[ 5.243457] qcom,apr 4c00000.remoteproc:glink-edge.adsp_apps.-1.-1: Adding APR/GPR dev: gprsvc:service:2:1
[ 5.243487] qcom,apr 4c00000.remoteproc:glink-edge.adsp_apps.-1.-1: Adding APR/GPR dev: gprsvc:service:2:2
[ 5.259454] platform 4c00000.remoteproc:glink-edge:fastrpc:compute-cb@3: Adding to iommu group 5
[ 5.260433] platform 4c00000.remoteproc:glink-edge:fastrpc:compute-cb@4: Adding to iommu group 6
[ 5.261131] platform 4c00000.remoteproc:glink-edge:fastrpc:compute-cb@5: Adding to iommu group 7
[ 5.261770] platform 4c00000.remoteproc:glink-edge:fastrpc:compute-cb@6: Adding to iommu group 8
[ 5.393166] snd-sc8280xp sound: ASoC: Parent card not yet available, widget card binding deferred
[ 5.395934] ALSA: Control name 'stream0.vol_ctrl0 MultiMedia1 Playback Volume' truncated to 'stream0.vol_ctrl0 MultiMedia1 Playback Volu'
So on Nord platform:
Tested-by: Shawn Guo <shengchao.guo@oss.qualcomm.com>
> ---
> drivers/soc/qcom/apr.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/soc/qcom/apr.c b/drivers/soc/qcom/apr.c
> index ea7f83916d8d..829e5c8fdf98 100644
> --- a/drivers/soc/qcom/apr.c
> +++ b/drivers/soc/qcom/apr.c
> @@ -365,13 +365,24 @@ static int apr_device_probe(struct device *dev)
> {
> struct apr_device *adev = to_apr_device(dev);
> struct apr_driver *adrv = to_apr_driver(dev->driver);
> + struct packet_router *apr = dev_get_drvdata(dev->parent);
> int ret;
>
> + if (apr->type == PR_TYPE_GPR)
I wonder whether it's really necessary to have this GPR condition guard.
How would it possibly cause problem for APR?
The code will be much cleaner without the GPR guard.
Shawn
> + adev->svc.callback = adrv->gpr_callback;
> +
> ret = adrv->probe(adev);
> - if (!ret)
> + if (ret) {
> + if (apr->type == PR_TYPE_GPR)
> + adev->svc.callback = NULL;
> +
> + return ret;
> + }
> +
> + if (apr->type != PR_TYPE_GPR)
> adev->svc.callback = adrv->gpr_callback;
>
> - return ret;
> + return 0;
> }
>
> static void apr_device_remove(struct device *dev)
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: (subset) [PATCH 0/2] Fix GPR callback registration race during probe
2026-10-22 14:41 [PATCH 0/2] Fix GPR callback registration race during probe Mohit Sharma
2026-10-22 14:41 ` [PATCH 1/2] ASoC: qcom: q6apm: Guard callbacks until probe data is ready Mohit Sharma
2026-10-22 14:41 ` [PATCH 2/2] soc: qcom: apr: Publish GPR callback before client probe Mohit Sharma
@ 2026-11-02 22:38 ` Mark Brown
2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-11-02 22:38 UTC (permalink / raw)
To: Srinivas Kandagatla, Bjorn Andersson, Mohit Sharma
Cc: Ajay Kumar Nandam, Liam Girdwood, Konrad Dybcio, Jaroslav Kysela,
Takashi Iwai, Krzysztof Kozlowski, linux-sound, linux-arm-msm,
linux-kernel
On Thu, 22 Oct 2026 20:11:28 +0530, Mohit Sharma wrote:
> Fix GPR callback registration race during probe
>
> GPR service drivers can issue synchronous commands directly from their
> probe callbacks or indirectly while populating child devices. The GPR
> bus currently publishes the service callback only after the client probe
> returns. Consequently, a DSP response received during probe cannot be
> dispatched and the command times out.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.4
Thanks!
[1/2] ASoC: qcom: q6apm: Guard callbacks until probe data is ready
https://git.kernel.org/broonie/sound/c/ef7062864c05
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread