From patchwork Tue Jan 7 01:40:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 22900 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f70.google.com (mail-pb0-f70.google.com [209.85.160.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BBBDA23A3F for ; Tue, 7 Jan 2014 01:40:48 +0000 (UTC) Received: by mail-pb0-f70.google.com with SMTP id rq2sf52951238pbb.5 for ; Mon, 06 Jan 2014 17:40:48 -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 :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=9cfT/BkT83Jbj/vCpgU0MSb38r5qMgO84XbIOYMxKWc=; b=A9yUuVjXkWHUJ2qHr80a4C+fGXMaeeWxdWYmN7BZQpIdoeytNIxyQEsS3UzORViNGv TT9Pit/izixHdMvkkKXVlnbhzeBclu1JQZaNcCUVZ+OnXqMj5Og0WPL9BvzNWa9CpYYi NUvalfT5KBm2LvC3Es6b1TiQ/OX3KoMoMu9Vx/Cf0mUpl9aMqNfPzKA8N5WgG8Bh3UC0 y07P7iVDtiPOwpEh14+lhU0W7JNIlitDZ9Sa5z0SLzdsWsBd7ByDYcLOTaN8CO/BD1RC x3F8mbaIeJWFwo3PjuBzGaITSWarrQA2dqctIZQMfqfTYSVWYyMcaH1vII3yNCV/btdk Lg3g== X-Gm-Message-State: ALoCoQlmYkEQhG3OkqzWUM6kN7RuSYltJ4G67XHeFERegll4UzqlCTv7QkAeIeGI/1BWyEZ9Vt9z X-Received: by 10.66.149.67 with SMTP id ty3mr706432pab.27.1389058847950; Mon, 06 Jan 2014 17:40:47 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.15.70 with SMTP id v6ls1479287qec.47.gmail; Mon, 06 Jan 2014 17:40:47 -0800 (PST) X-Received: by 10.58.132.203 with SMTP id ow11mr61676085veb.1.1389058847689; Mon, 06 Jan 2014 17:40:47 -0800 (PST) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id gs2si32159714vdc.31.2014.01.06.17.40.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 06 Jan 2014 17:40:47 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id lh4so9385586vcb.23 for ; Mon, 06 Jan 2014 17:40:47 -0800 (PST) X-Received: by 10.52.162.168 with SMTP id yb8mr58377487vdb.8.1389058847615; Mon, 06 Jan 2014 17:40:47 -0800 (PST) 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.59.13.131 with SMTP id ey3csp130026ved; Mon, 6 Jan 2014 17:40:47 -0800 (PST) X-Received: by 10.68.163.193 with SMTP id yk1mr87596860pbb.138.1389058846681; Mon, 06 Jan 2014 17:40:46 -0800 (PST) Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com [209.85.220.48]) by mx.google.com with ESMTPS id sj5si56662636pab.313.2014.01.06.17.40.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 06 Jan 2014 17:40:46 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.48 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.220.48; Received: by mail-pa0-f48.google.com with SMTP id rd3so19371985pab.35 for ; Mon, 06 Jan 2014 17:40:45 -0800 (PST) X-Received: by 10.66.171.196 with SMTP id aw4mr1754824pac.51.1389058845100; Mon, 06 Jan 2014 17:40:45 -0800 (PST) Received: from localhost ([122.167.240.254]) by mx.google.com with ESMTPSA id oc9sm131831856pbb.10.2014.01.06.17.40.41 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 06 Jan 2014 17:40:44 -0800 (PST) From: Viresh Kumar To: rjw@rjwysocki.net Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH Resend 4/4] cpufreq: stats: create sysfs entries when cpufreq_stats is a module Date: Tue, 7 Jan 2014 07:10:13 +0530 Message-Id: <8d7429272d9f4791556db4e186ab7c74860e2b18.1389058746.git.viresh.kumar@linaro.org> 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.220.178 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. Acked-and-tested-by: Nicolas Pitre 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) {