Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1390406 > unrolled thread

[PATCH v2 1/2] PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_,}remove_table

Started bySudeep Holla <sudeep.holla@arm.com>
First post2016-04-28 19:10 +0200
Last post2016-04-29 11:30 +0200
Articles 7 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 1/2] PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_,}remove_table Sudeep Holla <sudeep.holla@arm.com> - 2016-04-28 19:10 +0200
    Re: [PATCH v2 1/2] PM / OPP: add non-OF versions of  dev_pm_opp_{cpumask_,}remove_table Viresh Kumar <viresh.kumar@linaro.org> - 2016-04-29 06:10 +0200
      Re: [PATCH v2 1/2] PM / OPP: add non-OF versions of  dev_pm_opp_{cpumask_,}remove_table Sudeep Holla <sudeep.holla@arm.com> - 2016-04-29 11:30 +0200
    Re: [PATCH v2 1/2][UPDATE] PM / OPP: add non-OF versions of  dev_pm_opp_{cpumask_,}remove_table Viresh Kumar <viresh.kumar@linaro.org> - 2016-04-29 11:30 +0200
      Re: [PATCH v2 1/2][UPDATE] PM / OPP: add non-OF versions of  dev_pm_opp_{cpumask_,}remove_table Sudeep Holla <sudeep.holla@arm.com> - 2016-04-29 11:40 +0200
        Re: [PATCH v2 1/2][UPDATE] PM / OPP: add non-OF versions of  dev_pm_opp_{cpumask_,}remove_table Viresh Kumar <viresh.kumar@linaro.org> - 2016-04-29 11:40 +0200
    [PATCH v2 1/2][UPDATE] PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_,}remove_table Sudeep Holla <sudeep.holla@arm.com> - 2016-04-29 11:30 +0200

#1390406 — [PATCH v2 1/2] PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_,}remove_table

FromSudeep Holla <sudeep.holla@arm.com>
Date2016-04-28 19:10 +0200
Subject[PATCH v2 1/2] PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_,}remove_table
Message-ID<rsXBV-7sB-11@gated-at.bofh.it>
Functions dev_pm_opp_of_{cpumask_,}remove_table removes/frees all the
static OPP entries associated with the device and/or all cpus(in case
of cpumask) that are created from DT.

However the OPP entries are populated reading from the firmware or some
different method using dev_pm_opp_add are marked dynamic and can't be
removed using above functions.

This patch adds non DT/OF versions of dev_pm_opp_{cpumask_,}remove_table
to support the above mentioned usecase.

This is in preparation to make use of the same in scpi-cpufreq.c

Cc: Viresh Kumar <vireshk@kernel.org>
Cc: Nishanth Menon <nm@ti.com>
CC: Stephen Boyd <sboyd@codeaurora.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/base/power/opp/core.c | 51 ++++++++++++++++++++++++++++++++-----
 drivers/base/power/opp/cpu.c  | 58 ++++++++++++++++++++++++++++++++-----------
 include/linux/pm_opp.h        | 10 ++++++++
 3 files changed, 98 insertions(+), 21 deletions(-)

v1->v2:
	- Instead of renaming OF versions, created non-OF versions of
	  dev_pm_opp_{cpumask_,}remove_table as suggested by Viresh

diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index 433b60092972..e59b9e7c31ba 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -1845,13 +1845,14 @@ struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_get_notifier);
 
-#ifdef CONFIG_OF
 /**
- * dev_pm_opp_of_remove_table() - Free OPP table entries created from static DT
- *				  entries
+ * _dev_pm_opp_remove_table() - Free OPP table entries
  * @dev:	device pointer used to lookup OPP table.
+ * @remove_dyn:	specify whether to remove only OPPs created using
+ *              static entries from DT or even the dynamically add OPPs.
  *
- * Free OPPs created using static entries present in DT.
+ * Free OPPs either created using static entries present in DT or even the
+ * dynamically added entries based on @remove_dyn param.
  *
  * Locking: The internal opp_table and opp structures are RCU protected.
  * Hence this function indirectly uses RCU updater strategy with mutex locks
@@ -1859,7 +1860,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_get_notifier);
  * that this function is *NOT* called under RCU protection or in contexts where
  * mutex cannot be locked.
  */
