Skip to content

Commit ad86f7e

Browse files
pierregondoisvireshk
authored andcommitted
firmware: arm_scmi: Populate perf commands rate_limit
Arm SCMI spec. v3.2, s4.5.3.4 PERFORMANCE_DOMAIN_ATTRIBUTES defines a per-domain rate_limit for performance requests: """ Rate Limit in microseconds, indicating the minimum time required between successive requests. A value of 0 indicates that this field is not supported by the platform. This field does not apply to FastChannels. """" The field is first defined in SCMI v1.0. Add support to fetch this value and advertise it through a rate_limit_get() callback. Signed-off-by: Pierre Gondois <pierre.gondois@arm.com> Reviewed-by: Cristian Marussi <cristian.marussi@arm.com> Acked-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent 3093fa3 commit ad86f7e

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

drivers/firmware/arm_scmi/perf.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ struct perf_dom_info {
153153
bool perf_fastchannels;
154154
bool level_indexing_mode;
155155
u32 opp_count;
156+
u32 rate_limit_us;
156157
u32 sustained_freq_khz;
157158
u32 sustained_perf_level;
158159
unsigned long mult_factor;
@@ -266,6 +267,8 @@ scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph,
266267
if (PROTOCOL_REV_MAJOR(version) >= 0x4)
267268
dom_info->level_indexing_mode =
268269
SUPPORTS_LEVEL_INDEXING(flags);
270+
dom_info->rate_limit_us = le32_to_cpu(attr->rate_limit_us) &
271+
GENMASK(19, 0);
269272
dom_info->sustained_freq_khz =
270273
le32_to_cpu(attr->sustained_freq_khz);
271274
dom_info->sustained_perf_level =
@@ -842,6 +845,23 @@ scmi_dvfs_transition_latency_get(const struct scmi_protocol_handle *ph,
842845
return dom->opp[dom->opp_count - 1].trans_latency_us * 1000;
843846
}
844847

848+
static int
849+
scmi_dvfs_rate_limit_get(const struct scmi_protocol_handle *ph,
850+
u32 domain, u32 *rate_limit)
851+
{
852+
struct perf_dom_info *dom;
853+
854+
if (!rate_limit)
855+
return -EINVAL;
856+
857+
dom = scmi_perf_domain_lookup(ph, domain);
858+
if (IS_ERR(dom))
859+
return PTR_ERR(dom);
860+
861+
*rate_limit = dom->rate_limit_us;
862+
return 0;
863+
}
864+
845865
static int scmi_dvfs_freq_set(const struct scmi_protocol_handle *ph, u32 domain,
846866
unsigned long freq, bool poll)
847867
{
@@ -957,6 +977,7 @@ static const struct scmi_perf_proto_ops perf_proto_ops = {
957977
.level_set = scmi_perf_level_set,
958978
.level_get = scmi_perf_level_get,
959979
.transition_latency_get = scmi_dvfs_transition_latency_get,
980+
.rate_limit_get = scmi_dvfs_rate_limit_get,
960981
.device_opps_add = scmi_dvfs_device_opps_add,
961982
.freq_set = scmi_dvfs_freq_set,
962983
.freq_get = scmi_dvfs_freq_get,

include/linux/scmi_protocol.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ struct scmi_perf_domain_info {
128128
* @level_set: sets the performance level of a domain
129129
* @level_get: gets the performance level of a domain
130130
* @transition_latency_get: gets the DVFS transition latency for a given device
131+
* @rate_limit_get: gets the minimum time (us) required between successive
132+
* requests
131133
* @device_opps_add: adds all the OPPs for a given device
132134
* @freq_set: sets the frequency for a given device using sustained frequency
133135
* to sustained performance level mapping
@@ -154,6 +156,8 @@ struct scmi_perf_proto_ops {
154156
u32 *level, bool poll);
155157
int (*transition_latency_get)(const struct scmi_protocol_handle *ph,
156158
u32 domain);
159+
int (*rate_limit_get)(const struct scmi_protocol_handle *ph,
160+
u32 domain, u32 *rate_limit);
157161
int (*device_opps_add)(const struct scmi_protocol_handle *ph,
158162
struct device *dev, u32 domain);
159163
int (*freq_set)(const struct scmi_protocol_handle *ph, u32 domain,

0 commit comments

Comments
 (0)