summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukasz Luba <lukasz.luba@arm.com>2024-02-08 11:55:55 +0000
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2024-02-08 15:00:32 +0100
commit24e9fb635df2790eccb0e95ff65c6dee7a97fcb7 (patch)
tree7e7532b4574fe38467929a08e7123140d4657229
parent09417e673cbd578a1eaf8aba34a668119622d79c (diff)
PM: EM: Remove old table
Remove the old EM table which wasn't able to modify the data. Clean the unneeded function and refactor the code a bit. Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com> Tested-by: Dietmar Eggemann <dietmar.eggemann@arm.com> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--include/linux/energy_model.h2
-rw-r--r--kernel/power/energy_model.c46
2 files changed, 7 insertions, 41 deletions
diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h
index aabfc26fcd31..92866a81abe4 100644
--- a/include/linux/energy_model.h
+++ b/include/linux/energy_model.h
@@ -53,7 +53,6 @@ struct em_perf_table {
/**
* struct em_perf_domain - Performance domain
- * @table: List of performance states, in ascending order
* @em_table: Pointer to the runtime modifiable em_perf_table
* @nr_perf_states: Number of performance states
* @flags: See "em_perf_domain flags"
@@ -69,7 +68,6 @@ struct em_perf_table {
* field is unused.
*/
struct em_perf_domain {
- struct em_perf_state *table;
struct em_perf_table __rcu *em_table;
int nr_perf_states;
unsigned long flags;
diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
index 548908e686ed..57838d28af85 100644
--- a/kernel/power/energy_model.c
+++ b/kernel/power/energy_model.c
@@ -276,17 +276,6 @@ static int em_compute_costs(struct device *dev, struct em_perf_state *table,
return 0;
}
-static int em_allocate_perf_table(struct em_perf_domain *pd,
- int nr_states)
-{
- pd->table = kcalloc(nr_states, sizeof(struct em_perf_state),
- GFP_KERNEL);
- if (!pd->table)
- return -ENOMEM;
-
- return 0;
-}
-
/**
* em_dev_update_perf_domain() - Update runtime EM table for a device
* @dev : Device for which the EM is to be updated
@@ -331,24 +320,6 @@ int em_dev_update_perf_domain(struct device *dev,
}
EXPORT_SYMBOL_GPL(em_dev_update_perf_domain);
-static int em_create_runtime_table(struct em_perf_domain *pd)
-{
- struct em_perf_table __rcu *table;
- int table_size;
-
- table = em_table_alloc(pd);
- if (!table)
- return -ENOMEM;
-
- /* Initialize runtime table with existing data */
- table_size = sizeof(struct em_perf_state) * pd->nr_perf_states;
- memcpy(table->state, pd->table, table_size);
-
- rcu_assign_pointer(pd->em_table, table);
-
- return 0;
-}
-
static int em_create_perf_table(struct device *dev, struct em_perf_domain *pd,
struct em_perf_state *table,
struct em_data_callback *cb,
@@ -409,6 +380,7 @@ static int em_create_pd(struct device *dev, int nr_states,
struct em_data_callback *cb, cpumask_t *cpus,
unsigned long flags)
{
+ struct em_perf_table __rcu *em_table;
struct em_perf_domain *pd;
struct device *cpu_dev;
int cpu, ret, num_cpus;
@@ -435,17 +407,15 @@ static int em_create_pd(struct device *dev, int nr_states,
pd->nr_perf_states = nr_states;
- ret = em_allocate_perf_table(pd, nr_states);
- if (ret)
+ em_table = em_table_alloc(pd);
+ if (!em_table)
goto free_pd;
- ret = em_create_perf_table(dev, pd, pd->table, cb, flags);
+ ret = em_create_perf_table(dev, pd, em_table->state, cb, flags);
if (ret)
goto free_pd_table;
- ret = em_create_runtime_table(pd);
- if (ret)
- goto free_pd_table;
+ rcu_assign_pointer(pd->em_table, em_table);
if (_is_cpu_device(dev))
for_each_cpu(cpu, cpus) {
@@ -458,7 +428,7 @@ static int em_create_pd(struct device *dev, int nr_states,
return 0;
free_pd_table:
- kfree(pd->table);
+ kfree(em_table);
free_pd:
kfree(pd);
return -EINVAL;
@@ -629,7 +599,7 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
dev->em_pd->flags |= flags;
- em_cpufreq_update_efficiencies(dev, dev->em_pd->table);
+ em_cpufreq_update_efficiencies(dev, dev->em_pd->em_table->state);
em_debug_create_pd(dev);
dev_info(dev, "EM: created perf domain\n");
@@ -666,8 +636,6 @@ void em_dev_unregister_perf_domain(struct device *dev)
mutex_lock(&em_pd_mutex);
em_debug_remove_pd(dev);
- kfree(dev->em_pd->table);
-
em_table_free(dev->em_pd->em_table);
kfree(dev->em_pd);