Commit 57ec3c12 authored by Andrew Davis's avatar Andrew Davis Committed by Mathieu Poirier

remoteproc: k3-dsp: Add devm action to release tsp

Use a device lifecycle managed action to release tps ti_sci_proc handle.
This helps prevent mistakes like releasing out of order in cleanup
functions and forgetting to release on error paths.
Signed-off-by: default avatarAndrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20240205182753.36978-4-afd@ti.comSigned-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
parent 585fc027
...@@ -646,6 +646,13 @@ static void k3_dsp_reserved_mem_exit(struct k3_dsp_rproc *kproc) ...@@ -646,6 +646,13 @@ static void k3_dsp_reserved_mem_exit(struct k3_dsp_rproc *kproc)
iounmap(kproc->rmem[i].cpu_addr); iounmap(kproc->rmem[i].cpu_addr);
} }
static void k3_dsp_release_tsp(void *data)
{
struct ti_sci_proc *tsp = data;
ti_sci_proc_release(tsp);
}
static static
struct ti_sci_proc *k3_dsp_rproc_of_get_tsp(struct device *dev, struct ti_sci_proc *k3_dsp_rproc_of_get_tsp(struct device *dev,
const struct ti_sci_handle *sci) const struct ti_sci_handle *sci)
...@@ -682,7 +689,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) ...@@ -682,7 +689,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)
const char *fw_name; const char *fw_name;
bool p_state = false; bool p_state = false;
int ret = 0; int ret = 0;
int ret1;
data = of_device_get_match_data(dev); data = of_device_get_match_data(dev);
if (!data) if (!data)
...@@ -732,16 +738,17 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) ...@@ -732,16 +738,17 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)
dev_err_probe(dev, ret, "ti_sci_proc_request failed\n"); dev_err_probe(dev, ret, "ti_sci_proc_request failed\n");
return ret; return ret;
} }
ret = devm_add_action_or_reset(dev, k3_dsp_release_tsp, kproc->tsp);
if (ret)
return ret;
ret = k3_dsp_rproc_of_get_memories(pdev, kproc); ret = k3_dsp_rproc_of_get_memories(pdev, kproc);
if (ret) if (ret)
goto release_tsp; return ret;
ret = k3_dsp_reserved_mem_init(kproc); ret = k3_dsp_reserved_mem_init(kproc);
if (ret) { if (ret)
dev_err_probe(dev, ret, "reserved memory init failed\n"); return dev_err_probe(dev, ret, "reserved memory init failed\n");
goto release_tsp;
}
ret = kproc->ti_sci->ops.dev_ops.is_on(kproc->ti_sci, kproc->ti_sci_id, ret = kproc->ti_sci->ops.dev_ops.is_on(kproc->ti_sci, kproc->ti_sci_id,
NULL, &p_state); NULL, &p_state);
...@@ -793,10 +800,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) ...@@ -793,10 +800,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)
release_mem: release_mem:
k3_dsp_reserved_mem_exit(kproc); k3_dsp_reserved_mem_exit(kproc);
release_tsp:
ret1 = ti_sci_proc_release(kproc->tsp);
if (ret1)
dev_err(dev, "failed to release proc (%pe)\n", ERR_PTR(ret1));
return ret; return ret;
} }
...@@ -818,10 +821,6 @@ static void k3_dsp_rproc_remove(struct platform_device *pdev) ...@@ -818,10 +821,6 @@ static void k3_dsp_rproc_remove(struct platform_device *pdev)
rproc_del(kproc->rproc); rproc_del(kproc->rproc);
ret = ti_sci_proc_release(kproc->tsp);
if (ret)
dev_err(dev, "failed to release proc (%pe)\n", ERR_PTR(ret));
k3_dsp_reserved_mem_exit(kproc); k3_dsp_reserved_mem_exit(kproc);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment