Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2332751imm; Mon, 28 May 2018 06:13:52 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo0Gh/Sjbe/OUjW+pCjLGy81WYxFmyuL4v7M2eBj2L7PqDP1B+eeZCu3E8lmdzdAjOY3NNS X-Received: by 2002:a62:8d51:: with SMTP id z78-v6mr13448799pfd.69.1527513232482; Mon, 28 May 2018 06:13:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527513232; cv=none; d=google.com; s=arc-20160816; b=tHeQ5djDRETiGDiQiraqvO3nZWTdYOO2wBizQwkf0S8nkeLsJnLaTwQwUz5EdqIlLZ 0lBJ57P5tMbZejjSagLp5hjrV0ZCU4xR7pXGkmXhO7NKUXFsx5kTE+SCnhPcujK17PTW uhSoYVdUnLtnfPl6wWtV7FkDjPZo7rGaxn1nsWPkl+X8jJfFfzvY9Nc+WhEJfQ2GQ6mT rQsf1g7XUuy3zyjYjDJe4NDI2weNYBLjmyp8sF2IlWUmsx9TrE1Sw2mAjeD5eZfgZaDA pty0ClYbAo658C6BNv2FE32uZzdssN7xP6YTEZ576jvrLkFWSVMUtLxbUrDDdXZpsXkl CWdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=bGNJhujy932DhSqpCZe6H7nyGacvK5KA9qvrTHPJEW8=; b=aCkqCNFIbOl7xYvtjdcG7Nr7q305twPE7KSH9AtoDHTMVTc2ydNzwxOxdklcAJgvgn QmAM+Bi5B2rEIt2OgyoRt2OtWb4ekKxnpcK6QWeV0RIoTwGDaY+i8iuNzQwcgjj3rF5S LrMGCkP332TZOvFz+m34qD8l1kKqLf0cMs9GkvDvKr7JQnekPplcZivZX8xXYjimO/zn naNy3vORjqS2I8ptLu/zX/tInKw3d8JdYki+TMrOrulJXVA8tRYFH37plKfq8NAK9lL+ kryGA21fVjYtp6fRXgc2T3WLDgKQBAE4Or00TwEW2iBASHUw9DYR4TowfI+yYZ/TyC8F qlAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=R3F7097E; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d75-v6si16695798pga.322.2018.05.28.06.13.38; Mon, 28 May 2018 06:13:52 -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=@kernel.org header.s=default header.b=R3F7097E; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163733AbeE1Kus (ORCPT + 99 others); Mon, 28 May 2018 06:50:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:40232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163473AbeE1Kun (ORCPT ); Mon, 28 May 2018 06:50:43 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 37261204EE; Mon, 28 May 2018 10:50:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527504642; bh=eLiie7W6HDQFs/aah3cf8/eES0o69Nd0HT/BQ48R9+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R3F7097Eb7eL8WTvpFY+baNaRSNhUKUiBmnJI+W+eRXCcmj2Mb3jYIYOIzoFARHjT J/8QPLDZiEYseGDMyceID8l9coiIsHc45qffSuP3XHqyrAARaWVBj2C20C7MMZS53A bFuBtTzDBUVmaPvVzn8SO1dusmlAM5Wq/4aO2moI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eugeniy Paltsev , Vineet Gupta , Sasha Levin Subject: [PATCH 4.14 180/496] ARC: setup cpu possible mask according to possible-cpus dts property Date: Mon, 28 May 2018 11:59:25 +0200 Message-Id: <20180528100327.528488760@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eugeniy Paltsev [ Upstream commit a29a25275452c97fe35815f1eb9564f2a07a1965 ] 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 Signed-off-by: Vineet Gupta Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/arc/kernel/smp.c | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) --- 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)