From patchwork Fri Jul 25 01:07:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 4620931 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 70C73C0515 for ; Fri, 25 Jul 2014 01:11:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A65BE201ED for ; Fri, 25 Jul 2014 01:11:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CAFEC201E4 for ; Fri, 25 Jul 2014 01:11:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XATzh-0007AW-BJ; Fri, 25 Jul 2014 01:08:21 +0000 Received: from smtp.codeaurora.org ([198.145.11.231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XATzP-000761-IZ for linux-arm-kernel@lists.infradead.org; Fri, 25 Jul 2014 01:08:04 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id C4F6913F9DA; Fri, 25 Jul 2014 01:07:42 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id B464E13F9DF; Fri, 25 Jul 2014 01:07:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from skannan1-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: skannan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2228813F9DA; Fri, 25 Jul 2014 01:07:42 +0000 (UTC) From: Saravana Kannan To: "Rafael J . Wysocki" , Viresh Kumar , Todd Poynor , "Srivatsa S . Bhat" Subject: [PATCH v4 1/5] cpufreq: Don't wait for CPU to going offline to restart governor Date: Thu, 24 Jul 2014 18:07:24 -0700 Message-Id: <1406250448-470-2-git-send-email-skannan@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1406250448-470-1-git-send-email-skannan@codeaurora.org> References: <1406250448-470-1-git-send-email-skannan@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140724_180803_651919_D7A45445 X-CRM114-Status: GOOD ( 15.89 ) X-Spam-Score: -0.0 (/) Cc: linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, Stephen Boyd , linux-kernel@vger.kernel.org, Saravana Kannan , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP There's no need to wait for the CPU going down to fully go offline to restart the governor. We can stop the governor, change policy->cpus and immediately restart the governor. This should reduce the time without any CPUfreq monitoring and also help future patches with simplifying the code. Signed-off-by: Saravana Kannan --- drivers/cpufreq/cpufreq.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 62259d2..ee0eb7b 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1390,6 +1390,21 @@ static int __cpufreq_remove_dev_prepare(struct device *dev, cpufreq_driver->stop_cpu(policy); } + down_write(&policy->rwsem); + cpumask_clear_cpu(cpu, policy->cpus); + up_write(&policy->rwsem); + + if (cpus > 1 && has_target()) { + ret = __cpufreq_governor(policy, CPUFREQ_GOV_START); + if (!ret) + ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); + + if (ret) { + pr_err("%s: Failed to start governor\n", __func__); + return ret; + } + } + return 0; } @@ -1410,15 +1425,12 @@ static int __cpufreq_remove_dev_finish(struct device *dev, return -EINVAL; } - down_write(&policy->rwsem); + down_read(&policy->rwsem); cpus = cpumask_weight(policy->cpus); - - if (cpus > 1) - cpumask_clear_cpu(cpu, policy->cpus); - up_write(&policy->rwsem); + up_read(&policy->rwsem); /* If cpu is last user of policy, free policy */ - if (cpus == 1) { + if (cpus == 0) { if (has_target()) { ret = __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); @@ -1447,15 +1459,6 @@ static int __cpufreq_remove_dev_finish(struct device *dev, if (!cpufreq_suspended) cpufreq_policy_free(policy); - } else if (has_target()) { - ret = __cpufreq_governor(policy, CPUFREQ_GOV_START); - if (!ret) - ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); - - if (ret) { - pr_err("%s: Failed to start governor\n", __func__); - return ret; - } } per_cpu(cpufreq_cpu_data, cpu) = NULL;