From patchwork Wed Jul 8 09:08:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 50859 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 77904213FD for ; Wed, 8 Jul 2015 09:09:02 +0000 (UTC) Received: by laer2 with SMTP id r2sf64705249lae.3 for ; Wed, 08 Jul 2015 02:09:01 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=f9IjGLTADApkfkncUTxU7VulC64jMG26KDThxJUEJvc=; b=jk894uqp5ScQtAFEGeikwXJg8Kstf3DUw+sBV8IZfWhfz4dBXrqF6tMAQKxPErT66T l2aCLZ2afle8Lsrj9LVboTpJvKZ1LJ6HEezZeek0u/GAKtLGaVofmKYRmH+47o9SHmSR 6c7XHeBpGVg3Hl43wWPYeSccT2TzoJrIswdn6YtRQF3ooKvwjhVewT520E5UmVqM8qab iPJ/jr/rxWxQ9xOHsg3e+OQToN+5w5ShUSIOqVj5M/tlp16yYbV9Q65OLuD54fwj7Zj7 DSc624mfkcEX7BCs8r9y3Yzxx5rEjflf+Lk/0ePUFJiHsKIBmEVSdL8CrL1Rg1TGEgD8 OZBw== X-Gm-Message-State: ALoCoQnRXQkAxx1aziuCSKrJfv64pfujNhJRkOaZbNgN13HV9i9ZmeKpYravES/qWFFdbw3QXUGF X-Received: by 10.180.37.198 with SMTP id a6mr20150035wik.7.1436346541464; Wed, 08 Jul 2015 02:09:01 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.164 with SMTP id az4ls837966lab.16.gmail; Wed, 08 Jul 2015 02:09:01 -0700 (PDT) X-Received: by 10.112.46.130 with SMTP id v2mr1337096lbm.119.1436346541293; Wed, 08 Jul 2015 02:09:01 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id 8si1076407lan.120.2015.07.08.02.09.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jul 2015 02:09:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by lagx9 with SMTP id x9so220862969lag.1 for ; Wed, 08 Jul 2015 02:09:01 -0700 (PDT) X-Received: by 10.112.55.207 with SMTP id u15mr8302381lbp.88.1436346541106; Wed, 08 Jul 2015 02:09:01 -0700 (PDT) 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.108.230 with SMTP id hn6csp2934853lbb; Wed, 8 Jul 2015 02:09:00 -0700 (PDT) X-Received: by 10.68.69.6 with SMTP id a6mr18539199pbu.132.1436346539386; Wed, 08 Jul 2015 02:08:59 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id se6si3038789pbc.119.2015.07.08.02.08.58; Wed, 08 Jul 2015 02:08:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932997AbbGHJI5 (ORCPT + 11 others); Wed, 8 Jul 2015 05:08:57 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:36708 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933962AbbGHJIx (ORCPT ); Wed, 8 Jul 2015 05:08:53 -0400 Received: by pddu5 with SMTP id u5so54899299pdd.3 for ; Wed, 08 Jul 2015 02:08:52 -0700 (PDT) X-Received: by 10.68.240.7 with SMTP id vw7mr18393914pbc.135.1436346532000; Wed, 08 Jul 2015 02:08:52 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id do16sm1747042pac.15.2015.07.08.02.08.50 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 08 Jul 2015 02:08:51 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, edubezval@gmail.com, javi.merino@arm.com, pi-cheng.chen@linaro.org, Viresh Kumar , linux-kernel@vger.kernel.org (open list) Subject: [PATCH V2] cpufreq: Allow accessing freq_table for offline CPUs Date: Wed, 8 Jul 2015 14:38:41 +0530 Message-Id: <5b275fbf85738095a6045ddd7d470cc99a795664.1436346340.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.4.0 In-Reply-To: <20150708090144.GB2647@e104805> References: <20150708090144.GB2647@e104805> 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.42 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: , Users of freq table may want to access it for any CPU from policy->related_cpus mask. One such user is cpu-cooling layer. It gets a list of 'clip_cpus' (equivalent to policy->related_cpus) during registration and tries to get freq_table for the first CPU of this mask. If the CPU, for which it tries to fetch freq_table, is offline, cpufreq_frequency_get_table() fails. This happens because it relies on cpufreq_cpu_get_raw() for its functioning which returns policy only for online CPUs. Fix this by considering offline CPUs, but with a restriction that the policy is active at that time. Because we will be using 'cpufreq_cpu_data' now, which is internal to cpufreq-core, lets also move cpufreq_frequency_get_table() to cpufreq.c file. Reported-and-tested-by: Pi-Cheng Chen Signed-off-by: Viresh Kumar --- V2: Get rid of cpufreq_cpu_data()'s declaration as well.. Thanks Javi. drivers/cpufreq/cpufreq.c | 9 +++++++++ drivers/cpufreq/freq_table.c | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 2c22e3902e72..26063afb3eba 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -169,6 +169,15 @@ struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy) } EXPORT_SYMBOL_GPL(get_governor_parent_kobj); +struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu) +{ + struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); + + return policy && !policy_is_inactive(policy) ? + policy->freq_table : NULL; +} +EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table); + static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) { u64 idle_time; diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index df14766a8e06..dfbbf981ed56 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c @@ -297,15 +297,6 @@ int cpufreq_table_validate_and_show(struct cpufreq_policy *policy, } EXPORT_SYMBOL_GPL(cpufreq_table_validate_and_show); -struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu); - -struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu) -{ - struct cpufreq_policy *policy = cpufreq_cpu_get_raw(cpu); - return policy ? policy->freq_table : NULL; -} -EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table); - MODULE_AUTHOR("Dominik Brodowski "); MODULE_DESCRIPTION("CPUfreq frequency table helpers"); MODULE_LICENSE("GPL");