Skip to content

Commit f991782

Browse files
Sibi Sankargregkh
authored andcommitted
firmware: arm_scmi: Ensure that the message-id supports fastchannel
commit 94a263f 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: stable@vger.kernel.org Reported-by: Johan Hovold <johan+linaro@kernel.org> Closes: https://lore.kernel.org/lkml/ZoQjAWse2YxwyRJv@hovoldconsulting.com/ Fixes: 6f9ea4d ("firmware: arm_scmi: Generalize the fast channel support") Reviewed-by: Johan Hovold <johan+linaro@kernel.org> Tested-by: Johan Hovold <johan+linaro@kernel.org> Signed-off-by: Sibi Sankar <quic_sibis@quicinc.com> [Cristian: Modified the condition checked to establish support or not] Signed-off-by: Cristian Marussi <cristian.marussi@arm.com> Message-Id: <20250429141108.406045-2-cristian.marussi@arm.com> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 67a50f5 commit f991782

2 files changed

Lines changed: 45 additions & 33 deletions

File tree

drivers/firmware/arm_scmi/driver.c

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

1550+
/**
1551+
* scmi_protocol_msg_check - Check protocol message attributes
1552+
*
1553+
* @ph: A reference to the protocol handle.
1554+
* @message_id: The ID of the message to check.
1555+
* @attributes: A parameter to optionally return the retrieved message
1556+
* attributes, in case of Success.
1557+
*
1558+
* An helper to check protocol message attributes for a specific protocol
1559+
* and message pair.
1560+
*
1561+
* Return: 0 on SUCCESS
1562+
*/
1563+
static int scmi_protocol_msg_check(const struct scmi_protocol_handle *ph,
1564+
u32 message_id, u32 *attributes)
1565+
{
1566+
int ret;
1567+
struct scmi_xfer *t;
1568+
1569+
ret = xfer_get_init(ph, PROTOCOL_MESSAGE_ATTRIBUTES,
1570+
sizeof(__le32), 0, &t);
1571+
if (ret)
1572+
return ret;
1573+
1574+
put_unaligned_le32(message_id, t->tx.buf);
1575+
ret = do_xfer(ph, t);
1576+
if (!ret && attributes)
1577+
*attributes = get_unaligned_le32(t->rx.buf);
1578+
xfer_put(ph, t);
1579+
1580+
return ret;
1581+
}
1582+
15501583
/**
15511584
* struct scmi_iterator - Iterator descriptor
15521585
* @msg: A reference to the message TX buffer; filled by @prepare_message with
@@ -1688,6 +1721,7 @@ scmi_common_fastchannel_init(const struct scmi_protocol_handle *ph,
16881721
int ret;
16891722
u32 flags;
16901723
u64 phys_addr;
1724+
u32 attributes;
16911725
u8 size;
16921726
void __iomem *addr;
16931727
struct scmi_xfer *t;
@@ -1696,6 +1730,15 @@ scmi_common_fastchannel_init(const struct scmi_protocol_handle *ph,
16961730
struct scmi_msg_resp_desc_fc *resp;
16971731
const struct scmi_protocol_instance *pi = ph_to_pi(ph);
16981732

1733+
/* Check if the MSG_ID supports fastchannel */
1734+
ret = scmi_protocol_msg_check(ph, message_id, &attributes);
1735+
if (ret || !MSG_SUPPORTS_FASTCHANNEL(attributes)) {
1736+
dev_dbg(ph->dev,
1737+
"Skip FC init for 0x%02X/%d domain:%d - ret:%d\n",
1738+
pi->proto->id, message_id, domain, ret);
1739+
return;
1740+
}
1741+
16991742
if (!p_addr) {
17001743
ret = -EINVAL;
17011744
goto err_out;
@@ -1820,39 +1863,6 @@ static void scmi_common_fastchannel_db_ring(struct scmi_fc_db_info *db)
18201863
#endif
18211864
}
18221865

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-
18561866
static const struct scmi_proto_helpers_ops helpers_ops = {
18571867
.extended_name_get = scmi_common_extended_name_get,
18581868
.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)