diff options
author | Peng Fan <peng.fan@nxp.com> | 2024-04-18 04:32:28 +0300 |
---|---|---|
committer | Sudeep Holla <sudeep.holla@arm.com> | 2024-04-19 17:17:37 +0300 |
commit | 4869b5cc9641c0cdc100315f324a73f64576ee66 (patch) | |
tree | 593c62d34bd02e08697eace630d793bd06fb80c8 /drivers | |
parent | fc110108b98305efa24bb8c355e90b5cc2a01a5f (diff) | |
download | linux-4869b5cc9641c0cdc100315f324a73f64576ee66.tar.xz |
firmware: arm_scmi: Introduce get_max_msg_size() helper/accessor
When the agent is sending data to the SCMI platform, the drivers in the
agent could check the maximum message size supported to avoid potential
protocol buffer overflow.
Introduce the helper/accessor function get_max_msg_size() for the same.
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/r/20240418-pinctrl-scmi-v11-1-499dca9864a7@nxp.com
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/firmware/arm_scmi/driver.c | 15 | ||||
-rw-r--r-- | drivers/firmware/arm_scmi/protocols.h | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 36c4ff41dee1..ab5c138e0d09 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -1663,6 +1663,20 @@ out: } /** + * scmi_common_get_max_msg_size - Get maximum message size + * @ph: A protocol handle reference. + * + * Return: Maximum message size for the current protocol. + */ +static int scmi_common_get_max_msg_size(const struct scmi_protocol_handle *ph) +{ + const struct scmi_protocol_instance *pi = ph_to_pi(ph); + struct scmi_info *info = handle_to_scmi_info(pi->handle); + + return info->desc->max_msg_size; +} + +/** * struct scmi_iterator - Iterator descriptor * @msg: A reference to the message TX buffer; filled by @prepare_message with * a proper custom command payload for each multi-part command request. @@ -1973,6 +1987,7 @@ static int scmi_protocol_msg_check(const struct scmi_protocol_handle *ph, static const struct scmi_proto_helpers_ops helpers_ops = { .extended_name_get = scmi_common_extended_name_get, + .get_max_msg_size = scmi_common_get_max_msg_size, .iter_response_init = scmi_iterator_init, .iter_response_run = scmi_iterator_run, .protocol_msg_check = scmi_protocol_msg_check, diff --git a/drivers/firmware/arm_scmi/protocols.h b/drivers/firmware/arm_scmi/protocols.h index e17dbcfbf299..314371dc0f65 100644 --- a/drivers/firmware/arm_scmi/protocols.h +++ b/drivers/firmware/arm_scmi/protocols.h @@ -260,6 +260,7 @@ struct scmi_fc_info { * @fastchannel_init: A common helper used to initialize FC descriptors by * gathering FC descriptions from the SCMI platform server. * @fastchannel_db_ring: A common helper to ring a FC doorbell. + * @get_max_msg_size: A common helper to get the maximum message size. */ struct scmi_proto_helpers_ops { int (*extended_name_get)(const struct scmi_protocol_handle *ph, @@ -279,6 +280,7 @@ struct scmi_proto_helpers_ops { struct scmi_fc_db_info **p_db, u32 *rate_limit); void (*fastchannel_db_ring)(struct scmi_fc_db_info *db); + int (*get_max_msg_size)(const struct scmi_protocol_handle *ph); }; /** |