exynos: acme: dumb down code to take in any freq table
Don't validate it, just take it. This will make it much easier to tune CPU frequencies. Signed-off-by: Nahuel Gómez <nahuelgomez329@gmail.com>
This commit is contained in:
parent
e89716836f
commit
eb36a10226
1 changed files with 23 additions and 76 deletions
|
@ -1694,16 +1694,14 @@ static int init_fast_switch(struct exynos_cpufreq_domain *domain,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init_domain(struct exynos_cpufreq_domain *domain,
|
static int init_domain(struct exynos_cpufreq_domain *domain,
|
||||||
struct device_node *dn)
|
struct device_node *dn)
|
||||||
{
|
{
|
||||||
unsigned int val, raw_table_size;
|
unsigned int raw_table_size;
|
||||||
int index, i;
|
int index, cpu;
|
||||||
unsigned int freq_table[100];
|
unsigned int freq_table[100];
|
||||||
struct freq_volt *fv_table;
|
struct freq_volt *fv_table;
|
||||||
const char *buf;
|
const char *buf;
|
||||||
int cpu;
|
|
||||||
int ret;
|
int ret;
|
||||||
int cur_idx;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get cpumask which belongs to domain.
|
* Get cpumask which belongs to domain.
|
||||||
|
@ -1728,79 +1726,39 @@ static int init_domain(struct exynos_cpufreq_domain *domain,
|
||||||
domain->dss_type = domain->id;
|
domain->dss_type = domain->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Set min/max frequency from the device tree */
|
||||||
* Set min/max frequency.
|
if (of_property_read_u32(dn, "max-freq", &domain->max_freq)) {
|
||||||
* If max-freq property exists in device tree, max frequency is
|
pr_err("%s: max-freq does not exist\n", __func__);
|
||||||
* selected to smaller one between the value defined in device
|
return -ENODATA;
|
||||||
* tree and CAL. In case of min-freq, min frequency is selected
|
|
||||||
* to bigger one.
|
|
||||||
*/
|
|
||||||
domain->max_freq = cal_dfs_get_max_freq(domain->cal_id);
|
|
||||||
domain->min_freq = cal_dfs_get_min_freq(domain->cal_id);
|
|
||||||
|
|
||||||
if (!of_property_read_u32(dn, "max-freq", &val))
|
|
||||||
domain->max_freq = min(domain->max_freq, val);
|
|
||||||
if (!of_property_read_u32(dn, "min-freq", &val))
|
|
||||||
domain->min_freq = max(domain->min_freq, val);
|
|
||||||
|
|
||||||
if (domain->id == 1) { // BIG
|
|
||||||
domain->boot_freq = 2400000;
|
|
||||||
} else if (domain->id == 0) {
|
|
||||||
domain->boot_freq = 2002000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get freq-table from device tree and cut the out of range */
|
if (of_property_read_u32(dn, "min-freq", &domain->min_freq)) {
|
||||||
raw_table_size = of_property_count_u32_elems(dn, "freq-table");
|
pr_err("%s: min-freq does not exist\n", __func__);
|
||||||
if (of_property_read_u32_array(dn, "freq-table",
|
|
||||||
freq_table, raw_table_size)) {
|
|
||||||
pr_err("%s: freq-table does not exist\n", __func__);
|
|
||||||
return -ENODATA;
|
return -ENODATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the ECT's min/max frequency are asynchronous with the dts',
|
* Directly read the frequency table from the device tree.
|
||||||
* adjust the freq table with the ECT's min/max frequency.
|
|
||||||
* It only supports the situations when the ECT's min is higher than the dts'
|
|
||||||
* or the ECT's max is lower than the dts'.
|
|
||||||
*/
|
*/
|
||||||
adjust_freq_table_with_min_max_freq(freq_table, raw_table_size, domain);
|
raw_table_size = of_property_count_u32_elems(dn, "freq-table");
|
||||||
|
if (of_property_read_u32_array(dn, "freq-table", freq_table, raw_table_size)) {
|
||||||
domain->table_size = 0;
|
pr_err("%s: freq-table does not exist\n", __func__);
|
||||||
for (index = 0; index < raw_table_size; index++) {
|
return -ENODATA;
|
||||||
if (freq_table[index] > domain->max_freq ||
|
|
||||||
freq_table[index] < domain->min_freq) {
|
|
||||||
freq_table[index] = CPUFREQ_ENTRY_INVALID;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
domain->table_size++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
domain->table_size = raw_table_size;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get volt table from CAL with given freq-table
|
* Allocate and initialize the frequency-voltage table.
|
||||||
* cal_dfs_get_freq_volt_table() is called by filling the desired
|
|
||||||
* frequency in fv_table, the corresponding volt is filled.
|
|
||||||
*/
|
*/
|
||||||
fv_table = kzalloc(sizeof(struct freq_volt)
|
fv_table = kzalloc(sizeof(struct freq_volt) * domain->table_size, GFP_KERNEL);
|
||||||
* (domain->table_size), GFP_KERNEL);
|
|
||||||
if (!fv_table) {
|
if (!fv_table) {
|
||||||
pr_err("%s: failed to alloc fv_table\n", __func__);
|
pr_err("%s: failed to alloc fv_table\n", __func__);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
for (index = 0; index < domain->table_size; index++) {
|
||||||
for (index = 0; index < raw_table_size; index++) {
|
fv_table[index].freq = freq_table[index];
|
||||||
if (freq_table[index] == CPUFREQ_ENTRY_INVALID)
|
|
||||||
continue;
|
|
||||||
fv_table[i].freq = freq_table[index];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cal_dfs_get_freq_volt_table(domain->cal_id,
|
|
||||||
fv_table, domain->table_size)) {
|
|
||||||
pr_err("%s: failed to get fv table from CAL\n", __func__);
|
|
||||||
kfree(fv_table);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1808,8 +1766,7 @@ static int init_domain(struct exynos_cpufreq_domain *domain,
|
||||||
* Last row of frequency table must be set to CPUFREQ_TABLE_END.
|
* Last row of frequency table must be set to CPUFREQ_TABLE_END.
|
||||||
* Table size should be one larger than real table size.
|
* Table size should be one larger than real table size.
|
||||||
*/
|
*/
|
||||||
domain->freq_table = kzalloc(sizeof(struct cpufreq_frequency_table)
|
domain->freq_table = kzalloc(sizeof(struct cpufreq_frequency_table) * (domain->table_size + 1), GFP_KERNEL);
|
||||||
* (domain->table_size + 1), GFP_KERNEL);
|
|
||||||
if (!domain->freq_table) {
|
if (!domain->freq_table) {
|
||||||
kfree(fv_table);
|
kfree(fv_table);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -1828,9 +1785,7 @@ static int init_domain(struct exynos_cpufreq_domain *domain,
|
||||||
*/
|
*/
|
||||||
for (index = domain->table_size - 1; index >= 0; index--) {
|
for (index = domain->table_size - 1; index >= 0; index--) {
|
||||||
for_each_cpu_and(cpu, &domain->cpus, cpu_possible_mask)
|
for_each_cpu_and(cpu, &domain->cpus, cpu_possible_mask)
|
||||||
dev_pm_opp_add(get_cpu_device(cpu),
|
dev_pm_opp_add(get_cpu_device(cpu), fv_table[index].freq * 1000, fv_table[index].volt);
|
||||||
fv_table[index].freq * 1000,
|
|
||||||
fv_table[index].volt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kfree(fv_table);
|
kfree(fv_table);
|
||||||
|
@ -1840,20 +1795,12 @@ static int init_domain(struct exynos_cpufreq_domain *domain,
|
||||||
*/
|
*/
|
||||||
domain->resume_freq = cal_dfs_get_resume_freq(domain->cal_id);
|
domain->resume_freq = cal_dfs_get_resume_freq(domain->cal_id);
|
||||||
domain->old = get_freq(domain);
|
domain->old = get_freq(domain);
|
||||||
if (domain->old < domain->min_freq || domain->max_freq < domain->old) {
|
|
||||||
WARN(1, "Out-of-range freq(%dkhz) returned for domain%d in init time\n",
|
|
||||||
domain->old, domain->id);
|
|
||||||
domain->old = domain->boot_freq;
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_idx = exynos_cpufreq_find_index(domain, domain->old);
|
|
||||||
domain->old = domain->freq_table[cur_idx].frequency;
|
|
||||||
|
|
||||||
mutex_init(&domain->lock);
|
mutex_init(&domain->lock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize CPUFreq DVFS Manager
|
* Initialize CPUFreq DVFS Manager
|
||||||
* DVFS Manager is the optional function, it does not check return value
|
* DVFS Manager is the optional function, it does not check return value.
|
||||||
*/
|
*/
|
||||||
init_dm(domain, dn);
|
init_dm(domain, dn);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue