diff options
author | Guenter Roeck <linux@roeck-us.net> | 2013-12-14 09:30:15 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-12-18 16:45:38 -0800 |
commit | f36fdb9f0266811ee27140acc6ac5ff21199b159 (patch) | |
tree | db55e44e0d29792be1f0ebba9e92939e54d4d8a6 /drivers/char/i8k.c | |
parent | 14d32383965243ea37f00656538d91a2ea3a719f (diff) | |
download | linux-f36fdb9f0266811ee27140acc6ac5ff21199b159.tar.gz linux-f36fdb9f0266811ee27140acc6ac5ff21199b159.tar.bz2 linux-f36fdb9f0266811ee27140acc6ac5ff21199b159.zip |
i8k: Force SMM to run on CPU 0
On Studio 1555 with dual-core CPU, reading sensor attributes
exported by this driver resulted in random failures combined
with system hangups and forced logouts. Information in
drivers/firmware/dcdbas.c suggests that SMM accesses must
run on CPU 0. With this patch, the problems are gone,
suggesting that this is in fact the case.
Code derived from drivers/firmware/dcdbas.c.
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/char/i8k.c')
-rw-r--r-- | drivers/char/i8k.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c index 7e31e47ef987..f24bbcd848de 100644 --- a/drivers/char/i8k.c +++ b/drivers/char/i8k.c @@ -31,6 +31,7 @@ #include <linux/hwmon-sysfs.h> #include <linux/uaccess.h> #include <linux/io.h> +#include <linux/sched.h> #include <linux/i8k.h> @@ -130,6 +131,17 @@ static int i8k_smm(struct smm_regs *regs) { int rc; int eax = regs->eax; + cpumask_var_t old_mask; + + /* SMM requires CPU 0 */ + if (!alloc_cpumask_var(&old_mask, GFP_KERNEL)) + return -ENOMEM; + cpumask_copy(old_mask, ¤t->cpus_allowed); + set_cpus_allowed_ptr(current, cpumask_of(0)); + if (smp_processor_id() != 0) { + rc = -EBUSY; + goto out; + } #if defined(CONFIG_X86_64) asm volatile("pushq %%rax\n\t" @@ -185,9 +197,12 @@ static int i8k_smm(struct smm_regs *regs) : "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory"); #endif if (rc != 0 || (regs->eax & 0xffff) == 0xffff || regs->eax == eax) - return -EINVAL; + rc = -EINVAL; - return 0; +out: + set_cpus_allowed_ptr(current, old_mask); + free_cpumask_var(old_mask); + return rc; } /* |