tree:
https://github.com/0day-ci/linux/commits/UPDATE-20201214-224511/Lukasz-Lu...
head: b514d648f75d436e8da880bc18f4f2e7709eef44
commit: f2c969e1a3e02b7a647f423661bbe294ccdf4321 [4/5] thermal: devfreq_cooling: remove
old power model and use EM
config: riscv-randconfig-r004-20201214 (attached as .config)
compiler: riscv32-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O
~/bin/make.cross
chmod +x ~/bin/make.cross
#
https://github.com/0day-ci/linux/commit/f2c969e1a3e02b7a647f423661bbe294c...
git remote add linux-review
https://github.com/0day-ci/linux
git fetch --no-tags linux-review
UPDATE-20201214-224511/Lukasz-Luba/Thermal-devfreq-cooling-improvements-with-Energy-Model/20201210-225123
git checkout f2c969e1a3e02b7a647f423661bbe294ccdf4321
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=riscv
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All error/warnings (new ones prefixed by >>):
In file included from include/linux/dev_printk.h:14,
from include/linux/device.h:15,
from include/linux/devfreq.h:13,
from drivers/thermal/devfreq_cooling.c:13:
drivers/thermal/devfreq_cooling.c: In function
'devfreq_cooling_set_cur_state':
> drivers/thermal/devfreq_cooling.c:102:9: error: 'struct
device' has no member named 'em_pd'
102 | if (dev->em_pd) {
| ^~
include/linux/compiler.h:58:52: note: in definition of macro '__trace_if_var'
58 | #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) :
__trace_if_value(cond))
| ^~~~
drivers/thermal/devfreq_cooling.c:102:2: note: in expansion of macro 'if'
102 | if (dev->em_pd) {
| ^~
> drivers/thermal/devfreq_cooling.c:102:9: error: 'struct
device' has no member named 'em_pd'
102 | if (dev->em_pd) {
| ^~
include/linux/compiler.h:58:61: note: in definition of macro '__trace_if_var'
58 | #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) :
__trace_if_value(cond))
| ^~~~
drivers/thermal/devfreq_cooling.c:102:2: note: in expansion of macro 'if'
102 | if (dev->em_pd) {
| ^~
> drivers/thermal/devfreq_cooling.c:102:9: error: 'struct
device' has no member named 'em_pd'
102 | if (dev->em_pd) {
| ^~
include/linux/compiler.h:69:3: note: in definition of macro '__trace_if_value'
69 | (cond) ? \
| ^~~~
include/linux/compiler.h:56:28: note: in expansion of macro '__trace_if_var'
56 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
| ^~~~~~~~~~~~~~
drivers/thermal/devfreq_cooling.c:102:2: note: in expansion of macro 'if'
102 | if (dev->em_pd) {
| ^~
drivers/thermal/devfreq_cooling.c:104:13: error: 'struct device' has no member
named 'em_pd'
104 | freq = dev->em_pd->table[perf_idx].frequency * 1000;
| ^~
> drivers/thermal/devfreq_cooling.c:92:6: warning: variable
'perf_idx' set but not used [-Wunused-but-set-variable]
92 | int
perf_idx;
| ^~~~~~~~
drivers/thermal/devfreq_cooling.c: In function
'devfreq_cooling_get_requested_power':
drivers/thermal/devfreq_cooling.c:207:23: error: 'struct device' has no member
named 'em_pd'
207 | dfc->res_util = dev->em_pd->table[state].power;
| ^~
drivers/thermal/devfreq_cooling.c:217:30: error: 'struct device' has no member
named 'em_pd'
217 | perf_idx = get_perf_idx(dev->em_pd, freq / 1000);
| ^~
drivers/thermal/devfreq_cooling.c:226:15: error: 'struct device' has no member
named 'em_pd'
226 | *power = dev->em_pd->table[perf_idx].power;
| ^~
> drivers/thermal/devfreq_cooling.c:186:16: warning: variable
'state' set but not used [-Wunused-but-set-variable]
186 | unsigned
long state;
| ^~~~~
drivers/thermal/devfreq_cooling.c: In function 'devfreq_cooling_state2power':
drivers/thermal/devfreq_cooling.c:252:14: error: 'struct device' has no member
named 'em_pd'
252 | *power = dev->em_pd->table[perf_idx].power;
| ^~
drivers/thermal/devfreq_cooling.c:246:6: warning: variable 'perf_idx' set but
not used [-Wunused-but-set-variable]
246 | int perf_idx;
| ^~~~~~~~
In file included from include/linux/dev_printk.h:14,
from include/linux/device.h:15,
from include/linux/devfreq.h:13,
from drivers/thermal/devfreq_cooling.c:13:
drivers/thermal/devfreq_cooling.c: In function 'devfreq_cooling_power2state':
drivers/thermal/devfreq_cooling.c:290:23: error: 'struct device' has no member
named 'em_pd'
290 | if (est_power >= dev->em_pd->table[i].power)
| ^~
include/linux/compiler.h:58:52: note: in definition of macro '__trace_if_var'
58 | #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) :
__trace_if_value(cond))
| ^~~~
drivers/thermal/devfreq_cooling.c:290:3: note: in expansion of macro 'if'
290 | if (est_power >= dev->em_pd->table[i].power)
| ^~
drivers/thermal/devfreq_cooling.c:290:23: error: 'struct device' has no member
named 'em_pd'
290 | if (est_power >= dev->em_pd->table[i].power)
| ^~
include/linux/compiler.h:58:61: note: in definition of macro '__trace_if_var'
58 | #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) :
__trace_if_value(cond))
| ^~~~
drivers/thermal/devfreq_cooling.c:290:3: note: in expansion of macro 'if'
290 | if (est_power >= dev->em_pd->table[i].power)
| ^~
drivers/thermal/devfreq_cooling.c:290:23: error: 'struct device' has no member
named 'em_pd'
290 | if (est_power >= dev->em_pd->table[i].power)
| ^~
include/linux/compiler.h:69:3: note: in definition of macro '__trace_if_value'
69 | (cond) ? \
| ^~~~
include/linux/compiler.h:56:28: note: in expansion of macro '__trace_if_var'
56 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
| ^~~~~~~~~~~~~~
drivers/thermal/devfreq_cooling.c:290:3: note: in expansion of macro 'if'
290 | if (est_power >= dev->em_pd->table[i].power)
| ^~
drivers/thermal/devfreq_cooling.c: In function
'of_devfreq_cooling_register_power':
drivers/thermal/devfreq_cooling.c:377:9: error: 'struct device' has no member
named 'em_pd'
377 | if (dev->em_pd) {
| ^~
include/linux/compiler.h:58:52: note: in definition of macro '__trace_if_var'
58 | #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) :
__trace_if_value(cond))
| ^~~~
drivers/thermal/devfreq_cooling.c:377:2: note: in expansion of macro 'if'
377 | if (dev->em_pd) {
| ^~
drivers/thermal/devfreq_cooling.c:377:9: error: 'struct device' has no member
named 'em_pd'
377 | if (dev->em_pd) {
| ^~
include/linux/compiler.h:58:61: note: in definition of macro '__trace_if_var'
58 | #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) :
__trace_if_value(cond))
| ^~~~
drivers/thermal/devfreq_cooling.c:377:2: note: in expansion of macro 'if'
377 | if (dev->em_pd) {
| ^~
drivers/thermal/devfreq_cooling.c:377:9: error: 'struct device' has no member
named 'em_pd'
377 | if (dev->em_pd) {
| ^~
include/linux/compiler.h:69:3: note: in definition of macro '__trace_if_value'
69 | (cond) ? \
| ^~~~
include/linux/compiler.h:56:28: note: in expansion of macro '__trace_if_var'
56 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
| ^~~~~~~~~~~~~~
drivers/thermal/devfreq_cooling.c:377:2: note: in expansion of macro 'if'
377 | if (dev->em_pd) {
| ^~
drivers/thermal/devfreq_cooling.c:385:38: error: 'struct device' has no member
named 'em_pd'
385 | num_opps = em_pd_nr_perf_states(dev->em_pd);
| ^~
vim +102 drivers/thermal/devfreq_cooling.c
84
85 static int devfreq_cooling_set_cur_state(struct thermal_cooling_device *cdev,
86 unsigned long state)
87 {
88 struct devfreq_cooling_device *dfc = cdev->devdata;
89 struct devfreq *df = dfc->devfreq;
90 struct device *dev = df->dev.parent;
91 unsigned long freq;
92 int perf_idx;
93
94 if (state == dfc->cooling_state)
95 return 0;
96
97 dev_dbg(dev, "Setting cooling state %lu\n", state);
98
99 if (state > dfc->max_state)
100 return -EINVAL;
101
102 if (dev->em_pd) {
103 perf_idx = dfc->max_state
- state;
104 freq = dev->em_pd->table[perf_idx].frequency * 1000;
105 } else {
106 freq = dfc->freq_table[state];
107 }
108
109 dev_pm_qos_update_request(&dfc->req_max_freq,
110 DIV_ROUND_UP(freq, HZ_PER_KHZ));
111
112 dfc->cooling_state = state;
113
114 return 0;
115 }
116
117 /**
118 * get_perf_idx() - get the performance index corresponding to a frequency
119 * @em_pd: Pointer to device's Energy Model
120 * @freq: frequency in kHz
121 *
122 * Return: the performance index associated with the @freq, or
123 * -EINVAL if it wasn't found.
124 */
125 static int get_perf_idx(struct em_perf_domain *em_pd, unsigned long freq)
126 {
127 int i;
128
129 for (i = 0; i < em_pd->nr_perf_states; i++) {
130 if (em_pd->table[i].frequency == freq)
131 return i;
132 }
133
134 return -EINVAL;
135 }
136
137 static unsigned long get_voltage(struct devfreq *df, unsigned long freq)
138 {
139 struct device *dev = df->dev.parent;
140 unsigned long voltage;
141 struct dev_pm_opp *opp;
142
143 opp = dev_pm_opp_find_freq_exact(dev, freq, true);
144 if (PTR_ERR(opp) == -ERANGE)
145 opp = dev_pm_opp_find_freq_exact(dev, freq, false);
146
147 if (IS_ERR(opp)) {
148 dev_err_ratelimited(dev, "Failed to find OPP for frequency %lu:
%ld\n",
149 freq, PTR_ERR(opp));
150 return 0;
151 }
152
153 voltage = dev_pm_opp_get_voltage(opp) / 1000; /* mV */
154 dev_pm_opp_put(opp);
155
156 if (voltage == 0) {
157 dev_err_ratelimited(dev,
158 "Failed to get voltage for frequency %lu\n",
159 freq);
160 }
161
162 return voltage;
163 }
164
165 static void _normalize_load(struct devfreq_dev_status *status)
166 {
167 if (status->total_time > 0xfffff) {
168 status->total_time >>= 10;
169 status->busy_time >>= 10;
170 }
171
172 status->busy_time <<= 10;
173 status->busy_time /= status->total_time ? : 1;
174
175 status->busy_time = status->busy_time ? : 1;
176 status->total_time = 1024;
177 }
178
179 static int devfreq_cooling_get_requested_power(struct thermal_cooling_device
*cdev,
180 u32 *power)
181 {
182 struct devfreq_cooling_device *dfc = cdev->devdata;
183 struct devfreq *df = dfc->devfreq;
184 struct device *dev = df->dev.parent;
185 struct devfreq_dev_status status;
186 unsigned long state;
187 unsigned long freq;
188 unsigned long voltage;
189 int res, perf_idx;
190
191 mutex_lock(&df->lock);
192 status = df->last_status;
193 mutex_unlock(&df->lock);
194
195 freq = status.current_frequency;
196
197 if (dfc->power_ops && dfc->power_ops->get_real_power) {
198 voltage = get_voltage(df, freq);
199 if (voltage == 0) {
200 res = -EINVAL;
201 goto fail;
202 }
203
204 res = dfc->power_ops->get_real_power(df, power, freq, voltage);
205 if (!res) {
206 state = dfc->capped_state;
207 dfc->res_util = dev->em_pd->table[state].power;
208 dfc->res_util *= SCALE_ERROR_MITIGATION;
209
210 if (*power > 1)
211 dfc->res_util /= *power;
212 } else {
213 goto fail;
214 }
215 } else {
216 /* Energy Model frequencies are in kHz */
217 perf_idx = get_perf_idx(dev->em_pd, freq / 1000);
218 if (perf_idx < 0) {
219 res = -EAGAIN;
220 goto fail;
221 }
222
223 _normalize_load(&status);
224
225 /* Scale power for utilization */
226 *power = dev->em_pd->table[perf_idx].power;
227 *power *= status.busy_time;
228 *power >>= 10;
229 }
230
231 trace_thermal_power_devfreq_get_power(cdev, &status, freq, *power);
232
233 return 0;
234 fail:
235 /* It is safe to set max in this case */
236 dfc->res_util = SCALE_ERROR_MITIGATION;
237 return res;
238 }
239
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org