Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752492AbbGIFKi (ORCPT ); Thu, 9 Jul 2015 01:10:38 -0400 Received: from mail-pd0-f172.google.com ([209.85.192.172]:36168 "EHLO mail-pd0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751274AbbGIFKa (ORCPT ); Thu, 9 Jul 2015 01:10:30 -0400 Date: Thu, 9 Jul 2015 10:40:24 +0530 From: Viresh Kumar To: "Rafael J. Wysocki" Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Pi-Cheng Chen , "Jon Medhurst (Tixy)" , open list , Steven Rostedt Subject: Re: [PATCH] cpufreq: Initialize the governor again while restoring policy Message-ID: <20150709051024.GJ1805@linux> References: <3814282.YWYCHNROVv@vostro.rjw.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3814282.YWYCHNROVv@vostro.rjw.lan> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2940 Lines: 68 On 09-07-15, 02:33, Rafael J. Wysocki wrote: > > We also missed marking policy->governor as NULL while restoring the > > policy. Because of that, we call __cpufreq_governor(CPUFREQ_GOV_LIMITS) > > How exactly does that happen? Should have mentioned that in detail, sorry for being lazy. Hopefully this will look better: ---------------------------8<--------------------------- Message-Id: <5f17361741c009a7f0d8488f7f94bab80d9317fd.1436418101.git.viresh.kumar@linaro.org> From: Viresh Kumar Date: Wed, 8 Jul 2015 10:45:53 +0530 Subject: [PATCH V2] cpufreq: Initialize the governor again while restoring policy 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. But we also marking policy->governor as NULL while restoring the policy. Because policy->governor still points to the last governor while policy is restored, following sequence of event happens: - cpufreq_init_policy() called while restoring policy - find_governor() matches last_governor string for present governors and returns last used governor's pointer, say ondemand. policy->governor already has the same address, unless the governor was removed in between. - cpufreq_set_policy() is called with both old/new policies governor set as ondemand. - Because governors matched, we skip governor initialization and return after calling __cpufreq_governor(CPUFREQ_GOV_LIMITS). Because the governor wasn't initialized for this policy, it returned -EBUSY. - cpufreq_init_policy() exits the policy on this error, but doesn't destroy it properly (should be fixed separately). - And so we enter a scenario where the policy isn't completely initialized but used. Fix this by setting policy->governor to NULL while restoring the policy. Reported-and-tested-by: Pi-Cheng Chen Reported-and-tested-by: "Jon Medhurst (Tixy)" Tested-by: Steven Rostedt Fixes: 18bf3a124ef8 ("cpufreq: Mark policy->governor = NULL for inactive policies") Signed-off-by: Viresh Kumar --- V2: Detailed changelog 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/