Skip to content

Commit 7be4881

Browse files
suryasaimadhugroeck
authored andcommitted
hwmon: (fam15h_power) Disable preemption when reading registers
We need to read a bunch of registers on each compute unit and possibly on the current CPU too. Disable preemption around it. Otherwise, you get: BUG: using smp_processor_id() in preemptible [00000000] code: systemd-udevd/327 caller is read_registers+0x6a/0x110 [fam15h_power] CPU: 3 PID: 327 Comm: systemd-udevd Not tainted 4.7.0-rc1+ #4 Hardware name: HP HP EliteBook 745 G3/807E, BIOS N73 Ver. 01.08 01/28/2016 ... Suggested-by: Thomas Gleixner <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: Rui Huang <[email protected]> Cc: Sherry Hurwitz <[email protected]> Cc: Guenter Roeck <[email protected]> Acked-by: Huang Rui <[email protected]> Tested-by: Huang Rui <[email protected]> Fixes: fa79434 ("hwmon: (fam15h_power) Add compute unit accumulated power") Signed-off-by: Guenter Roeck <[email protected]>
1 parent af8c34c commit 7be4881

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

drivers/hwmon/fam15h_power.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ static void do_read_registers_on_cu(void *_data)
172172
*/
173173
static int read_registers(struct fam15h_power_data *data)
174174
{
175-
int this_cpu, ret, cpu;
176175
int core, this_core;
177176
cpumask_var_t mask;
177+
int ret, cpu;
178178

179179
ret = zalloc_cpumask_var(&mask, GFP_KERNEL);
180180
if (!ret)
@@ -183,7 +183,6 @@ static int read_registers(struct fam15h_power_data *data)
183183
memset(data->cu_on, 0, sizeof(int) * MAX_CUS);
184184

185185
get_online_cpus();
186-
this_cpu = smp_processor_id();
187186

188187
/*
189188
* Choose the first online core of each compute unit, and then
@@ -205,12 +204,9 @@ static int read_registers(struct fam15h_power_data *data)
205204
cpumask_set_cpu(cpumask_any(topology_sibling_cpumask(cpu)), mask);
206205
}
207206

208-
if (cpumask_test_cpu(this_cpu, mask))
209-
do_read_registers_on_cu(data);
207+
on_each_cpu_mask(mask, do_read_registers_on_cu, data, true);
210208

211-
smp_call_function_many(mask, do_read_registers_on_cu, data, true);
212209
put_online_cpus();
213-
214210
free_cpumask_var(mask);
215211

216212
return 0;

0 commit comments

Comments
 (0)