Skip to content

Commit 67a50f5

Browse files
cris-magregkh
authored andcommitted
firmware: arm_scmi: Add a common helper to check if a message is supported
commit 637b6d6 upstream. A common helper is provided to check if a specific protocol message is supported or not. Signed-off-by: Cristian Marussi <cristian.marussi@arm.com> Link: https://lore.kernel.org/r/20240212123233.1230090-3-cristian.marussi@arm.com Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6f27bbf commit 67a50f5

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

drivers/firmware/arm_scmi/driver.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,10 +1820,44 @@ static void scmi_common_fastchannel_db_ring(struct scmi_fc_db_info *db)
18201820
#endif
18211821
}
18221822

1823+
/**
1824+
* scmi_protocol_msg_check - Check protocol message attributes
1825+
*
1826+
* @ph: A reference to the protocol handle.
1827+
* @message_id: The ID of the message to check.
1828+
* @attributes: A parameter to optionally return the retrieved message
1829+
* attributes, in case of Success.
1830+
*
1831+
* An helper to check protocol message attributes for a specific protocol
1832+
* and message pair.
1833+
*
1834+
* Return: 0 on SUCCESS
1835+
*/
1836+
static int scmi_protocol_msg_check(const struct scmi_protocol_handle *ph,
1837+
u32 message_id, u32 *attributes)
1838+
{
1839+
int ret;
1840+
struct scmi_xfer *t;
1841+
1842+
ret = xfer_get_init(ph, PROTOCOL_MESSAGE_ATTRIBUTES,
1843+
sizeof(__le32), 0, &t);
1844+
if (ret)
1845+
return ret;
1846+
1847+
put_unaligned_le32(message_id, t->tx.buf);
1848+
ret = do_xfer(ph, t);
1849+
if (!ret && attributes)
1850+
*attributes = get_unaligned_le32(t->rx.buf);
1851+
xfer_put(ph, t);
1852+
1853+
return ret;
1854+
}
1855+
18231856
static const struct scmi_proto_helpers_ops helpers_ops = {
18241857
.extended_name_get = scmi_common_extended_name_get,
18251858
.iter_response_init = scmi_iterator_init,
18261859
.iter_response_run = scmi_iterator_run,
1860+
.protocol_msg_check = scmi_protocol_msg_check,
18271861
.fastchannel_init = scmi_common_fastchannel_init,
18281862
.fastchannel_db_ring = scmi_common_fastchannel_db_ring,
18291863
};

drivers/firmware/arm_scmi/protocols.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ struct scmi_fc_info {
250250
* provided in @ops.
251251
* @iter_response_run: A common helper to trigger the run of a previously
252252
* initialized iterator.
253+
* @protocol_msg_check: A common helper to check is a specific protocol message
254+
* is supported.
253255
* @fastchannel_init: A common helper used to initialize FC descriptors by
254256
* gathering FC descriptions from the SCMI platform server.
255257
* @fastchannel_db_ring: A common helper to ring a FC doorbell.
@@ -262,6 +264,8 @@ struct scmi_proto_helpers_ops {
262264
unsigned int max_resources, u8 msg_id,
263265
size_t tx_size, void *priv);
264266
int (*iter_response_run)(void *iter);
267+
int (*protocol_msg_check)(const struct scmi_protocol_handle *ph,
268+
u32 message_id, u32 *attributes);
265269
void (*fastchannel_init)(const struct scmi_protocol_handle *ph,
266270
u8 describe_id, u32 message_id,
267271
u32 valid_size, u32 domain,

0 commit comments

Comments
 (0)