[RFC][PATCH v0.1 2/6] PM: EM: Call em_compute_costs() from em_create_perf_table()

Rafael J. Wysocki posted 1 patch 2 weeks, 1 day ago
kernel/power/energy_model.c |    8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
[RFC][PATCH v0.1 2/6] PM: EM: Call em_compute_costs() from em_create_perf_table()
Posted by Rafael J. Wysocki 2 weeks, 1 day ago
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

In preparation for subsequent changes, move the em_compute_costs()
invocation from em_create_perf_table() to em_create_pd() which is its
only caller.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 kernel/power/energy_model.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux-pm/kernel/power/energy_model.c
===================================================================
--- linux-pm.orig/kernel/power/energy_model.c
+++ linux-pm/kernel/power/energy_model.c
@@ -388,10 +388,6 @@ static int em_create_perf_table(struct d
 
 	em_init_performance(dev, pd, table, nr_states);
 
-	ret = em_compute_costs(dev, table, cb, nr_states, flags);
-	if (ret)
-		return -EINVAL;
-
 	return 0;
 }
 
@@ -434,6 +430,10 @@ static int em_create_pd(struct device *d
 	if (ret)
 		goto free_pd_table;
 
+	ret = em_compute_costs(dev, em_table->state, cb, nr_states, flags);
+	if (ret)
+		goto free_pd_table;
+
 	rcu_assign_pointer(pd->em_table, em_table);
 
 	if (_is_cpu_device(dev))
Re: [RFC][PATCH v0.1 2/6] PM: EM: Call em_compute_costs() from em_create_perf_table()
Posted by Dietmar Eggemann 1 week, 4 days ago
On 08/11/2024 17:37, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> In preparation for subsequent changes, move the em_compute_costs()
> invocation from em_create_perf_table() to em_create_pd() which is its
> only caller.

You have to do this since em_create_perf_table() is only called when 'if
(cb->active_power) != NULL'.

And 'cb->active_power == NULL' is what you use for your new 'stub' PD case.

Maybe worth mentioning already here? You do mention this in the
following patch though.

[...]