Fwd: [PATCH v2] firmware: arm_scmi: Refrain set operations of perf

From: sean yang
Date: Thu Nov 02 2023 - 05:54:55 EST


---------- Forwarded message ---------
发件人: xinglong.yang <seanyang230@xxxxxxxxx>
Date: 2023年11月2日周四 15:59
Subject: [PATCH v2] firmware: arm_scmi: Refrain set operations of perf
To: <xinglong.yang@xxxxxxxxxxx>, <sudeep.holla@xxxxxxx>,
<cristian.marussi@xxxxxxx>
Cc: <linux-arm-kernel@xxxxxxxxxxxxxxxxxxx>


Refrain from trying to take the SET operation where the set_* operations
are not supported, because: (1.) avoid unneeded SCMI exchanges, (2.)
avoids to trust the FW reply blindly.

Signed-off-by: xinglong.yang <xinglong.yang@xxxxxxxxxxx>
---
drivers/firmware/arm_scmi/perf.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c
index 431bda9165c3..3bcdef91ed5c 100644
--- a/drivers/firmware/arm_scmi/perf.c
+++ b/drivers/firmware/arm_scmi/perf.c
@@ -377,6 +377,9 @@ static int scmi_perf_limits_set(const struct
scmi_protocol_handle *ph,
if (IS_ERR(dom))
return PTR_ERR(dom);

+ if (!dom->set_limits)
+ return -EOPNOTSUPP;
+
if (PROTOCOL_REV_MAJOR(pi->version) >= 0x3 && !max_perf && !min_perf)
return -EINVAL;

@@ -473,6 +476,9 @@ static int scmi_perf_level_set(const struct
scmi_protocol_handle *ph,
if (IS_ERR(dom))
return PTR_ERR(dom);

+ if (!dom->set_perf)
+ return -EOPNOTSUPP;
+
if (dom->fc_info && dom->fc_info[PERF_FC_LEVEL].set_addr) {
struct scmi_fc_info *fci = &dom->fc_info[PERF_FC_LEVEL];

--
2.42.0