-void dev_pm_opp_of_remove_table(struct device *dev)
+static void _dev_pm_opp_remove_table(struct device *dev, bool remove_dyn)
 {
 	struct opp_table *opp_table;
 	struct dev_pm_opp *opp, *tmp;
@@ -1884,7 +1885,7 @@ void dev_pm_opp_of_remove_table(struct device *dev)
 	if (list_is_singular(&opp_table->dev_list)) {
 		/* Free static OPPs */
 		list_for_each_entry_safe(opp, tmp, &opp_table->opp_list, node) {
-			if (!opp->dynamic)
+			if (!opp->dynamic || (opp->dynamic && remove_dyn))
 				_opp_remove(opp_table, opp, true);
 		}
 	} else {
@@ -1894,6 +1895,44 @@ void dev_pm_opp_of_remove_table(struct device *dev)
 unlock:
 	mutex_unlock(&opp_table_lock);
 }
+
+/**
+ * dev_pm_opp_of_remove_table() - Free OPP table entries created from static DT
+ *				  entries
+ * @dev:	device pointer used to lookup OPP table.
+ *
+ * Free all OPPs associated with the device
+ *
+ * Locking: The internal opp_table and opp structures are RCU protected.
+ * Hence this function indirectly uses RCU updater strategy with mutex locks
+ * to keep the integrity of the internal data structures. Callers should ensure
+ * that this function is *NOT* called under RCU protection or in contexts where
+ * mutex cannot be locked.
+ */
+void dev_pm_opp_remove_table(struct device *dev)
+{
+	_dev_pm_opp_remove_table(dev, true);
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_remove_table);
+
+#ifdef CONFIG_OF
+/**
+ * dev_pm_opp_of_remove_table() - Free OPP table entries created from static DT
+ *				  entries
+ * @dev:	device pointer used to lookup OPP table.
+ *
+ * Free OPPs created using static entries present in DT.
+ *
+ * Locking: The internal opp_table and opp structures are RCU protected.
+ * Hence this function indirectly uses RCU updater strategy with mutex locks
+ * to keep the integrity of the internal data structures. Callers should ensure
+ * that this function is *NOT* called under RCU protection or in contexts where
+ * mutex cannot be locked.
+ */
+void dev_pm_opp_of_remove_table(struct device *dev)
+{
+	_dev_pm_opp_remove_table(dev, false);
+}
 EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table);
 
 /* Returns opp descriptor node for a device, caller must do of_node_put() */
diff --git a/drivers/base/power/opp/cpu.c b/drivers/base/power/opp/cpu.c
index 55cbf9bd8707..9df4ad809c26 100644
--- a/drivers/base/power/opp/cpu.c
+++ b/drivers/base/power/opp/cpu.c
@@ -119,12 +119,54 @@ void dev_pm_opp_free_cpufreq_table(struct device *dev,
 EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table);
 #endif	/* CONFIG_CPU_FREQ */
 
+static void _dev_pm_opp_cpumask_remove_table(cpumask_var_t cpumask, bool of)
+{
+	struct device *cpu_dev;
+	int cpu;
+
+	WARN_ON(cpumask_empty(cpumask));
+
+	for_each_cpu(cpu, cpumask) {
+		cpu_dev = get_cpu_device(cpu);
+		if (!cpu_dev) {
+			pr_err("%s: failed to get cpu%d device\n", __func__,
+			       cpu);
+			continue;
+		}
+		if (of)
+			dev_pm_opp_of_remove_table(cpu_dev);
+		else
+			dev_pm_opp_remove_table(cpu_dev);
+	}
+}
+
+/**
+ * dev_pm_opp_of_cpumask_remove_table() - Removes OPP table for @cpumask
+ * @cpumask:	cpumask for which OPP table needs to be removed
+ *
+ * This removes the OPP tables for CPUs present in the @cpumask.
+ * This should be used to remove all the OPPs entries associated with
+ * the cpus in @cpumask.
+ *
+ * Locking: The internal opp_table and opp structures are RCU protected.
+ * Hence this function internally uses RCU updater strategy with mutex locks
+ * to keep the integrity of the internal data structures. Callers should ensure
+ * that this function is *NOT* called under RCU protection or in contexts where
+ * mutex cannot be locked.
+ */
+void dev_pm_opp_cpumask_remove_table(cpumask_var_t cpumask)
+{
+	_dev_pm_opp_cpumask_remove_table(cpumask, false);
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_cpumask_remove_table);
+
 #ifdef CONFIG_OF
 /**
  * dev_pm_opp_of_cpumask_remove_table() - Removes OPP table for @cpumask
  * @cpumask:	cpumask for which OPP table needs to be removed
  *
  * This removes the OPP tables for CPUs present in the @cpumask.
+ * This should be used only to remove static entries created from DT.
  *
  * Locking: The internal opp_table and opp structures are RCU protected.
  * Hence this function internally uses RCU updater strategy with mutex locks
@@ -134,21 +176,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table);
  */
 void dev_pm_opp_of_cpumask_remove_table(cpumask_var_t cpumask)
 {
-	struct device *cpu_dev;
-	int cpu;
-
-	WARN_ON(cpumask_empty(cpumask));
-
-	for_each_cpu(cpu, cpumask) {
-		cpu_dev = get_cpu_device(cpu);
-		if (!cpu_dev) {
-			pr_err("%s: failed to get cpu%d device\n", __func__,
-			       cpu);
-			continue;
-		}
-
-		dev_pm_opp_of_remove_table(cpu_dev);
-	}
+	_dev_pm_opp_cpumask_remove_table(cpumask, true);
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_remove_table);
 
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index 5b6ad31403a5..5c3781a79d31 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -66,6 +66,8 @@ int dev_pm_opp_set_regulator(struct device *dev, const char *name);
 void dev_pm_opp_put_regulator(struct device *dev);
 int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq);
 int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask);
