From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Cc: Ohad Ben-Cohen <ohad@wizery.com>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH] remoteproc: stm32: fix mbox_send_message call
Date: Thu, 27 May 2021 22:26:52 -0500 [thread overview]
Message-ID: <YLBi/JZ0u8394tI8@builder.lan> (raw)
In-Reply-To: <20210420091922.29429-1-arnaud.pouliquen@foss.st.com>
On Tue 20 Apr 04:19 CDT 2021, Arnaud Pouliquen wrote:
> mbox_send_message is called by passing a local dummy message or
> a function parameter. As the message is queued, it is dereferenced.
> This works because the message field is not used by the stm32 ipcc
> driver, but it is not clean.
>
> Fix by passing a constant string in all cases.
>
> The associated comments are removed because rproc should not have to
> deal with the behavior of the mailbox frame.
>
Didn't we conclude that the mailbox driver doesn't actually dereference
the pointer being passed?
If so I would prefer that you just pass NULL, so that if you in the
future need to pass some actual data it will be easy to distinguish the
old and new case.
Regards,
Bjorn
> Reported-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
> ---
> drivers/remoteproc/stm32_rproc.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c
> index 7353f9e7e7af..0e8203a432ab 100644
> --- a/drivers/remoteproc/stm32_rproc.c
> +++ b/drivers/remoteproc/stm32_rproc.c
> @@ -474,14 +474,12 @@ static int stm32_rproc_attach(struct rproc *rproc)
> static int stm32_rproc_detach(struct rproc *rproc)
> {
> struct stm32_rproc *ddata = rproc->priv;
> - int err, dummy_data, idx;
> + int err, idx;
>
> /* Inform the remote processor of the detach */
> idx = stm32_rproc_mbox_idx(rproc, STM32_MBX_DETACH);
> if (idx >= 0 && ddata->mb[idx].chan) {
> - /* A dummy data is sent to allow to block on transmit */
> - err = mbox_send_message(ddata->mb[idx].chan,
> - &dummy_data);
> + err = mbox_send_message(ddata->mb[idx].chan, "stop");
> if (err < 0)
> dev_warn(&rproc->dev, "warning: remote FW detach without ack\n");
> }
> @@ -493,15 +491,13 @@ static int stm32_rproc_detach(struct rproc *rproc)
> static int stm32_rproc_stop(struct rproc *rproc)
> {
> struct stm32_rproc *ddata = rproc->priv;
> - int err, dummy_data, idx;
> + int err, idx;
>
> /* request shutdown of the remote processor */
> if (rproc->state != RPROC_OFFLINE) {
> idx = stm32_rproc_mbox_idx(rproc, STM32_MBX_SHUTDOWN);
> if (idx >= 0 && ddata->mb[idx].chan) {
> - /* a dummy data is sent to allow to block on transmit */
> - err = mbox_send_message(ddata->mb[idx].chan,
> - &dummy_data);
> + err = mbox_send_message(ddata->mb[idx].chan, "detach");
> if (err < 0)
> dev_warn(&rproc->dev, "warning: remote FW shutdown without ack\n");
> }
> @@ -556,7 +552,7 @@ static void stm32_rproc_kick(struct rproc *rproc, int vqid)
> continue;
> if (!ddata->mb[i].chan)
> return;
> - err = mbox_send_message(ddata->mb[i].chan, (void *)(long)vqid);
> + err = mbox_send_message(ddata->mb[i].chan, "kick");
> if (err < 0)
> dev_err(&rproc->dev, "%s: failed (%s, err:%d)\n",
> __func__, ddata->mb[i].name, err);
> --
> 2.17.1
>
next prev parent reply other threads:[~2021-05-28 3:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-20 9:19 [PATCH] remoteproc: stm32: fix mbox_send_message call Arnaud Pouliquen
2021-05-28 3:26 ` Bjorn Andersson [this message]
2021-05-28 8:03 ` Arnaud POULIQUEN
2021-06-22 7:56 ` Arnaud POULIQUEN
2021-06-23 18:45 ` Bjorn Andersson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YLBi/JZ0u8394tI8@builder.lan \
--to=bjorn.andersson@linaro.org \
--cc=arnaud.pouliquen@foss.st.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mathieu.poirier@linaro.org \
--cc=ohad@wizery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox