Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758656AbcDEOyW (ORCPT ); Tue, 5 Apr 2016 10:54:22 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:47972 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758502AbcDEOyU (ORCPT ); Tue, 5 Apr 2016 10:54:20 -0400 Date: Tue, 5 Apr 2016 07:54:14 -0700 From: Guenter Roeck To: Juergen Gross Cc: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, boris.ostrovsky@oracle.com, david.vrabel@citrix.com, mingo@redhat.com, peterz@infradead.org, Douglas_Warzecha@dell.com, pali.rohar@gmail.com, jdelvare@suse.com, tglx@linutronix.de, hpa@zytor.com, jeremy@goop.org, chrisw@sous-sol.org, akataria@vmware.com, rusty@rustcorp.com.au, virtualization@lists.linux-foundation.org, x86@kernel.org Subject: Re: [PATCH v4 6/6] hwmon: use smp_call_on_cpu() for dell-smm i8k Message-ID: <20160405145414.GB27359@roeck-us.net> References: <1459833007-11618-1-git-send-email-jgross@suse.com> <1459833007-11618-7-git-send-email-jgross@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1459833007-11618-7-git-send-email-jgross@suse.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2474 Lines: 98 On Tue, Apr 05, 2016 at 07:10:07AM +0200, Juergen Gross wrote: > Use the smp_call_on_cpu() function to call system management > mode on cpu 0. > Make call secure by adding get_online_cpus() to avoid e.g. suspend > resume cycles in between. > > Signed-off-by: Juergen Gross > --- > V4: add call to get_online_cpus() Pali, any chance to test this ? Thanks, Guenter > --- > drivers/hwmon/dell-smm-hwmon.c | 35 ++++++++++++++++++++--------------- > 1 file changed, 20 insertions(+), 15 deletions(-) > > diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c > index c43318d..643f3a1 100644 > --- a/drivers/hwmon/dell-smm-hwmon.c > +++ b/drivers/hwmon/dell-smm-hwmon.c > @@ -21,6 +21,7 @@ > > #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > > +#include > #include > #include > #include > @@ -35,6 +36,7 @@ > #include > #include > #include > +#include > > #include > > @@ -130,23 +132,15 @@ static inline const char *i8k_get_dmi_data(int field) > /* > * Call the System Management Mode BIOS. Code provided by Jonathan Buzzard. > */ > -static int i8k_smm(struct smm_regs *regs) > +static int i8k_smm_func(void *par) > { > int rc; > + struct smm_regs *regs = par; > 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); > - rc = set_cpus_allowed_ptr(current, cpumask_of(0)); > - if (rc) > - goto out; > - if (smp_processor_id() != 0) { > - rc = -EBUSY; > - goto out; > - } > + if (smp_processor_id() != 0) > + return -EBUSY; > > #if defined(CONFIG_X86_64) > asm volatile("pushq %%rax\n\t" > @@ -204,13 +198,24 @@ static int i8k_smm(struct smm_regs *regs) > if (rc != 0 || (regs->eax & 0xffff) == 0xffff || regs->eax == eax) > rc = -EINVAL; > > -out: > - set_cpus_allowed_ptr(current, old_mask); > - free_cpumask_var(old_mask); > return rc; > } > > /* > + * Call the System Management Mode BIOS. > + */ > +static int i8k_smm(struct smm_regs *regs) > +{ > + int ret; > + > + get_online_cpus(); > + ret = smp_call_on_cpu(0, true, i8k_smm_func, regs); > + put_online_cpus(); > + > + return ret; > +} > + > +/* > * Read the fan status. > */ > static int i8k_get_fan_status(int fan) > -- > 2.6.2 >