Commit 75c8f430 authored by Vincent Guittot's avatar Vincent Guittot Committed by Sudeep Holla

firmware: arm_scmi: Fix response size warning for OPTEE transport

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:

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.

Link: https://lore.kernel.org/r/20220624074549.3298-1-vincent.guittot@linaro.orgReviewed-by: default avatarEtienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: default avatarCristian Marussi <cristian.marussi@arm.com>
Signed-off-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
parent 754f04ca
...@@ -117,6 +117,7 @@ struct scmi_optee_channel { ...@@ -117,6 +117,7 @@ struct scmi_optee_channel {
u32 channel_id; u32 channel_id;
u32 tee_session; u32 tee_session;
u32 caps; u32 caps;
u32 rx_len;
struct mutex mu; struct mutex mu;
struct scmi_chan_info *cinfo; struct scmi_chan_info *cinfo;
union { union {
...@@ -302,6 +303,9 @@ static int invoke_process_msg_channel(struct scmi_optee_channel *channel, size_t ...@@ -302,6 +303,9 @@ static int invoke_process_msg_channel(struct scmi_optee_channel *channel, size_t
return -EIO; return -EIO;
} }
/* Save response size */
channel->rx_len = param[2].u.memref.size;
return 0; return 0;
} }
...@@ -353,6 +357,7 @@ static int setup_dynamic_shmem(struct device *dev, struct scmi_optee_channel *ch ...@@ -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); shbuf = tee_shm_get_va(channel->tee_shm, 0);
memset(shbuf, 0, msg_size); memset(shbuf, 0, msg_size);
channel->req.msg = shbuf; channel->req.msg = shbuf;
channel->rx_len = msg_size;
return 0; return 0;
} }
...@@ -508,7 +513,7 @@ static void scmi_optee_fetch_response(struct scmi_chan_info *cinfo, ...@@ -508,7 +513,7 @@ static void scmi_optee_fetch_response(struct scmi_chan_info *cinfo,
struct scmi_optee_channel *channel = cinfo->transport_info; struct scmi_optee_channel *channel = cinfo->transport_info;
if (channel->tee_shm) 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 else
shmem_fetch_response(channel->req.shmem, xfer); shmem_fetch_response(channel->req.shmem, xfer);
} }
......
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