OPP Updates for 6.11

- Introduce an OF helper function to inform if required-opps is used (Ulf Hansson).
 - Generic cleanus (Ulf Hansson and Viresh Kumar).
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEx73Crsp7f6M6scA70rkcPK6BEhwFAmaM30EACgkQ0rkcPK6B
 EhyZExAAn/HJ4ysBdbY+toOuLDRiwqZzV9IQD7DZ6VOmw3531c8Ju6s8y8l8Mt5R
 PRRU6KQWJpxOobmGItZ3ftQmnEQb4QgzVNqJSMj2ikOq+z38g/cyG/2KI4ll0iaw
 /uhrLbbP045N8IjNApEIkCIyGxOCBs6FboiwVIVzFAZNi9J8j4IQUJ2wqFVi2yRH
 v9Fy7XzR3wg+fQ9pbIhHTBC1yDDmcMVW2FRVGxOZBrKQR/Zrz0ACkZNFPn8gG8ar
 buGGBKCYmzvkm8v+r7mr+J8yI7KwBPWDpNR3+ETDD1x9BI/pHmkOEDb6ORPb7KjF
 DW6SowKNXg3j8i0JmPiZlPo0WqZpINeYVKRgLqwePj/M4SbYJaEVf73MTB0nhS1p
 EZeJleKRvhQYO2CpUs+Pkzy9BRyKYVyg/jFEKuLFG8ohK0N7ffPb+kLD4z2ThbMr
 sJZwT84KYzJySCRuLLh52oyuWnYHQlQ6H59PWFEmekHim7+/1mLTY3WAyfNV7zNZ
 DCqSc9zm9nrWiJ3dgNbKIJ3hWshCxqzKwDAFyns08cQVh5tV/XkEPgK2RP9kbQ/C
 yguPaEGZnPkmuc1IEqQ6sLiqfg+cGbq1ChuG/tvoMiFGo8IZ2IqucNdG5VOu+ENh
 XpQSuGA9/QzkFOF+zTL8LmTjsgX555bhBhR8Dx+8bXLiWeeQUhQ=
 =+kXo
 -----END PGP SIGNATURE-----

Merge tag 'opp-updates-6.11' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/vireshk/pm into pm-opp

Merge OPP Updates for 6.11 from Viresh Kumar:

"- Introduce an OF helper function to inform if required-opps is
   used (Ulf Hansson).
 - Generic cleanups (Ulf Hansson and Viresh Kumar)."

* tag 'opp-updates-6.11' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/vireshk/pm:
  OPP: Introduce an OF helper function to inform if required-opps is used
  OPP: Drop a redundant in-parameter to _set_opp_level()
  OPP: Fix missing cleanup on error in _opp_attach_genpd()
This commit is contained in:
Rafael J. Wysocki 2024-07-09 18:00:18 +02:00
commit 4e89a5309a
3 changed files with 46 additions and 7 deletions

View File

@ -1102,8 +1102,7 @@ static int _set_required_opps(struct device *dev, struct opp_table *opp_table,
return 0;
}
static int _set_opp_level(struct device *dev, struct opp_table *opp_table,
struct dev_pm_opp *opp)
static int _set_opp_level(struct device *dev, struct dev_pm_opp *opp)
{
unsigned int level = 0;
int ret = 0;
@ -1171,7 +1170,7 @@ static int _disable_opp_table(struct device *dev, struct opp_table *opp_table)
if (opp_table->regulators)
regulator_disable(opp_table->regulators[0]);
ret = _set_opp_level(dev, opp_table, NULL);
ret = _set_opp_level(dev, NULL);
if (ret)
goto out;
@ -1220,7 +1219,7 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table,
return ret;
}
ret = _set_opp_level(dev, opp_table, opp);
ret = _set_opp_level(dev, opp);
if (ret)
return ret;
@ -1267,7 +1266,7 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table,
return ret;
}
ret = _set_opp_level(dev, opp_table, opp);
ret = _set_opp_level(dev, opp);
if (ret)
return ret;
@ -2443,8 +2442,10 @@ static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev,
* Cross check it again and fix if required.
*/
gdev = dev_to_genpd_dev(virt_dev);
if (IS_ERR(gdev))
return PTR_ERR(gdev);
if (IS_ERR(gdev)) {
ret = PTR_ERR(gdev);
goto err;
}
genpd_table = _find_opp_table(gdev);
if (!IS_ERR(genpd_table)) {

View File

@ -1443,6 +1443,38 @@ int of_get_required_opp_performance_state(struct device_node *np, int index)
}
EXPORT_SYMBOL_GPL(of_get_required_opp_performance_state);
/**
* dev_pm_opp_of_has_required_opp - Find out if a required-opps exists.
* @dev: The device to investigate.
*
* Returns true if the device's node has a "operating-points-v2" property and if
* the corresponding node for the opp-table describes opp nodes that uses the
* "required-opps" property.
*
* Return: True if a required-opps is present, else false.
*/
bool dev_pm_opp_of_has_required_opp(struct device *dev)
{
struct device_node *opp_np, *np;
int count;
opp_np = _opp_of_get_opp_desc_node(dev->of_node, 0);
if (!opp_np)
return false;
np = of_get_next_available_child(opp_np, NULL);
of_node_put(opp_np);
if (!np) {
dev_warn(dev, "Empty OPP table\n");
return false;
}
count = of_count_phandle_with_args(np, "required-opps", NULL);
of_node_put(np);
return count > 0;
}
/**
* dev_pm_opp_get_of_node() - Gets the DT node corresponding to an opp
* @opp: opp for which DT node has to be returned for

View File

@ -474,6 +474,7 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpuma
struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev);
struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp);
int of_get_required_opp_performance_state(struct device_node *np, int index);
bool dev_pm_opp_of_has_required_opp(struct device *dev);
int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table);
int dev_pm_opp_of_register_em(struct device *dev, struct cpumask *cpus);
int dev_pm_opp_calc_power(struct device *dev, unsigned long *uW,
@ -552,6 +553,11 @@ static inline int of_get_required_opp_performance_state(struct device_node *np,
return -EOPNOTSUPP;
}
static inline bool dev_pm_opp_of_has_required_opp(struct device *dev)
{
return false;
}
static inline int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table)
{
return -EOPNOTSUPP;