From patchwork Tue Nov 15 08:23:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 82273 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1410660qge; Tue, 15 Nov 2016 00:24:00 -0800 (PST) X-Received: by 10.99.146.76 with SMTP id s12mr35860300pgn.8.1479198240051; Tue, 15 Nov 2016 00:24:00 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b82si25560892pfe.235.2016.11.15.00.23.59; Tue, 15 Nov 2016 00:24:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965959AbcKOIXr (ORCPT + 26 others); Tue, 15 Nov 2016 03:23:47 -0500 Received: from mail-pf0-f172.google.com ([209.85.192.172]:33766 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965651AbcKOIXp (ORCPT ); Tue, 15 Nov 2016 03:23:45 -0500 Received: by mail-pf0-f172.google.com with SMTP id d2so35113555pfd.0 for ; Tue, 15 Nov 2016 00:23:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=IxUmypDszEWY6lL/SlySLNtUVHVXbbrph1rXzQK4FGY=; b=NFVVkoZOb3Y/98WJQqb9uehV03pI+3LeipLt64wDEHjAKDklzLWMNKgY2KbX2FSIno aGdzOw5r7Kim3BR7XAeKUouDmRd/XfeDJ+jTXpikBNKUudxm8ftlOTup+YqL2YvNtCFs OE6njM9FCLXGf73SgwVo3vb8TYf3RyeCAPj6Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=IxUmypDszEWY6lL/SlySLNtUVHVXbbrph1rXzQK4FGY=; b=G8XryUwZj404v0ZYmOSfWozx63m6xvq2Ipn99+ZhnYxGOf1p6c2FsnuIl0t3Ul/2gg kkze7h+LZ6jUDJhnufhkuFWvsS40uZjHk2sH30iMFKjTCXWsKJYil8TixO52J0Ww/7n+ oZzSoi75Qn3KhXed4SHBnMHka+aZsyzT21Xt5Dl0wfXYjRBLCikF2aJkapszqBgJDMGc HtvSbBR0KPFbYbLlAgOVY83VJnOCz2j+HWvAQ6OZGSpjW2LyrynmPyLKBGWQbCIaRfcj uqtyT3XOjL6AYvxVuJ64yB1GqtiAPkC+Fuo25LEoflm2Hc1HwFOYM6DtWStopSsfRhqF h85A== X-Gm-Message-State: ABUngvdx1YjUlFuHP4Upv2V3PfCGAkFWPGz7ix2mWH93ZoBj03Fynbww7QEbhNujFxrKtLJS X-Received: by 10.99.251.5 with SMTP id o5mr35716961pgh.160.1479198224663; Tue, 15 Nov 2016 00:23:44 -0800 (PST) Received: from localhost ([122.172.89.192]) by smtp.gmail.com with ESMTPSA id ya7sm40757829pab.28.2016.11.15.00.23.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Nov 2016 00:23:44 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Ingo Molnar , Peter Zijlstra Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , Juri Lelli , Robin Randhawa , Steve Muckle , Viresh Kumar Subject: [PATCH V2 2/4] cpufreq: schedutil: enable fast switch earlier Date: Tue, 15 Nov 2016 13:53:21 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The fast_switch_enabled flag will be used by both sugov_policy_alloc() and sugov_policy_free() with a later patch. Prepare for that by moving the calls to enable and disable it to the beginning of sugov_init() and end of sugov_exit(). Signed-off-by: Viresh Kumar --- kernel/sched/cpufreq_schedutil.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 8c4e1652e895..68f21bb6bd44 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -416,9 +416,13 @@ static int sugov_init(struct cpufreq_policy *policy) if (policy->governor_data) return -EBUSY; + cpufreq_enable_fast_switch(policy); + sg_policy = sugov_policy_alloc(policy); - if (!sg_policy) - return -ENOMEM; + if (!sg_policy) { + ret = -ENOMEM; + goto disable_fast_switch; + } mutex_lock(&global_tunables_lock); @@ -456,8 +460,6 @@ static int sugov_init(struct cpufreq_policy *policy) out: mutex_unlock(&global_tunables_lock); - - cpufreq_enable_fast_switch(policy); return 0; fail: @@ -468,6 +470,10 @@ static int sugov_init(struct cpufreq_policy *policy) mutex_unlock(&global_tunables_lock); sugov_policy_free(sg_policy); + +disable_fast_switch: + cpufreq_disable_fast_switch(policy); + pr_err("initialization failed (error %d)\n", ret); return ret; } @@ -478,8 +484,6 @@ static void sugov_exit(struct cpufreq_policy *policy) struct sugov_tunables *tunables = sg_policy->tunables; unsigned int count; - cpufreq_disable_fast_switch(policy); - mutex_lock(&global_tunables_lock); count = gov_attr_set_put(&tunables->attr_set, &sg_policy->tunables_hook); @@ -490,6 +494,7 @@ static void sugov_exit(struct cpufreq_policy *policy) mutex_unlock(&global_tunables_lock); sugov_policy_free(sg_policy); + cpufreq_disable_fast_switch(policy); } static int sugov_start(struct cpufreq_policy *policy)