On 05/22/2014 10:05 PM, Viresh Kumar wrote:
On 22 May 2014 22:09, Stephen Warren swarren@wwwdotorg.org wrote:
I think the call to tegra_target_intermediate() is wrong here; shouldn't the cpufreq core guarantee that tegra_target_intermediate() has always been called before tegra_target(), so there's no need to repeat that call here?
Also, tegra_target() doesn't seem to follow the rule documented by patch 2/3 that states ->target() should restore the orignal frequency on error. I'm not even sure if that's possible in general.
I thought I took care of that. Can you please give some example when we aren't restoring original frequency on failure ?
About the rule, that has to be the expectation from core as there is no way out that for core to know what happened at end of target_index()..
It can call get_rate() but that would be over engineering it looks ..
E.g. in the following code after the series is applied:
ret = clk_set_rate(pll_x_clk, rate * 1000); /* Restore to earlier frequency on error, i.e. pll_x */ if (ret) pr_err("Failed to change pll_x to %lu\n", rate);
ret = clk_set_parent(cpu_clk, pll_x_clk);
If the clk_set_rate() failed, we have no idea what the pll_x rate is; I don't think the clock API guarantees that zero HW changes have been made if the function fails. Yet the code switches the CPU clock back to pll_x without attempting to fix the pll_x rate to be the old rate. Perhaps there's not much that can be done here though, since if one clk_set_rate() failed, perhaps the one to fix it will too.
I suspect there are other issues, like switching between pll_p/pllx might not be restored on error, and the EMC frequency isn't switched back, etc.