Skip to content

Commit 24e9fb6

Browse files
lukaszluba-armrafaeljw
authored andcommitted
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>
1 parent 09417e6 commit 24e9fb6

File tree

2 files changed

+7
-41
lines changed

2 files changed

+7
-41
lines changed

include/linux/energy_model.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ struct em_perf_table {
5353

5454
/**
5555
* struct em_perf_domain - Performance domain
56-
* @table: List of performance states, in ascending order
5756
* @em_table: Pointer to the runtime modifiable em_perf_table
5857
* @nr_perf_states: Number of performance states
5958
* @flags: See "em_perf_domain flags"
@@ -69,7 +68,6 @@ struct em_perf_table {
6968
* field is unused.
7069
*/
7170
struct em_perf_domain {
72-
struct em_perf_state *table;
7371
struct em_perf_table __rcu *em_table;
7472
int nr_perf_states;
7573
unsigned long flags;

kernel/power/energy_model.c

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -276,17 +276,6 @@ static int em_compute_costs(struct device *dev, struct em_perf_state *table,
276276
return 0;
277277
}
278278

279-
static int em_allocate_perf_table(struct em_perf_domain *pd,
280-
int nr_states)
281-
{
282-
pd->table = kcalloc(nr_states, sizeof(struct em_perf_state),
283-
GFP_KERNEL);
284-
if (!pd->table)
285-
return -ENOMEM;
286-
287-
return 0;
288-
}
289-
290279
/**
291280
* em_dev_update_perf_domain() - Update runtime EM table for a device
292281
* @dev : Device for which the EM is to be updated
@@ -331,24 +320,6 @@ int em_dev_update_perf_domain(struct device *dev,
331320
}
332321
EXPORT_SYMBOL_GPL(em_dev_update_perf_domain);
333322

334-
static int em_create_runtime_table(struct em_perf_domain *pd)
335-
{
336-
struct em_perf_table __rcu *table;
337-
int table_size;
338-
339-
table = em_table_alloc(pd);
340-
if (!table)
341-
return -ENOMEM;
342-
343-
/* Initialize runtime table with existing data */
344-
table_size = sizeof(struct em_perf_state) * pd->nr_perf_states;
345-
memcpy(table->state, pd->table, table_size);
346-
347-
rcu_assign_pointer(pd->em_table, table);
348-
349-
return 0;
350-
}
351-
352323
static int em_create_perf_table(struct device *dev, struct em_perf_domain *pd,
353324
struct em_perf_state *table,
354325
struct em_data_callback *cb,
@@ -409,6 +380,7 @@ static int em_create_pd(struct device *dev, int nr_states,
409380
struct em_data_callback *cb, cpumask_t *cpus,
410381
unsigned long flags)
411382
{
383+
struct em_perf_table __rcu *em_table;
412384
struct em_perf_domain *pd;
413385
struct device *cpu_dev;
414386
int cpu, ret, num_cpus;
@@ -435,17 +407,15 @@ static int em_create_pd(struct device *dev, int nr_states,
435407

436408
pd->nr_perf_states = nr_states;
437409

438-
ret = em_allocate_perf_table(pd, nr_states);
439-
if (ret)
410+
em_table = em_table_alloc(pd);
411+
if (!em_table)
440412
goto free_pd;
441413

442-
ret = em_create_perf_table(dev, pd, pd->table, cb, flags);
414+
ret = em_create_perf_table(dev, pd, em_table->state, cb, flags);
443415
if (ret)
444416
goto free_pd_table;
445417

446-
ret = em_create_runtime_table(pd);
447-
if (ret)
448-
goto free_pd_table;
418+
rcu_assign_pointer(pd->em_table, em_table);
449419

450420
if (_is_cpu_device(dev))
451421
for_each_cpu(cpu, cpus) {
@@ -458,7 +428,7 @@ static int em_create_pd(struct device *dev, int nr_states,
458428
return 0;
459429

460430
free_pd_table:
461-
kfree(pd->table);
431+
kfree(em_table);
462432
free_pd:
463433
kfree(pd);
464434
return -EINVAL;
@@ -629,7 +599,7 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
629599

630600
dev->em_pd->flags |= flags;
631601

632-
em_cpufreq_update_efficiencies(dev, dev->em_pd->table);
602+
em_cpufreq_update_efficiencies(dev, dev->em_pd->em_table->state);
633603

634604
em_debug_create_pd(dev);
635605
dev_info(dev, "EM: created perf domain\n");
@@ -666,8 +636,6 @@ void em_dev_unregister_perf_domain(struct device *dev)
666636
mutex_lock(&em_pd_mutex);
667637
em_debug_remove_pd(dev);
668638

669-
kfree(dev->em_pd->table);
670-
671639
em_table_free(dev->em_pd->em_table);
672640

673641
kfree(dev->em_pd);

0 commit comments

Comments
 (0)