From patchwork Wed Jul 8 07:38:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 50858 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 38DF4213FD for ; Wed, 8 Jul 2015 07:39:22 +0000 (UTC) Received: by wgbbj7 with SMTP id bj7sf68287753wgb.2 for ; Wed, 08 Jul 2015 00:39:21 -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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=hUrFgvgkq90dn11/OcwJXEtNhxn5DI8lKYL1Wa4UMQ0=; b=j9cxo6E1A3QYoYcAziwsn1l2d6+QpdC6bZvAhMJWZ6at/JJ2vZzLR6VXev/QoLzhat 1S6ozwVxi3ku6kEXry7qGNsoB2kHX4kS90e3rr6mFc561KNS0Z2h3MkgjNusKvGn2v3D 8yddw30OtJvAYXesW+FbO1zgti7OeJV4xoAi0II5tYtEzCj+sIwv7j23xw9jOdtG430o IsifHiqwW+3QmBgPwuy9P6sE9+tFcdHfLfl0YRR9pM7oykudCnl32zSuaacY+0jRlWcM XsPn+iXlCrc7IDeW7Qm6NXgUYuqkCId1mNwT9gHjqqk8538UytDYBY8HA0IeRwOoughV COOw== X-Gm-Message-State: ALoCoQnCek+T2D+AlVGIWIm2fSPOblhAdfBlfoX1m+c+4bGSfGQO8pOAZSLCvSTs7s9NixmCqgI8 X-Received: by 10.180.35.162 with SMTP id i2mr33001344wij.6.1436341161562; Wed, 08 Jul 2015 00:39:21 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.39 with SMTP id b7ls837470lae.85.gmail; Wed, 08 Jul 2015 00:39:21 -0700 (PDT) X-Received: by 10.152.3.70 with SMTP id a6mr7939932laa.44.1436341161367; Wed, 08 Jul 2015 00:39:21 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id r11si1216635lby.31.2015.07.08.00.39.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jul 2015 00:39:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lbnk3 with SMTP id k3so50793027lbn.1 for ; Wed, 08 Jul 2015 00:39:21 -0700 (PDT) X-Received: by 10.152.36.102 with SMTP id p6mr7925824laj.19.1436341161252; Wed, 08 Jul 2015 00:39:21 -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 hn6csp2884905lbb; Wed, 8 Jul 2015 00:39:20 -0700 (PDT) X-Received: by 10.70.134.70 with SMTP id pi6mr17602335pdb.100.1436341159525; Wed, 08 Jul 2015 00:39:19 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ag9si2653629pbd.75.2015.07.08.00.39.18; Wed, 08 Jul 2015 00:39:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 S934194AbbGHHjN (ORCPT + 29 others); Wed, 8 Jul 2015 03:39:13 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:32933 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934171AbbGHHi6 (ORCPT ); Wed, 8 Jul 2015 03:38:58 -0400 Received: by pdbdz6 with SMTP id dz6so46416513pdb.0 for ; Wed, 08 Jul 2015 00:38:57 -0700 (PDT) X-Received: by 10.70.34.38 with SMTP id w6mr17740666pdi.147.1436341137475; Wed, 08 Jul 2015 00:38:57 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id wa4sm1428218pab.17.2015.07.08.00.38.55 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 08 Jul 2015 00:38:56 -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, Viresh Kumar , Pi-Cheng Chen , linux-kernel@vger.kernel.org (open list) Subject: [PATCH] cpufreq: Allow accessing freq_table for offline CPUs Date: Wed, 8 Jul 2015 13:08:15 +0530 Message-Id: X-Mailer: git-send-email 2.4.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@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.171 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-by: Pi-Cheng Chen Signed-off-by: Viresh Kumar Tested-by: Pi-Cheng Chen --- This was recently tried by Pi cheng but in a completely different way: http://marc.info/?l=linux-pm&m=143572367402758&w=2 Its not broken by any stuff in 4.2, but would be good if we can push this for 4.2 as well. drivers/cpufreq/cpufreq.c | 9 +++++++++ drivers/cpufreq/freq_table.c | 7 ------- 2 files changed, 9 insertions(+), 7 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..7551f01e8536 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c @@ -299,13 +299,6 @@ 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");