From patchwork Thu Feb 19 11:32:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 44818 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f200.google.com (mail-we0-f200.google.com [74.125.82.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7A47F21554 for ; Thu, 19 Feb 2015 11:33:48 +0000 (UTC) Received: by wesq59 with SMTP id q59sf4670051wes.2 for ; Thu, 19 Feb 2015 03:33:47 -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=tSRkjfi+nCh2wCUD5IQVKa4YpCa/szUYCNRzPsh6rqM=; b=bv0Pd0ZXjtlbGBKTG5AgQPmiCVa0yOFQGL8wAIPAnCX9EH9q6D+pKOUCx80mxqlEJX yk5O4YNJE33JaHjAswlKHkQG4MfRQqkAEAko7pv5zC50CfE02H4s2yOJEtryJ+GxbXQT tFfc9D2X741B7zHbjonjwp8K/me6Bi82AIomkn1xDprvtgjxhMOBG87K4G5Oef4eSxYY t8fHD9YZxG71jfrsmDBZHwYUVK7WErhVdaB4Z2IeNCA7+53SwCVkvZSvyo4smwhs3YPr D/fdBOY60iLU98Ps8RFCH4rHaDnK4d9bZ0qvu0BOxA23LeDZ3TSJbZi6mSrmEG0aCKps XYlw== X-Gm-Message-State: ALoCoQkb4V3lMDSZfwjwQePs16wpoTdVmhx/GKNdGHbXJhbn0mCKz4SAd/BDXJ+V8n9W5pHe/x17 X-Received: by 10.180.72.44 with SMTP id a12mr641414wiv.0.1424345627768; Thu, 19 Feb 2015 03:33:47 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.5.33 with SMTP id cj1ls156245lad.53.gmail; Thu, 19 Feb 2015 03:33:47 -0800 (PST) X-Received: by 10.112.45.9 with SMTP id i9mr3515020lbm.5.1424345627597; Thu, 19 Feb 2015 03:33:47 -0800 (PST) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id dk7si14593349lac.109.2015.02.19.03.33.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Feb 2015 03:33:47 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by labhs14 with SMTP id hs14so7009943lab.1 for ; Thu, 19 Feb 2015 03:33:47 -0800 (PST) X-Received: by 10.152.87.3 with SMTP id t3mr3534269laz.19.1424345627501; Thu, 19 Feb 2015 03:33:47 -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 h5csp431579lbj; Thu, 19 Feb 2015 03:33:46 -0800 (PST) X-Received: by 10.66.97.68 with SMTP id dy4mr6882864pab.148.1424345625643; Thu, 19 Feb 2015 03:33:45 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id on3si3330575pac.16.2015.02.19.03.33.44; Thu, 19 Feb 2015 03:33:45 -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 S1753354AbbBSLdj (ORCPT + 11 others); Thu, 19 Feb 2015 06:33:39 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:35825 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753381AbbBSLdh (ORCPT ); Thu, 19 Feb 2015 06:33:37 -0500 Received: by padfa1 with SMTP id fa1so8894828pad.2 for ; Thu, 19 Feb 2015 03:33:37 -0800 (PST) X-Received: by 10.70.34.227 with SMTP id c3mr6726304pdj.97.1424345617353; Thu, 19 Feb 2015 03:33:37 -0800 (PST) Received: from localhost ([122.172.249.58]) by mx.google.com with ESMTPSA id ca2sm23395592pbc.68.2015.02.19.03.33.36 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 19 Feb 2015 03:33:36 -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 V2 04/20] cpufreq: Keep a single path for adding managed CPUs Date: Thu, 19 Feb 2015 17:02:06 +0530 Message-Id: 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.215.45 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 9da8ed5bdd21..d06d1241a900 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -992,6 +992,10 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, int ret = 0; unsigned long flags; + /* 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) { @@ -1147,16 +1151,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)) {