From patchwork Wed Jul 18 11:25:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 10532203 X-Patchwork-Delegate: geert@linux-m68k.org 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 B8F03600F4 for ; Wed, 18 Jul 2018 11:25:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DBA128639 for ; Wed, 18 Jul 2018 11:25:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 905FA28FBF; Wed, 18 Jul 2018 11:25:42 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 106E028639 for ; Wed, 18 Jul 2018 11:25:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729914AbeGRMDH (ORCPT ); Wed, 18 Jul 2018 08:03:07 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:60784 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729700AbeGRMDH (ORCPT ); Wed, 18 Jul 2018 08:03:07 -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 4C9D180D; Wed, 18 Jul 2018 04:25:41 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.211.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EBC243F318; Wed, 18 Jul 2018 04:25:39 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , Will Deacon , Linux-Renesas , Geert Uytterhoeven , Mark Rutland , Lorenzo Pieralisi Subject: [PATCH] drivers/firmware: psci_checker: stash and use topology_core_cpumask for hotplug tests Date: Wed, 18 Jul 2018 12:25:32 +0100 Message-Id: <1531913132-21022-1-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 7f9545aa1a91 ("arm64: smp: remove cpu and numa topology information when hotplugging out CPU") updates the cpu topology when the CPU is hotplugged out. However the PSCI checker code uses the topology_core_cpumask pointers for some of the cpu hotplug testing. Since the pointer to the core_cpumask of the first CPU in the group is used, which when that CPU itself is hotpugged out is just set to itself, the testing terminates after that particular CPU is tested out. But the intention of this tests is to cover all the CPU in the group. In order to support that, we need to stash the topology_core_cpumask before the start of the test and use that value instead of pointer to a cpumask which will be updated on CPU hotplug. Fixes: 7f9545aa1a91a9a4 ("arm64: smp: remove cpu and numa topology information when hotplugging out CPU") Reported-by: Geert Uytterhoeven Tested-by: Geert Uytterhoeven Cc: Mark Rutland Cc: Lorenzo Pieralisi Signed-off-by: Sudeep Holla --- drivers/firmware/psci_checker.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/firmware/psci_checker.c b/drivers/firmware/psci_checker.c index bb1c068bff19..e330c6cb45f5 100644 --- a/drivers/firmware/psci_checker.c +++ b/drivers/firmware/psci_checker.c @@ -77,21 +77,23 @@ static int psci_ops_check(void) return 0; } -static int find_cpu_groups(const struct cpumask *cpus, - const struct cpumask **cpu_groups) +static int find_cpu_groups(cpumask_var_t *cpu_groups) { unsigned int nb = 0; cpumask_var_t tmp; if (!alloc_cpumask_var(&tmp, GFP_KERNEL)) return -ENOMEM; - cpumask_copy(tmp, cpus); + cpumask_copy(tmp, cpu_online_mask); while (!cpumask_empty(tmp)) { const struct cpumask *cpu_group = topology_core_cpumask(cpumask_any(tmp)); - cpu_groups[nb++] = cpu_group; + if (cpu_groups && cpu_groups[nb]) + cpumask_copy(cpu_groups[nb], cpu_group); + + nb++; cpumask_andnot(tmp, tmp, cpu_group); } @@ -169,25 +171,31 @@ static unsigned int down_and_up_cpus(const struct cpumask *cpus, static int hotplug_tests(void) { int err; - cpumask_var_t offlined_cpus; + cpumask_var_t offlined_cpus, *cpu_groups; int i, nb_cpu_group; - const struct cpumask **cpu_groups; char *page_buf; + /* first run to just get the number of cpu groups */ + nb_cpu_group = find_cpu_groups(NULL); + err = -ENOMEM; if (!alloc_cpumask_var(&offlined_cpus, GFP_KERNEL)) return err; - /* We may have up to nb_available_cpus cpu_groups. */ - cpu_groups = kmalloc_array(nb_available_cpus, sizeof(*cpu_groups), - GFP_KERNEL); + cpu_groups = kcalloc(nb_cpu_group, sizeof(cpu_groups), GFP_KERNEL); if (!cpu_groups) goto out_free_cpus; + + for (i = 0; i < nb_cpu_group; ++i) + if (!alloc_cpumask_var(&cpu_groups[i], GFP_KERNEL)) + goto out_free_cpu_groups; + page_buf = (char *)__get_free_page(GFP_KERNEL); if (!page_buf) goto out_free_cpu_groups; err = 0; - nb_cpu_group = find_cpu_groups(cpu_online_mask, cpu_groups); + /* second run to populate/copy the cpumask */ + nb_cpu_group = find_cpu_groups(cpu_groups); /* * Of course the last CPU cannot be powered down and cpu_down() should @@ -212,6 +220,8 @@ static int hotplug_tests(void) free_page((unsigned long)page_buf); out_free_cpu_groups: + for (i = 0; i < nb_cpu_group; ++i) + free_cpumask_var(cpu_groups[i]); kfree(cpu_groups); out_free_cpus: free_cpumask_var(offlined_cpus);