All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: "Bjorn Andersson" <andersson@kernel.org>,
	"Philipp Zabel" <p.zabel@pengutronix.de>,
	"Suman Anna" <s-anna@ti.com>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	"Udit Kumar" <u-kumar1@ti.com>,
	"Thomas Richard" <thomas.richard@bootlin.com>,
	"Gregory CLEMENT" <gregory.clement@bootlin.com>,
	"Hari Nagalla" <hnagalla@ti.com>,
	"Théo Lebrun" <theo.lebrun@bootlin.com>,
	linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] remoteproc: k3-r5: Fix IPC-only mode detection
Date: Fri, 28 Jun 2024 13:53:30 -0600	[thread overview]
Message-ID: <Zn8UumUllbGS4/p9@p14s> (raw)
In-Reply-To: <20240621150058.319524-2-richard.genoud@bootlin.com>

Good day,

On Fri, Jun 21, 2024 at 05:00:55PM +0200, Richard Genoud wrote:
> ret variable was used to test reset status, get from
> reset_control_status() call. But this variable was overwritten by
> ti_sci_proc_get_status() a few lines bellow.
> And as ti_sci_proc_get_status() returns 0 or a negative value (in this
> latter case, followed by a return), the expression !ret was always true,
> 
> Clearly, this was not what was intended:
> In the comment above it's said that "requires both local and module
> resets to be deasserted"; if reset_control_status() returns 0 it means
> that the reset line is deasserted.
> So, it's pretty clear that the return value of reset_control_status()
> was intended to be used instead of ti_sci_proc_get_status() return
> value.
> 
> This could lead in an incorrect IPC-only mode detection if reset line is
> asserted (so reset_control_status() return > 0) and c_state != 0 and
> halted == 0.
> In this case, the old code would have detected an IPC-only mode instead
> of a mismatched mode.
> 

Your assessment seems to be correct.  That said I'd like to have an RB or a TB
from someone in the TI delegation - guys please have a look.

Thanks,
Mathieu

> Fixes: 1168af40b1ad ("remoteproc: k3-r5: Add support for IPC-only mode for all R5Fs")
> Signed-off-by: Richard Genoud <richard.genoud@bootlin.com>
> ---
>  drivers/remoteproc/ti_k3_r5_remoteproc.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c
> index 50e486bcfa10..39a47540c590 100644
> --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c
> +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c
> @@ -1144,6 +1144,7 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc)
>  	u32 atcm_enable, btcm_enable, loczrama;
>  	struct k3_r5_core *core0;
>  	enum cluster_mode mode = cluster->mode;
> +	int reset_ctrl_status;
>  	int ret;
>  
>  	core0 = list_first_entry(&cluster->cores, struct k3_r5_core, elem);
> @@ -1160,11 +1161,11 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc)
>  			 r_state, c_state);
>  	}
>  
> -	ret = reset_control_status(core->reset);
> -	if (ret < 0) {
> +	reset_ctrl_status = reset_control_status(core->reset);
> +	if (reset_ctrl_status < 0) {
>  		dev_err(cdev, "failed to get initial local reset status, ret = %d\n",
> -			ret);
> -		return ret;
> +			reset_ctrl_status);
> +		return reset_ctrl_status;
>  	}
>  
>  	/*
> @@ -1199,7 +1200,7 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc)
>  	 * irrelevant if module reset is asserted (POR value has local reset
>  	 * deasserted), and is deemed as remoteproc mode
>  	 */
> -	if (c_state && !ret && !halted) {
> +	if (c_state && !reset_ctrl_status && !halted) {
>  		dev_info(cdev, "configured R5F for IPC-only mode\n");
>  		kproc->rproc->state = RPROC_DETACHED;
>  		ret = 1;
> @@ -1217,7 +1218,7 @@ static int k3_r5_rproc_configure_mode(struct k3_r5_rproc *kproc)
>  		ret = 0;
>  	} else {
>  		dev_err(cdev, "mismatched mode: local_reset = %s, module_reset = %s, core_state = %s\n",
> -			!ret ? "deasserted" : "asserted",
> +			!reset_ctrl_status ? "deasserted" : "asserted",
>  			c_state ? "deasserted" : "asserted",
>  			halted ? "halted" : "unhalted");
>  		ret = -EINVAL;

  reply	other threads:[~2024-06-28 19:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-21 15:00 [PATCH 0/4] remoteproc: k3-r5: Introduce suspend to ram support Richard Genoud
2024-06-21 15:00 ` [PATCH 1/4] remoteproc: k3-r5: Fix IPC-only mode detection Richard Genoud
2024-06-28 19:53   ` Mathieu Poirier [this message]
2024-06-28 19:58     ` Mathieu Poirier
2024-07-01  9:13       ` Hari Nagalla
2024-07-01 16:38         ` Mathieu Poirier
2024-06-21 15:00 ` [PATCH 2/4] remoteproc: k3-r5: Introduce PM suspend/resume handlers Richard Genoud
2024-06-28 20:48   ` Mathieu Poirier
2024-07-01  7:30     ` Richard GENOUD
2024-07-01 19:02   ` kernel test robot
2024-06-21 15:00 ` [PATCH 3/4] remoteproc: k3-r5: k3_r5_rproc_stop: code reorder Richard Genoud
2024-06-28 21:18   ` Mathieu Poirier
2024-07-01  8:03     ` Richard GENOUD
2024-07-01 16:35       ` Mathieu Poirier
2024-07-01 16:49         ` Richard GENOUD
2024-06-21 15:00 ` [PATCH 4/4] remoteproc: k3-r5: support for graceful stop of remote cores Richard Genoud
2024-06-28 21:20   ` Mathieu Poirier
2024-07-01 16:38     ` Richard GENOUD
2024-06-28 22:50   ` Andrew Davis
2024-07-01 16:48     ` Richard GENOUD
2024-07-01 21:55   ` kernel test robot
2024-06-28 21:23 ` [PATCH 0/4] remoteproc: k3-r5: Introduce suspend to ram support Mathieu Poirier
2024-07-01  9:59 ` Hari Nagalla
2024-07-08  7:33   ` Richard GENOUD

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=Zn8UumUllbGS4/p9@p14s \
    --to=mathieu.poirier@linaro.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andersson@kernel.org \
    --cc=gregory.clement@bootlin.com \
    --cc=hnagalla@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=s-anna@ti.com \
    --cc=theo.lebrun@bootlin.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=thomas.richard@bootlin.com \
    --cc=u-kumar1@ti.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.