From patchwork Fri Jun 23 09:25:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 106250 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp112351qgd; Fri, 23 Jun 2017 02:26:19 -0700 (PDT) X-Received: by 10.84.136.129 with SMTP id 1mr7843903pll.213.1498209979313; Fri, 23 Jun 2017 02:26:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498209979; cv=none; d=google.com; s=arc-20160816; b=Ol3+eb0clH1mk2hQ9s5CaIgfuCGDDypw66m6DA3f4amzs9ljfRRC6svSVSTEEs4lwt IgR76rD7A6rwK1UklxbAfKabSvmk9bHd8LwTkmUc5Ij896bYLw+cesrsQVBdZZkEvTjH NxfvshUFSpknvCvbu1RFwsn0y+TWhLXB/VobmJXKgEfgLUO/t6xLc6HL6+dUpzMdz6iu S0Yr/soZjYh0x62Hzc4eyezjUcp/oA7XfMTW1UA0PvJdPafw8WmKJbWUjQaGlX7qBEIg g/sh0vjv+LhdIGwTHvxEKw6X/JLU1xyRHLna/YUQDKRQQ8X1HcG9FsjxYdMUDV6ZjyFD jxYw== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=8hTt9qoVuLZvprh667SfMZB0mqtWyBGI6UY7vV4wwI8=; b=wqoLP7232qKDDWQebdvo5j+4RDnGcEUv/RRL+hvziTIbQH8UOUlvZQ8V7Ue0sJEWef SDZ0UbLhEBgwcSp30bIhCYp1MeIQMa6KtN/vUTa44I7BF3U9qFxBFP7efwvy0e2FnhmH i4fUosGnWkm54yOR7qJ8SgaRqf/Ve3hmaKdLZGI0lSFAUvsRlFOZxl5nu58Fw12IckJU nd4XIuEX/wjFNRXkvXMCaqw2ZuaLg9bfcWq6L17zvS75qy+uY+DYQ5S0LrIv32YiMHZ0 U74EESdOEVOw121WLeepP4UCGLFwE8CXDc9/D/GdTqrnwvttzRFbCPGOY17WvrLZYaP3 USpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=QE0zu0FQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t18si2984519pge.491.2017.06.23.02.26.19; Fri, 23 Jun 2017 02:26: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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=QE0zu0FQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754662AbdFWJZx (ORCPT + 25 others); Fri, 23 Jun 2017 05:25:53 -0400 Received: from mail-pg0-f48.google.com ([74.125.83.48]:33074 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754161AbdFWJZu (ORCPT ); Fri, 23 Jun 2017 05:25:50 -0400 Received: by mail-pg0-f48.google.com with SMTP id f127so19038101pgc.0 for ; Fri, 23 Jun 2017 02:25:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=8hTt9qoVuLZvprh667SfMZB0mqtWyBGI6UY7vV4wwI8=; b=QE0zu0FQaLwh3dSk5xOUHKF/L2do42B8F/rvJl/J4c/nw1uFzmgxKB6+w8RiegRkZZ PlCoxNIQvyvOqQ0C6FJ7s8egCsG7sUKiFzWL6cbHV47OEdf2EVDcoA5OoOWVEFsCfLbN saSlzUmVPO+4u1IiARwXfGUf6/gFIJejDVMjk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=8hTt9qoVuLZvprh667SfMZB0mqtWyBGI6UY7vV4wwI8=; b=VrFWiixJL7eWGSVFsqAhcyBXJUDYV5iZ+c+Ud8Am55KZugRejWq/eJV/SRDmMLoizT P+a8jXnze5HorV9LFEtFbY0pEkzt4Fxa6iGicXo5ACKNF238LbcSaA9QsbJgykcEEp9w GFzkKOe24KISoy0rGrHHikXNie4Ym08ZJf5gIwugLmldRxQlCUr2Qg7F4LMlK6V+OtrP UCA5NUVmE4XFIyXyzlpSZReR2KGAiiVmmnCyCLcu4epBQDAQdWgelcEb/BAhX92G94Uy MdjIhrq3QigDZniNnzSDdX8I3XzUucMC+Y1YpPuzYstPGE7W/6RPXgHY58W7bc/2Q9Hk sYCg== X-Gm-Message-State: AKS2vOxJitS3QGycoAIo2CTAVp6j++ZrafQs5zp03n2SKicrXGfnVaZe +ET/8lATwXlLOmW3 X-Received: by 10.98.80.139 with SMTP id g11mr7334039pfj.146.1498209949706; Fri, 23 Jun 2017 02:25:49 -0700 (PDT) Received: from localhost ([122.172.59.234]) by smtp.gmail.com with ESMTPSA id 5sm8102267pfe.60.2017.06.23.02.25.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jun 2017 02:25:49 -0700 (PDT) From: Viresh Kumar To: Juri Lelli , Greg Kroah-Hartman Cc: Viresh Kumar , linux-arm-kernel@lists.infradead.org, Catalin Marinas , linux@arm.linux.org.uk, Will Deacon , Vincent Guittot , arnd.bergmann@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH V3 4/5] arch_topology: Localize cap_parsing_failed to topology_parse_cpu_capacity() Date: Fri, 23 Jun 2017 14:55:33 +0530 Message-Id: <12320387190373d6574a4cf618809ed60dd5b9be.1498209817.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.13.0.71.gd7076ec9c9cb In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org cap_parsing_failed is only required in topology_parse_cpu_capacity() to know if we have already tried to allocate raw_capacity and failed, or if at least one of the cpu_node didn't had the required "capacity-dmips-mhz" property. All other users can use raw_capacity instead of cap_parsing_failed. Make sure we set raw_capacity to NULL after we free it. Signed-off-by: Viresh Kumar --- drivers/base/arch_topology.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) -- 2.13.0.71.gd7076ec9c9cb diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 5728e2fbb765..9e4d2107f4fa 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -95,14 +95,21 @@ subsys_initcall(register_cpu_capacity_sysctl); static u32 capacity_scale; static u32 *raw_capacity; -static bool cap_parsing_failed; + +static int __init free_raw_capacity(void) +{ + kfree(raw_capacity); + raw_capacity = NULL; + + return 0; +} void topology_normalize_cpu_scale(void) { u64 capacity; int cpu; - if (!raw_capacity || cap_parsing_failed) + if (!raw_capacity) return; pr_debug("cpu_capacity: capacity_scale=%u\n", capacity_scale); @@ -121,6 +128,7 @@ void topology_normalize_cpu_scale(void) bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu) { + static bool cap_parsing_failed; int ret; u32 cpu_capacity; @@ -151,7 +159,7 @@ bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu) pr_err("cpu_capacity: partial information: fallback to 1024 for all CPUs\n"); } cap_parsing_failed = true; - kfree(raw_capacity); + free_raw_capacity(); } return !ret; @@ -171,7 +179,7 @@ init_cpu_capacity_callback(struct notifier_block *nb, struct cpufreq_policy *policy = data; int cpu; - if (cap_parsing_failed || cap_parsing_done) + if (!raw_capacity || cap_parsing_done) return 0; if (val != CPUFREQ_NOTIFY) @@ -191,7 +199,7 @@ init_cpu_capacity_callback(struct notifier_block *nb, if (cpumask_empty(cpus_to_visit)) { topology_normalize_cpu_scale(); - kfree(raw_capacity); + free_raw_capacity(); pr_debug("cpu_capacity: parsing done\n"); cap_parsing_done = true; schedule_work(&parsing_done_work); @@ -233,11 +241,5 @@ static void parsing_done_workfn(struct work_struct *work) } #else -static int __init free_raw_capacity(void) -{ - kfree(raw_capacity); - - return 0; -} core_initcall(free_raw_capacity); #endif