+void dev_pm_opp_remove_table(struct device *dev);
+void dev_pm_opp_cpumask_remove_table(cpumask_var_t cpumask);
 #else
 static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
 {
@@ -184,6 +186,14 @@ static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, cpumask_va
 	return -ENOSYS;
 }
 
+static inline void dev_pm_opp_remove_table(struct device *dev)
+{
+}
+
+static inline void dev_pm_opp_cpumask_remove_table(cpumask_var_t cpumask)
+{
+}
+
 #endif		/* CONFIG_PM_OPP */
 
 #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
-- 
1.9.1

[toc] | [next] | [standalone]


#1390721 — Re: [PATCH v2 1/2] PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_,}remove_table

FromViresh Kumar <viresh.kumar@linaro.org>
Date2016-04-29 06:10 +0200
SubjectRe: [PATCH v2 1/2] PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_,}remove_table
Message-ID<rt7UB-82c-1@gated-at.bofh.it>
In reply to#1390406
On 28-04-16, 18:07, Sudeep Holla wrote:
> diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
> index 433b60092972..e59b9e7c31ba 100644
> --- a/drivers/base/power/opp/core.c
> +++ b/drivers/base/power/opp/core.c
> @@ -1845,13 +1845,14 @@ struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev)
>  }
>  EXPORT_SYMBOL_GPL(dev_pm_opp_get_notifier);
>  
> -#ifdef CONFIG_OF
>  /**
> - * dev_pm_opp_of_remove_table() - Free OPP table entries created from static DT
> - *				  entries
> + * _dev_pm_opp_remove_table() - Free OPP table entries

This is an internal routine and doesn't really require a doc-style comment at
all. Please remove it. You can add a simple comment for things you want to
mention though.

>   * @dev:	device pointer used to lookup OPP table.
> + * @remove_dyn:	specify whether to remove only OPPs created using
> + *              static entries from DT or even the dynamically add OPPs.
>   *
> - * Free OPPs created using static entries present in DT.
> + * Free OPPs either created using static entries present in DT or even the
> + * dynamically added entries based on @remove_dyn param.
>   *
>   * Locking: The internal opp_table and opp structures are RCU protected.
>   * Hence this function indirectly uses RCU updater strategy with mutex locks
> @@ -1859,7 +1860,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_get_notifier);
>   * that this function is *NOT* called under RCU protection or in contexts where
>   * mutex cannot be locked.
>   */
> -void dev_pm_opp_of_remove_table(struct device *dev)
> +static void _dev_pm_opp_remove_table(struct device *dev, bool remove_dyn)

Maybe s/remove_dyn/remove_all ..

>  {
>  	struct opp_table *opp_table;
>  	struct dev_pm_opp *opp, *tmp;
> @@ -1884,7 +1885,7 @@ void dev_pm_opp_of_remove_table(struct device *dev)
>  	if (list_is_singular(&opp_table->dev_list)) {
>  		/* Free static OPPs */
>  		list_for_each_entry_safe(opp, tmp, &opp_table->opp_list, node) {
> -			if (!opp->dynamic)
> +			if (!opp->dynamic || (opp->dynamic && remove_dyn))

Well, that's a funny one :)

The second conditional statement doesn't require opp->dynamic, as that is
guaranteed to be true, as the first condition failed.

So this should be:

if (remove_all || !opp->dynamic)

>  				_opp_remove(opp_table, opp, true);
>  		}
>  	} else {
> @@ -1894,6 +1895,44 @@ void dev_pm_opp_of_remove_table(struct device *dev)
>  unlock:
>  	mutex_unlock(&opp_table_lock);
>  }
> +
> +/**
> + * dev_pm_opp_of_remove_table() - Free OPP table entries created from static DT

No, this isn't the OF specific function.

> + *				  entries
> + * @dev:	device pointer used to lookup OPP table.
> + *
> + * Free all OPPs associated with the device

Full stop at the end.

> + *
> + * Locking: The internal opp_table and opp structures are RCU protected.
> + * Hence this function indirectly uses RCU updater strategy with mutex locks
> + * to keep the integrity of the internal data structures. Callers should ensure
> + * that this function is *NOT* called under RCU protection or in contexts where
> + * mutex cannot be locked.
> + */
> +void dev_pm_opp_remove_table(struct device *dev)
> +{
> +	_dev_pm_opp_remove_table(dev, true);
> +}
> +EXPORT_SYMBOL_GPL(dev_pm_opp_remove_table);
> +
> +#ifdef CONFIG_OF
> +/**
> + * dev_pm_opp_of_remove_table() - Free OPP table entries created from static DT
> + *				  entries
> + * @dev:	device pointer used to lookup OPP table.
> + *
> + * Free OPPs created using static entries present in DT.
> + *
> + * Locking: The internal opp_table and opp structures are RCU protected.
> + * Hence this function indirectly uses RCU updater strategy with mutex locks
> + * to keep the integrity of the internal data structures. Callers should ensure
> + * that this function is *NOT* called under RCU protection or in contexts where
> + * mutex cannot be locked.
> + */
> +void dev_pm_opp_of_remove_table(struct device *dev)
> +{
> +	_dev_pm_opp_remove_table(dev, false);
> +}
>  EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table);
>  
>  /* Returns opp descriptor node for a device, caller must do of_node_put() */
> diff --git a/drivers/base/power/opp/cpu.c b/drivers/base/power/opp/cpu.c
> index 55cbf9bd8707..9df4ad809c26 100644
> --- a/drivers/base/power/opp/cpu.c
> +++ b/drivers/base/power/opp/cpu.c
> @@ -119,12 +119,54 @@ void dev_pm_opp_free_cpufreq_table(struct device *dev,
>  EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table);
>  #endif	/* CONFIG_CPU_FREQ */
>  
> +static void _dev_pm_opp_cpumask_remove_table(cpumask_var_t cpumask, bool of)
> +{
> +	struct device *cpu_dev;
> +	int cpu;
> +
> +	WARN_ON(cpumask_empty(cpumask));
> +
> +	for_each_cpu(cpu, cpumask) {
> +		cpu_dev = get_cpu_device(cpu);
> +		if (!cpu_dev) {
> +			pr_err("%s: failed to get cpu%d device\n", __func__,
> +			       cpu);
> +			continue;
> +		}

Blank line here.

> +		if (of)
> +			dev_pm_opp_of_remove_table(cpu_dev);
> +		else
> +			dev_pm_opp_remove_table(cpu_dev);
> +	}
> +}
> +
> +/**
> + * dev_pm_opp_of_cpumask_remove_table() - Removes OPP table for @cpumask

of :(

> + * @cpumask:	cpumask for which OPP table needs to be removed
> + *
> + * This removes the OPP tables for CPUs present in the @cpumask.
> + * This should be used to remove all the OPPs entries associated with
> + * the cpus in @cpumask.
> + *
> + * Locking: The internal opp_table and opp structures are RCU protected.
> + * Hence this function internally uses RCU updater strategy with mutex locks
> + * to keep the integrity of the internal data structures. Callers should ensure
> + * that this function is *NOT* called under RCU protection or in contexts where
> + * mutex cannot be locked.
> + */
> +void dev_pm_opp_cpumask_remove_table(cpumask_var_t cpumask)
> +{
> +	_dev_pm_opp_cpumask_remove_table(cpumask, false);
> +}
> +EXPORT_SYMBOL_GPL(dev_pm_opp_cpumask_remove_table);
> +
>  #ifdef CONFIG_OF
>  /**
>   * dev_pm_opp_of_cpumask_remove_table() - Removes OPP table for @cpumask
>   * @cpumask:	cpumask for which OPP table needs to be removed
>   *
>   * This removes the OPP tables for CPUs present in the @cpumask.
> + * This should be used only to remove static entries created from DT.
>   *
>   * Locking: The internal opp_table and opp structures are RCU protected.
>   * Hence this function internally uses RCU updater strategy with mutex locks
> @@ -134,21 +176,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table);
>   */
>  void dev_pm_opp_of_cpumask_remove_table(cpumask_var_t cpumask)
>  {
> -	struct device *cpu_dev;
> -	int cpu;
> -
> -	WARN_ON(cpumask_empty(cpumask));
> -
> -	for_each_cpu(cpu, cpumask) {
> -		cpu_dev = get_cpu_device(cpu);
> -		if (!cpu_dev) {
> -			pr_err("%s: failed to get cpu%d device\n", __func__,
> -			       cpu);
> -			continue;
> -		}
> -
> -		dev_pm_opp_of_remove_table(cpu_dev);
> -	}
> +	_dev_pm_opp_cpumask_remove_table(cpumask, true);
>  }
>  EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_remove_table);
>  
> diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
> index 5b6ad31403a5..5c3781a79d31 100644
> --- a/include/linux/pm_opp.h
> +++ b/include/linux/pm_opp.h
> @@ -66,6 +66,8 @@ int dev_pm_opp_set_regulator(struct device *dev, const char *name);
>  void dev_pm_opp_put_regulator(struct device *dev);
>  int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq);
>  int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask);
> +void dev_pm_opp_remove_table(struct device *dev);
> +void dev_pm_opp_cpumask_remove_table(cpumask_var_t cpumask);
>  #else
>  static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
>  {
> @@ -184,6 +186,14 @@ static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, cpumask_va
>  	return -ENOSYS;
>  }
>  
> +static inline void dev_pm_opp_remove_table(struct device *dev)
> +{
> +}
> +
> +static inline void dev_pm_opp_cpumask_remove_table(cpumask_var_t cpumask)
> +{
> +}
> +
>  #endif		/* CONFIG_PM_OPP */
>  
>  #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
> -- 
> 1.9.1

