firmware: arm_scmi: Populate fast channel rate_limit
authorPierre Gondois <pierre.gondois@arm.com>
Thu, 22 Feb 2024 13:57:00 +0000 (14:57 +0100)
committerViresh Kumar <viresh.kumar@linaro.org>
Wed, 6 Mar 2024 05:24:21 +0000 (10:54 +0530)
Arm SCMI spec. v3.2, s4.5.3.12 PERFORMANCE_DESCRIBE_FASTCHANNEL
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 applicable or supported
on the platform.
""""
The field is first defined in SCMI v2.0.

Add support to fetch this value and advertise it through
a fast_switch_rate_limit() 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>
drivers/firmware/arm_scmi/driver.c
drivers/firmware/arm_scmi/perf.c
drivers/firmware/arm_scmi/powercap.c
drivers/firmware/arm_scmi/protocols.h
include/linux/scmi_protocol.h

index 3ea64b22cf0dfd4493c8179de90b81b822759342..1d38ecfafc59af6418cfbfa534fe1a2645f19ac8 100644 (file)
@@ -1617,7 +1617,7 @@ static void
 scmi_common_fastchannel_init(const struct scmi_protocol_handle *ph,
                             u8 describe_id, u32 message_id, u32 valid_size,
                             u32 domain, void __iomem **p_addr,
-                            struct scmi_fc_db_info **p_db)
+                            struct scmi_fc_db_info **p_db, u32 *rate_limit)
 {
        int ret;
        u32 flags;
@@ -1661,6 +1661,9 @@ scmi_common_fastchannel_init(const struct scmi_protocol_handle *ph,
                goto err_xfer;
        }
 
+       if (rate_limit)
+               *rate_limit = le32_to_cpu(resp->rate_limit) & GENMASK(19, 0);
+
        phys_addr = le32_to_cpu(resp->chan_addr_low);
        phys_addr |= (u64)le32_to_cpu(resp->chan_addr_high) << 32;
        addr = devm_ioremap(ph->dev, phys_addr, size);
index 3269415ff77d78ee3dfadbe80b73fcbd20753517..be1801fb848db28cc34f63fd8f209e7ffedc5ca6 100644 (file)
@@ -776,23 +776,27 @@ static void scmi_perf_domain_init_fc(const struct scmi_protocol_handle *ph,
 
        ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL,
                                   PERF_LEVEL_GET, 4, dom->id,
-                                  &fc[PERF_FC_LEVEL].get_addr, NULL);
+                                  &fc[PERF_FC_LEVEL].get_addr, NULL,
+                                  &fc[PERF_FC_LEVEL].rate_limit);
 
        ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL,
                                   PERF_LIMITS_GET, 8, dom->id,
-                                  &fc[PERF_FC_LIMIT].get_addr, NULL);
+                                  &fc[PERF_FC_LIMIT].get_addr, NULL,
+                                  &fc[PERF_FC_LIMIT].rate_limit);
 
        if (dom->info.set_perf)
                ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL,
                                           PERF_LEVEL_SET, 4, dom->id,
                                           &fc[PERF_FC_LEVEL].set_addr,
-                                          &fc[PERF_FC_LEVEL].set_db);
+                                          &fc[PERF_FC_LEVEL].set_db,
+                                          &fc[PERF_FC_LEVEL].rate_limit);
 
        if (dom->set_limits)
                ph->hops->fastchannel_init(ph, PERF_DESCRIBE_FASTCHANNEL,
                                           PERF_LIMITS_SET, 8, dom->id,
                                           &fc[PERF_FC_LIMIT].set_addr,
-                                          &fc[PERF_FC_LIMIT].set_db);
+                                          &fc[PERF_FC_LIMIT].set_db,
+                                          &fc[PERF_FC_LIMIT].rate_limit);
 
        dom->fc_info = fc;
 }
@@ -961,6 +965,25 @@ static bool scmi_fast_switch_possible(const struct scmi_protocol_handle *ph,
        return dom->fc_info && dom->fc_info[PERF_FC_LEVEL].set_addr;
 }
 
+static int scmi_fast_switch_rate_limit(const struct scmi_protocol_handle *ph,
+                                      u32 domain, u32 *rate_limit)
+{
+       struct perf_dom_info *dom;
+
+       if (!rate_limit)
+               return -EINVAL;
+
+       dom = scmi_perf_domain_lookup(ph, domain);
+       if (IS_ERR(dom))
+               return PTR_ERR(dom);
+
+       if (!dom->fc_info)
+               return -EINVAL;
+
+       *rate_limit = dom->fc_info[PERF_FC_LEVEL].rate_limit;
+       return 0;
+}
+
 static enum scmi_power_scale
 scmi_power_scale_get(const struct scmi_protocol_handle *ph)
 {
@@ -983,6 +1006,7 @@ static const struct scmi_perf_proto_ops perf_proto_ops = {
        .freq_get = scmi_dvfs_freq_get,
        .est_power_get = scmi_dvfs_est_power_get,
        .fast_switch_possible = scmi_fast_switch_possible,
+       .fast_switch_rate_limit = scmi_fast_switch_rate_limit,
        .power_scale_get = scmi_power_scale_get,
 };
 
index a4c6cd4716fe4497681a76e5fc662f7fb670e0c5..604184c044ff60c293b2003a4ae5aa5f977786c5 100644 (file)
@@ -703,20 +703,24 @@ static void scmi_powercap_domain_init_fc(const struct scmi_protocol_handle *ph,
        ph->hops->fastchannel_init(ph, POWERCAP_DESCRIBE_FASTCHANNEL,
                                   POWERCAP_CAP_SET, 4, domain,
                                   &fc[POWERCAP_FC_CAP].set_addr,
-                                  &fc[POWERCAP_FC_CAP].set_db);
+                                  &fc[POWERCAP_FC_CAP].set_db,
+                                  &fc[POWERCAP_FC_CAP].rate_limit);
 
        ph->hops->fastchannel_init(ph, POWERCAP_DESCRIBE_FASTCHANNEL,
                                   POWERCAP_CAP_GET, 4, domain,
-                                  &fc[POWERCAP_FC_CAP].get_addr, NULL);
+                                  &fc[POWERCAP_FC_CAP].get_addr, NULL,
+                                  &fc[POWERCAP_FC_CAP].rate_limit);
 
        ph->hops->fastchannel_init(ph, POWERCAP_DESCRIBE_FASTCHANNEL,
                                   POWERCAP_PAI_SET, 4, domain,
                                   &fc[POWERCAP_FC_PAI].set_addr,
-                                  &fc[POWERCAP_FC_PAI].set_db);
+                                  &fc[POWERCAP_FC_PAI].set_db,
+                                  &fc[POWERCAP_FC_PAI].rate_limit);
 
        ph->hops->fastchannel_init(ph, POWERCAP_DESCRIBE_FASTCHANNEL,
                                   POWERCAP_PAI_GET, 4, domain,
-                                  &fc[POWERCAP_FC_PAI].get_addr, NULL);
+                                  &fc[POWERCAP_FC_PAI].get_addr, NULL,
+                                  &fc[POWERCAP_PAI_GET].rate_limit);
 
        *p_fc = fc;
 }
index e683c26f24eb0cffac8a817c6d8162a61ae1d4c2..8b5d9ce4a33a16fd0fc8cb191dabc67d09476d78 100644 (file)
@@ -234,6 +234,7 @@ struct scmi_fc_info {
        void __iomem *set_addr;
        void __iomem *get_addr;
        struct scmi_fc_db_info *set_db;
+       u32 rate_limit;
 };
 
 /**
@@ -268,7 +269,8 @@ struct scmi_proto_helpers_ops {
                                 u8 describe_id, u32 message_id,
                                 u32 valid_size, u32 domain,
                                 void __iomem **p_addr,
-                                struct scmi_fc_db_info **p_db);
+                                struct scmi_fc_db_info **p_db,
+                                u32 *rate_limit);
        void (*fastchannel_db_ring)(struct scmi_fc_db_info *db);
 };
 
index acd956ffcb848484b91ff70916140c4bb912ac7d..fafedb3b6604b65bd545501652a42ad7f672b366 100644 (file)
@@ -139,6 +139,8 @@ struct scmi_perf_domain_info {
  *     at a given frequency
  * @fast_switch_possible: indicates if fast DVFS switching is possible or not
  *     for a given device
+ * @fast_switch_rate_limit: gets the minimum time (us) required between
+ *     successive fast_switching requests
  * @power_scale_mw_get: indicates if the power values provided are in milliWatts
  *     or in some other (abstract) scale
  */
@@ -168,6 +170,8 @@ struct scmi_perf_proto_ops {
                             unsigned long *rate, unsigned long *power);
        bool (*fast_switch_possible)(const struct scmi_protocol_handle *ph,
                                     u32 domain);
+       int (*fast_switch_rate_limit)(const struct scmi_protocol_handle *ph,
+                                     u32 domain, u32 *rate_limit);
        enum scmi_power_scale (*power_scale_get)(const struct scmi_protocol_handle *ph);
 };