diff options
-rw-r--r-- | drivers/base/power/opp/core.c | 58 | ||||
-rw-r--r-- | drivers/base/power/opp/cpu.c | 68 | ||||
-rw-r--r-- | include/linux/pm_opp.h | 30 |
3 files changed, 112 insertions, 44 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 | } |
1846 | EXPORT_SYMBOL_GPL(dev_pm_opp_get_notifier); | 1846 | EXPORT_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 | */ |
1862 | void dev_pm_opp_of_remove_table(struct device *dev) | 1852 | static 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) | |||
1894 | unlock: | 1884 | unlock: |
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 | */ | ||
1901 | void dev_pm_opp_remove_table(struct device *dev) | ||
1902 | { | ||
1903 | _dev_pm_opp_remove_table(dev, true); | ||
1904 | } | ||
1905 | EXPORT_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 | */ | ||
1921 | void dev_pm_opp_of_remove_table(struct device *dev) | ||
1922 | { | ||
1923 | _dev_pm_opp_remove_table(dev, false); | ||
1924 | } | ||
1897 | EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table); | 1925 | EXPORT_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 3428380dfca7..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, | |||
119 | EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table); | 119 | EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table); |
120 | #endif /* CONFIG_CPU_FREQ */ | 120 | #endif /* CONFIG_CPU_FREQ */ |
121 | 121 | ||
122 | #ifdef CONFIG_OF | 122 | static 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 | */ | ||
135 | void dev_pm_opp_of_cpumask_remove_table(cpumask_var_t 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(cpumask_var_t 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 | */ | ||
159 | void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask) | ||
160 | { | ||
161 | _dev_pm_opp_cpumask_remove_table(cpumask, false); | ||
162 | } | ||
163 | EXPORT_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 | */ | ||
179 | void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask) | ||
180 | { | ||
181 | _dev_pm_opp_cpumask_remove_table(cpumask, true); | ||
182 | } | ||
153 | EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_remove_table); | 183 | EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_remove_table); |
154 | 184 | ||
155 | /** | 185 | /** |
@@ -164,7 +194,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_remove_table); | |||
164 | * that this function is *NOT* called under RCU protection or in contexts where | 194 | * that this function is *NOT* called under RCU protection or in contexts where |
165 | * mutex cannot be locked. | 195 | * mutex cannot be locked. |
166 | */ | 196 | */ |
167 | int dev_pm_opp_of_cpumask_add_table(cpumask_var_t cpumask) | 197 | int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask) |
168 | { | 198 | { |
169 | struct device *cpu_dev; | 199 | struct device *cpu_dev; |
170 | int cpu, ret = 0; | 200 | int cpu, ret = 0; |
@@ -217,7 +247,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_add_table); | |||
217 | * that this function is *NOT* called under RCU protection or in contexts where | 247 | * that this function is *NOT* called under RCU protection or in contexts where |
218 | * mutex cannot be locked. | 248 | * mutex cannot be locked. |
219 | */ | 249 | */ |
220 | int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask) | 250 | int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask) |
221 | { | 251 | { |
222 | struct device_node *np, *tmp_np; | 252 | struct device_node *np, *tmp_np; |
223 | struct device *tcpu_dev; | 253 | struct device *tcpu_dev; |
@@ -288,7 +318,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_get_sharing_cpus); | |||
288 | * mutex cannot be locked. | 318 | * mutex cannot be locked. |
289 | */ | 319 | */ |
290 | int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, | 320 | int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, |
291 | const cpumask_var_t cpumask) | 321 | const struct cpumask *cpumask) |
292 | { | 322 | { |
293 | struct opp_device *opp_dev; | 323 | struct opp_device *opp_dev; |
294 | struct opp_table *opp_table; | 324 | struct opp_table *opp_table; |
@@ -346,7 +376,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_set_sharing_cpus); | |||
346 | * that this function is *NOT* called under RCU protection or in contexts where | 376 | * that this function is *NOT* called under RCU protection or in contexts where |
347 | * mutex cannot be locked. | 377 | * mutex cannot be locked. |
348 | */ | 378 | */ |
349 | int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask) | 379 | int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask) |
350 | { | 380 | { |
351 | struct opp_device *opp_dev; | 381 | struct opp_device *opp_dev; |
352 | struct opp_table *opp_table; | 382 | struct opp_table *opp_table; |
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 15f554443b59..bca26157f5b6 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h | |||
@@ -65,8 +65,10 @@ void dev_pm_opp_put_prop_name(struct device *dev); | |||
65 | int dev_pm_opp_set_regulator(struct device *dev, const char *name); | 65 | int dev_pm_opp_set_regulator(struct device *dev, const char *name); |
66 | void dev_pm_opp_put_regulator(struct device *dev); | 66 | void dev_pm_opp_put_regulator(struct device *dev); |
67 | int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq); | 67 | int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq); |
68 | int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const cpumask_var_t cpumask); | 68 | int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask); |
69 | int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask); | 69 | int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); |
70 | void dev_pm_opp_remove_table(struct device *dev); | ||
71 | void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask); | ||
70 | #else | 72 | #else |
71 | static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp) | 73 | static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp) |
72 | { | 74 | { |
@@ -180,24 +182,32 @@ static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_f | |||
180 | return -ENOTSUPP; | 182 | return -ENOTSUPP; |
181 | } | 183 | } |
182 | 184 | ||
183 | static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const cpumask_var_t cpumask) | 185 | static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask) |
184 | { | 186 | { |
185 | return -ENOTSUPP; | 187 | return -ENOTSUPP; |
186 | } | 188 | } |
187 | 189 | ||
188 | static inline int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask) | 190 | static inline int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask) |
189 | { | 191 | { |
190 | return -EINVAL; | 192 | return -EINVAL; |
191 | } | 193 | } |
192 | 194 | ||
195 | static inline void dev_pm_opp_remove_table(struct device *dev) | ||
196 | { | ||
197 | } | ||
198 | |||
199 | static 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) |
196 | int dev_pm_opp_of_add_table(struct device *dev); | 206 | int dev_pm_opp_of_add_table(struct device *dev); |
197 | void dev_pm_opp_of_remove_table(struct device *dev); | 207 | void dev_pm_opp_of_remove_table(struct device *dev); |
198 | int dev_pm_opp_of_cpumask_add_table(cpumask_var_t cpumask); | 208 | int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask); |
199 | void dev_pm_opp_of_cpumask_remove_table(cpumask_var_t cpumask); | 209 | void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask); |
200 | int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask); | 210 | int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); |
201 | #else | 211 | #else |
202 | static inline int dev_pm_opp_of_add_table(struct device *dev) | 212 | static inline int dev_pm_opp_of_add_table(struct device *dev) |
203 | { | 213 | { |
@@ -208,16 +218,16 @@ static inline void dev_pm_opp_of_remove_table(struct device *dev) | |||
208 | { | 218 | { |
209 | } | 219 | } |
210 | 220 | ||
211 | static inline int dev_pm_opp_of_cpumask_add_table(cpumask_var_t cpumask) | 221 | static inline int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask) |
212 | { | 222 | { |
213 | return -ENOTSUPP; | 223 | return -ENOTSUPP; |
214 | } | 224 | } |
215 | 225 | ||
216 | static inline void dev_pm_opp_of_cpumask_remove_table(cpumask_var_t cpumask) | 226 | static inline void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask) |
217 | { | 227 | { |
218 | } | 228 | } |
219 | 229 | ||
220 | static inline int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask) | 230 | static inline int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask) |
221 | { | 231 | { |
222 | return -ENOTSUPP; | 232 | return -ENOTSUPP; |
223 | } | 233 | } |