diff mbox series

[v7,06/19] PM / devfreq: tegra30: Use kHz units uniformly in the code

Message ID 20191029220019.26773-7-digetx@gmail.com
State Not Applicable, archived
Headers show
Series More improvements for Tegra30 devfreq driver | expand

Commit Message

Dmitry Osipenko Oct. 29, 2019, 10 p.m. UTC
Part of the code uses Hz units and the other kHz, let's switch to kHz
everywhere for consistency. A small benefit from this change (besides
code's cleanup) is that now powertop utility correctly displays devfreq's
stats, for some reason it expects them to be in kHz.

Tested-by: Peter Geis <pgwipeout@gmail.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/devfreq/tegra30-devfreq.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Chanwoo Choi Oct. 31, 2019, 4:44 a.m. UTC | #1
On 19. 10. 30. 오전 7:00, Dmitry Osipenko wrote:
> Part of the code uses Hz units and the other kHz, let's switch to kHz
> everywhere for consistency. A small benefit from this change (besides
> code's cleanup) is that now powertop utility correctly displays devfreq's
> stats, for some reason it expects them to be in kHz.
> 
> Tested-by: Peter Geis <pgwipeout@gmail.com>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/devfreq/tegra30-devfreq.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/devfreq/tegra30-devfreq.c b/drivers/devfreq/tegra30-devfreq.c
> index 1d22f5239cd5..06c5376a7201 100644
> --- a/drivers/devfreq/tegra30-devfreq.c
> +++ b/drivers/devfreq/tegra30-devfreq.c
> @@ -448,7 +448,7 @@ static int tegra_devfreq_target(struct device *dev, unsigned long *freq,
>  	rate = dev_pm_opp_get_freq(opp);
>  	dev_pm_opp_put(opp);
>  
> -	err = clk_set_min_rate(tegra->emc_clock, rate);
> +	err = clk_set_min_rate(tegra->emc_clock, rate * KHZ);
>  	if (err)
>  		return err;
>  
> @@ -477,7 +477,7 @@ static int tegra_devfreq_get_dev_status(struct device *dev,
>  	stat->private_data = tegra;
>  
>  	/* The below are to be used by the other governors */
> -	stat->current_frequency = cur_freq * KHZ;
> +	stat->current_frequency = cur_freq;
>  
>  	actmon_dev = &tegra->devices[MCALL];
>  
> @@ -527,7 +527,7 @@ static int tegra_governor_get_target(struct devfreq *devfreq,
>  		target_freq = max(target_freq, dev->target_freq);
>  	}
>  
> -	*freq = target_freq * KHZ;
> +	*freq = target_freq;
>  
>  	return 0;
>  }
> @@ -663,7 +663,7 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
>  			goto remove_opps;
>  		}
>  
> -		err = dev_pm_opp_add(&pdev->dev, rate, 0);
> +		err = dev_pm_opp_add(&pdev->dev, rate / KHZ, 0);
>  		if (err) {
>  			dev_err(&pdev->dev, "Failed to add OPP: %d\n", err);
>  			goto remove_opps;
> @@ -686,7 +686,8 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
>  		goto unreg_notifier;
>  	}
>  
> -	tegra_devfreq_profile.initial_freq = clk_get_rate(tegra->emc_clock);
> +	tegra_devfreq_profile.initial_freq = tegra->cur_freq;
> +
>  	devfreq = devfreq_add_device(&pdev->dev, &tegra_devfreq_profile,
>  				     "tegra_actmon", NULL);
>  	if (IS_ERR(devfreq)) {
> 

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Dmitry Osipenko Oct. 31, 2019, 11:08 p.m. UTC | #2
31.10.2019 07:44, Chanwoo Choi пишет:
> On 19. 10. 30. 오전 7:00, Dmitry Osipenko wrote:
>> Part of the code uses Hz units and the other kHz, let's switch to kHz
>> everywhere for consistency. A small benefit from this change (besides
>> code's cleanup) is that now powertop utility correctly displays devfreq's
>> stats, for some reason it expects them to be in kHz.
>>
>> Tested-by: Peter Geis <pgwipeout@gmail.com>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>>  drivers/devfreq/tegra30-devfreq.c | 11 ++++++-----
>>  1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/devfreq/tegra30-devfreq.c b/drivers/devfreq/tegra30-devfreq.c
>> index 1d22f5239cd5..06c5376a7201 100644
>> --- a/drivers/devfreq/tegra30-devfreq.c
>> +++ b/drivers/devfreq/tegra30-devfreq.c
>> @@ -448,7 +448,7 @@ static int tegra_devfreq_target(struct device *dev, unsigned long *freq,
>>  	rate = dev_pm_opp_get_freq(opp);
>>  	dev_pm_opp_put(opp);
>>  
>> -	err = clk_set_min_rate(tegra->emc_clock, rate);
>> +	err = clk_set_min_rate(tegra->emc_clock, rate * KHZ);
>>  	if (err)
>>  		return err;
>>  
>> @@ -477,7 +477,7 @@ static int tegra_devfreq_get_dev_status(struct device *dev,
>>  	stat->private_data = tegra;
>>  
>>  	/* The below are to be used by the other governors */
>> -	stat->current_frequency = cur_freq * KHZ;
>> +	stat->current_frequency = cur_freq;
>>  
>>  	actmon_dev = &tegra->devices[MCALL];
>>  
>> @@ -527,7 +527,7 @@ static int tegra_governor_get_target(struct devfreq *devfreq,
>>  		target_freq = max(target_freq, dev->target_freq);
>>  	}
>>  
>> -	*freq = target_freq * KHZ;
>> +	*freq = target_freq;
>>  
>>  	return 0;
>>  }
>> @@ -663,7 +663,7 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
>>  			goto remove_opps;
>>  		}
>>  
>> -		err = dev_pm_opp_add(&pdev->dev, rate, 0);
>> +		err = dev_pm_opp_add(&pdev->dev, rate / KHZ, 0);
>>  		if (err) {
>>  			dev_err(&pdev->dev, "Failed to add OPP: %d\n", err);
>>  			goto remove_opps;
>> @@ -686,7 +686,8 @@ static int tegra_devfreq_probe(struct platform_device *pdev)
>>  		goto unreg_notifier;
>>  	}
>>  
>> -	tegra_devfreq_profile.initial_freq = clk_get_rate(tegra->emc_clock);
>> +	tegra_devfreq_profile.initial_freq = tegra->cur_freq;
>> +
>>  	devfreq = devfreq_add_device(&pdev->dev, &tegra_devfreq_profile,
>>  				     "tegra_actmon", NULL);
>>  	if (IS_ERR(devfreq)) {
>>
> 
> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
> 

Thank you, looking forward to the comments to the rest of the patches.
Will be nice if this series could get ready for 5.5.
diff mbox series

Patch

diff --git a/drivers/devfreq/tegra30-devfreq.c b/drivers/devfreq/tegra30-devfreq.c
index 1d22f5239cd5..06c5376a7201 100644
--- a/drivers/devfreq/tegra30-devfreq.c
+++ b/drivers/devfreq/tegra30-devfreq.c
@@ -448,7 +448,7 @@  static int tegra_devfreq_target(struct device *dev, unsigned long *freq,
 	rate = dev_pm_opp_get_freq(opp);
 	dev_pm_opp_put(opp);
 
-	err = clk_set_min_rate(tegra->emc_clock, rate);
+	err = clk_set_min_rate(tegra->emc_clock, rate * KHZ);
 	if (err)
 		return err;
 
@@ -477,7 +477,7 @@  static int tegra_devfreq_get_dev_status(struct device *dev,
 	stat->private_data = tegra;
 
 	/* The below are to be used by the other governors */
-	stat->current_frequency = cur_freq * KHZ;
+	stat->current_frequency = cur_freq;
 
 	actmon_dev = &tegra->devices[MCALL];
 
@@ -527,7 +527,7 @@  static int tegra_governor_get_target(struct devfreq *devfreq,
 		target_freq = max(target_freq, dev->target_freq);
 	}
 
-	*freq = target_freq * KHZ;
+	*freq = target_freq;
 
 	return 0;
 }
@@ -663,7 +663,7 @@  static int tegra_devfreq_probe(struct platform_device *pdev)
 			goto remove_opps;
 		}
 
-		err = dev_pm_opp_add(&pdev->dev, rate, 0);
+		err = dev_pm_opp_add(&pdev->dev, rate / KHZ, 0);
 		if (err) {
 			dev_err(&pdev->dev, "Failed to add OPP: %d\n", err);
 			goto remove_opps;
@@ -686,7 +686,8 @@  static int tegra_devfreq_probe(struct platform_device *pdev)
 		goto unreg_notifier;
 	}
 
-	tegra_devfreq_profile.initial_freq = clk_get_rate(tegra->emc_clock);
+	tegra_devfreq_profile.initial_freq = tegra->cur_freq;
+
 	devfreq = devfreq_add_device(&pdev->dev, &tegra_devfreq_profile,
 				     "tegra_actmon", NULL);
 	if (IS_ERR(devfreq)) {