Re: [PATCH v2 0/3] ASoC: qcom: qdsp6: Fix audio after an ADSP restart

From: Ajay Kumar Nandam

Date: Tue Dec 01 2026 - 05:55:57 EST




On 11/30/2026 1:23 PM, Shawn Guo wrote:
On Qualcomm Nord, audio does not come back after an ADSP restart
(echo stop/start > /sys/class/remoteproc/remoteproc0/state). There are
two separate problems:

- The sound card takes 5 seconds to come back. The q6apm GPR service
probes about 0.5 ms after remoteproc reports the DSP up, which is
too early for SPF. SPF drops the command without replying, and
apm_probe() waits out the 5 second command timeout before the card
can bind. If the card binds earlier than that, its shared memory map
times out and the card fails to come up.

- Once the card is back, playback fails:

pcm1681 0-004c: Failed to enable sck: -6

The q6prm clock controller is a child of the q6prm GPR device, so it
is unregistered when the DSP stops. Its consumers stay bound, and
their clk handles are left pointing at clk_nodrv_ops. In addition,
the DSP forgets every clock request and vote when it stops, so
clocks that consumers held prepared across the restart are no
longer running.

Patch 1 polls SPF with a short per-command timeout before q6apm
registers its component.

Patch 2 makes q6dsp-lpass-clocks track prepared clocks, and adds
q6dsp_clock_dsp_down()/q6dsp_clock_dsp_up() so the DSP service driver
can mark them lost and request them again. On its own, it does not
change behaviour.

Patch 3 makes q6prm keep the clock controller device across DSP
restarts, parented to the remoteproc platform device, and calls the
new helpers from its probe and remove functions. No DT or binding
changes are needed.

Hi Shawn

I have been working independently on the same clock-controller lifetime issue after an ADSP restart, and I took a slightly different approach.

In my case, the clock-controller device is still destroyed and recreated. During the new provider's probe(), before the provider is marked bound, I re-add the consumer links using device_link_add(..., DL_FLAG_AUTOPROBE_CONSUMER). The links are therefore dormant when probe() returns, and device_links_driver_bound() subsequently picks up the consumers for reprobe. I have validated this across repeated ADSP restart cycles on Kodiak & Glymur setups.

I saw your comment that you tried re-adding the device link but the consumer was not automatically reprobed. Do you remember where in the provider lifecycle you added the link? I'm wondering whether the difference is that mine is added from inside the provider's probe() before it returns.

below is my patch so you can compare the two approaches.

Signed-off-by: Ajay Kumar Nandam <ajay.nandam@xxxxxxxxxxxxxxxx>
---
sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c | 53 ++++++++++++++++++++++
1 file changed, 53 insertions(+)

diff --git a/sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c b/sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c
index 94d96130245e..3cafdfee4e7e 100644
--- a/sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c
+++ b/sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c
@@ -8,6 +8,7 @@
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/of.h>
+#include <linux/of_platform.h>
#include <linux/slab.h>
#include <dt-bindings/sound/qcom,q6dsp-lpass-ports.h>
#include "q6dsp-lpass-clocks.h"
@@ -126,6 +127,55 @@ static struct clk_hw *q6dsp_of_clk_hw_get(struct of_phandle_args *clkspec,
return ERR_PTR(-ENOENT);
}

+/*
+ * Recreate provider-owned clock links after an audio DSP restart. fw_devlink
+ * creates these links only for the provider instance seen during boot.
+ */
+static void q6dsp_link_consumers(struct platform_device *pdev)
+{
+ struct device_node *prov_np = pdev->dev.of_node;
+ struct device_node *cnp = NULL;
+
+ for_each_node_with_property(cnp, "clocks") {
+ struct device_link *link;
+ struct of_phandle_args args;
+ struct platform_device *cdev;
+ bool refs_this = false;
+ int i, n;
+
+ /* A disabled node is never populated as a device; skip it. */
+ if (!of_device_is_available(cnp))
+ continue;
+
+ n = of_count_phandle_with_args(cnp, "clocks", "#clock-cells");
+ for (i = 0; i < n; i++) {
+ if (of_parse_phandle_with_args(cnp, "clocks",
+ "#clock-cells", i, &args))
+ continue;
+ if (args.np == prov_np)
+ refs_this = true;
+ of_node_put(args.np);
+ if (refs_this)
+ break;
+ }
+ if (!refs_this)
+ continue;
+
+ cdev = of_find_device_by_node(cnp);
+ if (!cdev)
+ continue;
+
+ /* Persistent managed link; probe ordering only, not runtime PM. */
+ link = device_link_add(&cdev->dev, &pdev->dev,
+ DL_FLAG_AUTOPROBE_CONSUMER);
+ if (!link)
+ dev_warn(&pdev->dev, "failed to link clock consumer %s\n",
+ dev_name(&cdev->dev));
+
+ put_device(&cdev->dev); /* of_find_device_by_node() ref */
+ }
+}
+
int q6dsp_clock_dev_probe(struct platform_device *pdev)
{
struct q6dsp_cc *cc;
@@ -180,6 +230,9 @@ int q6dsp_clock_dev_probe(struct platform_device *pdev)

dev_set_drvdata(dev, cc);

+ /* Recreate links while they are still dormant for autoprobe. */
+ q6dsp_link_consumers(pdev);
+
return 0;
}
EXPORT_SYMBOL_GPL(q6dsp_clock_dev_probe);
--
2.43.0





Changes for v2:
- Rebase on next-20261127
- Patch 3: Explain in the commit message why correcting the fw_devlink
supplier of the clock consumers does not help (Srini)
- Link to v1: https://lore.kernel.org/all/20261115032027.414953-1-shengchao.guo@xxxxxxxxxxxxxxxx/

Shawn Guo (3):
ASoC: qcom: q6apm: Wait for SPF to be ready before registering
ASoC: qcom: q6dsp-lpass-clocks: Restore clocks after a DSP restart
ASoC: qcom: q6prm: Keep the clock controller across DSP restarts

sound/soc/qcom/Kconfig | 1 +
sound/soc/qcom/qdsp6/q6apm.c | 50 +++++-
sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c | 147 ++++++++++++++---
sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.h | 2 +
sound/soc/qcom/qdsp6/q6prm.c | 190 ++++++++++++++++++++--
5 files changed, 350 insertions(+), 40 deletions(-)