linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: (fam15h_power) Disable preemption when reading registers
@ 2016-06-01 10:04 Borislav Petkov
  2016-06-01 13:22 ` Guenter Roeck
  0 siblings, 1 reply; 14+ messages in thread
From: Borislav Petkov @ 2016-06-01 10:04 UTC (permalink / raw)
  To: linux-hwmon; +Cc: X86 ML, LKML, Rui Huang, Sherry Hurwitz, Guenter Roeck

From: Borislav Petkov <bp@suse.de>

We need to read a bunch of registers on each compute unit and possibly
on the current CPU too. Disable preemption around it.

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>
---
 drivers/hwmon/fam15h_power.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
index eb97a9241d17..69bb810f528b 100644
--- a/drivers/hwmon/fam15h_power.c
+++ b/drivers/hwmon/fam15h_power.c
@@ -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,10 +204,13 @@ 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))
+	preempt_disable();
+	smp_call_function_many(mask, do_read_registers_on_cu, data, true);
+
+	if (cpumask_test_cpu(smp_processor_id(), mask))
 		do_read_registers_on_cu(data);
 
-	smp_call_function_many(mask, do_read_registers_on_cu, data, true);
+	preempt_enable();
 	put_online_cpus();
 
 	free_cpumask_var(mask);
-- 
2.7.3

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2016-06-06  7:53 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-01 10:04 [PATCH] hwmon: (fam15h_power) Disable preemption when reading registers Borislav Petkov
2016-06-01 13:22 ` Guenter Roeck
2016-06-01 13:41   ` Borislav Petkov
2016-06-01 18:15     ` Guenter Roeck
2016-06-02  7:26       ` Borislav Petkov
2016-06-02  7:47         ` Thomas Gleixner
2016-06-02  7:58           ` Borislav Petkov
2016-06-02  8:14             ` Borislav Petkov
2016-06-03 18:18               ` Guenter Roeck
2016-06-03 18:29                 ` Borislav Petkov
2016-06-04 14:55                   ` Guenter Roeck
2016-06-06  7:58                     ` Huang Rui
2016-06-01 15:26   ` Huang, Ray
2016-06-01 15:35     ` Huang, Ray

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).