All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] drm/panfrost: missing remove opp table in case of failure
@ 2020-04-13 17:33 ` Clément Péron
  0 siblings, 0 replies; 4+ messages in thread
From: Clément Péron @ 2020-04-13 17:33 UTC (permalink / raw)
  To: Rob Herring, Tomeu Vizoso, Steven Price, Alyssa Rosenzweig,
	Viresh Kumar, Nishanth Menon, Stephen Boyd
  Cc: dri-devel, linux-kernel, Clément Péron

In case of failure we need to remove OPP table.

Use Linux classic error handling with goto usage.

Reviewed-by: Steven Price <steven.price@arm.com>
Signed-off-by: Clément Péron <peron.clem@gmail.com>
---
 drivers/gpu/drm/panfrost/panfrost_devfreq.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
index 413987038fbf..62541f4edd81 100644
--- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
+++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
@@ -90,8 +90,11 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
 	cur_freq = clk_get_rate(pfdev->clock);
 
 	opp = devfreq_recommended_opp(dev, &cur_freq, 0);
-	if (IS_ERR(opp))
-		return PTR_ERR(opp);
+	if (IS_ERR(opp)) {
+		DRM_DEV_ERROR(dev, "Failed to set recommended OPP\n");
+		ret = PTR_ERR(opp);
+		goto err_opp;
+	}
 
 	panfrost_devfreq_profile.initial_freq = cur_freq;
 	dev_pm_opp_put(opp);
@@ -100,8 +103,8 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
 					  DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL);
 	if (IS_ERR(devfreq)) {
 		DRM_DEV_ERROR(dev, "Couldn't initialize GPU devfreq\n");
-		dev_pm_opp_of_remove_table(dev);
-		return PTR_ERR(devfreq);
+		ret = PTR_ERR(devfreq);
+		goto err_opp;
 	}
 	pfdev->devfreq.devfreq = devfreq;
 
@@ -112,6 +115,11 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
 		pfdev->devfreq.cooling = cooling;
 
 	return 0;
+
+err_opp:
+	dev_pm_opp_of_remove_table(dev);
+
+	return ret;
 }
 
 void panfrost_devfreq_fini(struct panfrost_device *pfdev)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] drm/panfrost: missing remove opp table in case of failure
@ 2020-04-13 17:33 ` Clément Péron
  0 siblings, 0 replies; 4+ messages in thread
From: Clément Péron @ 2020-04-13 17:33 UTC (permalink / raw)
  To: Rob Herring, Tomeu Vizoso, Steven Price, Alyssa Rosenzweig,
	Viresh Kumar, Nishanth Menon, Stephen Boyd
  Cc: Clément Péron, linux-kernel, dri-devel

In case of failure we need to remove OPP table.

Use Linux classic error handling with goto usage.

Reviewed-by: Steven Price <steven.price@arm.com>
Signed-off-by: Clément Péron <peron.clem@gmail.com>
---
 drivers/gpu/drm/panfrost/panfrost_devfreq.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
index 413987038fbf..62541f4edd81 100644
--- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
+++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
@@ -90,8 +90,11 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
 	cur_freq = clk_get_rate(pfdev->clock);
 
 	opp = devfreq_recommended_opp(dev, &cur_freq, 0);
-	if (IS_ERR(opp))
-		return PTR_ERR(opp);
+	if (IS_ERR(opp)) {
+		DRM_DEV_ERROR(dev, "Failed to set recommended OPP\n");
+		ret = PTR_ERR(opp);
+		goto err_opp;
+	}
 
 	panfrost_devfreq_profile.initial_freq = cur_freq;
 	dev_pm_opp_put(opp);
@@ -100,8 +103,8 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
 					  DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL);
 	if (IS_ERR(devfreq)) {
 		DRM_DEV_ERROR(dev, "Couldn't initialize GPU devfreq\n");
-		dev_pm_opp_of_remove_table(dev);
-		return PTR_ERR(devfreq);
+		ret = PTR_ERR(devfreq);
+		goto err_opp;
 	}
 	pfdev->devfreq.devfreq = devfreq;
 
@@ -112,6 +115,11 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
 		pfdev->devfreq.cooling = cooling;
 
 	return 0;
+
+err_opp:
+	dev_pm_opp_of_remove_table(dev);
+
+	return ret;
 }
 
 void panfrost_devfreq_fini(struct panfrost_device *pfdev)
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] drm/panfrost: add devfreq regulator support
  2020-04-13 17:33 ` Clément Péron
@ 2020-04-13 17:33   ` Clément Péron
  -1 siblings, 0 replies; 4+ messages in thread
From: Clément Péron @ 2020-04-13 17:33 UTC (permalink / raw)
  To: Rob Herring, Tomeu Vizoso, Steven Price, Alyssa Rosenzweig,
	Viresh Kumar, Nishanth Menon, Stephen Boyd
  Cc: dri-devel, linux-kernel, Clément Péron

OPP table can defined both frequency and voltage.

Register mali regulators to OPP driver.

Signed-off-by: Clément Péron <peron.clem@gmail.com>
---
 drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++++++++++++++++++---
 drivers/gpu/drm/panfrost/panfrost_device.h  |  1 +
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
index 62541f4edd81..54a109bbdc18 100644
--- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
+++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
@@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
 	struct device *dev = &pfdev->pdev->dev;
 	struct devfreq *devfreq;
 	struct thermal_cooling_device *cooling;
+	struct opp_table *opp_table;
+
+	/* Regulator is optional */
+	opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names,
+					      pfdev->comp->num_supplies);
+	if (IS_ERR(opp_table)) {
+		ret = PTR_ERR(opp_table);
+		if (ret != -ENODEV) {
+			DRM_DEV_ERROR(dev, "Failed to set regulator: %d\n", ret);
+			return ret;
+		}
+	}
+	pfdev->devfreq.opp_table = opp_table;
 
 	ret = dev_pm_opp_of_add_table(dev);
