Received: by 10.223.185.116 with SMTP id b49csp912302wrg; Fri, 23 Feb 2018 08:43:28 -0800 (PST) X-Google-Smtp-Source: AH8x224D1J13mrynbkRcVAEqTY7rQp0yNCesTnlMdRFHBJSzr5NF2PIbj/bGWmKLj7sm6VdT/MVg X-Received: by 10.99.4.197 with SMTP id 188mr1844635pge.359.1519404208586; Fri, 23 Feb 2018 08:43:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519404208; cv=none; d=google.com; s=arc-20160816; b=YXYkmx07Mx6ejQf0JYZFdjxEFW6XMcnMFFq9aMwrg3eZZ2JDwVYf9A91daxMj6qWWJ U7fPC1fDy5EUXxQLOXpT7Fg4b0VKb6Ba9Wmlpeuhscf+oHrj2CQrK80gyo4jydh3afNW wL+4FMPCIPxv0UppsfKLkI8d8JgOMbUr5Mdc9ysEKrvmLsMlcp+5Sd69UN4U5sg2fGxM AkzhyLesNWW594AJBPAYHDbX7Y6d9YfyngSsORiIe74eGDnupWdBUazfyOzGd4leUpXC tF5xRn0yEoOM429ZKsqm5sklw0+LxAHZgxLQ0doHEEXuEmUf9j1vGzwS+a5p30vl8V4z mOZg== 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:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Np9i6izE01xr7BoI5p/MrleHpyf9FQguLhcCSt1ZiGo=; b=kpMphTEcoIiF6ZnuH/aBFQZByBw6htxLMf6VQw5VXeIDSbZAjXH2xKN6mec2Dq7M2G d3jdPf02fnsiGZxa514xihXcOCzHziAuHKO+Oyz8dVDxhl5Mslu8IAtMfAPhlWBQ8Luj 7Qy+6KmRsUIXWt9x1P58kSSWHc2j0lY6jvSXjznEgVB88vqVePwCIdOF4jklWjInUDMd VL/zsOuaiUOijAvISWazll4Dluq+kOQcA6O7U6qpUl70J04Lg7gAFlGL73r7CAERfmL7 KEgnyJeXiJkBvEdEePXUrKnEzAIhCC+mkyqux9aBJSLEhO8bz2LEH1ZCSAynMbkMoTUm GmuA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9-v6si2079349pli.588.2018.02.23.08.43.13; Fri, 23 Feb 2018 08:43:28 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752114AbeBWQmc (ORCPT + 99 others); Fri, 23 Feb 2018 11:42:32 -0500 Received: from smtprelay.synopsys.com ([198.182.60.111]:38010 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752067AbeBWQmC (ORCPT ); Fri, 23 Feb 2018 11:42:02 -0500 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 731E010C0FB4; Fri, 23 Feb 2018 08:42:02 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 4D61617C4; Fri, 23 Feb 2018 08:42:02 -0800 (PST) Received: from localhost.internal.synopsys.com (unknown [10.121.3.43]) by mailhost.synopsys.com (Postfix) with ESMTP id DC7081775; Fri, 23 Feb 2018 08:42:00 -0800 (PST) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Vineet Gupta , Alexey Brodkin , Eugeniy Paltsev Subject: [PATCH v2 3/3] ARC: setup cpu possible mask according to possible-cpus dts property Date: Fri, 23 Feb 2018 19:41:54 +0300 Message-Id: <20180223164154.22377-3-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180223164154.22377-1-Eugeniy.Paltsev@synopsys.com> References: <20180223164154.22377-1-Eugeniy.Paltsev@synopsys.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As we have option in u-boot to set CPU mask for running linux, we want to pass information to kernel about CPU cores should be brought up. So we patch kernel dtb in u-boot to set possible-cpus property. This also allows us to have correctly setuped MCIP debug mask. Signed-off-by: Eugeniy Paltsev --- Changes v1->v2: * no changes. arch/arc/kernel/smp.c | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c index efe8b42..21d86c3 100644 --- a/arch/arc/kernel/smp.c +++ b/arch/arc/kernel/smp.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -47,6 +48,42 @@ void __init smp_prepare_boot_cpu(void) { } +static int __init arc_get_cpu_map(const char *name, struct cpumask *cpumask) +{ + unsigned long dt_root = of_get_flat_dt_root(); + const char *buf; + + buf = of_get_flat_dt_prop(dt_root, name, NULL); + if (!buf) + return -EINVAL; + + if (cpulist_parse(buf, cpumask)) + return -EINVAL; + + return 0; +} + +/* + * Read from DeviceTree and setup cpu possible mask. If there is no + * "possible-cpus" property in DeviceTree pretend all [0..NR_CPUS-1] exist. + */ +static void __init arc_init_cpu_possible(void) +{ + struct cpumask cpumask; + + if (arc_get_cpu_map("possible-cpus", &cpumask)) { + pr_warn("Failed to get possible-cpus from dtb, pretending all %u cpus exist\n", + NR_CPUS); + + cpumask_setall(&cpumask); + } + + if (!cpumask_test_cpu(0, &cpumask)) + panic("Master cpu (cpu[0]) is missed in cpu possible mask!"); + + init_cpu_possible(&cpumask); +} + /* * Called from setup_arch() before calling setup_processor() * @@ -58,10 +95,7 @@ void __init smp_prepare_boot_cpu(void) */ void __init smp_init_cpus(void) { - unsigned int i; - - for (i = 0; i < NR_CPUS; i++) - set_cpu_possible(i, true); + arc_init_cpu_possible(); if (plat_smp_ops.init_early_smp) plat_smp_ops.init_early_smp(); @@ -70,16 +104,12 @@ void __init smp_init_cpus(void) /* called from init ( ) => process 1 */ void __init smp_prepare_cpus(unsigned int max_cpus) { - int i; - /* * if platform didn't set the present map already, do it now * boot cpu is set to present already by init/main.c */ - if (num_present_cpus() <= 1) { - for (i = 0; i < max_cpus; i++) - set_cpu_present(i, true); - } + if (num_present_cpus() <= 1) + init_cpu_present(cpu_possible_mask); } void __init smp_cpus_done(unsigned int max_cpus) -- 2.9.3