Re: [PATCH v6 2/3] PM / devfreq: Cache OPP table reference in devfreq

2021-02-04 Thread Viresh Kumar
On 04-02-21, 17:46, Chanwoo Choi wrote:
> > Signed-off-by: Saravana Kannan 
> > Reviewed-by: Chanwoo Choi 
> > Acked-by: MyungJoo Ham 
> > Signed-off-by: Hsin-Yi Wang 
> 
> Acked-by: Chanwoo Choi 

I am not sure if keeping both Acked-by and Reviewed-by make sense. I
am keeping Acked-by as it was the latest of the two, lemme know your
opinion as well.

-- 
viresh


Re: [PATCH v6 2/3] PM / devfreq: Cache OPP table reference in devfreq

2021-02-04 Thread Chanwoo Choi
Hi Hsin-Yi,

On 2/4/21 5:14 PM, Hsin-Yi Wang wrote:
> From: Saravana Kannan 
> 
> The OPP table can be used often in devfreq. Trying to get it each time can
> be expensive, so cache it in the devfreq struct.
> 
> Signed-off-by: Saravana Kannan 
> Reviewed-by: Chanwoo Choi 
> Acked-by: MyungJoo Ham 
> Signed-off-by: Hsin-Yi Wang 
> ---
>  drivers/devfreq/devfreq.c | 6 ++
>  include/linux/devfreq.h   | 2 ++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 6aa10de792b33..a5899c9ae16fc 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -757,6 +757,8 @@ static void devfreq_dev_release(struct device *dev)
>   if (devfreq->profile->exit)
>   devfreq->profile->exit(devfreq->dev.parent);
>  
> + if (devfreq->opp_table)
> + dev_pm_opp_put_opp_table(devfreq->opp_table);
>   mutex_destroy(>lock);
>   kfree(devfreq);
>  }
> @@ -844,6 +846,10 @@ struct devfreq *devfreq_add_device(struct device *dev,
>   }
>  
>   devfreq->suspend_freq = dev_pm_opp_get_suspend_opp_freq(dev);
> + devfreq->opp_table = dev_pm_opp_get_opp_table(dev);
> + if (IS_ERR(devfreq->opp_table))
> + devfreq->opp_table = NULL;
> +
>   atomic_set(>suspend_count, 0);
>  
>   dev_set_name(>dev, "%s", dev_name(dev));
> diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
> index b6d3bae1c74d8..26ea0850be9bb 100644
> --- a/include/linux/devfreq.h
> +++ b/include/linux/devfreq.h
> @@ -137,6 +137,7 @@ struct devfreq_stats {
>   *   using devfreq.
>   * @profile: device-specific devfreq profile
>   * @governor:method how to choose frequency based on the usage.
> + * @opp_table:   Reference to OPP table of dev.parent, if one exists.
>   * @nb:  notifier block used to notify devfreq object that it 
> should
>   *   reevaluate operable frequencies. Devfreq users may use
>   *   devfreq.nb to the corresponding register notifier call chain.
> @@ -173,6 +174,7 @@ struct devfreq {
>   struct device dev;
>   struct devfreq_dev_profile *profile;
>   const struct devfreq_governor *governor;
> + struct opp_table *opp_table;
>   struct notifier_block nb;
>   struct delayed_work work;
>  
> 

Acked-by: Chanwoo Choi 

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics


[PATCH v6 2/3] PM / devfreq: Cache OPP table reference in devfreq

2021-02-04 Thread Hsin-Yi Wang
From: Saravana Kannan 

The OPP table can be used often in devfreq. Trying to get it each time can
be expensive, so cache it in the devfreq struct.

Signed-off-by: Saravana Kannan 
Reviewed-by: Chanwoo Choi 
Acked-by: MyungJoo Ham 
Signed-off-by: Hsin-Yi Wang 
---
 drivers/devfreq/devfreq.c | 6 ++
 include/linux/devfreq.h   | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 6aa10de792b33..a5899c9ae16fc 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -757,6 +757,8 @@ static void devfreq_dev_release(struct device *dev)
if (devfreq->profile->exit)
devfreq->profile->exit(devfreq->dev.parent);
 
+   if (devfreq->opp_table)
+   dev_pm_opp_put_opp_table(devfreq->opp_table);
mutex_destroy(>lock);
kfree(devfreq);
 }
@@ -844,6 +846,10 @@ struct devfreq *devfreq_add_device(struct device *dev,
}
 
devfreq->suspend_freq = dev_pm_opp_get_suspend_opp_freq(dev);
+   devfreq->opp_table = dev_pm_opp_get_opp_table(dev);
+   if (IS_ERR(devfreq->opp_table))
+   devfreq->opp_table = NULL;
+
atomic_set(>suspend_count, 0);
 
dev_set_name(>dev, "%s", dev_name(dev));
diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
index b6d3bae1c74d8..26ea0850be9bb 100644
--- a/include/linux/devfreq.h
+++ b/include/linux/devfreq.h
@@ -137,6 +137,7 @@ struct devfreq_stats {
  * using devfreq.
  * @profile:   device-specific devfreq profile
  * @governor:  method how to choose frequency based on the usage.
+ * @opp_table: Reference to OPP table of dev.parent, if one exists.
  * @nb:notifier block used to notify devfreq object that it 
should
  * reevaluate operable frequencies. Devfreq users may use
  * devfreq.nb to the corresponding register notifier call chain.
@@ -173,6 +174,7 @@ struct devfreq {
struct device dev;
struct devfreq_dev_profile *profile;
const struct devfreq_governor *governor;
+   struct opp_table *opp_table;
struct notifier_block nb;
struct delayed_work work;
 
-- 
2.30.0.365.g02bc693789-goog