-- 
viresh

[toc] | [prev] | [next] | [standalone]


#1390928 — Re: [PATCH v2 1/2] PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_,}remove_table

FromSudeep Holla <sudeep.holla@arm.com>
Date2016-04-29 11:30 +0200
SubjectRe: [PATCH v2 1/2] PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_,}remove_table
Message-ID<rtcUi-3th-23@gated-at.bofh.it>
In reply to#1390721

On 29/04/16 05:07, Viresh Kumar wrote:
> On 28-04-16, 18:07, Sudeep Holla wrote:
>> diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
>> index 433b60092972..e59b9e7c31ba 100644
>> --- a/drivers/base/power/opp/core.c
>> +++ b/drivers/base/power/opp/core.c

[...]

>>   {
>>   	struct opp_table *opp_table;
>>   	struct dev_pm_opp *opp, *tmp;
>> @@ -1884,7 +1885,7 @@ void dev_pm_opp_of_remove_table(struct device *dev)
>>   	if (list_is_singular(&opp_table->dev_list)) {
>>   		/* Free static OPPs */
>>   		list_for_each_entry_safe(opp, tmp, &opp_table->opp_list, node) {
>> -			if (!opp->dynamic)
>> +			if (!opp->dynamic || (opp->dynamic && remove_dyn))
>
> Well, that's a funny one :)
>
> The second conditional statement doesn't require opp->dynamic, as that is
> guaranteed to be true, as the first condition failed.
>
> So this should be:
>
> if (remove_all || !opp->dynamic)
>

Yes, initially I thought we may need to support a mix where both static
entries from DT and dynamic entries will be present and this function
must remove the latter only. But I soon realized that it's not required
and also will get ugly. However I forgot to change this part :(

>>   				_opp_remove(opp_table, opp, true);
>>   		}
>>   	} else {
>> @@ -1894,6 +1895,44 @@ void dev_pm_opp_of_remove_table(struct device *dev)
>>   unlock:
>>   	mutex_unlock(&opp_table_lock);
>>   }
>> +
>> +/**
>> + * dev_pm_opp_of_remove_table() - Free OPP table entries created from static DT
>
> No, this isn't the OF specific function.
>

Sorry, copy-paste disease :) esp. for documenting.

-- 
Regards,
Sudeep

[toc] | [prev] | [next] | [standalone]


#1390919 — Re: [PATCH v2 1/2][UPDATE] PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_,}remove_table

FromViresh Kumar <viresh.kumar@linaro.org>
Date2016-04-29 11:30 +0200
SubjectRe: [PATCH v2 1/2][UPDATE] PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_,}remove_table
Message-ID<rtcUh-3th-1@gated-at.bofh.it>
In reply to#1390406
This isn't V2, but V3

On 29-04-16, 10:22, Sudeep Holla wrote:
> Functions dev_pm_opp_of_{cpumask_,}remove_table removes/frees all the
> static OPP entries associated with the device and/or all cpus(in case
> of cpumask) that are created from DT.
> 
> However the OPP entries are populated reading from the firmware or some
> different method using dev_pm_opp_add are marked dynamic and can't be
> removed using above functions.
> 
> This patch adds non DT/OF versions of dev_pm_opp_{cpumask_,}remove_table
> to support the above mentioned usecase.
> 
> This is in preparation to make use of the same in scpi-cpufreq.c
> 
> Cc: Viresh Kumar <vireshk@kernel.org>
> Cc: Nishanth Menon <nm@ti.com>
> CC: Stephen Boyd <sboyd@codeaurora.org>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: linux-pm@vger.kernel.org
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
>  drivers/base/power/opp/core.c | 56 ++++++++++++++++++++++++++++++----------
>  drivers/base/power/opp/cpu.c  | 59 ++++++++++++++++++++++++++++++++-----------
>  include/linux/pm_opp.h        | 10 ++++++++
>  3 files changed, 96 insertions(+), 29 deletions(-)
> 
> v1->v2:
> 	- Instead of renaming OF versions, created non-OF versions of
> 	  dev_pm_opp_{cpumask_,}remove_table as suggested by Viresh
> 

You should have added v2->v3 here

> This version also updates all the errors in documentation and changes
> to use remove_all rather than remove_dyn.

But all that isn't going to be part of the history, so it should be fine :)

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

-- 
viresh

[toc] | [prev] | [next] | [standalone]


#1390937 — Re: [PATCH v2 1/2][UPDATE] PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_,}remove_table

FromSudeep Holla <sudeep.holla@arm.com>
Date2016-04-29 11:40 +0200
SubjectRe: [PATCH v2 1/2][UPDATE] PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_,}remove_table
Message-ID<rtd3X-3yC-1@gated-at.bofh.it>
In reply to#1390919

On 29/04/16 10:28, Viresh Kumar wrote:
> This isn't V2, but V3
>
> On 29-04-16, 10:22, Sudeep Holla wrote:
>> Functions dev_pm_opp_of_{cpumask_,}remove_table removes/frees all the
>> static OPP entries associated with the device and/or all cpus(in case
>> of cpumask) that are created from DT.
>>
>> However the OPP entries are populated reading from the firmware or some
>> different method using dev_pm_opp_add are marked dynamic and can't be
>> removed using above functions.
>>
>> This patch adds non DT/OF versions of dev_pm_opp_{cpumask_,}remove_table
>> to support the above mentioned usecase.
>>
>> This is in preparation to make use of the same in scpi-cpufreq.c
>>
>> Cc: Viresh Kumar <vireshk@kernel.org>
>> Cc: Nishanth Menon <nm@ti.com>
>> CC: Stephen Boyd <sboyd@codeaurora.org>
>> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
>> Cc: linux-pm@vger.kernel.org
>> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
>> ---
>>   drivers/base/power/opp/core.c | 56 ++++++++++++++++++++++++++++++----------
>>   drivers/base/power/opp/cpu.c  | 59 ++++++++++++++++++++++++++++++++-----------
>>   include/linux/pm_opp.h        | 10 ++++++++
>>   3 files changed, 96 insertions(+), 29 deletions(-)
>>
>> v1->v2:
>> 	- Instead of renaming OF versions, created non-OF versions of
>> 	  dev_pm_opp_{cpumask_,}remove_table as suggested by Viresh
>>
>
> You should have added v2->v3 here
>

No, thought I will post v3 of both the patches with your ACK so that
it's easy for Rafael to pick up if he has no comments :)

>> This version also updates all the errors in documentation and changes
>> to use remove_all rather than remove_dyn.
>
> But all that isn't going to be part of the history, so it should be fine :)
>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
>

Thanks

-- 
Regards,
Sudeep

[toc] | [prev] | [next] | [standalone]


#1390939 — Re: [PATCH v2 1/2][UPDATE] PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_,}remove_table

FromViresh Kumar <viresh.kumar@linaro.org>
Date2016-04-29 11:40 +0200
SubjectRe: [PATCH v2 1/2][UPDATE] PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_,}remove_table
Message-ID<rtd3Y-3yC-5@gated-at.bofh.it>
In reply to#1390937
On 29-04-16, 10:31, Sudeep Holla wrote:
> 
> 
> On 29/04/16 10:28, Viresh Kumar wrote:
> >This isn't V2, but V3
> >
> >On 29-04-16, 10:22, Sudeep Holla wrote:
> >>Functions dev_pm_opp_of_{cpumask_,}remove_table removes/frees all the
> >>static OPP entries associated with the device and/or all cpus(in case
> >>of cpumask) that are created from DT.
> >>
> >>However the OPP entries are populated reading from the firmware or some
> >>different method using dev_pm_opp_add are marked dynamic and can't be
> >>removed using above functions.
> >>
> >>This patch adds non DT/OF versions of dev_pm_opp_{cpumask_,}remove_table
> >>to support the above mentioned usecase.
> >>
> >>This is in preparation to make use of the same in scpi-cpufreq.c
> >>
> >>Cc: Viresh Kumar <vireshk@kernel.org>
> >>Cc: Nishanth Menon <nm@ti.com>
> >>CC: Stephen Boyd <sboyd@codeaurora.org>
> >>Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> >>Cc: linux-pm@vger.kernel.org
> >>Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> >>---
> >>  drivers/base/power/opp/core.c | 56 ++++++++++++++++++++++++++++++----------
> >>  drivers/base/power/opp/cpu.c  | 59 ++++++++++++++++++++++++++++++++-----------
> >>  include/linux/pm_opp.h        | 10 ++++++++
> >>  3 files changed, 96 insertions(+), 29 deletions(-)
> >>
> >>v1->v2:
> >>	- Instead of renaming OF versions, created non-OF versions of
> >>	  dev_pm_opp_{cpumask_,}remove_table as suggested by Viresh
> >>
> >
> >You should have added v2->v3 here
> >
> 
> No, thought I will post v3 of both the patches with your ACK so that
> it's easy for Rafael to pick up if he has no comments :)

Whatever you do, this was v3 unquestionably.

-- 
viresh

[toc] | [prev] | [next] | [standalone]


#1390935 — [PATCH v2 1/2][UPDATE] PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_,}remove_table

FromSudeep Holla <sudeep.holla@arm.com>
Date2016-04-29 11:30 +0200
Subject[PATCH v2 1/2][UPDATE] PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_,}remove_table
Message-ID<rtcUh-3th-3@gated-at.bofh.it>
In reply to#1390406
Functions dev_pm_opp_of_{cpumask_,}remove_table removes/frees all the
static OPP entries associated with the device and/or all cpus(in case
of cpumask) that are created from DT.

However the OPP entries are populated reading from the firmware or some
different method using dev_pm_opp_add are marked dynamic and can't be
removed using above functions.

This patch adds non DT/OF versions of dev_pm_opp_{cpumask_,}remove_table
to support the above mentioned usecase.

This is in preparation to make use of the same in scpi-cpufreq.c

Cc: Viresh Kumar <vireshk@kernel.org>
Cc: Nishanth Menon <nm@ti.com>
CC: Stephen Boyd <sboyd@codeaurora.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/base/power/opp/core.c | 56 ++++++++++++++++++++++++++++++----------
 drivers/base/power/opp/cpu.c  | 59 ++++++++++++++++++++++++++++++++-----------
 include/linux/pm_opp.h        | 10 ++++++++
 3 files changed, 96 insertions(+), 29 deletions(-)

v1->v2:
	- Instead of renaming OF versions, created non-OF versions of
	  dev_pm_opp_{cpumask_,}remove_table as suggested by Viresh

This version also updates all the errors in documentation and changes
to use remove_all rather than remove_dyn.

diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index 433b60092972..15536d45832a 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -1845,21 +1845,11 @@ struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_get_notifier);
 
-#ifdef CONFIG_OF
 /**
- * dev_pm_opp_of_remove_table() - Free OPP table entries created from static DT
- *				  entries
- * @dev:	device pointer used to lookup OPP table.
- *
- * Free OPPs created using static entries present in DT.
- *
- * Locking: The internal opp_table and opp structures are RCU protected.
- * Hence this function indirectly uses RCU updater strategy with mutex locks
- * to keep the integrity of the internal data structures. Callers should ensure
- * that this function is *NOT* called under RCU protection or in contexts where
- * mutex cannot be locked.
+ * Free OPPs either created using static entries present in DT or even the
+ * dynamically added entries based on remove_all param.
  */
-void dev_pm_opp_of_remove_table(struct device *dev)
+static void _dev_pm_opp_remove_table(struct device *dev, bool remove_all)
 {
 	struct opp_table *opp_table;
 	struct dev_pm_opp *opp, *tmp;
@@ -1884,7 +1874,7 @@ void dev_pm_opp_of_remove_table(struct device *dev)
 	if (list_is_singular(&opp_table->dev_list)) {
 		/* Free static OPPs */
 		list_for_each_entry_safe(opp, tmp, &opp_table->opp_list, node) {
-			if (!opp->dynamic)
+			if (remove_all || !opp->dynamic)
 				_opp_remove(opp_table, opp, true);
 		}
 	} else {
@@ -1894,6 +1884,44 @@ void dev_pm_opp_of_remove_table(struct device *dev)
 unlock:
 	mutex_unlock(&opp_table_lock);
 }
+
+/**
+ * dev_pm_opp_remove_table() - Free all OPPs associated with the device
+ * @dev:	device pointer used to lookup OPP table.
+ *
+ * Free both OPPs created using static entries present in DT and the
+ * dynamically added entries.
+ *
+ * Locking: The internal opp_table and opp structures are RCU protected.
+ * Hence this function indirectly uses RCU updater strategy with mutex locks
+ * to keep the integrity of the internal data structures. Callers should ensure
+ * that this function is *NOT* called under RCU protection or in contexts where
+ * mutex cannot be locked.
+ */
+void dev_pm_opp_remove_table(struct device *dev)
+{
+	_dev_pm_opp_remove_table(dev, true);
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_remove_table);
+
+#ifdef CONFIG_OF
+/**
+ * dev_pm_opp_of_remove_table() - Free OPP table entries created from static DT
+ *				  entries
+ * @dev:	device pointer used to lookup OPP table.
+ *
+ * Free OPPs created using static entries present in DT.
+ *
+ * Locking: The internal opp_table and opp structures are RCU protected.
+ * Hence this function indirectly uses RCU updater strategy with mutex locks
+ * to keep the integrity of the internal data structures. Callers should ensure
+ * that this function is *NOT* called under RCU protection or in contexts where
+ * mutex cannot be locked.
+ */
+void dev_pm_opp_of_remove_table(struct device *dev)
+{
+	_dev_pm_opp_remove_table(dev, false);
+}
 EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table);
 
 /* Returns opp descriptor node for a device, caller must do of_node_put() */
diff --git a/drivers/base/power/opp/cpu.c b/drivers/base/power/opp/cpu.c
index 55cbf9bd8707..2dc39543d88b 100644
--- a/drivers/base/power/opp/cpu.c
+++ b/drivers/base/power/opp/cpu.c
@@ -119,20 +119,7 @@ void dev_pm_opp_free_cpufreq_table(struct device *dev,
 EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table);
 #endif	/* CONFIG_CPU_FREQ */
 
-#ifdef CONFIG_OF
-/**
- * dev_pm_opp_of_cpumask_remove_table() - Removes OPP table for @cpumask
- * @cpumask:	cpumask for which OPP table needs to be removed
- *
- * This removes the OPP tables for CPUs present in the @cpumask.
- *
- * Locking: The internal opp_table and opp structures are RCU protected.
- * Hence this function internally uses RCU updater strategy with mutex locks
- * to keep the integrity of the internal data structures. Callers should ensure
- * that this function is *NOT* called under RCU protection or in contexts where
- * mutex cannot be locked.
- */
-void dev_pm_opp_of_cpumask_remove_table(cpumask_var_t cpumask)
+static void _dev_pm_opp_cpumask_remove_table(cpumask_var_t cpumask, bool of)
 {
 	struct device *cpu_dev;
 	int cpu;
@@ -147,9 +134,51 @@ void dev_pm_opp_of_cpumask_remove_table(cpumask_var_t cpumask)
 			continue;
 		}
 
-		dev_pm_opp_of_remove_table(cpu_dev);
+		if (of)
+			dev_pm_opp_of_remove_table(cpu_dev);
+		else
+			dev_pm_opp_remove_table(cpu_dev);
 	}
 }
