linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/panfrost: devfreq: Round frequencies to OPPs
@ 2019-11-18 17:30 Steven Price
  2019-11-26 14:28 ` Alyssa Rosenzweig
  2019-12-06 17:16 ` Rob Herring
  0 siblings, 2 replies; 3+ messages in thread
From: Steven Price @ 2019-11-18 17:30 UTC (permalink / raw)
  To: Daniel Vetter, David Airlie, Rob Herring, Tomeu Vizoso
  Cc: Alyssa Rosenzweig, dri-devel, linux-kernel, Steven Price

Currently when setting a frequency in panfrost_devfreq_target the
returned frequency is the actual frequency that the clock driver reports
(the return of clk_get_rate()). However, where the provided OPPs don't
precisely match the frequencies that the clock actually achieves devfreq
will then complain (repeatedly):

  devfreq devfreq0: Couldn't update frequency transition information.

To avoid this change panfrost_devfreq_target() to fetch the opp using
devfreq_recommened_opp() and not actually query the clock for the
frequency.

A similar problem exists with panfrost_devfreq_get_cur_freq(), but in
this case because the function is optional we can just remove it and
devfreq will fall back to using the previously set frequency.

Fixes: 221bc77914cb ("drm/panfrost: Use generic code for devfreq")
Signed-off-by: Steven Price <steven.price@arm.com>
---
 drivers/gpu/drm/panfrost/panfrost_devfreq.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
index 4c4e8a30a1ac..536ba93b0f46 100644
--- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
+++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
@@ -18,15 +18,18 @@ static void panfrost_devfreq_update_utilization(struct panfrost_device *pfdev);
 static int panfrost_devfreq_target(struct device *dev, unsigned long *freq,
 				   u32 flags)
 {
-	struct panfrost_device *pfdev = dev_get_drvdata(dev);
+	struct dev_pm_opp *opp;
 	int err;
 
+	opp = devfreq_recommended_opp(dev, freq, flags);
+	if (IS_ERR(opp))
+		return PTR_ERR(opp);
+	dev_pm_opp_put(opp);
+
 	err = dev_pm_opp_set_rate(dev, *freq);
 	if (err)
 		return err;
 
-	*freq = clk_get_rate(pfdev->clock);
-
 	return 0;
 }
 
@@ -60,20 +63,10 @@ static int panfrost_devfreq_get_dev_status(struct device *dev,
 	return 0;
 }
 
-static int panfrost_devfreq_get_cur_freq(struct device *dev, unsigned long *freq)
-{
-	struct panfrost_device *pfdev = platform_get_drvdata(to_platform_device(dev));
-
-	*freq = clk_get_rate(pfdev->clock);
-
-	return 0;
-}
-
 static struct devfreq_dev_profile panfrost_devfreq_profile = {
 	.polling_ms = 50, /* ~3 frames */
 	.target = panfrost_devfreq_target,
 	.get_dev_status = panfrost_devfreq_get_dev_status,
-	.get_cur_freq = panfrost_devfreq_get_cur_freq,
 };
 
 int panfrost_devfreq_init(struct panfrost_device *pfdev)
-- 
2.20.1


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

* Re: [PATCH] drm/panfrost: devfreq: Round frequencies to OPPs
  2019-11-18 17:30 [PATCH] drm/panfrost: devfreq: Round frequencies to OPPs Steven Price
@ 2019-11-26 14:28 ` Alyssa Rosenzweig
  2019-12-06 17:16 ` Rob Herring
  1 sibling, 0 replies; 3+ messages in thread
From: Alyssa Rosenzweig @ 2019-11-26 14:28 UTC (permalink / raw)
  To: Steven Price
  Cc: Daniel Vetter, David Airlie, Rob Herring, Tomeu Vizoso,
	dri-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2751 bytes --]

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

