From patchwork Tue Jan 27 08:36:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 43828 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CEFAA2409D for ; Tue, 27 Jan 2015 08:37:41 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id l4sf6831426lbv.1 for ; Tue, 27 Jan 2015 00:37:40 -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=SpVwupb6rfQYVc6sH8/FuqxSWk4+HGmmQk68XHaYUhQ=; b=Awk9/grj0Yom6hriHyocYrmR3mrLjoAb18BAm+33t259VEOioc7meOTuq7cf6kMw9K FgNp2DnxmF03t9U7qaoklxLt/cMckcFA3WR0URXO3NP43vZF47BeCyB/C9vpRzAXVM1n 0ZVcSpiavK4AY29L0xralLvKgFKjnTQfDM1+yu1ZCBlZHau+I6s+Vt7p+RF897TYomH9 BKrsKps9EcfEsRgQGSJJxPkKQs8P8lrUNLrQnQkBom3KZBI7613KGBEmOo0QRXd9++6V 2ESl+9O4dDteP/1VeL2WkCn6EgCsv7l6ZpgNAB8g5l+QLIbZ24f1MbSujF/Vajks6p2t /ZWw== X-Gm-Message-State: ALoCoQnRpRalWx4P8BXNQodDhMNhU6bOAna0RMP//2JWiUFK79/FNOsngSTHZWy1okucT1ovsi61 X-Received: by 10.112.213.72 with SMTP id nq8mr33950lbc.18.1422347860793; Tue, 27 Jan 2015 00:37:40 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.229 with SMTP id e5ls847laa.105.gmail; Tue, 27 Jan 2015 00:37:40 -0800 (PST) X-Received: by 10.112.164.101 with SMTP id yp5mr142076lbb.82.1422347860589; Tue, 27 Jan 2015 00:37:40 -0800 (PST) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id xw4si511778lbb.105.2015.01.27.00.37.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 27 Jan 2015 00:37:40 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by mail-lb0-f182.google.com with SMTP id l4so11805247lbv.13 for ; Tue, 27 Jan 2015 00:37:40 -0800 (PST) X-Received: by 10.152.197.5 with SMTP id iq5mr216169lac.6.1422347860494; Tue, 27 Jan 2015 00:37:40 -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 h5csp1025592lbj; Tue, 27 Jan 2015 00:37:39 -0800 (PST) X-Received: by 10.68.216.161 with SMTP id or1mr156848pbc.120.1422347855189; Tue, 27 Jan 2015 00:37:35 -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.34; Tue, 27 Jan 2015 00:37:35 -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 S1757884AbbA0Ihc (ORCPT + 11 others); Tue, 27 Jan 2015 03:37:32 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:44005 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754074AbbA0Iha (ORCPT ); Tue, 27 Jan 2015 03:37:30 -0500 Received: by mail-pa0-f46.google.com with SMTP id lj1so17155217pab.5 for ; Tue, 27 Jan 2015 00:37:30 -0800 (PST) X-Received: by 10.66.118.109 with SMTP id kl13mr62448pab.19.1422347849991; Tue, 27 Jan 2015 00:37:29 -0800 (PST) Received: from localhost ([122.178.198.250]) by mx.google.com with ESMTPSA id di10sm818533pad.41.2015.01.27.00.37.28 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 27 Jan 2015 00:37:29 -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 13/18] cpufreq: Keep a single path for adding managed CPUs Date: Tue, 27 Jan 2015 14:06:19 +0530 Message-Id: <9e01ff84016534936c02b96ecf7f40b2a41cf26d.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.182 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: , There are two cases when we may try to add already managed CPUs: - On boot, the first cpu has marked all policy->cpus managed and so we will find policy for all other policy->cpus later on. - When a managed cpu is hotplugged out and later brought back in. Currently we manage these two with separate paths and checks. While the first one is detected by testing cpu against 'policy->cpus', the other one is detected by testing cpu against 'policy->related_cpus'. We can manage both these via a single path and there is no need to do special checking for the first one. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 0e33c63b4a0e..8b110a50c22e 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1014,6 +1014,10 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, { int ret = 0; + /* Is cpu already managed ? */ + if (cpumask_test_cpu(cpu, policy->cpus)) + return 0; + if (has_target()) { ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP); if (ret) { @@ -1149,16 +1153,10 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) pr_debug("adding CPU %u\n", cpu); - /* check whether a different CPU already registered this - * CPU because it is in the same boat. */ - policy = cpufreq_cpu_get_raw(cpu); - if (unlikely(policy)) - return 0; - if (!down_read_trylock(&cpufreq_rwsem)) return 0; - /* Check if this cpu was hot-unplugged earlier and has siblings */ + /* Check if this cpu already has a policy to manage it */ read_lock_irqsave(&cpufreq_driver_lock, flags); for_each_policy(policy) { if (cpumask_test_cpu(cpu, policy->related_cpus)) {