Re: [PATCH v1] cpufreq: qcom: Read voltage LUT and populate OPP
From: Matthias Kaehlcke
Date: Mon Jan 07 2019 - 19:02:18 EST
Hi Taniya.
On Mon, Dec 24, 2018 at 12:29:18AM +0530, Taniya Das wrote:
> Could you help validating with the patch below?
...
> diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c
> b/drivers/cpufreq/qcom-cpufreq-hw.c
> index 7559b87..23338b2 100644
> --- a/drivers/cpufreq/qcom-cpufreq-hw.c
> +++ b/drivers/cpufreq/qcom-cpufreq-hw.c
> @@ -81,7 +81,6 @@ static int qcom_cpufreq_hw_read_lut(struct device *dev,
> u32 volt;
> unsigned int max_cores = cpumask_weight(policy->cpus);
> struct cpufreq_frequency_table *table;
> - unsigned long cpu_r;
>
> table = kcalloc(LUT_MAX_ENTRIES + 1, sizeof(*table), GFP_KERNEL);
> if (!table)
> @@ -110,6 +109,8 @@ static int qcom_cpufreq_hw_read_lut(struct device *dev,
> table[i].frequency = freq;
> dev_dbg(dev, "index=%d freq=%d, core_count %d\n", i,
> freq, core_count);
> + dev_pm_opp_add(get_cpu_device(policy->cpu),
> + freq * 1000, volt);
> }
>
> /*
> @@ -126,6 +127,8 @@ static int qcom_cpufreq_hw_read_lut(struct device *dev,
> if (prev_cc != max_cores) {
> prev->frequency = prev_freq;
> prev->flags = CPUFREQ_BOOST_FREQ;
> + dev_pm_opp_add(get_cpu_device(policy->cpu),
> + prev_freq * 1000, volt);
> }
>
> break;
> @@ -133,12 +136,9 @@ static int qcom_cpufreq_hw_read_lut(struct device *dev,
>
> prev_cc = core_count;
> prev_freq = freq;
> -
> - freq *= 1000;
> - for_each_cpu(cpu_r, policy->cpus)
> - dev_pm_opp_add(get_cpu_device(cpu_r), freq, volt);
> }
>
> + dev_pm_opp_set_sharing_cpus(get_cpu_device(policy->cpu),
> policy->cpus);
> table[i].frequency = CPUFREQ_TABLE_END;
> policy->freq_table = table;
>
> @@ -245,6 +245,7 @@ static int qcom_cpufreq_hw_cpu_exit(struct
> cpufreq_policy *policy)
> {
> void __iomem *base = policy->driver_data - REG_PERF_STATE;
>
> + dev_pm_opp_cpumask_remove_table(policy->cpus);
Evan found that this doesn't actually remove dynamically added
OPPs. You'll have to use the shiny new dev_pm_opp_remove_all_dynamic()
(https://lore.kernel.org/patchwork/patch/1028942/) instead.
Cheers
Matthias