[PATCH v2] drm/lima: Fix opp clkname setting in case of missing regulator

Erico Nunes posted 1 patch 3 years, 5 months ago
drivers/gpu/drm/lima/lima_devfreq.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
[PATCH v2] drm/lima: Fix opp clkname setting in case of missing regulator
Posted by Erico Nunes 3 years, 5 months ago
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()")
Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
---
v2: revert back to using devm_pm_opp_set_clkname and
devm_pm_opp_set_regulators
---
 drivers/gpu/drm/lima/lima_devfreq.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/lima/lima_devfreq.c b/drivers/gpu/drm/lima/lima_devfreq.c
index 011be7ff51e1..bc8fb4e38d0a 100644
--- a/drivers/gpu/drm/lima/lima_devfreq.c
+++ b/drivers/gpu/drm/lima/lima_devfreq.c
@@ -112,11 +112,6 @@ int lima_devfreq_init(struct lima_device *ldev)
 	unsigned long cur_freq;
 	int ret;
 	const char *regulator_names[] = { "mali", NULL };
-	const char *clk_names[] = { "core", NULL };
-	struct dev_pm_opp_config config = {
-		.regulator_names = regulator_names,
-		.clk_names = clk_names,
-	};
 
 	if (!device_property_present(dev, "operating-points-v2"))
 		/* Optional, continue without devfreq */
@@ -124,7 +119,15 @@ int lima_devfreq_init(struct lima_device *ldev)
 
 	spin_lock_init(&ldevfreq->lock);
 
-	ret = devm_pm_opp_set_config(dev, &config);
+	/*
+	 * clkname is set separately so it is not affected by the optional
+	 * regulator setting which may return error.
+	 */
+	ret = devm_pm_opp_set_clkname(dev, "core");
+	if (ret)
+		return ret;
+
+	ret = devm_pm_opp_set_regulators(dev, regulator_names);
 	if (ret) {
 		/* Continue if the optional regulator is missing */
 		if (ret != -ENODEV)
-- 
2.37.3
Re: [PATCH v2] drm/lima: Fix opp clkname setting in case of missing regulator
Posted by Viresh Kumar 3 years, 5 months ago
On 27-10-22, 09:32, Erico Nunes wrote:
> 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()")
> Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
> ---
> v2: revert back to using devm_pm_opp_set_clkname and
> devm_pm_opp_set_regulators
> ---
>  drivers/gpu/drm/lima/lima_devfreq.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/lima/lima_devfreq.c b/drivers/gpu/drm/lima/lima_devfreq.c
> index 011be7ff51e1..bc8fb4e38d0a 100644
> --- a/drivers/gpu/drm/lima/lima_devfreq.c
> +++ b/drivers/gpu/drm/lima/lima_devfreq.c
> @@ -112,11 +112,6 @@ int lima_devfreq_init(struct lima_device *ldev)
>  	unsigned long cur_freq;
>  	int ret;
>  	const char *regulator_names[] = { "mali", NULL };
> -	const char *clk_names[] = { "core", NULL };
> -	struct dev_pm_opp_config config = {
> -		.regulator_names = regulator_names,
> -		.clk_names = clk_names,
> -	};
>  
>  	if (!device_property_present(dev, "operating-points-v2"))
>  		/* Optional, continue without devfreq */
> @@ -124,7 +119,15 @@ int lima_devfreq_init(struct lima_device *ldev)
>  
>  	spin_lock_init(&ldevfreq->lock);
>  
> -	ret = devm_pm_opp_set_config(dev, &config);
> +	/*
> +	 * clkname is set separately so it is not affected by the optional
> +	 * regulator setting which may return error.
> +	 */
> +	ret = devm_pm_opp_set_clkname(dev, "core");
> +	if (ret)
> +		return ret;
> +
> +	ret = devm_pm_opp_set_regulators(dev, regulator_names);
>  	if (ret) {
>  		/* Continue if the optional regulator is missing */
>  		if (ret != -ENODEV)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh
Re: [PATCH v2] drm/lima: Fix opp clkname setting in case of missing regulator
Posted by Erico Nunes 3 years, 5 months ago
On Thu, Oct 27, 2022 at 10:05 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

Thanks.

Could someone take a final look and apply this? I don't have drm-misc
commit rights.

Erico
Re: [PATCH v2] drm/lima: Fix opp clkname setting in case of missing regulator
Posted by Qiang Yu 3 years, 4 months ago
Applied to drm-misc-fixes.

On Mon, Oct 31, 2022 at 6:35 PM Erico Nunes <nunes.erico@gmail.com> wrote:
>
> On Thu, Oct 27, 2022 at 10:05 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> > Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
>
> Thanks.
>
> Could someone take a final look and apply this? I don't have drm-misc
> commit rights.
>
> Erico