linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scmi/optee: fix response size warning
@ 2022-06-24  7:45 Vincent Guittot
  2022-06-24  9:22 ` Cristian Marussi
  2022-06-29 10:05 ` Sudeep Holla
  0 siblings, 2 replies; 4+ messages in thread
From: Vincent Guittot @ 2022-06-24  7:45 UTC (permalink / raw)
  To: sudeep.holla, cristian.marussi, linux-arm-kernel,
	etienne.carriere, linux-kernel
  Cc: Vincent Guittot

Some protocols check the response size with the expected value but optee
shared memory doesn't return such size whereas it is available in the
optee output buffer.

As an example, the base protocol compares the response size with the
expected result when requesting the list of protocol which triggers a
warning with optee shared memory:

[    1.260306] arm-scmi firmware:scmi0: Malformed reply - real_sz:116  calc_sz:4  (loop_num_ret:4)

Save the output buffer length and use it when fetching the answer.

Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
---

Tested on sudeep's for-next/scmi branch

 drivers/firmware/arm_scmi/optee.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/arm_scmi/optee.c b/drivers/firmware/arm_scmi/optee.c
index b503c22cfd32..8abace56b958 100644
--- a/drivers/firmware/arm_scmi/optee.c
+++ b/drivers/firmware/arm_scmi/optee.c
@@ -117,6 +117,7 @@ struct scmi_optee_channel {
 	u32 channel_id;
 	u32 tee_session;
 	u32 caps;
+	u32 rx_len;
 	struct mutex mu;
 	struct scmi_chan_info *cinfo;
 	union {
@@ -302,6 +303,9 @@ static int invoke_process_msg_channel(struct scmi_optee_channel *channel, size_t
 		return -EIO;
 	}
 
+	/* Save response size */
+	channel->rx_len = param[2].u.memref.size;
+
 	return 0;
 }
 
@@ -353,6 +357,7 @@ static int setup_dynamic_shmem(struct device *dev, struct scmi_optee_channel *ch
 	shbuf = tee_shm_get_va(channel->tee_shm, 0);
 	memset(shbuf, 0, msg_size);
 	channel->req.msg = shbuf;
+	channel->rx_len = msg_size;
 
 	return 0;
 }
@@ -508,7 +513,7 @@ static void scmi_optee_fetch_response(struct scmi_chan_info *cinfo,
 	struct scmi_optee_channel *channel = cinfo->transport_info;
 
 	if (channel->tee_shm)
-		msg_fetch_response(channel->req.msg, SCMI_OPTEE_MAX_MSG_SIZE, xfer);
+		msg_fetch_response(channel->req.msg, channel->rx_len, xfer);
 	else
 		shmem_fetch_response(channel->req.shmem, xfer);
 }
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] scmi/optee: fix response size warning
  2022-06-24  7:45 [PATCH] scmi/optee: fix response size warning Vincent Guittot
@ 2022-06-24  9:22 ` Cristian Marussi
  2022-06-27 10:47   ` Etienne Carriere
  2022-06-29 10:05 ` Sudeep Holla
  1 sibling, 1 reply; 4+ messages in thread
From: Cristian Marussi @ 2022-06-24  9:22 UTC (permalink / raw)
  To: Vincent Guittot
  Cc: sudeep.holla, linux-arm-kernel, etienne.carriere, linux-kernel

On Fri, Jun 24, 2022 at 09:45:49AM +0200, Vincent Guittot wrote:
> Some protocols check the response size with the expected value but optee
> shared memory doesn't return such size whereas it is available in the
> optee output buffer.
> 
> As an example, the base protocol compares the response size with the
> expected result when requesting the list of protocol which triggers a
> warning with optee shared memory:
> 
> [    1.260306] arm-scmi firmware:scmi0: Malformed reply - real_sz:116  calc_sz:4  (loop_num_ret:4)
> 
> Save the output buffer length and use it when fetching the answer.
> 
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>

Hi Vincent,

> ---
> 
> Tested on sudeep's for-next/scmi branch
> 
>  drivers/firmware/arm_scmi/optee.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/arm_scmi/optee.c b/drivers/firmware/arm_scmi/optee.c
> index b503c22cfd32..8abace56b958 100644
> --- a/drivers/firmware/arm_scmi/optee.c
> +++ b/drivers/firmware/arm_scmi/optee.c
> @@ -117,6 +117,7 @@ struct scmi_optee_channel {
>  	u32 channel_id;
>  	u32 tee_session;
>  	u32 caps;
> +	u32 rx_len;
>  	struct mutex mu;
>  	struct scmi_chan_info *cinfo;
>  	union {
> @@ -302,6 +303,9 @@ static int invoke_process_msg_channel(struct scmi_optee_channel *channel, size_t
>  		return -EIO;
>  	}
>  
> +	/* Save response size */
> +	channel->rx_len = param[2].u.memref.size;
> +
>  	return 0;
>  }
>  
> @@ -353,6 +357,7 @@ static int setup_dynamic_shmem(struct device *dev, struct scmi_optee_channel *ch
>  	shbuf = tee_shm_get_va(channel->tee_shm, 0);
>  	memset(shbuf, 0, msg_size);
>  	channel->req.msg = shbuf;
> +	channel->rx_len = msg_size;
>  
>  	return 0;
>  }
> @@ -508,7 +513,7 @@ static void scmi_optee_fetch_response(struct scmi_chan_info *cinfo,
>  	struct scmi_optee_channel *channel = cinfo->transport_info;
>  
>  	if (channel->tee_shm)
> -		msg_fetch_response(channel->req.msg, SCMI_OPTEE_MAX_MSG_SIZE, xfer);
> +		msg_fetch_response(channel->req.msg, channel->rx_len, xfer);
>  	else
>  		shmem_fetch_response(channel->req.shmem, xfer);
>  }

Looks good to me.

Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>

Thanks,
Cristian


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scmi/optee: fix response size warning
  2022-06-24  9:22 ` Cristian Marussi
