From patchwork Mon Feb 8 11:39:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 61391 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1383767lbl; Mon, 8 Feb 2016 03:40:43 -0800 (PST) X-Received: by 10.98.31.21 with SMTP id f21mr29393243pff.134.1454931643205; Mon, 08 Feb 2016 03:40:43 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64si38796413pfi.163.2016.02.08.03.40.42; Mon, 08 Feb 2016 03:40:43 -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 S1752461AbcBHLki (ORCPT + 30 others); Mon, 8 Feb 2016 06:40:38 -0500 Received: from mail-pa0-f51.google.com ([209.85.220.51]:35041 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752263AbcBHLkc (ORCPT ); Mon, 8 Feb 2016 06:40:32 -0500 Received: by mail-pa0-f51.google.com with SMTP id ho8so72601782pac.2 for ; Mon, 08 Feb 2016 03:40:32 -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=DN9eeG2fOei6lmVkg4cA2ZHjkeSWfHP6Gz4WN9ZlNlQ=; b=jBNWQ/n5nJlXH57DA3rosK6kHStDyGu3qsxAwFYdMhMMbhNX6TvOjML4XQlHDZv1fF IMcfKrDqM4LMyZ3TLkx8rCigwjTylH17/oUXuz1AViep6D5y7YUmSIajFkOL/CyUGVCx A57TL7kY1kn/vLoFTvDtf9n/JRihZh6HC6n8k= 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=DN9eeG2fOei6lmVkg4cA2ZHjkeSWfHP6Gz4WN9ZlNlQ=; b=RDz53TqWrTBpM/KkRKW4wJo3jGmqQf08FRQDGQTLf2+9+0q+d+DDPPDYysC05C3ULO B5y/AE8iyJy+1CIv93IvfdbuZ/JPpTX4yxzFjJe2n8Qx+0HhqMfKbiXMpYVEf0vgQ4FA gERz/c4li0HLL9L7bWDDzI1qABrgDYydcBeZwJWZ7xk5zJsvbC53K7MkcxwvSu9NQMmy QTcOokg1cdcdBHF36FRwvbJoC6A5fi8xIziaQKuJFsC2yN1sEVaWurImHp7XQ1doWTEW K606tfHssfIDDYQqJvh4QrBYHLvGAoHltpXVGWE2LypmoM8WWFkhlZRL7fDbcZxtX2hG xDAg== X-Gm-Message-State: AG10YOTTEzQMM/75BF4nxGlqUMA33S/1F5frygHGWSaPzXx9qONpzvWllE76E6c9/sJ4kdmw X-Received: by 10.66.234.104 with SMTP id ud8mr41761082pac.143.1454931632454; Mon, 08 Feb 2016 03:40:32 -0800 (PST) Received: from localhost ([122.172.22.246]) by smtp.gmail.com with ESMTPSA id m75sm42909069pfj.38.2016.02.08.03.40.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 03:40:31 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , juri.lelli@arm.com Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, skannan@codeaurora.org, peterz@infradead.org, mturquette@baylibre.com, steve.muckle@linaro.org, vincent.guittot@linaro.org, morten.rasmussen@arm.com, dietmar.eggemann@arm.com, shilpa.bhat@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH V3 06/13] cpufreq: Merge cpufreq_offline_prepare/finish routines Date: Mon, 8 Feb 2016 17:09:20 +0530 Message-Id: <3ea57cc1f0f061470d2f7fadf95f4deff3e2c09a.1454931188.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 The offline routine was separated into two halves earlier by 'commit 1aee40ac9c86 ("cpufreq: Invoke __cpufreq_remove_dev_finish() after releasing cpu_hotplug.lock");. And the reasons cited were, race issues between accessing policy's sysfs files and policy kobject's cleanup. That race isn't valid anymore, as we don't remove the policy & its kobject completely on hotplugs, but do that from ->remove() callback of subsys framework. These two routines can be merged back now. This is a preparatory step for the next patch, that will enforce policy->rwsem lock around __cpufreq_governor() routines STOP/EXIT sequence. Signed-off-by: Viresh Kumar --- 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: