Skip to content

Commit 9429f3e

Browse files
Sibi Sankargregkh
authored andcommitted
firmware: arm_scmi: Ensure that the message-id supports fastchannel
commit 94a263f981a3fa3d93f65c31e0fed0756736be43 upstream. Currently the perf and powercap protocol relies on the protocol domain attributes, which just ensures that one fastchannel per domain, before instantiating fastchannels for all possible message-ids. Fix this by ensuring that each message-id supports fastchannel before initialization. Logs: | scmi: Failed to get FC for protocol 13 [MSG_ID:6 / RES_ID:0] - ret:-95. Using regular messaging | scmi: Failed to get FC for protocol 13 [MSG_ID:6 / RES_ID:1] - ret:-95. Using regular messaging | scmi: Failed to get FC for protocol 13 [MSG_ID:6 / RES_ID:2] - ret:-95. Using regular messaging CC: [email protected] Reported-by: Johan Hovold <[email protected]> Closes: https://lore.kernel.org/lkml/[email protected]/ Fixes: 6f9ea4d ("firmware: arm_scmi: Generalize the fast channel support") Reviewed-by: Johan Hovold <[email protected]> Tested-by: Johan Hovold <[email protected]> Signed-off-by: Sibi Sankar <[email protected]> [Cristian: Modified the condition checked to establish support or not] Signed-off-by: Cristian Marussi <[email protected]> Message-Id: <[email protected]> Signed-off-by: Sudeep Holla <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e8bc38f commit 9429f3e

File tree

2 files changed

+45
-33
lines changed

2 files changed

+45
-33
lines changed

drivers/firmware/arm_scmi/driver.c

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,39 @@ static int scmi_common_extended_name_get(const struct scmi_protocol_handle *ph,
11771177
return ret;
11781178
}
11791179

1180+
/**
1181+
* scmi_protocol_msg_check - Check protocol message attributes
1182+
*
1183+
* @ph: A reference to the protocol handle.
1184+
* @message_id: The ID of the message to check.
1185+
* @attributes: A parameter to optionally return the retrieved message
1186+
* attributes, in case of Success.
1187+
*
1188+
* An helper to check protocol message attributes for a specific protocol
1189+
* and message pair.
1190+
*
1191+
* Return: 0 on SUCCESS
1192+
*/
1193+
static int scmi_protocol_msg_check(const struct scmi_protocol_handle *ph,
1194+
u32 message_id, u32 *attributes)
1195+
{
1196+
int ret;
1197+
struct scmi_xfer *t;
1198+
1199+
ret = xfer_get_init(ph, PROTOCOL_MESSAGE_ATTRIBUTES,
1200+
sizeof(__le32), 0, &t);
1201+
if (ret)
1202+
return ret;
1203+
1204+
put_unaligned_le32(message_id, t->tx.buf);
1205+
ret = do_xfer(ph, t);
1206+
if (!ret && attributes)
1207+
*attributes = get_unaligned_le32(t->rx.buf);
1208+
xfer_put(ph, t);
1209+
1210+
return ret;
1211+
}
1212+
11801213
/**
11811214
* struct scmi_iterator - Iterator descriptor
11821215
* @msg: A reference to the message TX buffer; filled by @prepare_message with
@@ -1318,6 +1351,7 @@ scmi_common_fastchannel_init(const struct scmi_protocol_handle *ph,
13181351
int ret;
13191352
u32 flags;
13201353
u64 phys_addr;
1354+
u32 attributes;
13211355
u8 size;
13221356
void __iomem *addr;
13231357
struct scmi_xfer *t;
@@ -1326,6 +1360,15 @@ scmi_common_fastchannel_init(const struct scmi_protocol_handle *ph,
13261360
struct scmi_msg_resp_desc_fc *resp;
13271361
const struct scmi_protocol_instance *pi = ph_to_pi(ph);
13281362

1363+
/* Check if the MSG_ID supports fastchannel */
1364+
ret = scmi_protocol_msg_check(ph, message_id, &attributes);
1365+
if (ret || !MSG_SUPPORTS_FASTCHANNEL(attributes)) {
1366+
dev_dbg(ph->dev,
1367+
"Skip FC init for 0x%02X/%d domain:%d - ret:%d\n",
1368+
pi->proto->id, message_id, domain, ret);
1369+
return;
1370+
}
1371+
13291372
if (!p_addr) {
13301373
ret = -EINVAL;
13311374
goto err_out;
@@ -1450,39 +1493,6 @@ static void scmi_common_fastchannel_db_ring(struct scmi_fc_db_info *db)
14501493
#endif
14511494
}
14521495

1453-
/**
1454-
* scmi_protocol_msg_check - Check protocol message attributes
1455-
*
1456-
* @ph: A reference to the protocol handle.
1457-
* @message_id: The ID of the message to check.
1458-
* @attributes: A parameter to optionally return the retrieved message
1459-
* attributes, in case of Success.
1460-
*
1461-
* An helper to check protocol message attributes for a specific protocol
1462-
* and message pair.
1463-
*
1464-
* Return: 0 on SUCCESS
1465-
*/
1466-
static int scmi_protocol_msg_check(const struct scmi_protocol_handle *ph,
1467-
u32 message_id, u32 *attributes)
1468-
{
1469-
int ret;
1470-
struct scmi_xfer *t;
1471-
1472-
ret = xfer_get_init(ph, PROTOCOL_MESSAGE_ATTRIBUTES,
1473-
sizeof(__le32), 0, &t);
1474-
if (ret)
1475-
return ret;
1476-
1477-
put_unaligned_le32(message_id, t->tx.buf);
1478-
ret = do_xfer(ph, t);
1479-
if (!ret && attributes)
1480-
*attributes = get_unaligned_le32(t->rx.buf);
1481-
xfer_put(ph, t);
1482-
1483-
return ret;
1484-
}
1485-
14861496
static const struct scmi_proto_helpers_ops helpers_ops = {
14871497
.extended_name_get = scmi_common_extended_name_get,
14881498
.iter_response_init = scmi_iterator_init,

drivers/firmware/arm_scmi/protocols.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#define PROTOCOL_REV_MAJOR(x) ((u16)(FIELD_GET(PROTOCOL_REV_MAJOR_MASK, (x))))
3030
#define PROTOCOL_REV_MINOR(x) ((u16)(FIELD_GET(PROTOCOL_REV_MINOR_MASK, (x))))
3131

32+
#define MSG_SUPPORTS_FASTCHANNEL(x) ((x) & BIT(0))
33+
3234
enum scmi_common_cmd {
3335
PROTOCOL_VERSION = 0x0,
3436
PROTOCOL_ATTRIBUTES = 0x1,

0 commit comments

Comments
 (0)