+
+/**
+ * dev_pm_opp_cpumask_remove_table() - Removes OPP table for @cpumask
+ * @cpumask:	cpumask for which OPP table needs to be removed
+ *
+ * This removes the OPP tables for CPUs present in the @cpumask.
+ * This should be used to remove all the OPPs entries associated with
+ * the cpus in @cpumask.
+ *
+ * Locking: The internal opp_table and opp structures are RCU protected.
+ * Hence this function internally uses RCU updater strategy with mutex locks
+ * to keep the integrity of the internal data structures. Callers should ensure
+ * that this function is *NOT* called under RCU protection or in contexts where
+ * mutex cannot be locked.
+ */
+void dev_pm_opp_cpumask_remove_table(cpumask_var_t cpumask)
+{
+	_dev_pm_opp_cpumask_remove_table(cpumask, false);
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_cpumask_remove_table);
+
+#ifdef CONFIG_OF
+/**
+ * dev_pm_opp_of_cpumask_remove_table() - Removes OPP table for @cpumask
+ * @cpumask:	cpumask for which OPP table needs to be removed
+ *
+ * This removes the OPP tables for CPUs present in the @cpumask.
+ * This should be used only to remove static entries created from DT.
+ *
+ * Locking: The internal opp_table and opp structures are RCU protected.
+ * Hence this function internally uses RCU updater strategy with mutex locks
+ * to keep the integrity of the internal data structures. Callers should ensure
+ * that this function is *NOT* called under RCU protection or in contexts where
+ * mutex cannot be locked.
+ */
+void dev_pm_opp_of_cpumask_remove_table(cpumask_var_t cpumask)
+{
+	_dev_pm_opp_cpumask_remove_table(cpumask, true);
+}
 EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_remove_table);
 
 /**
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index 5b6ad31403a5..5c3781a79d31 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -66,6 +66,8 @@ int dev_pm_opp_set_regulator(struct device *dev, const char *name);
 void dev_pm_opp_put_regulator(struct device *dev);
 int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq);
 int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask);
+void dev_pm_opp_remove_table(struct device *dev);
+void dev_pm_opp_cpumask_remove_table(cpumask_var_t cpumask);
 #else
 static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
 {
@@ -184,6 +186,14 @@ static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, cpumask_va
 	return -ENOSYS;
 }
 
+static inline void dev_pm_opp_remove_table(struct device *dev)
+{
+}
+
+static inline void dev_pm_opp_cpumask_remove_table(cpumask_var_t cpumask)
+{
+}
+
 #endif		/* CONFIG_PM_OPP */
 
 #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
-- 
1.9.1

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web