remoteproc: k3-dsp: Assert local reset during .prepare callback
authorBeleswar Padhi <b-padhi@ti.com>
Tue, 13 May 2025 05:44:58 +0000 (11:14 +0530)
committerMathieu Poirier <mathieu.poirier@linaro.org>
Tue, 20 May 2025 17:19:11 +0000 (11:19 -0600)
The ti_k3_dsp_remoteproc.c driver asserts the local reset in probe
and releases the module reset in .prepare callback. This is done to
ensure the core does not execute bogus code when module reset is
deasserted.

Put both of these operations together in .prepare callback, which is
more suitable as it ensures local reset is asserted for subsequent core
start operations from sysfs. This is done to align the .prepare callback
of DSP with the M4 driver which can be factored out at a later stage.

Signed-off-by: Beleswar Padhi <b-padhi@ti.com>
Tested-by: Judith Mendez <jm@ti.com>
Reviewed-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20250513054510.3439842-25-b-padhi@ti.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
drivers/remoteproc/ti_k3_dsp_remoteproc.c

index 9037e39..a437153 100644 (file)
@@ -44,6 +44,22 @@ static int k3_dsp_rproc_prepare(struct rproc *rproc)
        if (rproc->state == RPROC_DETACHED)
                return 0;
 
+       /*
+        * Ensure the local reset is asserted so the core doesn't
+        * execute bogus code when the module reset is released.
+        */
+       if (kproc->data->uses_lreset) {
+               ret = k3_rproc_reset(kproc);
+               if (ret)
+                       return ret;
+
+               ret = reset_control_status(kproc->reset);
+               if (ret <= 0) {
+                       dev_err(dev, "local reset still not asserted\n");
+                       return ret;
+               }
+       }
+
        ret = kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci,
                                                    kproc->ti_sci_id);
        if (ret)
@@ -471,20 +487,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)
                rproc->state = RPROC_DETACHED;
        } else {
                dev_info(dev, "configured DSP for remoteproc mode\n");
-               /*
-                * ensure the DSP local reset is asserted to ensure the DSP
-                * doesn't execute bogus code in .prepare() when the module
-                * reset is released.
-                */
-               if (data->uses_lreset) {
-                       ret = reset_control_status(kproc->reset);
-                       if (ret < 0) {
-                               return dev_err_probe(dev, ret, "failed to get reset status\n");
-                       } else if (ret == 0) {
-                               dev_warn(dev, "local reset is deasserted for device\n");
-                               k3_rproc_reset(kproc);
-                       }
-               }
        }
 
        ret = devm_rproc_add(dev, rproc);