All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/panfrost: Register devfreq cooling device
@ 2019-11-28 20:54 Robin Murphy
  2019-11-29  9:38 ` Steven Price
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Robin Murphy @ 2019-11-28 20:54 UTC (permalink / raw)
  To: robh, tomeu.vizoso; +Cc: alyssa.rosenzweig, dri-devel, steven.price

When we have devfreq, also try to register a basic cooling device in
case GPU workloads manage to hit thermal throttling thresholds.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
 drivers/gpu/drm/panfrost/panfrost_devfreq.c | 32 ++++++++++++++-------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
index 4c4e8a30a1ac..fe8ee77c96e4 100644
--- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
+++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /* Copyright 2019 Collabora ltd. */
 #include <linux/devfreq.h>
+#include <linux/devfreq_cooling.h>
 #include <linux/platform_device.h>
 #include <linux/pm_opp.h>
 #include <linux/clk.h>
@@ -81,8 +82,11 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
 	int ret;
 	struct dev_pm_opp *opp;
 	unsigned long cur_freq;
+	struct device *dev = &pfdev->pdev->dev;
+	struct devfreq *devfreq;
+	struct thermal_cooling_device *cooling;
 
-	ret = dev_pm_opp_of_add_table(&pfdev->pdev->dev);
+	ret = dev_pm_opp_of_add_table(dev);
 	if (ret == -ENODEV) /* Optional, continue without devfreq */
 		return 0;
 	else if (ret)
@@ -92,29 +96,35 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
 
 	cur_freq = clk_get_rate(pfdev->clock);
 
-	opp = devfreq_recommended_opp(&pfdev->pdev->dev, &cur_freq, 0);
+	opp = devfreq_recommended_opp(dev, &cur_freq, 0);
 	if (IS_ERR(opp))
 		return PTR_ERR(opp);
 
 	panfrost_devfreq_profile.initial_freq = cur_freq;
 	dev_pm_opp_put(opp);
 
-	pfdev->devfreq.devfreq = devm_devfreq_add_device(&pfdev->pdev->dev,
-			&panfrost_devfreq_profile, DEVFREQ_GOV_SIMPLE_ONDEMAND,
-			NULL);
-	if (IS_ERR(pfdev->devfreq.devfreq)) {
-		DRM_DEV_ERROR(&pfdev->pdev->dev, "Couldn't initialize GPU devfreq\n");
-		ret = PTR_ERR(pfdev->devfreq.devfreq);
-		pfdev->devfreq.devfreq = NULL;
-		dev_pm_opp_of_remove_table(&pfdev->pdev->dev);
-		return ret;
+	devfreq = devm_devfreq_add_device(dev, &panfrost_devfreq_profile,
+					  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);
 	}
+	pfdev->devfreq.devfreq = devfreq;
+
+	cooling = of_devfreq_cooling_register(dev->of_node, devfreq);
+	if (IS_ERR(cooling))
+		DRM_DEV_INFO(dev, "Failed to register cooling device\n");
+	else
+		pfdev->devfreq.cooling = cooling;
 
 	return 0;
 }
 
 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);
 }
 
-- 
2.17.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

* Re: [PATCH] drm/panfrost: Register devfreq cooling device
  2019-11-28 20:54 [PATCH] drm/panfrost: Register devfreq cooling device Robin Murphy
@ 2019-11-29  9:38 ` Steven Price
  2019-12-03 18:26 ` Alyssa Rosenzweig
  2019-12-06 17:15 ` Rob Herring
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Price @ 2019-11-29  9:38 UTC (permalink / raw)
  To: Robin Murphy, robh, tomeu.vizoso; +Cc: alyssa.rosenzweig, dri-devel

On 28/11/2019 20:54, Robin Murphy wrote:
> When we have devfreq, also try to register a basic cooling device in
> case GPU workloads manage to hit thermal throttling thresholds.
> 
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>

Reviewed-by: Steven Price <steven.price@arm.com>

