From patchwork Tue Jan 27 08:36:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 43833 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 639932409D for ; Tue, 27 Jan 2015 08:37:55 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id d49sf6816205eek.2 for ; Tue, 27 Jan 2015 00:37:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=+txCDr/z/ZMKrM5r57T7/aNvj+FerJiVqLKDNTHBF54=; b=iE0bdBoXDi2qNYiCh0zq3QjujiIYZRRK7uZ4AYO3O5weF6qdMqdAldL0+XBB+kMslH uA5kn2H5I+zOJqSH72kdq5RvmZRSNqTzn6wP6BOo5EOfT4E5r8qVsT+53ZVX7BG8srVq Yfhd6n6PG7R9PPTPlFoQKs7J3+O1Ap8Ax8AfoU6Pa7/PBYclyv0fjkzyyUfSnD/bDAEn e7eWRanvPTKnWeTVXAjo7Jwp6eiNu7s6a4wA9KKta5KyYqyaVc0nVblYlwKSD1Ek2lo5 sxZhg5EvE/AHqGW5njG+IB4Xsno6Et6hwSUIy04NyXb5rtluLK93cuNvojTAS4Mr03xu hqCw== X-Gm-Message-State: ALoCoQksIHW0vvc88AtRzYKQJg3ep6uPzuzdIuEXHYuxTi2sAnbcAkSjh/mqcfpl2kBfKQu78PH/ X-Received: by 10.112.175.10 with SMTP id bw10mr28134lbc.7.1422347874664; Tue, 27 Jan 2015 00:37:54 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.220.164 with SMTP id px4ls3592lac.34.gmail; Tue, 27 Jan 2015 00:37:54 -0800 (PST) X-Received: by 10.112.47.135 with SMTP id d7mr174219lbn.54.1422347874306; Tue, 27 Jan 2015 00:37:54 -0800 (PST) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id t1si571938laz.36.2015.01.27.00.37.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 27 Jan 2015 00:37:54 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id 10so11849808lbg.6 for ; Tue, 27 Jan 2015 00:37:54 -0800 (PST) X-Received: by 10.112.98.99 with SMTP id eh3mr194164lbb.32.1422347874202; Tue, 27 Jan 2015 00:37:54 -0800 (PST) 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.35.133 with SMTP id h5csp1025655lbj; Tue, 27 Jan 2015 00:37:53 -0800 (PST) X-Received: by 10.70.103.162 with SMTP id fx2mr40683669pdb.117.1422347867360; Tue, 27 Jan 2015 00:37:47 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g8si627522pdk.182.2015.01.27.00.37.46; Tue, 27 Jan 2015 00:37:47 -0800 (PST) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757930AbbA0Ihp (ORCPT + 11 others); Tue, 27 Jan 2015 03:37:45 -0500 Received: from mail-pd0-f180.google.com ([209.85.192.180]:45284 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757922AbbA0Iho (ORCPT ); Tue, 27 Jan 2015 03:37:44 -0500 Received: by mail-pd0-f180.google.com with SMTP id ft15so17538050pdb.11 for ; Tue, 27 Jan 2015 00:37:44 -0800 (PST) X-Received: by 10.68.253.101 with SMTP id zz5mr262400pbc.50.1422347864611; Tue, 27 Jan 2015 00:37:44 -0800 (PST) Received: from localhost ([122.178.198.250]) by mx.google.com with ESMTPSA id q1sm844947pdq.17.2015.01.27.00.37.43 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 27 Jan 2015 00:37:44 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, sboyd@codeaurora.org, prarit@redhat.com, skannan@codeaurora.org, Viresh Kumar Subject: [PATCH 17/18] cpufreq: Restart governor as soon as possible Date: Tue, 27 Jan 2015 14:06:23 +0530 Message-Id: <529898a0821ded6de14eb31c457d2f441382e9f5.1422346933.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.3.0.rc0.44.ga94655d In-Reply-To: References: In-Reply-To: References: 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.217.175 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 cpu hot-unplug, we don't need to wait for POST_DEAD notification to restart the governor if the policy has atleast one online cpu left. We can restart the governor right from the DOWN_PREPARE notification instead. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 59 +++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 35 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 0e03ae1bc96a..bcc042a6221a 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1338,7 +1338,7 @@ static int __cpufreq_remove_dev_prepare(struct device *dev, struct subsys_interface *sif) { unsigned int cpu = dev->id, cpus; - int ret; + int ret = 0; unsigned long flags; struct cpufreq_policy *policy; @@ -1379,25 +1379,35 @@ static int __cpufreq_remove_dev_prepare(struct device *dev, CPUFREQ_NAME_LEN); } - if (cpu != policy->cpu) - return 0; - if (cpus > 1) { - /* Nominate new CPU */ down_write(&policy->rwsem); - policy->cpu = cpumask_any_but(policy->cpus, cpu); + cpumask_clear_cpu(cpu, policy->cpus); + + /* Nominate new CPU */ + if (cpu == policy->cpu) + policy->cpu = cpumask_any(policy->cpus); up_write(&policy->rwsem); + + if (has_target()) { + /* Start governor again */ + 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__); + } } else if (cpufreq_driver->stop_cpu) { cpufreq_driver->stop_cpu(policy); } - return 0; + return ret; } static int __cpufreq_remove_dev_finish(struct device *dev, struct subsys_interface *sif) { - unsigned int cpu = dev->id, cpus; + unsigned int cpu = dev->id; int ret; unsigned long flags; struct cpufreq_policy *policy; @@ -1406,34 +1416,13 @@ static int __cpufreq_remove_dev_finish(struct device *dev, policy = cpufreq_cpu_get_raw(cpu); read_unlock_irqrestore(&cpufreq_driver_lock, flags); - if (!policy) { - pr_debug("%s: No cpu_data found\n", __func__); - return -EINVAL; - } - - down_write(&policy->rwsem); - cpus = cpumask_weight(policy->cpus); - - if (cpus > 1) - cpumask_clear_cpu(cpu, policy->cpus); - up_write(&policy->rwsem); - - /* Not the last cpu of policy, start governor again ? */ - if (cpus > 1) { - if (!has_target()) - return 0; - - 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; - } - + /* + * If this isn't the last cpu of policy, we will fail to get policy here + * as the cpumask in policy->cpus is already cleared. Hence we don't + * need to proceed here anymore + */ + if (!policy) return 0; - } /* If cpu is last user of policy, free policy */ if (has_target()) {