From patchwork Thu Jul 9 05:10:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 50915 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D1627213FD for ; Thu, 9 Jul 2015 05:10:36 +0000 (UTC) Received: by wgjx7 with SMTP id x7sf75483988wgj.3 for ; Wed, 08 Jul 2015 22:10:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to:cc:subject:message-id :references:mime-version:content-type:content-disposition :in-reply-to:user-agent:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=8ac90HqkV6eABbBbD31faFPca3jJwqGWyE7lI5VFU8Q=; b=LYFG5806NVrmrEHRzqO00coIWrmTboVV3JVW/9Sv7xeD3/PZjmlaCUXWVLWF8CmloF GK829tmsTss1N+cWxDtE6BSDQkkaj7aZOtA7NoApJvZDdYbHG18DQ+WWSFo1iLHLmU6b Y8aw5q4nq2gBGBEEcZyi+1Sb2pnA7mMzVcB43Jr6MM6NQKP7hM4GFzPDZJXaTY1kSQRw LKr0J3v+qEuxR/9+KwPkiNbDfkaqC4kVZeikpE/zOIkEdRVp7zAkrVSGEfkwydxx71bZ nvO10L4Ip5R48O1vYCiRUxtDkh3guTw5fQkFAKLDLRJDn2pwmAAKV5pwFhjRt2BiAX98 Ujug== X-Gm-Message-State: ALoCoQn+HMea9dR7R4lB2cOxVQuP1c9UZiyFnS199NovLmxdB8WoiyLnAlsGNOTvg2KOrkuiDfu/ X-Received: by 10.152.37.101 with SMTP id x5mr6869474laj.5.1436418636133; Wed, 08 Jul 2015 22:10:36 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.10 with SMTP id p10ls1062681lag.29.gmail; Wed, 08 Jul 2015 22:10:36 -0700 (PDT) X-Received: by 10.112.137.232 with SMTP id ql8mr12852665lbb.121.1436418635981; Wed, 08 Jul 2015 22:10:35 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id z1si3795328lbm.136.2015.07.08.22.10.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jul 2015 22:10:35 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by laar3 with SMTP id r3so239292328laa.0 for ; Wed, 08 Jul 2015 22:10:35 -0700 (PDT) X-Received: by 10.152.37.228 with SMTP id b4mr12734424lak.117.1436418635543; Wed, 08 Jul 2015 22:10:35 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp406532lbb; Wed, 8 Jul 2015 22:10:34 -0700 (PDT) X-Received: by 10.66.229.65 with SMTP id so1mr27422620pac.92.1436418633760; Wed, 08 Jul 2015 22:10:33 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dm6si7344893pdb.96.2015.07.08.22.10.32; Wed, 08 Jul 2015 22:10:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751471AbbGIFKb (ORCPT + 11 others); Thu, 9 Jul 2015 01:10:31 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:33057 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751525AbbGIFKa (ORCPT ); Thu, 9 Jul 2015 01:10:30 -0400 Received: by pdbqm3 with SMTP id qm3so14721053pdb.0 for ; Wed, 08 Jul 2015 22:10:29 -0700 (PDT) X-Received: by 10.68.69.11 with SMTP id a11mr27405996pbu.169.1436418629711; Wed, 08 Jul 2015 22:10:29 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id qo6sm4335646pab.23.2015.07.08.22.10.27 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 08 Jul 2015 22:10:28 -0700 (PDT) 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-Disposition: inline In-Reply-To: <3814282.YWYCHNROVv@vostro.rjw.lan> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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(+) the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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-pm" in