Skip to contentSkip to conversation

drm/lima: Fix dev_pm_opp_set_config in case of missing regulator

PATCH Superseded Erico Nunes 2 participants 3 messages Oct 26, 2022

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/lima: Fix dev_pm_opp_set_config in case of missing regulator

Commit d8c32d3971e4 ("drm/lima: Migrate to dev_pm_opp_set_config()") introduced a regression as it may undo the clk_names setting in case the optional regulator is missing. This resulted in test and performance regressions with lima.

Restore the old behavior where clk_names is set separately so it is not undone in case of a missing optional regulator.

Fixes d8c32d3971e4 ("drm/lima: Migrate to dev_pm_opp_set_config()")
---
 drivers/gpu/drm/lima/lima_devfreq.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/gpu/drm/lima/lima_devfreq.c +13 -3
index 011be7ff51e1..9c8654934fea 100644
@@ -113,10 +113,12 @@ int lima_devfreq_init(struct lima_device *ldev)
 	int ret;
 	const char *regulator_names[] = { "mali", NULL };
 	const char *clk_names[] = { "core", NULL };
-	struct dev_pm_opp_config config = {
-		.regulator_names = regulator_names,
+	struct dev_pm_opp_config config_clk_names = {
 		.clk_names = clk_names,
 	};
+	struct dev_pm_opp_config config_regulator_names = {
+		.regulator_names = regulator_names,
+	};
 
 	if (!device_property_present(dev, "operating-points-v2"))
 		/* Optional, continue without devfreq */
@@ -124,7 +126,15 @@ int lima_devfreq_init(struct lima_device *ldev)
 
 	spin_lock_init(&ldevfreq->lock);
 
-	ret = devm_pm_opp_set_config(dev, &config);
+	/*
+	 * Set clk_names separately so it is not undone in case of
+	 * a missing optional regulator.
+	 */
+	ret = devm_pm_opp_set_config(dev, &config_clk_names);
+	if (ret)
+		return ret;
+
+	ret = devm_pm_opp_set_config(dev, &config_regulator_names);
 	if (ret) {
 		/* Continue if the optional regulator is missing */
 		if (ret != -ENODEV)
Signature · 1 line
2.37.3
#1 lore raw
Quoted 37 lines · Erico Nunes

Commit d8c32d3971e4 ("drm/lima: Migrate to dev_pm_opp_set_config()") introduced a regression as it may undo the clk_names setting in case the optional regulator is missing. This resulted in test and performance regressions with lima.

Restore the old behavior where clk_names is set separately so it is not undone in case of a missing optional regulator.

Fixes d8c32d3971e4 ("drm/lima: Migrate to dev_pm_opp_set_config()")
---
 drivers/gpu/drm/lima/lima_devfreq.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/gpu/drm/lima/lima_devfreq.c +4 -2
index 011be7ff51e1..9c8654934fea 100644
@@ -113,10 +113,12 @@ int lima_devfreq_init(struct lima_device *ldev)
 	int ret;
 	const char *regulator_names[] = { "mali", NULL };
 	const char *clk_names[] = { "core", NULL };
-	struct dev_pm_opp_config config = {
-		.regulator_names = regulator_names,
+	struct dev_pm_opp_config config_clk_names = {
 		.clk_names = clk_names,
 	};
+	struct dev_pm_opp_config config_regulator_names = {
+		.regulator_names = regulator_names,
+	};
 
 	if (!device_property_present(dev, "operating-points-v2"))
 		/* Optional, continue without devfreq */
@@ -124,7 +126,15 @@ int lima_devfreq_init(struct lima_device *ldev)
 
 	spin_lock_init(&ldevfreq->lock);
 

drivers/gpu/drm/lima/lima_devfreq.c int lima_devfreq_init(struct lima_device *ldev) · line 137

Quoted 10 lines
drivers/gpu/drm/lima/lima_devfreq.c +9 -1
-	ret = devm_pm_opp_set_config(dev, &config);
+	/*
+	 * Set clk_names separately so it is not undone in case of
+	 * a missing optional regulator.
+	 */
+	ret = devm_pm_opp_set_config(dev, &config_clk_names);
+	if (ret)
+		return ret;
+
+	ret = devm_pm_opp_set_config(dev, &config_regulator_names);

You can directly call devm_pm_opp_set_clkname() and devm_pm_opp_set_regulators(), like it was done before my patch, for single configurations. So basically a simple revert of my commit, with additional comments you added above.

Quoted 5 lines
drivers/gpu/drm/lima/lima_devfreq.c +0 -0
 	if (ret) {
 		/* Continue if the optional regulator is missing */
 		if (ret != -ENODEV)
Signature · 1 line
2.37.3
Signature · 1 line
viresh
#2 lore raw

Hello,

Quoted 4 lines · Viresh Kumar

You can directly call devm_pm_opp_set_clkname() and devm_pm_opp_set_regulators(), like it was done before my patch, for single configurations. So basically a simple revert of my commit, with additional comments you added above.

Ok, I'll send a v2 with that.

Thanks

Erico