Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.org
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

authored by

Vincent Guittot and committed by
Sudeep Holla
75c8f430 754f04ca

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