From patchwork Thu Jul 6 09:49:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dietmar Eggemann X-Patchwork-Id: 107095 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1881642qge; Thu, 6 Jul 2017 02:50:38 -0700 (PDT) X-Received: by 10.84.224.4 with SMTP id r4mr27494371plj.85.1499334638189; Thu, 06 Jul 2017 02:50:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499334638; cv=none; d=google.com; s=arc-20160816; b=qtSCz7Sw4PUlQk7mVYPaZpwzjbULD/GEzonhm9MU3yENSSPQNVH/c9TP5ndQ0U+GEf iPgxxhTry2RHM9yH1k6OOFysInfKCs0TNaXDdFEuoS88OPtNGo3PqrRoGCz1dV2laKQw eH85YaPow3DzW2CqLg30mZDlgKIUr1oz5HiekoHt+Oea5T+D/VR3VFe0Z6rSEq8idX5I kfSyTDaRJM/yjEihfj/JujNwvhd3dWYdK4CwpoEma6BUy1aBkXjZhnESI5ZngpVT7A4O kyOhM/o7OyFvYvgTOvjIBw3NjFfbCgkeBlLWrt55ziVmlD9PItT1JEwjQvAFReLiLAus cykQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=XD6HOrob8RxDHHkYKav2Wx3BsPjBcbA3cltxkhwzFBg=; b=b8c+gyJMJj/GC1DpguE4pJwXWofCQqwSFa6lfo482GFpGulsOF/xR9M99Y1PRk5pOI cSMXk4BIpZfWgF1q7qwzsErECSj5Af/SVkhbVY2D2aUP4W32kEBSYshGFdtR3dgW4Xyd vQPuDoFmFYuRH44qXLeQjRmiXMQiKy19iDPJKeiv1Xl3Of01iPLNw7ZTi+hpVctmowTV 4EKSvTARHlgMd0G/JSAEYaKzxUS1wQCWFdEQhHdHcMQtbEfgeUHWfXmwrn3RHMLG4rXb zxDs2vE/4Yw057PHW08cqILFz7obmWuIU9PiPXOwtp25y37tL7GUCOAUOE1KO4v2mEYf jrWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l74si1153861pfb.386.2017.07.06.02.50.37; Thu, 06 Jul 2017 02:50:38 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752347AbdGFJuY (ORCPT + 25 others); Thu, 6 Jul 2017 05:50:24 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:36086 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751057AbdGFJuV (ORCPT ); Thu, 6 Jul 2017 05:50:21 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5337615BE; Thu, 6 Jul 2017 02:50:20 -0700 (PDT) Received: from e107985-lin.cambridge.arm.com (e107985-lin.cambridge.arm.com [10.1.210.41]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4E0013F3E1; Thu, 6 Jul 2017 02:50:18 -0700 (PDT) From: Dietmar Eggemann To: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org, linux@arm.linux.org.uk, Greg Kroah-Hartman , Russell King , Catalin Marinas , Will Deacon , Juri Lelli , Vincent Guittot , Peter Zijlstra , Morten Rasmussen , Viresh Kumar , "Rafael J . Wysocki" Subject: [PATCH v2 02/10] cpufreq: provide data for frequency-invariant load-tracking support Date: Thu, 6 Jul 2017 10:49:40 +0100 Message-Id: <20170706094948.8779-3-dietmar.eggemann@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170706094948.8779-1-dietmar.eggemann@arm.com> References: <20170706094948.8779-1-dietmar.eggemann@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A frequency-invariant load-tracking solution based on cpufreq transition notifier will not work for future fast frequency switching policies. That is why a different solution is presented with this patch. Let cpufreq call the function arch_set_freq_scale() to pass the current frequency, the max supported frequency and the cpumask of the related cpus to a consumer (an arch) which defines arch_set_freq_scale(). The consumer has to associate arch_set_freq_scale with the name of its own implementation foo_set_freq_scale() to overwrite the empty standard definition in drivers/cpufreq/cpufreq.c. An arch could do this in one of its arch-specific header files (e.g. arch/$ARCH/include/asm/topology.h) which gets included in drivers/cpufreq/cpufreq.c. In case arch_set_freq_scale() is not defined (and because of the pr_debug() drivers/cpufreq/cpufreq.c is not compiled with -DDEBUG) the function cpufreq_set_freq_scale() gets compiled out. Cc: Rafael J. Wysocki Cc: Viresh Kumar Signed-off-by: Dietmar Eggemann --- drivers/cpufreq/cpufreq.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) -- 2.11.0 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 9bf97a366029..a04c5886a5ce 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -347,6 +347,28 @@ static void __cpufreq_notify_transition(struct cpufreq_policy *policy, } } +/********************************************************************* + * FREQUENCY INVARIANT CPU CAPACITY SUPPORT * + *********************************************************************/ + +#ifndef arch_set_freq_scale +static void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq, + unsigned long max_freq) +{} +#endif + +static void cpufreq_set_freq_scale(struct cpufreq_policy *policy, + struct cpufreq_freqs *freqs) +{ + unsigned long cur_freq = freqs ? freqs->new : policy->cur; + unsigned long max_freq = policy->cpuinfo.max_freq; + + pr_debug("cpus %*pbl cur/cur max freq %lu/%lu kHz\n", + cpumask_pr_args(policy->related_cpus), cur_freq, max_freq); + + arch_set_freq_scale(policy->related_cpus, cur_freq, max_freq); +} + /** * cpufreq_notify_transition - call notifier chain and adjust_jiffies * on frequency transition. @@ -405,6 +427,8 @@ void cpufreq_freq_transition_begin(struct cpufreq_policy *policy, spin_unlock(&policy->transition_lock); + cpufreq_set_freq_scale(policy, freqs); + cpufreq_notify_transition(policy, freqs, CPUFREQ_PRECHANGE); } EXPORT_SYMBOL_GPL(cpufreq_freq_transition_begin); @@ -2203,6 +2227,8 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, blocking_notifier_call_chain(&cpufreq_policy_notifier_list, CPUFREQ_NOTIFY, new_policy); + cpufreq_set_freq_scale(new_policy, NULL); + policy->min = new_policy->min; policy->max = new_policy->max;