From patchwork Thu Sep 26 10:29:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20584 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3A15723A4E for ; Thu, 26 Sep 2013 10:33:16 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id hf12sf775806vcb.7 for ; Thu, 26 Sep 2013 03:33:16 -0700 (PDT) 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 :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=4zDQqKbR2ZvqIXJFFU/+dJMCCJ6RSZVWiVdVPBxlxOY=; b=OSh506Z3qiPpAMdWWp1xqPbeslowaYL6BuqPACZwffCOkSUija+KHG2k3QUOOzqCu7 H/1Meicjqw8ds7t8tSQOpbOD8Rzzgnz5AztaWY1WjcDnugHGxgQbX2EzR3ZZ/qvMUig7 CTL290qP/U8e5CXvTsDarKBUya/U/VQiTAHSJ0XPMt38LQZ8EY/MOcbVMHQP1ByhCvXP 4pBKX3mnz1ChI7PBmaxms0VxsWNZGpsm1V/WNnwRpOWEethh5TXBxXZDTnlSlendUnCb aQlzBjtWmT4YgBP5DYJ5kmEwaME1kiXeBCQvAXr0K6Ft/5x7aPh7VGjjsNegNYifnvUq Wafg== X-Gm-Message-State: ALoCoQkdE/tcnyDzHWSjKQlmPMlcxFspJsDoNX+604jDmdbgtYK4a4UrZik7VvaXXjMfyKqMHbRu X-Received: by 10.236.75.201 with SMTP id z49mr52972yhd.0.1380191596065; Thu, 26 Sep 2013 03:33:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.94.8 with SMTP id cy8ls788963qeb.18.gmail; Thu, 26 Sep 2013 03:33:15 -0700 (PDT) X-Received: by 10.52.94.5 with SMTP id cy5mr69982vdb.90.1380191595946; Thu, 26 Sep 2013 03:33:15 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id bk8si224287vec.18.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Sep 2013 03:33:15 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id jy13so703728veb.5 for ; Thu, 26 Sep 2013 03:32:45 -0700 (PDT) X-Received: by 10.58.24.35 with SMTP id r3mr69685vef.96.1380191565858; Thu, 26 Sep 2013 03:32:45 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp357979vcz; Thu, 26 Sep 2013 03:32:45 -0700 (PDT) X-Received: by 10.66.192.132 with SMTP id hg4mr4555470pac.84.1380191564649; Thu, 26 Sep 2013 03:32:44 -0700 (PDT) Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by mx.google.com with ESMTPS id yk3si2932358pac.331.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Sep 2013 03:32:44 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.47 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.220.47; Received: by mail-pa0-f47.google.com with SMTP id kp14so1115822pab.6 for ; Thu, 26 Sep 2013 03:32:44 -0700 (PDT) X-Received: by 10.66.121.131 with SMTP id lk3mr4370230pab.61.1380191564163; Thu, 26 Sep 2013 03:32:44 -0700 (PDT) Received: from localhost ([223.238.78.153]) by mx.google.com with ESMTPSA id sz3sm1315557pbc.36.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 26 Sep 2013 03:32:43 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, srivatsa.bhat@linux.vnet.ibm.com, nicolas.pitre@linaro.org, Viresh Kumar Subject: [PATCH 4/4] cpufreq: stats: create sysfs entries when cpufreq_stats is a module Date: Thu, 26 Sep 2013 15:59:54 +0530 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , When cpufreq_stats is compiled in as a module, cpufreq driver would have already been registered. And so the CPUFREQ_CREATE_POLICY notifiers wouldn't be called for it. Hence no sysfs entries for stats. :( This patch calls cpufreq_stats_create_table() for each online cpu from cpufreq_stats_init() and so if policy is already created for CPUx then we will register sysfs stats for it. When its not compiled as module, we will return early as policy wouldn't be found for any of the CPUs. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq_stats.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index 9dd5883..5793e14 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -180,7 +180,7 @@ static void cpufreq_stats_free_table(unsigned int cpu) cpufreq_cpu_put(policy); } -static int cpufreq_stats_create_table(struct cpufreq_policy *policy, +static int __cpufreq_stats_create_table(struct cpufreq_policy *policy, struct cpufreq_frequency_table *table) { unsigned int i, j, count = 0, ret = 0; @@ -253,6 +253,26 @@ error_get_fail: return ret; } +static void cpufreq_stats_create_table(unsigned int cpu) +{ + struct cpufreq_policy *policy; + struct cpufreq_frequency_table *table; + + /* + * "likely(!policy)" because normally cpufreq_stats will be registered + * before cpufreq driver + */ + policy = cpufreq_cpu_get(cpu); + if (likely(!policy)) + return; + + table = cpufreq_frequency_get_table(policy->cpu); + if (likely(table)) + __cpufreq_stats_create_table(policy, table); + + cpufreq_cpu_put(policy); +} + static void cpufreq_stats_update_policy_cpu(struct cpufreq_policy *policy) { struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, @@ -284,7 +304,7 @@ static int cpufreq_stat_notifier_policy(struct notifier_block *nb, return 0; if (val == CPUFREQ_CREATE_POLICY) - ret = cpufreq_stats_create_table(policy, table); + ret = __cpufreq_stats_create_table(policy, table); else if (val == CPUFREQ_REMOVE_POLICY) __cpufreq_stats_free_table(policy); @@ -346,6 +366,9 @@ static int __init cpufreq_stats_init(void) if (ret) return ret; + for_each_online_cpu(cpu) + cpufreq_stats_create_table(cpu); + ret = cpufreq_register_notifier(¬ifier_trans_block, CPUFREQ_TRANSITION_NOTIFIER); if (ret) {