@ 2022-06-27 10:47   ` Etienne Carriere
  0 siblings, 0 replies; 4+ messages in thread
From: Etienne Carriere @ 2022-06-27 10:47 UTC (permalink / raw)
  To: Cristian Marussi
  Cc: Vincent Guittot, sudeep.holla, linux-arm-kernel, linux-kernel

Hello Vincent,

On Fri, 24 Jun 2022 at 11:23, Cristian Marussi <cristian.marussi@arm.com> wrote:
>
> On Fri, Jun 24, 2022 at 09:45:49AM +0200, Vincent Guittot wrote:
> > Some protocols check the response size with the expected value but optee
> > shared memory doesn't return such size whereas it is available in the
> > optee output buffer.
> >
> > As an example, the base protocol compares the response size with the
> > expected result when requesting the list of protocol which triggers a
> > warning with optee shared memory:
> >
> > [    1.260306] arm-scmi firmware:scmi0: Malformed reply - real_sz:116  calc_sz:4  (loop_num_ret:4)
> >
> > Save the output buffer length and use it when fetching the answer.
> >
> > Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
>
> Hi Vincent,
>
> > ---
> >
> > Tested on sudeep's for-next/scmi branch
> >
> >  drivers/firmware/arm_scmi/optee.c | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/firmware/arm_scmi/optee.c b/drivers/firmware/arm_scmi/optee.c
> > index b503c22cfd32..8abace56b958 100644
> > --- a/drivers/firmware/arm_scmi/optee.c
> > +++ b/drivers/firmware/arm_scmi/optee.c
> > @@ -117,6 +117,7 @@ struct scmi_optee_channel {
> >       u32 channel_id;
> >       u32 tee_session;
> >       u32 caps;
> > +     u32 rx_len;
> >       struct mutex mu;
> >       struct scmi_chan_info *cinfo;
> >       union {
> > @@ -302,6 +303,9 @@ static int invoke_process_msg_channel(struct scmi_optee_channel *channel, size_t
> >               return -EIO;
> >       }
> >
> > +     /* Save response size */
> > +     channel->rx_len = param[2].u.memref.size;
> > +
> >       return 0;
> >  }
> >
> > @@ -353,6 +357,7 @@ static int setup_dynamic_shmem(struct device *dev, struct scmi_optee_channel *ch
> >       shbuf = tee_shm_get_va(channel->tee_shm, 0);
> >       memset(shbuf, 0, msg_size);
> >       channel->req.msg = shbuf;
> > +     channel->rx_len = msg_size;
> >
> >       return 0;
> >  }
> > @@ -508,7 +513,7 @@ static void scmi_optee_fetch_response(struct scmi_chan_info *cinfo,
> >       struct scmi_optee_channel *channel = cinfo->transport_info;
> >
> >       if (channel->tee_shm)
> > -             msg_fetch_response(channel->req.msg, SCMI_OPTEE_MAX_MSG_SIZE, xfer);
> > +             msg_fetch_response(channel->req.msg, channel->rx_len, xfer);
> >       else
> >               shmem_fetch_response(channel->req.shmem, xfer);
> >  }

Thanks for the fix.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>


>
> Looks good to me.
>
> Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
>
> Thanks,
> Cristian
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scmi/optee: fix response size warning
  2022-06-24  7:45 [PATCH] scmi/optee: fix response size warning Vincent Guittot
  2022-06-24  9:22 ` Cristian Marussi
@ 2022-06-29 10:05 ` Sudeep Holla
  1 sibling, 0 replies; 4+ messages in thread
From: Sudeep Holla @ 2022-06-29 10:05 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, cristian.marussi,
	Vincent Guittot, etienne.carriere
  Cc: Sudeep Holla

On Fri, 24 Jun 2022 09:45:49 +0200, Vincent Guittot wrote:
> Some protocols check the response size with the expected value but optee
> shared memory doesn't return such size whereas it is available in the
> optee output buffer.
> 
> As an example, the base protocol compares the response size with the
> expected result when requesting the list of protocol which triggers a
> warning with optee shared memory:
> 
> [...]

Applied to sudeep.holla/linux (for-next/juno), thanks!

[1/1] scmi/optee: fix response size warning
      https://git.kernel.org/sudeep.holla/c/75c8f430d8

--
Regards,
Sudeep


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-06-29 10:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-24  7:45 [PATCH] scmi/optee: fix response size warning Vincent Guittot
2022-06-24  9:22 ` Cristian Marussi
2022-06-27 10:47   ` Etienne Carriere
2022-06-29 10:05 ` Sudeep Holla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).