From patchwork Thu Feb 11 12:01:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 61730 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp145843lbl; Thu, 11 Feb 2016 04:01:33 -0800 (PST) X-Received: by 10.66.163.196 with SMTP id yk4mr66378771pab.115.1455192093364; Thu, 11 Feb 2016 04:01:33 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wq13si12262788pac.86.2016.02.11.04.01.33; Thu, 11 Feb 2016 04:01:33 -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; 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; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752145AbcBKMBb (ORCPT + 30 others); Thu, 11 Feb 2016 07:01:31 -0500 Received: from mail-pf0-f175.google.com ([209.85.192.175]:33974 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750928AbcBKMB2 (ORCPT ); Thu, 11 Feb 2016 07:01:28 -0500 Received: by mail-pf0-f175.google.com with SMTP id x65so28591015pfb.1 for ; Thu, 11 Feb 2016 04:01:27 -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=vYmc/kjggrJavyr5QpFoK252v2OL9R6PvZ4EtDeYNW4=; b=eDr+PODPW2egxCr8edd7D4UzSjCU1+jq+vIt8dOhnWLGzo6UXOfoZooaPT1RKVTYLq HYxwShvvPqheeGWOnuq2C4zrRMx1k+/yDdSB7ZXoVbyDddopz+quzkDpAMk4ed+TnDKe ltFkftolfETlUXJ4Qc4/zNtZsmw4Q1rbXa5v8= 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=vYmc/kjggrJavyr5QpFoK252v2OL9R6PvZ4EtDeYNW4=; b=aCWt0wE8+EASiTsGCEEY+1h4KF47tjQStZFKL8HhiUFoAqbtS9CWIxJijw9n4TWLEk Owud+mBcLGuEwolwJzf9NtDrDsLDE3U8C9uIqfbGxra0YIlLABjQIxzYF8IT6A+k5xSj 6sDzXs6Jh8GEDrllIGGwZf1mvVEU1rVvdSInbpH6bE/2kjtCVE4F/3ldc9luUTmgeHbG bqgCSlExiD22bCF1fsJjF19byfNweuoxfGtJcahHG4q08IvsSlRsnD8AEg+j/IyizMsw 5CVfO/Llh/zyZkoKUoSTxpIvISO8DGXUgUWr8BRYfiNx6bOfB3MVXBKcZB5gW/0UcyAP GRbw== X-Gm-Message-State: AG10YORci4AYsYAYd7wyJW1eC0oPcVEli87jsS60pMzsQwaiEMh6AyG6hB3H+CsdwCfsBytK X-Received: by 10.98.7.146 with SMTP id 18mr32138816pfh.47.1455192087621; Thu, 11 Feb 2016 04:01:27 -0800 (PST) Received: from localhost ([122.172.89.184]) by smtp.gmail.com with ESMTPSA id s197sm11931940pfs.62.2016.02.11.04.01.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Feb 2016 04:01:26 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , juri.lelli@arm.com Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, shilpa.bhat@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH V5 1/6] cpufreq: Merge cpufreq_offline_prepare/finish routines Date: Thu, 11 Feb 2016 17:31:11 +0530 Message-Id: <4266bafe3c9baad4996352e3f7780344e854b002.1455191663.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.370.gb2aa7f8 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 Governor sysfs attributes are still removed in __cpufreq_governor(_EXIT), though, so had store() been used for them, the deadlock described in the changelog of commit 1aee40ac9c86 would have been possible. Fortunately, we don't use store() (which still does get_online_cpus()) for those attributes now. We use governor_store() for them and that doesn't call get_online_cpus(). And so we don't need to split cpufreq-offline functionality into DOWN_PREPARE and POST_DEAD hotplug notifiers anymore. Signed-off-by: Viresh Kumar [ rjw: Changelog ] Tested-by: Juri Lelli Tested-by: Shilpasri G Bhat --- drivers/cpufreq/cpufreq.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) -- 2.7.1.370.gb2aa7f8 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 9c62bf35b9dc..863ac26c4ecf 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1361,9 +1361,10 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) return ret; } -static void cpufreq_offline_prepare(unsigned int cpu) +static void cpufreq_offline(unsigned int cpu) { struct cpufreq_policy *policy; + int ret; pr_debug("%s: unregistering CPU %u\n", __func__, cpu); @@ -1374,7 +1375,7 @@ static void cpufreq_offline_prepare(unsigned int cpu) } if (has_target()) { - int ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP); + ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP); if (ret) pr_err("%s: Failed to stop governor\n", __func__); } @@ -1397,34 +1398,23 @@ static void cpufreq_offline_prepare(unsigned int cpu) /* Start governor again for active policy */ if (!policy_is_inactive(policy)) { if (has_target()) { - int ret = __cpufreq_governor(policy, CPUFREQ_GOV_START); + 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); - } -} -static void cpufreq_offline_finish(unsigned int cpu) -{ - struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); - - if (!policy) { - pr_debug("%s: No cpu_data found\n", __func__); return; } - /* Only proceed for inactive policies */ - if (!policy_is_inactive(policy)) - return; + if (cpufreq_driver->stop_cpu) + cpufreq_driver->stop_cpu(policy); /* If cpu is last user of policy, free policy */ if (has_target()) { - int ret = __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); + ret = __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); if (ret) pr_err("%s: Failed to exit governor\n", __func__); } @@ -1453,10 +1443,8 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) if (!policy) return; - if (cpu_online(cpu)) { - cpufreq_offline_prepare(cpu); - cpufreq_offline_finish(cpu); - } + if (cpu_online(cpu)) + cpufreq_offline(cpu); cpumask_clear_cpu(cpu, policy->real_cpus); remove_cpu_dev_symlink(policy, cpu); @@ -2304,11 +2292,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb, break; case CPU_DOWN_PREPARE: - cpufreq_offline_prepare(cpu); - break; - - case CPU_POST_DEAD: - cpufreq_offline_finish(cpu); + cpufreq_offline(cpu); break; case CPU_DOWN_FAILED: