From patchwork Fri Jan 2 07:04:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 42686 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1684426CD1 for ; Fri, 2 Jan 2015 07:05:55 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id l15sf10430644wiw.4 for ; Thu, 01 Jan 2015 23:05:54 -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=T0DDdhABYo7G0w8pZIAa/FdQ7OkoeKB3Fo9fMvnaJ7A=; b=iGxBGRIuO2yBjOKaTK/Wg6fl2hLRd6kkrYn+xaRthU+Iym1H7ToRFa7/6Uze3fWkQK J1QW4plYNellD2yskeQN3q31U5t6WvTmjo0BTwY2UKgDpi1n4EFNCdOTt/irX9AWHxcx q77BL27n3pAiGX4ryQvp35xEgU2NvYbUcb51CEYx4F9mbmuqQaWIuAkyV7ahc3Wjofsp AITB7zebl4R3z4bC/lZIMUkPQnb+slhb/1xSBfCngXaaTykEzzIIi3Pyq/to9xzG1cWA bEd3rJrKby1L17mdpNipb6lbucLQaBFF2WzOdTAdUt4/vBMp3JmsPjriOnxwDsZOK1Ai 9l2g== X-Gm-Message-State: ALoCoQly8fhG/wDUTzPgHUgeXWTC+fYfLULbz96b+CYYoZqJOEZU0Rb2ar006ggINad0k5lcPMLY X-Received: by 10.180.98.38 with SMTP id ef6mr7907828wib.4.1420182354385; Thu, 01 Jan 2015 23:05:54 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.66 with SMTP id le2ls2207449lac.90.gmail; Thu, 01 Jan 2015 23:05:54 -0800 (PST) X-Received: by 10.152.21.134 with SMTP id v6mr74605015lae.13.1420182354129; Thu, 01 Jan 2015 23:05:54 -0800 (PST) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id xr6si50506846lbb.1.2015.01.01.23.05.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 Jan 2015 23:05:54 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by mail-la0-f41.google.com with SMTP id hv19so15039472lab.14 for ; Thu, 01 Jan 2015 23:05:54 -0800 (PST) X-Received: by 10.152.18.135 with SMTP id w7mr60041026lad.47.1420182353963; Thu, 01 Jan 2015 23:05:53 -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.9.200 with SMTP id c8csp126225lbb; Thu, 1 Jan 2015 23:05:52 -0800 (PST) X-Received: by 10.68.69.106 with SMTP id d10mr119614599pbu.60.1420182350559; Thu, 01 Jan 2015 23:05:50 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dl1si29047854pbb.67.2015.01.01.23.05.49; Thu, 01 Jan 2015 23:05:50 -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 S1750765AbbABHFs (ORCPT + 12 others); Fri, 2 Jan 2015 02:05:48 -0500 Received: from mail-pa0-f43.google.com ([209.85.220.43]:49305 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750744AbbABHFs (ORCPT ); Fri, 2 Jan 2015 02:05:48 -0500 Received: by mail-pa0-f43.google.com with SMTP id kx10so23779532pab.30 for ; Thu, 01 Jan 2015 23:05:47 -0800 (PST) X-Received: by 10.70.34.196 with SMTP id b4mr95542223pdj.120.1420182347663; Thu, 01 Jan 2015 23:05:47 -0800 (PST) Received: from localhost ([122.167.116.151]) by mx.google.com with ESMTPSA id jo12sm30363198pbb.33.2015.01.01.23.05.46 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 01 Jan 2015 23:05:47 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, prarit@redhat.com, skannan@codeaurora.org, Viresh Kumar Subject: [PATCH 14/17] cpufreq: check cpufreq_policy_list instead of scanning policies for all CPUs Date: Fri, 2 Jan 2015 12:34:35 +0530 Message-Id: X-Mailer: git-send-email 2.2.0 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.41 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: , CPUFREQ_STICKY flag is set by drivers which don't want to get unregistered even if cpufreq-core isn't able to initialize policy for any CPU. When this flag isn't set, we try to unregister the driver. To find out which CPUs are registered and which are not, we try to check per_cpu cpufreq_cpu_data for all CPUs. Because we have a list of valid policies available now, we better check if the list is empty or not instead of the 'for' loop. That will be much more efficient. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 74169ad47546..09426671eb79 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2442,23 +2442,12 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) if (ret) goto err_boost_unreg; - if (!(cpufreq_driver->flags & CPUFREQ_STICKY)) { - int i; - ret = -ENODEV; - - /* check for at least one working CPU */ - for (i = 0; i < nr_cpu_ids; i++) - if (cpu_possible(i) && per_cpu(cpufreq_cpu_data, i)) { - ret = 0; - break; - } - + if (!(cpufreq_driver->flags & CPUFREQ_STICKY) && + list_empty(&cpufreq_policy_list)) { /* if all ->init() calls failed, unregister */ - if (ret) { - pr_debug("no CPU initialized for driver %s\n", - driver_data->name); - goto err_if_unreg; - } + pr_debug("%s: No CPU initialized for driver %s\n", __func__, + driver_data->name); + goto err_if_unreg; } register_hotcpu_notifier(&cpufreq_cpu_notifier);