Lines Matching +full:performance +full:- +full:domain

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (c) 2018-2021, Arm ltd.
21 * Mutex serializing the registrations of performance domains and letting
34 return (dev->bus == &cpu_subsys); in _is_cpu_device()
48 struct em_dbg_info *em_dbg = s->private; \
53 table = em_perf_state_from_pd(em_dbg->pd); \
54 val = table[em_dbg->ps_id].name; \
65 DEFINE_EM_DBG_SHOW(performance, performance);
87 /* Create per-ps directory */ in em_debug_create_ps()
95 debugfs_create_file("performance", 0444, d, &em_dbg[i], in em_debug_create_ps()
103 seq_printf(s, "%*pbl\n", cpumask_pr_args(to_cpumask(s->private))); in em_debug_cpus_show()
111 struct em_perf_domain *pd = s->private; in em_debug_flags_show()
113 seq_printf(s, "%#lx\n", pd->flags); in em_debug_flags_show()
125 /* Create the directory of the performance domain */ in em_debug_create_pd()
129 debugfs_create_file("cpus", 0444, d, dev->em_pd->cpus, in em_debug_create_pd()
132 debugfs_create_file("flags", 0444, d, dev->em_pd, in em_debug_create_pd()
135 em_dbg = devm_kcalloc(dev, dev->em_pd->nr_perf_states, in em_debug_create_pd()
140 /* Create a sub-directory for each performance state */ in em_debug_create_pd()
141 for (i = 0; i < dev->em_pd->nr_perf_states; i++) in em_debug_create_pd()
142 em_debug_create_ps(dev->em_pd, em_dbg, i, d); in em_debug_create_pd()
179 call_rcu(&table->rcu, em_destroy_table_rcu); in em_release_table_kref()
183 * em_table_free() - Handles safe free of the EM table when needed
190 kref_put(&table->kref, em_release_table_kref); in em_table_free()
194 * em_table_alloc() - Allocate a new EM table
195 * @pd : EM performance domain for which this must be done
206 table_size = sizeof(struct em_perf_state) * pd->nr_perf_states; in em_table_alloc()
212 kref_init(&table->kref); in em_table_alloc()
230 * Calculate the performance value for each frequency with in em_init_performance()
234 fmax = (u64) table[nr_states - 1].frequency; in em_init_performance()
237 table[i].performance = div64_u64(max_cap * table[i].frequency, in em_init_performance()
248 /* Compute the cost of each performance state. */ in em_compute_costs()
249 for (i = nr_states - 1; i >= 0; i--) { in em_compute_costs()
252 if ((flags & EM_PERF_DOMAIN_ARTIFICIAL) && cb->get_cost) { in em_compute_costs()
253 ret = cb->get_cost(dev, table[i].frequency, &cost); in em_compute_costs()
257 return -EINVAL; in em_compute_costs()
262 cost = power_res / table[i].performance; in em_compute_costs()
280 * em_dev_compute_costs() - Calculate cost values for new runtime EM table
283 * @nr_states : Number of performance states
287 * the efficiency flag for each performance state. When the function finish
299 * em_dev_update_perf_domain() - Update runtime EM table for a device
306 * from a non-sleeping context.
317 return -EINVAL; in em_dev_update_perf_domain()
322 if (!dev->em_pd) { in em_dev_update_perf_domain()
324 return -EINVAL; in em_dev_update_perf_domain()
326 pd = dev->em_pd; in em_dev_update_perf_domain()
328 kref_get(&new_table->kref); in em_dev_update_perf_domain()
330 old_table = pd->em_table; in em_dev_update_perf_domain()
331 rcu_assign_pointer(pd->em_table, new_table); in em_dev_update_perf_domain()
333 em_cpufreq_update_efficiencies(dev, new_table->state); in em_dev_update_perf_domain()
348 int nr_states = pd->nr_perf_states; in em_create_perf_table()
351 /* Build the list of performance states for this performance domain */ in em_create_perf_table()
355 * lowest performance state of 'dev' above 'freq' and updates in em_create_perf_table()
358 ret = cb->active_power(dev, &power, &freq); in em_create_perf_table()
362 return -EINVAL; in em_create_perf_table()
367 * higher performance states. in em_create_perf_table()
370 dev_err(dev, "EM: non-increasing freq: %lu\n", in em_create_perf_table()
372 return -EINVAL; in em_create_perf_table()
382 return -EINVAL; in em_create_perf_table()
393 return -EINVAL; in em_create_perf_table()
413 return -EINVAL; in em_create_pd()
418 return -ENOMEM; in em_create_pd()
424 return -ENOMEM; in em_create_pd()
427 pd->nr_perf_states = nr_states; in em_create_pd()
433 ret = em_create_perf_table(dev, pd, em_table->state, cb, flags); in em_create_pd()
437 rcu_assign_pointer(pd->em_table, em_table); in em_create_pd()
442 cpu_dev->em_pd = pd; in em_create_pd()
445 dev->em_pd = pd; in em_create_pd()
453 return -EINVAL; in em_create_pd()
459 struct em_perf_domain *pd = dev->em_pd; in em_cpufreq_update_efficiencies()
480 for (i = 0; i < pd->nr_perf_states; i++) { in em_cpufreq_update_efficiencies()
497 pd->flags |= EM_PERF_DOMAIN_SKIP_INEFFICIENCIES; in em_cpufreq_update_efficiencies()
501 * em_pd_get() - Return the performance domain for a device
502 * @dev : Device to find the performance domain for
504 * Returns the performance domain to which @dev belongs, or NULL if it doesn't
512 return dev->em_pd; in em_pd_get()
517 * em_cpu_get() - Return the performance domain for a CPU
518 * @cpu : CPU to find the performance domain for
520 * Returns the performance domain to which @cpu belongs, or NULL if it doesn't
536 * em_dev_register_perf_domain() - Register the Energy Model (EM) for a device
538 * @nr_states : Number of performance states to register
541 * obligatory. It can be taken from i.e. 'policy->cpus'. For other
543 * @microwatts : Flag indicating that the power values are in micro-Watts or
546 * Create Energy Model tables for a performance domain using the callbacks
550 * sub-systems might rely on this flag and check if all devices in the EM are
553 * If multiple clients register the same performance domain, all but the first
567 return -EINVAL; in em_dev_register_perf_domain()
570 * Use a mutex to serialize the registration of performance domains and in em_dev_register_perf_domain()
571 * let the driver-defined callback functions sleep. in em_dev_register_perf_domain()
575 if (dev->em_pd) { in em_dev_register_perf_domain()
576 ret = -EEXIST; in em_dev_register_perf_domain()
583 ret = -EINVAL; in em_dev_register_perf_domain()
590 ret = -EEXIST; in em_dev_register_perf_domain()
594 * All CPUs of a domain must have the same in em_dev_register_perf_domain()
595 * micro-architecture since they all share the same in em_dev_register_perf_domain()
603 ret = -EINVAL; in em_dev_register_perf_domain()
612 else if (cb->get_cost) in em_dev_register_perf_domain()
622 ret = -EINVAL; in em_dev_register_perf_domain()
630 dev->em_pd->flags |= flags; in em_dev_register_perf_domain()
631 dev->em_pd->min_perf_state = 0; in em_dev_register_perf_domain()
632 dev->em_pd->max_perf_state = nr_states - 1; in em_dev_register_perf_domain()
634 em_cpufreq_update_efficiencies(dev, dev->em_pd->em_table->state); in em_dev_register_perf_domain()
637 dev_info(dev, "EM: created perf domain\n"); in em_dev_register_perf_domain()
650 * em_dev_unregister_perf_domain() - Unregister Energy Model (EM) for a device
657 if (IS_ERR_OR_NULL(dev) || !dev->em_pd) in em_dev_unregister_perf_domain()
665 * from potential clean-up/setup issues in the debugfs directories. in em_dev_unregister_perf_domain()
671 em_table_free(dev->em_pd->em_table); in em_dev_unregister_perf_domain()
673 kfree(dev->em_pd); in em_dev_unregister_perf_domain()
674 dev->em_pd = NULL; in em_dev_unregister_perf_domain()
689 new_ps = em_table->state; in em_table_dup()
694 ps_size = sizeof(struct em_perf_state) * pd->nr_perf_states; in em_table_dup()
707 ret = em_compute_costs(dev, em_table->state, NULL, pd->nr_perf_states, in em_recalc_and_update()
708 pd->flags); in em_recalc_and_update()
717 * This is one-time-update, so give up the ownership in this updater. in em_recalc_and_update()
727 * Adjustment of CPU performance values after boot, when all CPUs capacites
742 em_init_performance(dev, pd, em_table->state, pd->nr_perf_states); in em_adjust_new_capacity()
789 em_max_perf = table[pd->nr_perf_states - 1].performance; in em_check_capacity_update()
794 * and trigger the update for new performance values. in em_check_capacity_update()
815 * em_dev_update_chip_binning() - Update Energy Model after the new voltage
830 return -EINVAL; in em_dev_update_chip_binning()
835 return -EINVAL; in em_dev_update_chip_binning()
841 return -ENOMEM; in em_dev_update_chip_binning()
845 for (i = 0; i < pd->nr_perf_states; i++) { in em_dev_update_chip_binning()
846 unsigned long freq = em_table->state[i].frequency; in em_dev_update_chip_binning()
855 em_table->state[i].power = power; in em_dev_update_chip_binning()
864 * em_update_performance_limits() - Update Energy Model with performance
866 * @pd : Performance Domain with EM that has to be updated.
871 * performance levels. It takes the minimum and maximum frequency in kHz
872 * and does internal translation to performance levels.
873 * Returns 0 on success or -EINVAL when failed.
879 int min_ps = -1; in em_update_performance_limits()
880 int max_ps = -1; in em_update_performance_limits()
884 return -EINVAL; in em_update_performance_limits()
889 for (i = 0; i < pd->nr_perf_states; i++) { in em_update_performance_limits()
899 return -EINVAL; in em_update_performance_limits()
904 pd->min_perf_state = min_ps; in em_update_performance_limits()
905 pd->max_perf_state = max_ps; in em_update_performance_limits()