> ---
>  drivers/gpu/drm/panfrost/panfrost_devfreq.c | 32 ++++++++++++++-------
>  1 file changed, 21 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> index 4c4e8a30a1ac..fe8ee77c96e4 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> @@ -1,6 +1,7 @@
>  // SPDX-License-Identifier: GPL-2.0
>  /* Copyright 2019 Collabora ltd. */
>  #include <linux/devfreq.h>
> +#include <linux/devfreq_cooling.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_opp.h>
>  #include <linux/clk.h>
> @@ -81,8 +82,11 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
>  	int ret;
>  	struct dev_pm_opp *opp;
>  	unsigned long cur_freq;
> +	struct device *dev = &pfdev->pdev->dev;
> +	struct devfreq *devfreq;
> +	struct thermal_cooling_device *cooling;
>  
> -	ret = dev_pm_opp_of_add_table(&pfdev->pdev->dev);
> +	ret = dev_pm_opp_of_add_table(dev);
>  	if (ret == -ENODEV) /* Optional, continue without devfreq */
>  		return 0;
>  	else if (ret)
> @@ -92,29 +96,35 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
>  
>  	cur_freq = clk_get_rate(pfdev->clock);
>  
> -	opp = devfreq_recommended_opp(&pfdev->pdev->dev, &cur_freq, 0);
> +	opp = devfreq_recommended_opp(dev, &cur_freq, 0);
>  	if (IS_ERR(opp))
>  		return PTR_ERR(opp);
>  
>  	panfrost_devfreq_profile.initial_freq = cur_freq;
>  	dev_pm_opp_put(opp);
>  
> -	pfdev->devfreq.devfreq = devm_devfreq_add_device(&pfdev->pdev->dev,
> -			&panfrost_devfreq_profile, DEVFREQ_GOV_SIMPLE_ONDEMAND,
> -			NULL);
> -	if (IS_ERR(pfdev->devfreq.devfreq)) {
> -		DRM_DEV_ERROR(&pfdev->pdev->dev, "Couldn't initialize GPU devfreq\n");
> -		ret = PTR_ERR(pfdev->devfreq.devfreq);
> -		pfdev->devfreq.devfreq = NULL;
> -		dev_pm_opp_of_remove_table(&pfdev->pdev->dev);
> -		return ret;
> +	devfreq = devm_devfreq_add_device(dev, &panfrost_devfreq_profile,
> +					  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);
>  	}
> +	pfdev->devfreq.devfreq = devfreq;
> +
> +	cooling = of_devfreq_cooling_register(dev->of_node, devfreq);
> +	if (IS_ERR(cooling))
> +		DRM_DEV_INFO(dev, "Failed to register cooling device\n");
> +	else
> +		pfdev->devfreq.cooling = cooling;
>  
>  	return 0;
>  }
>  
>  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);
>  }
>  
> 

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

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