-	if (ret == -ENODEV) /* Optional, continue without devfreq */
-		return 0;
-	else if (ret)
-		return ret;
+	if (ret) {
+		if (ret == -ENODEV) /* Optional, continue without devfreq */
+			ret = 0;
+		goto err_opp_reg;
+	}
 
 	panfrost_devfreq_reset(pfdev);
 
@@ -119,6 +133,12 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
 err_opp:
 	dev_pm_opp_of_remove_table(dev);
 
+err_opp_reg:
+	if (pfdev->devfreq.opp_table) {
+		dev_pm_opp_put_regulators(pfdev->devfreq.opp_table);
+		pfdev->devfreq.opp_table = NULL;
+	}
+
 	return ret;
 }
 
@@ -126,7 +146,13 @@ void panfrost_devfreq_fini(struct panfrost_device *pfdev)
 {
 	if (pfdev->devfreq.cooling)
 		devfreq_cooling_unregister(pfdev->devfreq.cooling);
+
 	dev_pm_opp_of_remove_table(&pfdev->pdev->dev);
+
+	if (pfdev->devfreq.opp_table) {
+		dev_pm_opp_put_regulators(pfdev->devfreq.opp_table);
+		pfdev->devfreq.opp_table = NULL;
+	}
 }
 
 void panfrost_devfreq_resume(struct panfrost_device *pfdev)
diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h
index c30c719a8059..c11d19430c0f 100644
--- a/drivers/gpu/drm/panfrost/panfrost_device.h
+++ b/drivers/gpu/drm/panfrost/panfrost_device.h
@@ -110,6 +110,7 @@ struct panfrost_device {
 	struct {
 		struct devfreq *devfreq;
 		struct thermal_cooling_device *cooling;
+		struct opp_table *opp_table;
 		ktime_t busy_time;
 		ktime_t idle_time;
 		ktime_t time_last_update;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] drm/panfrost: add devfreq regulator support
@ 2020-04-13 17:33   ` Clément Péron
  0 siblings, 0 replies; 4+ messages in thread
From: Clément Péron @ 2020-04-13 17:33 UTC (permalink / raw)
  To: Rob Herring, Tomeu Vizoso, Steven Price, Alyssa Rosenzweig,
	Viresh Kumar, Nishanth Menon, Stephen Boyd
  Cc: Clément Péron, linux-kernel, dri-devel

OPP table can defined both frequency and voltage.

Register mali regulators to OPP driver.

Signed-off-by: Clément Péron <peron.clem@gmail.com>
---
 drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++++++++++++++++++---
 drivers/gpu/drm/panfrost/panfrost_device.h  |  1 +
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
index 62541f4edd81..54a109bbdc18 100644
--- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
+++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
@@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
 	struct device *dev = &pfdev->pdev->dev;
 	struct devfreq *devfreq;
 	struct thermal_cooling_device *cooling;
+	struct opp_table *opp_table;
+
+	/* Regulator is optional */
+	opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names,
+					      pfdev->comp->num_supplies);
+	if (IS_ERR(opp_table)) {
+		ret = PTR_ERR(opp_table);
+		if (ret != -ENODEV) {
+			DRM_DEV_ERROR(dev, "Failed to set regulator: %d\n", ret);
+			return ret;
+		}
+	}
+	pfdev->devfreq.opp_table = opp_table;
 
 	ret = dev_pm_opp_of_add_table(dev);
-	if (ret == -ENODEV) /* Optional, continue without devfreq */
-		return 0;
-	else if (ret)
-		return ret;
+	if (ret) {
+		if (ret == -ENODEV) /* Optional, continue without devfreq */
+			ret = 0;
+		goto err_opp_reg;
+	}
 
 	panfrost_devfreq_reset(pfdev);
 
@@ -119,6 +133,12 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
 err_opp:
 	dev_pm_opp_of_remove_table(dev);
 
+err_opp_reg:
+	if (pfdev->devfreq.opp_table) {
+		dev_pm_opp_put_regulators(pfdev->devfreq.opp_table);
+		pfdev->devfreq.opp_table = NULL;
+	}
+
 	return ret;
 }
 
@@ -126,7 +146,13 @@ void panfrost_devfreq_fini(struct panfrost_device *pfdev)
 {
 	if (pfdev->devfreq.cooling)
 		devfreq_cooling_unregister(pfdev->devfreq.cooling);
+
 	dev_pm_opp_of_remove_table(&pfdev->pdev->dev);
+
+	if (pfdev->devfreq.opp_table) {
+		dev_pm_opp_put_regulators(pfdev->devfreq.opp_table);
+		pfdev->devfreq.opp_table = NULL;
+	}
 }
 
 void panfrost_devfreq_resume(struct panfrost_device *pfdev)
diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h
index c30c719a8059..c11d19430c0f 100644
--- a/drivers/gpu/drm/panfrost/panfrost_device.h
+++ b/drivers/gpu/drm/panfrost/panfrost_device.h
@@ -110,6 +110,7 @@ struct panfrost_device {
 	struct {
 		struct devfreq *devfreq;
 		struct thermal_cooling_device *cooling;
+		struct opp_table *opp_table;
 		ktime_t busy_time;
 		ktime_t idle_time;
 		ktime_t time_last_update;
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-14  7:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-13 17:33 [PATCH v2 1/2] drm/panfrost: missing remove opp table in case of failure Clément Péron
2020-04-13 17:33 ` Clément Péron
2020-04-13 17:33 ` [PATCH v2 2/2] drm/panfrost: add devfreq regulator support Clément Péron
2020-04-13 17:33   ` Clément Péron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.