History

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.

Vincent Guittot committed 4 years ago

Commit 75c8f431 parent 754f04c1 file · +6 −1Browse files

Unified · Split

drivers/firmware/arm_scmi/optee.c+6−1
@@ -117,6 +117,7 @@ struct scmi_optee_channel { · 116 unmodified lines
117 u32 channel_id;117 u32 channel_id;
118 u32 tee_session;118 u32 tee_session;
119 u32 caps;119 u32 caps;
120 u32 rx_len;
120 struct mutex mu;121 struct mutex mu;
121 struct scmi_chan_info *cinfo;122 struct scmi_chan_info *cinfo;
122 union {123 union {
@@ -302,6 +303,9 @@ static int invoke_process_msg_channel(struct scmi_optee_channel *channel, size_t · 179 unmodified lines
302 return -EIO;303 return -EIO;
303 }304 }
304 305
306 /* Save response size */
307 channel->rx_len = param[2].u.memref.size;
308
305 return 0;309 return 0;
306}310}
307 311
@@ -353,6 +357,7 @@ static int setup_dynamic_shmem(struct device *dev, struct scmi_optee_channel *ch · 45 unmodified lines
353 shbuf = tee_shm_get_va(channel->tee_shm, 0);357 shbuf = tee_shm_get_va(channel->tee_shm, 0);
354 memset(shbuf, 0, msg_size);358 memset(shbuf, 0, msg_size);
355 channel->req.msg = shbuf;359 channel->req.msg = shbuf;
360 channel->rx_len = msg_size;
356 361
357 return 0;362 return 0;
358}363}
@@ -508,7 +513,7 @@ static void scmi_optee_fetch_response(struct scmi_chan_info *cinfo, · 149 unmodified lines
508 struct scmi_optee_channel *channel = cinfo->transport_info;513 struct scmi_optee_channel *channel = cinfo->transport_info;
509 514
510 if (channel->tee_shm)515 if (channel->tee_shm)
511 msg_fetch_response(channel->req.msg, SCMI_OPTEE_MAX_MSG_SIZE, xfer);516 msg_fetch_response(channel->req.msg, channel->rx_len, xfer);
512 else517 else
513 shmem_fetch_response(channel->req.shmem, xfer);518 shmem_fetch_response(channel->req.shmem, xfer);
514}519}