Skip to content

Commit 4869b5c

Browse files
MrVansudeep-holla
authored andcommitted
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 <[email protected]> Reviewed-by: Dhruva Gole <[email protected]> Signed-off-by: Peng Fan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sudeep Holla <[email protected]>
1 parent fc11010 commit 4869b5c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

drivers/firmware/arm_scmi/driver.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,6 +1662,20 @@ static int scmi_common_extended_name_get(const struct scmi_protocol_handle *ph,
16621662
return ret;
16631663
}
16641664

1665+
/**
1666+
* scmi_common_get_max_msg_size - Get maximum message size
1667+
* @ph: A protocol handle reference.
1668+
*
1669+
* Return: Maximum message size for the current protocol.
1670+
*/
1671+
static int scmi_common_get_max_msg_size(const struct scmi_protocol_handle *ph)
1672+
{
1673+
const struct scmi_protocol_instance *pi = ph_to_pi(ph);
1674+
struct scmi_info *info = handle_to_scmi_info(pi->handle);
1675+
1676+
return info->desc->max_msg_size;
1677+
}
1678+
16651679
/**
16661680
* struct scmi_iterator - Iterator descriptor
16671681
* @msg: A reference to the message TX buffer; filled by @prepare_message with
@@ -1973,6 +1987,7 @@ static int scmi_protocol_msg_check(const struct scmi_protocol_handle *ph,
19731987

19741988
static const struct scmi_proto_helpers_ops helpers_ops = {
19751989
.extended_name_get = scmi_common_extended_name_get,
1990+
.get_max_msg_size = scmi_common_get_max_msg_size,
19761991
.iter_response_init = scmi_iterator_init,
19771992
.iter_response_run = scmi_iterator_run,
19781993
.protocol_msg_check = scmi_protocol_msg_check,

drivers/firmware/arm_scmi/protocols.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ struct scmi_fc_info {
260260
* @fastchannel_init: A common helper used to initialize FC descriptors by
261261
* gathering FC descriptions from the SCMI platform server.
262262
* @fastchannel_db_ring: A common helper to ring a FC doorbell.
263+
* @get_max_msg_size: A common helper to get the maximum message size.
263264
*/
264265
struct scmi_proto_helpers_ops {
265266
int (*extended_name_get)(const struct scmi_protocol_handle *ph,
@@ -279,6 +280,7 @@ struct scmi_proto_helpers_ops {
279280
struct scmi_fc_db_info **p_db,
280281
u32 *rate_limit);
281282
void (*fastchannel_db_ring)(struct scmi_fc_db_info *db);
283+
int (*get_max_msg_size)(const struct scmi_protocol_handle *ph);
282284
};
283285

284286
/**

0 commit comments

Comments
 (0)