From patchwork Thu Jul 9 05:13:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 50916 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 94127213FD for ; Thu, 9 Jul 2015 05:14:09 +0000 (UTC) Received: by lbbpo10 with SMTP id po10sf29236177lbb.1 for ; Wed, 08 Jul 2015 22:14:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to:cc:subject:message-id :references:mime-version:content-type:content-disposition :in-reply-to:user-agent:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=VPs6p0JV+giOA1LTXLjRvpLVCgh69ODzdQyoWbC/1YU=; b=gPfwRRXq7jr4/6JafgaEkJ5cUOJHHZwfiUJjyLgbc3mr63lBpWgFtJqQ3HI1asG5dT KkpKURM8CtjnlFQle0MAnNpEOVOocxR8zfw5PvIVVmZ6fP4X5VPm2as4u7j+sIMgtSjn Re+5uKn9b7HG0Mvo8gtkWXhekqqcz+eTDoyprhgERhPdGsGthv0IZWzU627+PYJiUF8X y21gFR10zc39sBx8MWvyO74zkPzE1X4NPijamY4PWQu71n89TxUIm+bRvkp/mX/tMZMA hTzfQIDHc8tSAXm57hMQuZJKWROCC9SlKemI582QCZb5gOwVim1MeV58Rq+m/5yw0GuU Xigw== X-Gm-Message-State: ALoCoQkE/QM6z0yKuH9qaH3q/gn4/so1VK+aA2Tj3ZihdJ+fx8r2JkWZN7l9TET0vWWvPvzgkQqH X-Received: by 10.152.88.70 with SMTP id be6mr6874906lab.9.1436418848441; Wed, 08 Jul 2015 22:14:08 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.178.164 with SMTP id cz4ls1068582lac.3.gmail; Wed, 08 Jul 2015 22:14:08 -0700 (PDT) X-Received: by 10.152.6.69 with SMTP id y5mr12790184lay.72.1436418848290; Wed, 08 Jul 2015 22:14:08 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id e10si1430137lam.131.2015.07.08.22.14.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jul 2015 22:14:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbnk3 with SMTP id k3so68336862lbn.1 for ; Wed, 08 Jul 2015 22:14:08 -0700 (PDT) X-Received: by 10.112.133.72 with SMTP id pa8mr1179763lbb.117.1436418847976; Wed, 08 Jul 2015 22:14:07 -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 hn6csp407951lbb; Wed, 8 Jul 2015 22:14:06 -0700 (PDT) X-Received: by 10.66.121.163 with SMTP id ll3mr28067135pab.100.1436418846177; Wed, 08 Jul 2015 22:14:06 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qn16si7294238pab.235.2015.07.08.22.14.05; Wed, 08 Jul 2015 22:14:06 -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 S1751818AbbGIFOE (ORCPT + 11 others); Thu, 9 Jul 2015 01:14:04 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:33273 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751058AbbGIFOD (ORCPT ); Thu, 9 Jul 2015 01:14:03 -0400 Received: by pacws9 with SMTP id ws9so145478186pac.0 for ; Wed, 08 Jul 2015 22:14:01 -0700 (PDT) X-Received: by 10.70.54.7 with SMTP id f7mr27165395pdp.75.1436418841866; Wed, 08 Jul 2015 22:14:01 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id v8sm4323043pdm.89.2015.07.08.22.13.59 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 08 Jul 2015 22:14:00 -0700 (PDT) Date: Thu, 9 Jul 2015 10:43:56 +0530 From: Viresh Kumar To: "Rafael J. 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 , open list Subject: Re: [PATCH] cpufreq: Allow accessing freq_table for offline CPUs Message-ID: <20150709051356.GK1805@linux> References: <2953689.ETebrTym45@vostro.rjw.lan> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2953689.ETebrTym45@vostro.rjw.lan> User-Agent: Mutt/1.5.21 (2010-09-15) 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.217.176 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: , On 09-07-15, 02:40, Rafael J. Wysocki wrote: > The above sentence is completely unclear to anyone unfamiliar with the > code in question. > > The fix is to access the policy data structure for the given CPU directly > (which also returns a valid policy for offline CPUs), but the policy > itself has to be active (meaning that at least one CPU using it is online) > for the frequency table to be returned. > > Right? Yeah.. -------------------8<-------------------- Message-Id: <9c37b9a711b6dc6e419e256fd62fcc93a29db4e4.1436418686.git.viresh.kumar@linaro.org> From: Viresh Kumar Date: Wed, 8 Jul 2015 12:53:03 +0530 Subject: [PATCH V3] cpufreq: Allow accessing freq_table for offline CPUs 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. The fix is to access the policy data structure for the given CPU directly (which also returns a valid policy for offline CPUs), but the policy itself has to be active (meaning that at least one CPU using it is online) for the frequency table to be returned. 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 --- V3-> Changelog improvement suggested by Rafael. drivers/cpufreq/cpufreq.c | 9 +++++++++ drivers/cpufreq/freq_table.c | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 36e97a5a7e20..a7b6ac6e048e 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");