forked from Minki/linux
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 <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Rui Huang <ray.huang@amd.com>
Cc: Sherry Hurwitz <sherry.hurwitz@amd.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Acked-by: Huang Rui <ray.huang@amd.com>
Tested-by: Huang Rui <ray.huang@amd.com>
Fixes: fa79434499
("hwmon: (fam15h_power) Add compute unit accumulated power")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
af8c34ce6a
commit
7be4881846
@ -172,9 +172,9 @@ static void do_read_registers_on_cu(void *_data)
|
||||
*/
|
||||
static int read_registers(struct fam15h_power_data *data)
|
||||
{
|
||||
int this_cpu, ret, cpu;
|
||||
int core, this_core;
|
||||
cpumask_var_t mask;
|
||||
int ret, cpu;
|
||||
|
||||
ret = zalloc_cpumask_var(&mask, GFP_KERNEL);
|
||||
if (!ret)
|
||||
@ -183,7 +183,6 @@ static int read_registers(struct fam15h_power_data *data)
|
||||
memset(data->cu_on, 0, sizeof(int) * MAX_CUS);
|
||||
|
||||
get_online_cpus();
|
||||
this_cpu = smp_processor_id();
|
||||
|
||||
/*
|
||||
* Choose the first online core of each compute unit, and then
|
||||
@ -205,12 +204,9 @@ static int read_registers(struct fam15h_power_data *data)
|
||||
cpumask_set_cpu(cpumask_any(topology_sibling_cpumask(cpu)), mask);
|
||||
}
|
||||
|
||||
if (cpumask_test_cpu(this_cpu, mask))
|
||||
do_read_registers_on_cu(data);
|
||||
on_each_cpu_mask(mask, do_read_registers_on_cu, data, true);
|
||||
|
||||
smp_call_function_many(mask, do_read_registers_on_cu, data, true);
|
||||
put_online_cpus();
|
||||
|
||||
free_cpumask_var(mask);
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user