* Re: [PATCH] drm/panfrost: Register devfreq cooling device
  2019-11-28 20:54 [PATCH] drm/panfrost: Register devfreq cooling device Robin Murphy
  2019-11-29  9:38 ` Steven Price
@ 2019-12-03 18:26 ` Alyssa Rosenzweig
  2019-12-06 17:15 ` Rob Herring
  2 siblings, 0 replies; 4+ messages in thread
From: Alyssa Rosenzweig @ 2019-12-03 18:26 UTC (permalink / raw)
  To: Robin Murphy; +Cc: dri-devel, tomeu.vizoso, steven.price


[-- Attachment #1.1: Type: text/plain, Size: 3135 bytes --]

Not sure if this was already pushed but:

	Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>

On Thu, Nov 28, 2019 at 08:54:27PM +0000, Robin Murphy wrote:
> When we have devfreq, also try to register a basic cooling device in
> case GPU workloads manage to hit thermal throttling thresholds.
> 
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>  drivers/gpu/drm/panfrost/panfrost_devfreq.c | 32 ++++++++++++++-------
>  1 file changed, 21 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> index 4c4e8a30a1ac..fe8ee77c96e4 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> @@ -1,6 +1,7 @@
>  // SPDX-License-Identifier: GPL-2.0
>  /* Copyright 2019 Collabora ltd. */
>  #include <linux/devfreq.h>
> +#include <linux/devfreq_cooling.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_opp.h>
>  #include <linux/clk.h>
> @@ -81,8 +82,11 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
>  	int ret;
>  	struct dev_pm_opp *opp;
>  	unsigned long cur_freq;
> +	struct device *dev = &pfdev->pdev->dev;
> +	struct devfreq *devfreq;
> +	struct thermal_cooling_device *cooling;
>  
> -	ret = dev_pm_opp_of_add_table(&pfdev->pdev->dev);
> +	ret = dev_pm_opp_of_add_table(dev);
>  	if (ret == -ENODEV) /* Optional, continue without devfreq */
>  		return 0;
>  	else if (ret)
> @@ -92,29 +96,35 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
>  
>  	cur_freq = clk_get_rate(pfdev->clock);
>  
> -	opp = devfreq_recommended_opp(&pfdev->pdev->dev, &cur_freq, 0);
> +	opp = devfreq_recommended_opp(dev, &cur_freq, 0);
>  	if (IS_ERR(opp))
>  		return PTR_ERR(opp);
>  
>  	panfrost_devfreq_profile.initial_freq = cur_freq;
>  	dev_pm_opp_put(opp);
>  
> -	pfdev->devfreq.devfreq = devm_devfreq_add_device(&pfdev->pdev->dev,
> -			&panfrost_devfreq_profile, DEVFREQ_GOV_SIMPLE_ONDEMAND,
> -			NULL);
> -	if (IS_ERR(pfdev->devfreq.devfreq)) {
> -		DRM_DEV_ERROR(&pfdev->pdev->dev, "Couldn't initialize GPU devfreq\n");
> -		ret = PTR_ERR(pfdev->devfreq.devfreq);
> -		pfdev->devfreq.devfreq = NULL;
> -		dev_pm_opp_of_remove_table(&pfdev->pdev->dev);
> -		return ret;
> +	devfreq = devm_devfreq_add_device(dev, &panfrost_devfreq_profile,
> +					  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);
>  	}
> +	pfdev->devfreq.devfreq = devfreq;
> +
> +	cooling = of_devfreq_cooling_register(dev->of_node, devfreq);
> +	if (IS_ERR(cooling))
> +		DRM_DEV_INFO(dev, "Failed to register cooling device\n");
> +	else
> +		pfdev->devfreq.cooling = cooling;
>  
>  	return 0;
>  }
>  
>  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);
>  }
>  
> -- 
> 2.17.1
> 

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

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

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

* Re: [PATCH] drm/panfrost: Register devfreq cooling device
  2019-11-28 20:54 [PATCH] drm/panfrost: Register devfreq cooling device Robin Murphy
  2019-11-29  9:38 ` Steven Price
  2019-12-03 18:26 ` Alyssa Rosenzweig
@ 2019-12-06 17:15 ` Rob Herring
  2 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2019-12-06 17:15 UTC (permalink / raw)
  To: Robin Murphy; +Cc: dri-devel, Alyssa Rosenzweig, Tomeu Vizoso, Steven Price

On Thu, Nov 28, 2019 at 2:54 PM Robin Murphy <robin.murphy@arm.com> wrote:
>
> When we have devfreq, also try to register a basic cooling device in
> case GPU workloads manage to hit thermal throttling thresholds.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>  drivers/gpu/drm/panfrost/panfrost_devfreq.c | 32 ++++++++++++++-------
>  1 file changed, 21 insertions(+), 11 deletions(-)

Applied.

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

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

end of thread, other threads:[~2019-12-06 17:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-28 20:54 [PATCH] drm/panfrost: Register devfreq cooling device Robin Murphy
2019-11-29  9:38 ` Steven Price
2019-12-03 18:26 ` Alyssa Rosenzweig
2019-12-06 17:15 ` Rob Herring

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.