From patchwork Thu Jun 8 07:55:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dietmar Eggemann X-Patchwork-Id: 9774151 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 921CD60350 for ; Thu, 8 Jun 2017 07:56:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F99D223B3 for ; Thu, 8 Jun 2017 07:56:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73AF628558; Thu, 8 Jun 2017 07:56:32 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0D22C223B3 for ; Thu, 8 Jun 2017 07:56:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=kVoHxHbns3f1BQ8bMwcvd9fNqWaoIb86DS6lBEh3FS4=; b=hnT3BWEYFiV943eYwIcLS8QTtL hMgVF/hr4yvsSYJyrD5dDLURN9x3ul9SwetXwc3OHKVWp6Zq+lyoFTq2OeNF++XLDCapqPTGleaUM gdzeYOdUnqXYgMgmUEzPCWLzjWsBHjsLOOY/ycBNoanXG2QNiWZYrNC2/azkLaEa46/T3aUp3jqHv GWi0VkwiKv/ejPoH8uXbaccAAJo9RUn/CKJmMCmM6oYjtrJAWxWMioXMVOPMUjJY5TNXWujbEmwsM 3s3zBMdRurZaXskuDbBkGskPAhnCWjXl7Ufin4GmluJh0hwVCONRyzEBhZ0MlySk2wFVGbC7m+s5Z rcuBKEqw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dIsIw-0001bD-Fo; Thu, 08 Jun 2017 07:56:30 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dIsIN-0008M4-E7 for linux-arm-kernel@lists.infradead.org; Thu, 08 Jun 2017 07:55:58 +0000 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 4271C15BF; Thu, 8 Jun 2017 00:55:36 -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 47A583F3E1; Thu, 8 Jun 2017 00:55:34 -0700 (PDT) From: Dietmar Eggemann To: linux-kernel@vger.kernel.org Subject: [PATCH 1/6] drivers base/arch_topology: prepare cpufreq policy notifier for frequency-invariant load-tracking support Date: Thu, 8 Jun 2017 08:55:08 +0100 Message-Id: <20170608075513.12475-2-dietmar.eggemann@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170608075513.12475-1-dietmar.eggemann@arm.com> References: <20170608075513.12475-1-dietmar.eggemann@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170608_005555_530646_F312B3CA X-CRM114-Status: GOOD ( 15.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux@arm.linux.org.uk, Juri Lelli , linux-pm@vger.kernel.org, Peter Zijlstra , Greg Kroah-Hartman , Will Deacon , Vincent Guittot , Russell King , Catalin Marinas , Morten Rasmussen , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch prepares the actual implementation of the frequency-invariant load-tracking support provided in the next patch ("drivers base/arch_topology: frequency-invariant load-tracking support"). The maximum supported frequency of a cpu (policy->cpuinfo.max_freq) has to be retrieved for frequency-invariant load-tracking. This can be achieved by coding this functionality into the existing cpufreq policy notifier (init_cpu_capacity_notifier) which is currently only used for setting up dt-based cpu capacities (cpu node property capacity-dmips-mhz). But frequency-invariant load-tracking has to work whether cpu capacity dt-parsing succeeded or not. Change init_cpu_capacity_notifier in such a way that even if the parsing of the cpu capacity information failed the notifier is called for each cpufreq policy to be able to set the maximum supported frequency. The exit condition in register_cpufreq_notifier() now only tests for !acpi_disabled because for frequency invariance the cpufreq policy notifier has to be enabled even if u32 *raw_capacity is NULL which occurs when there is no capacity-dmips-mhz property in the dt file or when the allocation for raw_capacity[cpu] has failed. The continue statement in init_cpu_capacity_callback() makes sure that we don't go on calculating capacity_scale in case the capacity parsing failed. It should be a break rather a continue here but the next patch introduces code to set the per-cpu variable max_freq in this for_each_cpu loop before the check if cap_parsing_failed so it has to be a continue. Cc: Catalin Marinas Cc: Will Deacon Cc: Russell King Cc: Greg Kroah-Hartman Cc: Juri Lelli Signed-off-by: Dietmar Eggemann Acked-by: Vincent Guittot --- drivers/base/arch_topology.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index d1c33a85059e..272831c89feb 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -173,7 +173,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_done) return 0; switch (val) { @@ -185,13 +185,17 @@ init_cpu_capacity_callback(struct notifier_block *nb, cpus_to_visit, policy->related_cpus); for_each_cpu(cpu, policy->related_cpus) { + if (cap_parsing_failed) + continue; raw_capacity[cpu] = topology_get_cpu_scale(NULL, cpu) * policy->cpuinfo.max_freq / 1000UL; capacity_scale = max(raw_capacity[cpu], capacity_scale); } if (cpumask_empty(cpus_to_visit)) { - topology_normalize_cpu_scale(); - kfree(raw_capacity); + if (!cap_parsing_failed) { + topology_normalize_cpu_scale(); + kfree(raw_capacity); + } pr_debug("cpu_capacity: parsing done\n"); cap_parsing_done = true; schedule_work(&parsing_done_work); @@ -211,7 +215,7 @@ static int __init register_cpufreq_notifier(void) * until we have the necessary code to parse the cpu capacity, so * skip registering cpufreq notifier. */ - if (!acpi_disabled || !raw_capacity) + if (!acpi_disabled) return -EINVAL; if (!alloc_cpumask_var(&cpus_to_visit, GFP_KERNEL)) {