From patchwork Tue Feb 9 03:46:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 61481 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1808292lbl; Mon, 8 Feb 2016 19:48:14 -0800 (PST) X-Received: by 10.66.227.73 with SMTP id ry9mr47397938pac.120.1454989692397; Mon, 08 Feb 2016 19:48:12 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g24si50954842pfj.184.2016.02.08.19.48.12; Mon, 08 Feb 2016 19:48:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755865AbcBIDru (ORCPT + 11 others); Mon, 8 Feb 2016 22:47:50 -0500 Received: from mail-pa0-f54.google.com ([209.85.220.54]:35231 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755563AbcBIDrZ (ORCPT ); Mon, 8 Feb 2016 22:47:25 -0500 Received: by mail-pa0-f54.google.com with SMTP id ho8so84280733pac.2 for ; Mon, 08 Feb 2016 19:47:25 -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=fR1vw9eLx5UwKx8cUbqbSJlb9g0m+oKmEpJBx9cAnP8=; b=NPhH8Hi0LrzKK0CwA+k0p4OT7x5uWeAs93wgQVSdUTiR2yTWCmJmEFzENsuv7fOzTU CxJ01hbcstBYUWLCB7oUfmQQLYjIfiv/R6Y/HeqVnfuqv8whqPfYZob8/UWLRQFU2eW/ ggG7AqJp5pe6UvM216bQMkP3ZiPHKQft5Pqzk= 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=fR1vw9eLx5UwKx8cUbqbSJlb9g0m+oKmEpJBx9cAnP8=; b=itRYdrLVee6CIMTG4gGfyHcbi9oVz9S/Myr9aDXLmO+ideKFrLmVjWTj1IPlc2df7X ukxVTJPZNBT40ezZCl0eXzzTtPhW4OxZQbMdwtwIEAjxyNT7iiMnAbXq6nPCTlBHum4K 3y3H4x79EqWLz+g58A1ChrMIkBFRykj9Y/GPU8qjmhKsII+n8pgFXTM/x+vdYWjKujxD EfTpp8/O+8IgXeuaVfHR+/cUMxSasMYvSLLzcyplOzSaBDd5ZbX+Nbgyu8i2+MsDHD/R pvTkNXwnGfFnxXnUUoTcyizoTdaSuA2eDjf6VZLNY1u2RQ8G1Kkj3noJSgFsIY19v6Ec p1Vw== X-Gm-Message-State: AG10YORUu+nNw9VlWXOd2VCFeofbu/D/4L2rmxfzNd3i2IVw39lx6gSS9xxpn1C3BXS+c2pC X-Received: by 10.66.139.234 with SMTP id rb10mr46820088pab.82.1454989645141; Mon, 08 Feb 2016 19:47:25 -0800 (PST) Received: from localhost ([122.172.22.246]) by smtp.gmail.com with ESMTPSA id e1sm46618678pas.1.2016.02.08.19.47.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 19:47:24 -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 V4 1/7] cpufreq: Merge cpufreq_offline_prepare/finish routines Date: Tue, 9 Feb 2016 09:16:13 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.370.gb2aa7f8 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 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 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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: