From: xinglong.yang Date: Thu, 9 Nov 2023 08:28:55 +0000 (+0800) Subject: firmware: arm_scmi: Check beforehand if the perf domain set operations are allowed X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=189df98777a32c17d73e116df144e22b2ac3ae6b;p=linux.git firmware: arm_scmi: Check beforehand if the perf domain set operations are allowed Certain SCMI performance domains may have restrictions on the set level and/or limits operation. If the set level/limits are performed by an agent who is not allowed to do so may get SCMI_ERR_SUPPORT. However, since this information about the domain is already known to the agent(OSPM here) obtained via PERF_DOMAIN_ATTRIBUTES, the agent(OSPM) can avoid making PERF_LEVEL_SET and PERF_LIMITS_SET calls to the firmware. Add those checks and return -ENOTSUPP to the caller without interacting with the firmware based on the information collected during the domain enumeration stage. Signed-off-by: xinglong.yang Link: https://lore.kernel.org/r/20231109082855.472681-1-xinglong.yang@cixtech.com Signed-off-by: Sudeep Holla --- diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index c2435be0ae1be..f5a063b0b1ab9 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -504,6 +504,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; @@ -654,6 +657,9 @@ static int scmi_perf_level_set(const struct scmi_protocol_handle *ph, if (IS_ERR(dom)) return PTR_ERR(dom); + if (!dom->info.set_perf) + return -EOPNOTSUPP; + if (dom->level_indexing_mode) { struct scmi_opp *opp;