firmware: arm_scmi: Align perf ops to use domain-id as in-parameter

Most scmi_perf_proto_ops are already using an "u32 domain" as an
in-parameter to indicate what performance domain we shall operate upon.
However, some of the ops are using a "struct device *dev", which means that
an additional OF parsing is needed each time the perf ops gets called, to
find the corresponding domain-id.

To avoid the above, but also to make the code more consistent, let's
replace the in-parameter "struct device *dev" with an "u32 domain". Note
that, this requires us to make some corresponding changes to the scmi
cpufreq driver, so let's do that too.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: https://lore.kernel.org/r/20230825112633.236607-5-ulf.hansson@linaro.org
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
This commit is contained in:
Ulf Hansson 2023-08-25 13:26:24 +02:00 committed by Sudeep Holla
parent e336baa419
commit 39dfa5b9e1
3 changed files with 16 additions and 26 deletions

View file

@ -137,7 +137,7 @@ scmi_get_cpu_power(struct device *cpu_dev, unsigned long *power,
static int scmi_cpufreq_init(struct cpufreq_policy *policy) static int scmi_cpufreq_init(struct cpufreq_policy *policy)
{ {
int ret, nr_opp; int ret, nr_opp, domain;
unsigned int latency; unsigned int latency;
struct device *cpu_dev; struct device *cpu_dev;
struct scmi_data *priv; struct scmi_data *priv;
@ -149,6 +149,10 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
return -ENODEV; return -ENODEV;
} }
domain = scmi_cpu_domain_id(cpu_dev);
if (domain < 0)
return domain;
priv = kzalloc(sizeof(*priv), GFP_KERNEL); priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
@ -187,7 +191,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
*/ */
nr_opp = dev_pm_opp_get_opp_count(cpu_dev); nr_opp = dev_pm_opp_get_opp_count(cpu_dev);
if (nr_opp <= 0) { if (nr_opp <= 0) {
ret = perf_ops->device_opps_add(ph, cpu_dev); ret = perf_ops->device_opps_add(ph, cpu_dev, domain);
if (ret) { if (ret) {
dev_warn(cpu_dev, "failed to add opps to the device\n"); dev_warn(cpu_dev, "failed to add opps to the device\n");
goto out_free_cpumask; goto out_free_cpumask;
@ -220,7 +224,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
} }
priv->cpu_dev = cpu_dev; priv->cpu_dev = cpu_dev;
priv->domain_id = scmi_cpu_domain_id(cpu_dev); priv->domain_id = domain;
policy->driver_data = priv; policy->driver_data = priv;
policy->freq_table = freq_table; policy->freq_table = freq_table;
@ -228,14 +232,14 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
/* SCMI allows DVFS request for any domain from any CPU */ /* SCMI allows DVFS request for any domain from any CPU */
policy->dvfs_possible_from_any_cpu = true; policy->dvfs_possible_from_any_cpu = true;
latency = perf_ops->transition_latency_get(ph, cpu_dev); latency = perf_ops->transition_latency_get(ph, domain);
if (!latency) if (!latency)
latency = CPUFREQ_ETERNAL; latency = CPUFREQ_ETERNAL;
policy->cpuinfo.transition_latency = latency; policy->cpuinfo.transition_latency = latency;
policy->fast_switch_possible = policy->fast_switch_possible =
perf_ops->fast_switch_possible(ph, cpu_dev); perf_ops->fast_switch_possible(ph, domain);
return 0; return 0;

View file

@ -795,17 +795,13 @@ static int scmi_dev_domain_id(struct device *dev)
} }
static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph, static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph,
struct device *dev) struct device *dev, u32 domain)
{ {
int idx, ret, domain; int idx, ret;
unsigned long freq; unsigned long freq;
struct scmi_opp *opp; struct scmi_opp *opp;
struct perf_dom_info *dom; struct perf_dom_info *dom;
domain = scmi_dev_domain_id(dev);
if (domain < 0)
return -EINVAL;
dom = scmi_perf_domain_lookup(ph, domain); dom = scmi_perf_domain_lookup(ph, domain);
if (IS_ERR(dom)) if (IS_ERR(dom))
return PTR_ERR(dom); return PTR_ERR(dom);
@ -838,15 +834,10 @@ static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph,
static int static int
scmi_dvfs_transition_latency_get(const struct scmi_protocol_handle *ph, scmi_dvfs_transition_latency_get(const struct scmi_protocol_handle *ph,
struct device *dev) u32 domain)
{ {
int domain;
struct perf_dom_info *dom; struct perf_dom_info *dom;
domain = scmi_dev_domain_id(dev);
if (domain < 0)
return -EINVAL;
dom = scmi_perf_domain_lookup(ph, domain); dom = scmi_perf_domain_lookup(ph, domain);
if (IS_ERR(dom)) if (IS_ERR(dom))
return PTR_ERR(dom); return PTR_ERR(dom);
@ -942,15 +933,10 @@ static int scmi_dvfs_est_power_get(const struct scmi_protocol_handle *ph,
} }
static bool scmi_fast_switch_possible(const struct scmi_protocol_handle *ph, static bool scmi_fast_switch_possible(const struct scmi_protocol_handle *ph,
struct device *dev) u32 domain)
{ {
int domain;
struct perf_dom_info *dom; struct perf_dom_info *dom;
domain = scmi_dev_domain_id(dev);
if (domain < 0)
return false;
dom = scmi_perf_domain_lookup(ph, domain); dom = scmi_perf_domain_lookup(ph, domain);
if (IS_ERR(dom)) if (IS_ERR(dom))
return false; return false;

View file

@ -149,9 +149,9 @@ struct scmi_perf_proto_ops {
u32 *level, bool poll); u32 *level, bool poll);
int (*device_domain_id)(struct device *dev); int (*device_domain_id)(struct device *dev);
int (*transition_latency_get)(const struct scmi_protocol_handle *ph, int (*transition_latency_get)(const struct scmi_protocol_handle *ph,
struct device *dev); u32 domain);
int (*device_opps_add)(const struct scmi_protocol_handle *ph, int (*device_opps_add)(const struct scmi_protocol_handle *ph,
struct device *dev); struct device *dev, u32 domain);
int (*freq_set)(const struct scmi_protocol_handle *ph, u32 domain, int (*freq_set)(const struct scmi_protocol_handle *ph, u32 domain,
unsigned long rate, bool poll); unsigned long rate, bool poll);
int (*freq_get)(const struct scmi_protocol_handle *ph, u32 domain, int (*freq_get)(const struct scmi_protocol_handle *ph, u32 domain,
@ -159,7 +159,7 @@ struct scmi_perf_proto_ops {
int (*est_power_get)(const struct scmi_protocol_handle *ph, u32 domain, int (*est_power_get)(const struct scmi_protocol_handle *ph, u32 domain,
unsigned long *rate, unsigned long *power); unsigned long *rate, unsigned long *power);
bool (*fast_switch_possible)(const struct scmi_protocol_handle *ph, bool (*fast_switch_possible)(const struct scmi_protocol_handle *ph,
struct device *dev); u32 domain);
enum scmi_power_scale (*power_scale_get)(const struct scmi_protocol_handle *ph); enum scmi_power_scale (*power_scale_get)(const struct scmi_protocol_handle *ph);
}; };