Received: by 10.223.185.116 with SMTP id b49csp862694wrg; Wed, 21 Feb 2018 08:07:12 -0800 (PST) X-Google-Smtp-Source: AH8x224IAaqAU9mqfTi7S/mWtQaOkVYkZlTPx6uqL3X/3ycB2BRQUvJ1yF3VvJwdvxqmnpk9Db0B X-Received: by 10.98.58.129 with SMTP id v1mr3755051pfj.203.1519229232871; Wed, 21 Feb 2018 08:07:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519229232; cv=none; d=google.com; s=arc-20160816; b=PhDRgreT5n39YDGIFKWzaV11lMT8Gj/cG/nVA6i6M0ZZuugiBw8UpPw1P6ccxuMFhw VcBEjXOdRVOyFnLaTYTBWH+DcI2uagnDQAjboTh83eWDEAC4C0oj/xEsjevIRgz+3r2/ GPUH8bPN2xi4SCOMnYanEQKQi/LOysDTdt+pJKD4oj/ipGCWTfZVGeQ2mf9Tuh2Kxac5 F0FVdTRHPtgqDExmEcEwcQX1IRvkBg5t1cVA9vh2teX1TJlk4fqT4mfThAr8L8Pr0Xc3 wMaUn2sQvZNLviZtFYg9ffmq79qp8gMEn+GCwCmRTjOgT37f3fSUnc7aF7TcCcR7nTkb bAXQ== 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=uI9EcizkrySobXnofDFBg58X2Si++6SOix1PDpv/Uck=; b=kx/+cdo68/dTOfUbkyT7I9q1Oic0i7TzQ5o3Oll6YyYkdVYrqSjrdo4pE+Fa5ZQ2mZ xM8bTJ/4CvxbQY8tbdKwlYXlVwdDKw/mO51StGrDThiSBuFCEaTsDh+KLoQW2m+1IaW2 9mnepjzlTXTJ61PnBthac0spd+WZd8wCBM1YmyKJ94Lx8AT39NkBUbtgK2UmZfaDpALk HxSWdTP/QVv1UgL1a2f2VWvUPHVJpvDUtHg9fBkTNwsw6f268KvtwJ59W6KyB4D8jTZc Fjd2GeBbOtDNnnZxmEqOxpbU4l2dnqlN3ClgtO87XlRmz2xCfSNi9rcVPPRNyRSjc4Xu a1bA== 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 t11-v6si179483plr.411.2018.02.21.08.06.58; Wed, 21 Feb 2018 08:07:12 -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 S932596AbeBUJkv (ORCPT + 99 others); Wed, 21 Feb 2018 04:40:51 -0500 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9]:39273 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932579AbeBUJkt (ORCPT ); Wed, 21 Feb 2018 04:40:49 -0500 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 3BD6024E1380; Wed, 21 Feb 2018 01:40:49 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 293483473; Wed, 21 Feb 2018 01:40:49 -0800 (PST) Received: from localhost.internal.synopsys.com (unknown [10.121.3.43]) by mailhost.synopsys.com (Postfix) with ESMTP id C1AF53452; Wed, 21 Feb 2018 01:40:47 -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 3/3] ARC: setup cpu possible mask according to possible-cpus dts property Date: Wed, 21 Feb 2018 12:40:27 +0300 Message-Id: <20180221094027.12674-3-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180221094027.12674-1-Eugeniy.Paltsev@synopsys.com> References: <20180221094027.12674-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 --- 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