From patchwork Wed Aug 31 17:08:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juri Lelli X-Patchwork-Id: 9307649 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9DA6D60756 for ; Wed, 31 Aug 2016 17:08:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 885A928FD6 for ; Wed, 31 Aug 2016 17:08:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CAFF28FE2; Wed, 31 Aug 2016 17:08:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E197E28FD6 for ; Wed, 31 Aug 2016 17:08:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753677AbcHaRIb (ORCPT ); Wed, 31 Aug 2016 13:08:31 -0400 Received: from foss.arm.com ([217.140.101.70]:38100 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754071AbcHaRI3 (ORCPT ); Wed, 31 Aug 2016 13:08:29 -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 399B6433; Wed, 31 Aug 2016 10:08:28 -0700 (PDT) Received: from e106622-lin (e106622-lin.cambridge.arm.com [10.1.211.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C89993F303; Wed, 31 Aug 2016 10:08:25 -0700 (PDT) Date: Wed, 31 Aug 2016 18:08:35 +0100 From: Juri Lelli To: Vincent Guittot Cc: linux-kernel , "linux-pm@vger.kernel.org" , LAK , "devicetree@vger.kernel.org" , Peter Zijlstra , Rob Herring , Mark Rutland , Russell King - ARM Linux , Sudeep Holla , Lorenzo Pieralisi , Catalin Marinas , Will Deacon , Morten Rasmussen , Dietmar Eggemann , Mark Brown Subject: Re: [PATCH v6 2/8] arm: parse cpu capacity-dmips-mhz from DT Message-ID: <20160831170835.GL9337@e106622-lin> References: <1468932048-31635-1-git-send-email-juri.lelli@arm.com> <1468932048-31635-3-git-send-email-juri.lelli@arm.com> <20160830162853.GF9337@e106622-lin> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 31/08/16 10:14, Vincent Guittot wrote: > On 30 August 2016 at 18:28, Juri Lelli wrote: > > Hi Vincent, > > > > On 16/08/16 10:20, Vincent Guittot wrote: > >> Hi Juri, > >> > >> > >> On 19 July 2016 at 14:40, Juri Lelli wrote: > > > > [...] > > > >> > +static int > >> > +init_cpu_capacity_callback(struct notifier_block *nb, > >> > + unsigned long val, > >> > + void *data) > >> > +{ > >> > + struct cpufreq_policy *policy = data; > >> > + int cpu; > >> > + > >> > + if (cap_parsing_failed || cap_parsing_done) > >> > + return 0; > >> > + > >> > + switch (val) { > >> > + case CPUFREQ_NOTIFY: > >> > + pr_debug("cpu_capacity: init cpu capacity for CPUs [%*pbl] (to_visit=%*pbl)\n", > >> > + cpumask_pr_args(policy->related_cpus), > >> > + cpumask_pr_args(cpus_to_visit)); > >> > + cpumask_andnot(cpus_to_visit, > >> > + cpus_to_visit, > >> > + policy->related_cpus); > >> > + for_each_cpu(cpu, policy->related_cpus) { > >> > + raw_capacity[cpu] = arch_scale_cpu_capacity(NULL, cpu) * > >> > + policy->max / 1000UL; > >> > >> Should it be policy->cpuinfo.max_freq instead of policy->max ? > >> > > > > Right. I'll fix the arm64 bits as well. > > > >> > + capacity_scale = max(raw_capacity[cpu], capacity_scale); > >> > + } > >> > + if (cpumask_empty(cpus_to_visit)) { > >> > + normalize_cpu_capacity(); > >> > + kfree(raw_capacity); > >> > + pr_debug("cpu_capacity: parsing done\n"); > >> > + cap_parsing_done = true; > >> > >> ok so you do that once with the 1st governor that will be registered > >> for the CPU. Can't you unregister the notifier then ? > >> > > > > I tried, but the only place I could find to unregister it is from the > > callback itself; and it is not possible to do so AFAIK. Suggestions? > > yes, you're right > Can't you queue a work to unregister your callback ? You mean something like this? I guess I thought it would be much more ugly. :) If it looks OK, I'll add the same for arm64 and test it a bit more. --->8--- arch/arm/kernel/topology.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 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/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c index cbc57c287145..672ae22e2768 100644 --- a/arch/arm/kernel/topology.c +++ b/arch/arm/kernel/topology.c @@ -215,7 +215,8 @@ static void normalize_cpu_capacity(void) #ifdef CONFIG_CPU_FREQ static cpumask_var_t cpus_to_visit; -static bool cap_parsing_done; +static void parsing_done_workfn(struct work_struct *work); +static DECLARE_WORK(parsing_done_work, parsing_done_workfn); static int init_cpu_capacity_callback(struct notifier_block *nb, @@ -225,7 +226,7 @@ init_cpu_capacity_callback(struct notifier_block *nb, struct cpufreq_policy *policy = data; int cpu; - if (cap_parsing_failed || cap_parsing_done) + if (cap_parsing_failed) return 0; switch (val) { @@ -245,7 +246,7 @@ init_cpu_capacity_callback(struct notifier_block *nb, normalize_cpu_capacity(); kfree(raw_capacity); pr_debug("cpu_capacity: parsing done\n"); - cap_parsing_done = true; + schedule_work(&parsing_done_work); } } return 0; @@ -270,6 +271,13 @@ static int __init register_cpufreq_notifier(void) CPUFREQ_POLICY_NOTIFIER); } core_initcall(register_cpufreq_notifier); + +static void parsing_done_workfn(struct work_struct *work) +{ + cpufreq_unregister_notifier(&init_cpu_capacity_notifier, + CPUFREQ_POLICY_NOTIFIER); +} + #else static int __init free_raw_capacity(void) {