[<prev] [next>] [day] [month] [year] [list]
Message-ID: <591e219df99da6f02c9d402f7854bc3ab23e76f9.1726328417.git.christophe.jaillet@wanadoo.fr>
Date: Sat, 14 Sep 2024 17:41:13 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Bjorn Andersson <andersson@...nel.org>,
Mathieu Poirier <mathieu.poirier@...aro.org>,
Beleswar Padhi <b-padhi@...com>,
Andrew Davis <afd@...com>
Cc: linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org,
Christophe JAILLET <christophe.jaillet@...adoo.fr>,
linux-remoteproc@...r.kernel.org
Subject: [PATCH v3] remoteproc: k3-dsp: Fix an error handling path in k3_dsp_rproc_probe()
If an error occurs after mbox_request_channel() in
k3_dsp_rproc_request_mbox(), mbox_free_channel() must be called,
as already done in the remove function.
Instead of adding an error handling path in the probe and changing all
error handling in the function, add a new devm_add_action_or_reset() and
simplify the error handling path of k3_dsp_rproc_request_mbox() and the
.remove() function.
Fixes: ea1d6fb5b571 ("remoteproc: k3-dsp: Acquire mailbox handle during probe routine")
Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
Reviewed-by: Andrew Davis <afd@...com>
---
Compile tested only.
Change in v3:
- pass the correct variable to devm_add_action_or_reset() [Mathieu Poirier]
- move the devm_add_action_or_reset() call just after
mbox_request_channel() and simplify error handling in
k3_dsp_rproc_request_mbox()
- Because of these changes, remove previous R-b tag
Change in v2:
- fix the subject (cut'n'paste issue) [Andrew Davis]
- add R-b tag
v1: https://lore.kernel.org/all/9485e127a00419c76cf13dbccf4874af395ef6ba.1725653543.git.christophe.jaillet@wanadoo.fr/
---
drivers/remoteproc/ti_k3_dsp_remoteproc.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c
index 8be3f631c192..f0da29fa7f60 100644
--- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c
+++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c
@@ -224,6 +224,13 @@ static int k3_dsp_rproc_release(struct k3_dsp_rproc *kproc)
return ret;
}
+static void k3_dsp_free_channel(void *data)
+{
+ struct k3_dsp_rproc *kproc = data;
+
+ mbox_free_channel(kproc->mbox);
+}
+
static int k3_dsp_rproc_request_mbox(struct rproc *rproc)
{
struct k3_dsp_rproc *kproc = rproc->priv;
@@ -242,6 +249,10 @@ static int k3_dsp_rproc_request_mbox(struct rproc *rproc)
return dev_err_probe(dev, PTR_ERR(kproc->mbox),
"mbox_request_channel failed\n");
+ ret = devm_add_action_or_reset(dev, k3_dsp_free_channel, kproc);
+ if (ret)
+ return ret;
+
/*
* Ping the remote processor, this is only for sanity-sake for now;
* there is no functional effect whatsoever.
@@ -252,7 +263,6 @@ static int k3_dsp_rproc_request_mbox(struct rproc *rproc)
ret = mbox_send_message(kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST);
if (ret < 0) {
dev_err(dev, "mbox_send_message failed (%pe)\n", ERR_PTR(ret));
- mbox_free_channel(kproc->mbox);
return ret;
}
@@ -741,8 +751,6 @@ static void k3_dsp_rproc_remove(struct platform_device *pdev)
if (ret)
dev_err(dev, "failed to detach proc (%pe)\n", ERR_PTR(ret));
}
-
- mbox_free_channel(kproc->mbox);
}
static const struct k3_dsp_mem_data c66_mems[] = {
--
2.46.0
Powered by blists - more mailing lists