aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSudeep Holla <Sudeep.Holla@arm.com>2016-05-03 10:05:04 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-05-04 19:38:44 -0400
commit411466c5081d2f649b3583cae0f6c9ad5edec636 (patch)
treece07767ac0e4c5f1e5371e336819aa47598ae31e
parentddbb74bc70c0dbaab85d1aa2564b0b3217267454 (diff)
PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_, }remove_table
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 Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/base/power/opp/core.c58
-rw-r--r--drivers/base/power/opp/cpu.c60
-rw-r--r--include/linux/pm_opp.h10
3 files changed, 98 insertions, 30 deletions
diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index 433b60092972..9f8bf04b4dbe 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)
1845} 1845}
1846EXPORT_SYMBOL_GPL(dev_pm_opp_get_notifier); 1846EXPORT_SYMBOL_GPL(dev_pm_opp_get_notifier);
1847 1847
1848#ifdef CONFIG_OF 1848/*
1849/** 1849 * Free OPPs either created using static entries present in DT or even the
1850 * dev_pm_opp_of_remove_table() - Free OPP table entries created from static DT 1850 * dynamically added entries based on remove_all param.
1851 * entries
1852 * @dev: device pointer used to lookup OPP table.
1853 *
1854 * Free OPPs created using static entries present in DT.
1855 *
1856 * Locking: The internal opp_table and opp structures are RCU protected.
1857 * Hence this function indirectly uses RCU updater strategy with mutex locks
1858 * to keep the integrity of the internal data structures. Callers should ensure
1859 * that this function is *NOT* called under RCU protection or in contexts where
1860 * mutex cannot be locked.
1861 */ 1851 */
1862void dev_pm_opp_of_remove_table(struct device *dev) 1852static void _dev_pm_opp_remove_table(struct device *dev, bool remove_all)
1863{ 1853{
1864 struct opp_table *opp_table; 1854 struct opp_table *opp_table;
1865 struct dev_pm_opp *opp, *tmp; 1855 struct dev_pm_opp *opp, *tmp;
@@ -1884,7 +1874,7 @@ void dev_pm_opp_of_remove_table(struct device *dev)
1884 if (list_is_singular(&opp_table->dev_list)) { 1874 if (list_is_singular(&opp_table->dev_list)) {
1885 /* Free static OPPs */ 1875 /* Free static OPPs */
1886 list_for_each_entry_safe(opp, tmp, &opp_table->opp_list, node) { 1876 list_for_each_entry_safe(opp, tmp, &opp_table->opp_list, node) {
1887 if (!opp->dynamic) 1877 if (remove_all || !opp->dynamic)
1888 _opp_remove(opp_table, opp, true); 1878 _opp_remove(opp_table, opp, true);
1889 } 1879 }
1890 } else { 1880 } else {
@@ -1894,6 +1884,44 @@ void dev_pm_opp_of_remove_table(struct device *dev)
1894unlock: 1884unlock:
1895 mutex_unlock(&opp_table_lock); 1885 mutex_unlock(&opp_table_lock);
1896} 1886}
1887
1888/**
1889 * dev_pm_opp_remove_table() - Free all OPPs associated with the device
1890 * @dev: device pointer used to lookup OPP table.
1891 *
1892 * Free both OPPs created using static entries present in DT and the
1893 * dynamically added entries.
1894 *
1895 * Locking: The internal opp_table and opp structures are RCU protected.
1896 * Hence this function indirectly uses RCU updater strategy with mutex locks
1897 * to keep the integrity of the internal data structures. Callers should ensure
1898 * that this function is *NOT* called under RCU protection or in contexts where
1899 * mutex cannot be locked.
1900 */
1901void dev_pm_opp_remove_table(struct device *dev)
1902{
1903 _dev_pm_opp_remove_table(dev, true);
1904}
1905EXPORT_SYMBOL_GPL(dev_pm_opp_remove_table);
1906
1907#ifdef CONFIG_OF
1908/**
1909 * dev_pm_opp_of_remove_table() - Free OPP table entries created from static DT
1910 * entries
1911 * @dev: device pointer used to lookup OPP table.
1912 *
1913 * Free OPPs created using static entries present in DT.
1914 *
1915 * Locking: The internal opp_table and opp structures are RCU protected.
1916 * Hence this function indirectly uses RCU updater strategy with mutex locks
1917 * to keep the integrity of the internal data structures. Callers should ensure
1918 * that this function is *NOT* called under RCU protection or in contexts where
1919 * mutex cannot be locked.
1920 */
1921void dev_pm_opp_of_remove_table(struct device *dev)
1922{
1923 _dev_pm_opp_remove_table(dev, false);
1924}
1897EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table); 1925EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table);
1898 1926
1899/* Returns opp descriptor node for a device, caller must do of_node_put() */ 1927/* 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 8e0b6349d7d4..357781e0b791 100644
--- a/drivers/base/power/opp/cpu.c
+++ b/drivers/base/power/opp/cpu.c
@@ -119,20 +119,8 @@ void dev_pm_opp_free_cpufreq_table(struct device *dev,
119EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table); 119EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table);
120#endif /* CONFIG_CPU_FREQ */ 120#endif /* CONFIG_CPU_FREQ */
121 121
122#ifdef CONFIG_OF 122static void
123/** 123_dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, bool of)
124 * dev_pm_opp_of_cpumask_remove_table() - Removes OPP table for @cpumask
125 * @cpumask: cpumask for which OPP table needs to be removed
126 *
127 * This removes the OPP tables for CPUs present in the @cpumask.
128 *
129 * Locking: The internal opp_table and opp structures are RCU protected.
130 * Hence this function internally uses RCU updater strategy with mutex locks
131 * to keep the integrity of the internal data structures. Callers should ensure
132 * that this function is *NOT* called under RCU protection or in contexts where
133 * mutex cannot be locked.
134 */
135void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask)
136{ 124{
137 struct device *cpu_dev; 125 struct device *cpu_dev;
138 int cpu; 126 int cpu;
@@ -147,9 +135,51 @@ void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask)
147 continue; 135 continue;
148 } 136 }
149 137
150 dev_pm_opp_of_remove_table(cpu_dev); 138 if (of)
139 dev_pm_opp_of_remove_table(cpu_dev);
140 else
141 dev_pm_opp_remove_table(cpu_dev);
151 } 142 }
152} 143}
144
145/**
146 * dev_pm_opp_cpumask_remove_table() - Removes OPP table for @cpumask
147 * @cpumask: cpumask for which OPP table needs to be removed
148 *
149 * This removes the OPP tables for CPUs present in the @cpumask.
150 * This should be used to remove all the OPPs entries associated with
151 * the cpus in @cpumask.
152 *
153 * Locking: The internal opp_table and opp structures are RCU protected.
154 * Hence this function internally uses RCU updater strategy with mutex locks
155 * to keep the integrity of the internal data structures. Callers should ensure
156 * that this function is *NOT* called under RCU protection or in contexts where
157 * mutex cannot be locked.
158 */
159void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask)
160{
161 _dev_pm_opp_cpumask_remove_table(cpumask, false);
162}
163EXPORT_SYMBOL_GPL(dev_pm_opp_cpumask_remove_table);
164
165#ifdef CONFIG_OF
166/**
167 * dev_pm_opp_of_cpumask_remove_table() - Removes OPP table for @cpumask
168 * @cpumask: cpumask for which OPP table needs to be removed
169 *
170 * This removes the OPP tables for CPUs present in the @cpumask.
171 * This should be used only to remove static entries created from DT.
172 *
173 * Locking: The internal opp_table and opp structures are RCU protected.
174 * Hence this function internally uses RCU updater strategy with mutex locks
175 * to keep the integrity of the internal data structures. Callers should ensure
176 * that this function is *NOT* called under RCU protection or in contexts where
177 * mutex cannot be locked.
178 */
179void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask)
180{
181 _dev_pm_opp_cpumask_remove_table(cpumask, true);
182}
153EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_remove_table); 183EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_remove_table);
154 184
155/** 185/**
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index 5221d259e413..bca26157f5b6 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -67,6 +67,8 @@ void dev_pm_opp_put_regulator(struct device *dev);
67int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq); 67int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq);
68int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask); 68int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask);
69int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); 69int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask);
70void dev_pm_opp_remove_table(struct device *dev);
71void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask);
70#else 72#else
71static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp) 73static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
72{ 74{
@@ -190,6 +192,14 @@ static inline int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpu
190 return -EINVAL; 192 return -EINVAL;
191} 193}
192 194
195static inline void dev_pm_opp_remove_table(struct device *dev)
196{
197}
198
199static inline void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask)
200{
201}
202
193#endif /* CONFIG_PM_OPP */ 203#endif /* CONFIG_PM_OPP */
194 204
195#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF) 205#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)