On Mon, Nov 18, 2019 at 05:30:02PM +0000, Steven Price wrote:
> Currently when setting a frequency in panfrost_devfreq_target the
> returned frequency is the actual frequency that the clock driver reports
> (the return of clk_get_rate()). However, where the provided OPPs don't
> precisely match the frequencies that the clock actually achieves devfreq
> will then complain (repeatedly):
> 
>   devfreq devfreq0: Couldn't update frequency transition information.
> 
> To avoid this change panfrost_devfreq_target() to fetch the opp using
> devfreq_recommened_opp() and not actually query the clock for the
> frequency.
> 
> A similar problem exists with panfrost_devfreq_get_cur_freq(), but in
> this case because the function is optional we can just remove it and
> devfreq will fall back to using the previously set frequency.
> 
> Fixes: 221bc77914cb ("drm/panfrost: Use generic code for devfreq")
> Signed-off-by: Steven Price <steven.price@arm.com>
> ---
>  drivers/gpu/drm/panfrost/panfrost_devfreq.c | 19 ++++++-------------
>  1 file changed, 6 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> index 4c4e8a30a1ac..536ba93b0f46 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c
> @@ -18,15 +18,18 @@ static void panfrost_devfreq_update_utilization(struct panfrost_device *pfdev);
>  static int panfrost_devfreq_target(struct device *dev, unsigned long *freq,
>  				   u32 flags)
>  {
> -	struct panfrost_device *pfdev = dev_get_drvdata(dev);
> +	struct dev_pm_opp *opp;
>  	int err;
>  
> +	opp = devfreq_recommended_opp(dev, freq, flags);
> +	if (IS_ERR(opp))
> +		return PTR_ERR(opp);
> +	dev_pm_opp_put(opp);
> +
>  	err = dev_pm_opp_set_rate(dev, *freq);
>  	if (err)
>  		return err;
>  
> -	*freq = clk_get_rate(pfdev->clock);
> -
>  	return 0;
>  }
>  
> @@ -60,20 +63,10 @@ static int panfrost_devfreq_get_dev_status(struct device *dev,
>  	return 0;
>  }
>  
> -static int panfrost_devfreq_get_cur_freq(struct device *dev, unsigned long *freq)
> -{
> -	struct panfrost_device *pfdev = platform_get_drvdata(to_platform_device(dev));
> -
> -	*freq = clk_get_rate(pfdev->clock);
> -
> -	return 0;
> -}
> -
>  static struct devfreq_dev_profile panfrost_devfreq_profile = {
>  	.polling_ms = 50, /* ~3 frames */
>  	.target = panfrost_devfreq_target,
>  	.get_dev_status = panfrost_devfreq_get_dev_status,
> -	.get_cur_freq = panfrost_devfreq_get_cur_freq,
>  };
>  
>  int panfrost_devfreq_init(struct panfrost_device *pfdev)
> -- 
> 2.20.1
> 

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

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

* Re: [PATCH] drm/panfrost: devfreq: Round frequencies to OPPs
  2019-11-18 17:30 [PATCH] drm/panfrost: devfreq: Round frequencies to OPPs Steven Price
  2019-11-26 14:28 ` Alyssa Rosenzweig
@ 2019-12-06 17:16 ` Rob Herring
  1 sibling, 0 replies; 3+ messages in thread
From: Rob Herring @ 2019-12-06 17:16 UTC (permalink / raw)
  To: Steven Price
  Cc: Daniel Vetter, David Airlie, Tomeu Vizoso, Alyssa Rosenzweig,
	dri-devel, linux-kernel

On Mon, Nov 18, 2019 at 11:30 AM Steven Price <steven.price@arm.com> wrote:
>
> Currently when setting a frequency in panfrost_devfreq_target the
> returned frequency is the actual frequency that the clock driver reports
> (the return of clk_get_rate()). However, where the provided OPPs don't
> precisely match the frequencies that the clock actually achieves devfreq
> will then complain (repeatedly):
>
>   devfreq devfreq0: Couldn't update frequency transition information.
>
> To avoid this change panfrost_devfreq_target() to fetch the opp using
> devfreq_recommened_opp() and not actually query the clock for the
> frequency.
>
> A similar problem exists with panfrost_devfreq_get_cur_freq(), but in
> this case because the function is optional we can just remove it and
> devfreq will fall back to using the previously set frequency.
>
> Fixes: 221bc77914cb ("drm/panfrost: Use generic code for devfreq")
> Signed-off-by: Steven Price <steven.price@arm.com>
> ---
>  drivers/gpu/drm/panfrost/panfrost_devfreq.c | 19 ++++++-------------
>  1 file changed, 6 insertions(+), 13 deletions(-)

Applied.

Rob

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-18 17:30 [PATCH] drm/panfrost: devfreq: Round frequencies to OPPs Steven Price
2019-11-26 14:28 ` Alyssa Rosenzweig
2019-12-06 17:16 ` Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).