From patchwork Thu Mar 14 06:42:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 10852231 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4FF9713B5 for ; Thu, 14 Mar 2019 06:43:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 382AB2A1BF for ; Thu, 14 Mar 2019 06:43:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C82A2A1C4; Thu, 14 Mar 2019 06:43:40 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 CBF552A1BF for ; Thu, 14 Mar 2019 06:43:39 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=21RoNez/W0ybHzKU9DPpWK0C/o1t4iiffvjJ/IJHH2s=; b=n89Xc0exyUQks5 wN62D7bnNO1TY6cia5zcFEM6SepxuYZJ30COIW8SiEqjZd61tXcizJhxHOD5asYdf3L8JZTch09WK nGIppyh5H+9RIEoCZNZLagM+mfdjfK6sE6Vo3+Vvg7QkXHMvjyJKCymhWGSARj7UcYaJbK0Pp63ln tNvppaoXzP8ZK2WfZMbcKzhKfoNLoW/enebN+zZ/zNfoEy38qXx8SptR9MkU3XsJKNGRLyVxpSiEz Z3k3GMG8ilL6pr0HKD+yPIthI6XHI9bZZlOsevW+DgUukgo0MgQ7lAqN36x2d21RBb3sfbwcp33H2 CfIfF94Ju40WMPyNV/Uw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h4K5V-0003t3-N3; Thu, 14 Mar 2019 06:43:33 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h4K5L-0003bB-8r for linux-arm-kernel@lists.infradead.org; Thu, 14 Mar 2019 06:43:27 +0000 Received: by mail-pg1-x543.google.com with SMTP id 125so3299273pgc.12 for ; Wed, 13 Mar 2019 23:43:23 -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 :mime-version:content-transfer-encoding; bh=lorcbNHNRFiGuz7eBUCSVribuTSrEkumL8TszzbxjzE=; b=RAUy/ZE/2HUVSglg0pbU6Z/RrAdT63TPxc7bUux3usECJno//O90wuudOKDCcvBCtx xTAJIZqajAEKv1st0pog2fnZG47Mxm3N3NhF7H0TNIF8kvedGrvu//HObZRKeUMkXTHw V+jmHs/DlShzFtQvesKJdHHvm9SiMcg56285396HhWSDi9pFH2bwLcxjaYQCKHevb/r+ NjAQS0v8ZaCje2Q6MUsVztwhgzGaKa2tmiqDpxW/5Q+lANxvrVLOZ/pyi3d4pIQEE/mJ OtCx9am3vcsp11RzES7y6vGGI9XQg7xAogBQiIm8p+SwrBW6POGBp+/pZzYimSv4dKa8 90Pg== 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:mime-version:content-transfer-encoding; bh=lorcbNHNRFiGuz7eBUCSVribuTSrEkumL8TszzbxjzE=; b=LsVSyWY/8+kxE2FoajPPtd+G58GTfaj1CCuKvDUkVD3t8N/4xxw94H/GYw8Az9T8L4 lM298R30oqGpyeX7OUS9f8LQs+W9UjpMPp+cVwh4ldy2PXcU4Z2B/0QDKgbQLuVcxT6c OE+THUg0XDjWPmyeG+8irZWKt3FsSoo1ez7dFZ5FadKB69+kEM69LS8zrsXkgf+9FJ2I 9B51IkOJr1qxqFDxlD7sOUsh9ppETCLsJ4T/zo5uJI5ZT3NvPmKEoQxXAo91vyhVZNnQ GMeMNFpJ8TLwdnS5CnUG0MMJFACRRObxpiqDXNgUZqh/Pn3z8e5mPFAM5kGlybcTIwQr EKHw== X-Gm-Message-State: APjAAAVmjKUQMStornssEyDvVTQKf7NZGbJaU5FJYhSq4p9Ghb42IkJ2 RKKlMtaqYatjFshyPKpwT21GqQ== X-Google-Smtp-Source: APXvYqwIIW6dzmk2JsSBenA1IcKwZgqTKG0LG6o6lVpVx4PDXhvngIw7tSCMXe22PloKIQkXeduD+Q== X-Received: by 2002:a65:41ca:: with SMTP id b10mr43786224pgq.146.1552545802717; Wed, 13 Mar 2019 23:43:22 -0700 (PDT) Received: from localhost ([122.166.134.37]) by smtp.gmail.com with ESMTPSA id k125sm46777131pgc.51.2019.03.13.23.43.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 23:43:22 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Russell King Subject: [PATCH 2/7] ARM: smp: Update cpufreq transition notifier to handle multiple CPUs Date: Thu, 14 Mar 2019 12:12:48 +0530 Message-Id: <4bcc5e47e3b5959e9b1e21578323a84dc9a3c79a.1552545525.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190313_234323_759272_14B50AE4 X-CRM114-Status: GOOD ( 13.44 ) 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: Viresh Kumar , Vincent Guittot , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org 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 The cpufreq core currently calls the cpufreq transition notifier callback once for each affected CPU. This is going to change soon and the cpufreq core will call the callback only once for each cpufreq policy. The callback must look at the newly added field in struct cpufreq_freqs, "cpus", which contains policy->related_cpus (both online/offline CPUs) and perform per-cpu actions for them if any. This patch updates cpufreq_callback() to use the new "cpus" field. Signed-off-by: Viresh Kumar --- arch/arm/kernel/smp.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 1d6f5ea522f4..59ee0f4db449 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -758,15 +758,19 @@ static int cpufreq_callback(struct notifier_block *nb, unsigned long val, void *data) { struct cpufreq_freqs *freq = data; - int cpu = freq->cpu; + int cpu, first = cpumask_first(freq->cpus); + unsigned int lpj; if (freq->flags & CPUFREQ_CONST_LOOPS) return NOTIFY_OK; - if (!per_cpu(l_p_j_ref, cpu)) { - per_cpu(l_p_j_ref, cpu) = - per_cpu(cpu_data, cpu).loops_per_jiffy; - per_cpu(l_p_j_ref_freq, cpu) = freq->old; + if (!per_cpu(l_p_j_ref, first)) { + for_each_cpu(cpu, freq->cpus) { + per_cpu(l_p_j_ref, cpu) = + per_cpu(cpu_data, cpu).loops_per_jiffy; + per_cpu(l_p_j_ref_freq, cpu) = freq->old; + } + if (!global_l_p_j_ref) { global_l_p_j_ref = loops_per_jiffy; global_l_p_j_ref_freq = freq->old; @@ -778,10 +782,11 @@ static int cpufreq_callback(struct notifier_block *nb, loops_per_jiffy = cpufreq_scale(global_l_p_j_ref, global_l_p_j_ref_freq, freq->new); - per_cpu(cpu_data, cpu).loops_per_jiffy = - cpufreq_scale(per_cpu(l_p_j_ref, cpu), - per_cpu(l_p_j_ref_freq, cpu), - freq->new); + + lpj = cpufreq_scale(per_cpu(l_p_j_ref, first), + per_cpu(l_p_j_ref_freq, first), freq->new); + for_each_cpu(cpu, freq->cpus) + per_cpu(cpu_data, cpu).loops_per_jiffy = lpj; } return NOTIFY_OK; }