[PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper
Dmitry Osipenko
digetx at gmail.com
Mon Aug 23 13:24:02 PDT 2021
20.08.2021 15:57, Ulf Hansson пишет:
...
>> We already have similar APIs, so that won't be a problem. We also have
>> a mechanism inside the OPP core, frequency based, which is used to
>> guess the current OPP. Maybe we can enhance and use that directly
>> here.
>
> After reading the last reply from Dmitry, I am starting to think that
> the problem he is facing can be described and solved in a much easier
> way.
>
> If I am correct, it looks like we don't need to add APIs to get OPPs
> for a clock rate or set initial performance state values according to
> the HW in genpd.
>
> See my other response to Dmitry, let's see where that leads us.
I'm going to start preparing v9 with GENPD performance state syncing moved into driver's probe where appropriate.
It's not clear to me whether it will be okay to add a generic OPP syncing by clock rate or should it be a Tegra-specific helper. Viresh, what do you think about this generic OPP helper:
/**
* dev_pm_opp_sync_with_clk_rate() - Sync OPP state with clock rate
* @dev: device for which we do this operation
*
* Sync OPP table state with the current clock rate of device.
*
* Return: 0 on success or a negative error value.
*/
int dev_pm_opp_sync_with_clk_rate(struct device *dev)
{
struct opp_table *opp_table;
int ret = 0;
/* Device may not have OPP table */
opp_table = _find_opp_table(dev);
if (IS_ERR(opp_table))
return 0;
/* Device may not use clock */
if (IS_ERR(opp_table->clk))
goto put_table;
/* Device may have empty OPP table */
if (!_get_opp_count(opp_table))
goto put_table;
ret = dev_pm_opp_set_rate(dev, clk_get_rate(opp_table->clk));
put_table:
/* Drop reference taken by _find_opp_table() */
dev_pm_opp_put_opp_table(opp_table);
return ret;
}
EXPORT_SYMBOL_GPL(dev_pm_opp_sync_with_clk_rate);
More information about the linux-mtd
mailing list