Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964906AbbGHJvQ (ORCPT ); Wed, 8 Jul 2015 05:51:16 -0400 Received: from queue01c.mail.zen.net.uk ([212.23.3.237]:35165 "EHLO queue01c.mail.zen.net.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933271AbbGHJvM (ORCPT ); Wed, 8 Jul 2015 05:51:12 -0400 X-Greylist: delayed 1438 seconds by postgrey-1.27 at vger.kernel.org; Wed, 08 Jul 2015 05:51:12 EDT Message-ID: <1436347629.2844.12.camel@linaro.org> Subject: Re: [PATCH] cpufreq: Initialize the governor again while restoring policy From: "Jon Medhurst (Tixy)" To: Viresh Kumar Cc: Rafael Wysocki , linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Pi-Cheng Chen , open list Date: Wed, 08 Jul 2015 10:27:09 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Originating-smarthost01d-IP: [82.69.122.217] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2048 Lines: 52 On Wed, 2015-07-08 at 11:23 +0530, Viresh Kumar wrote: > When all CPUs of a policy are hot-unplugged, we EXIT the governor but > don't mark policy->governor as NULL. This was done in order to keep last > used governor's information intact in sysfs, while the CPUs are offline. > > We also missed marking policy->governor as NULL while restoring the > policy. Because of that, we call __cpufreq_governor(CPUFREQ_GOV_LIMITS) > for an uninitialized policy. Which eventually returns -EBUSY. > > Fix this by setting policy->governor to NULL while restoring the policy. > > Reported-by: Pi-Cheng Chen > Reported-by: "Jon Medhurst (Tixy)" > Fixes: 18bf3a124ef8 ("cpufreq: Mark policy->governor = NULL for inactive policies") > Signed-off-by: Viresh Kumar > --- Tested-by: Jon Medhurst Thanks for that. I believe this also fixes the other issue I mentioned (nullptr deref in in arm_big_little driver). To test that, after applying this patch, I modified the code to force __cpufreq_governor to still return an error when a cpu is hotpluged back in. Now the arm_big_little driver doesn't get called when I manually poke scaling_setspeed, presumably because policy->governor==NULL prevents that from reaching the driver? > For 4.2-rc > > drivers/cpufreq/cpufreq.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index b612411655f9..2c22e3902e72 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -1132,6 +1132,7 @@ static struct cpufreq_policy *cpufreq_policy_restore(unsigned int cpu) > > down_write(&policy->rwsem); > policy->cpu = cpu; > + policy->governor = NULL; > up_write(&policy->rwsem); > } > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/