From patchwork Fri Dec 22 19:08:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 852522 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PzVRxDhm"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="DhG8KLfX"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3z3J2p6q34z9s03 for ; Sat, 23 Dec 2017 06:09:06 +1100 (AEDT) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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:In-Reply-To: References:List-Owner; bh=cu1ZhehJ3o4MLRxJPrRWVsdzo/g7rHDF8X2U4h5Xmls=; b=PzV RxDhm2TJGelh0dBXP66FFBt+MqY91EXyi1oP0tW/kRq9CrlYDMrI3/uGZNl3ZRNWmGR++Q2pMUWbm eVi3XxYeXhnXZibsXVneujyoOr9oK8QGvcLvQ8fRB/uyrJ2rlhvTqJeVBRrmcQllAr87PWOA6jcw4 GqoCE69314FJt66bNKeaBZ5UVjHdBabbbNXvd/guKgmA42LA4Iz2fhRMOSTwSf9Xn0qkXhH0+fASm 1t4K3Ymc1TbIISe0SfJSGF27VslmP7Jn5wKGUuCQRpfFfHYer4YvoABmQnRjs0ndSIz3TgkSxwbXw dDo+59rVygpSXvFWeBd1JBln7qndXPw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eSSgq-0007vm-Qr; Fri, 22 Dec 2017 19:09:04 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eSSgp-0007vX-8N for linux-snps-arc@bombadil.infradead.org; Fri, 22 Dec 2017 19:09:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=s4XkxT3CU18f7uVfeU8jC77NWghvoP8m63RQo4dx+SU=; b=DhG8KLfXDTCHYIjCSyKWDGAUZ yXzEZYrmT/48VikLqWDABYnIopKLJ/Hb12aXOGD+x9oCEW+S+upwp2eelD1gzVUyKZv+GKtqBdl+Z LFsqqNUtqEhPMVdNNxcN+NwT15XeI8Fdz/6snnWO8lEZFfRMfwZ5dBf9Ns360i4dNl8dsWS9N0q8d w4BxImzmAo2IenNvgekuYpcw8SFSvLQ8Dc0gW5RklLk34vaaHU7gHbIRNkGYhYs/7MMJ1zueY6sUT hnJypPGgKkYKGGOUWBdSg1+Ij1bdgqhdMjcIhJhrpPu+RBG0d1LNNPGgVFaroWhymgtOmN44R1cru 7Fd6cK7Hw==; Received: from smtprelay.synopsys.com ([198.182.60.111]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eSSgk-0005uG-KM for linux-snps-arc@lists.infradead.org; Fri, 22 Dec 2017 19:09:01 +0000 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 2936A10C110D; Fri, 22 Dec 2017 11:08:32 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 122A49D6; Fri, 22 Dec 2017 11:08:32 -0800 (PST) Received: from localhost.internal.synopsys.com (unknown [10.121.8.106]) by mailhost.synopsys.com (Postfix) with ESMTP id 737CF9CC; Fri, 22 Dec 2017 11:08:30 -0800 (PST) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org Subject: [RFC] ARC: setup cpu possible mask according to status field in dts Date: Fri, 22 Dec 2017 22:08:28 +0300 Message-Id: <20171222190828.29162-1-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.9.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171222_190859_014546_4184BA49 X-CRM114-Status: GOOD ( 16.03 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (-1.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.60.111 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vineet Gupta , Alexey Brodkin , Eugeniy Paltsev , linux-kernel@vger.kernel.org, Rob Herring MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.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 CPUs status. On linux boot we setup cpu possible mask according to status field in each cpu node. It is generic method according to ePAPR: status - a standard property describing the state of a CPU. This property shall be present for nodes representing CPUs in a symmetric multiprocessing (SMP) configuration. For a CPU node the meaning of the "okay" and "disabled" values are as follows: "okay" - The CPU is running; "disabled" - The CPU is in a quiescent state." Also we setup MCIP debug mask according cpu possible mask. Signed-off-by: Eugeniy Paltsev --- arch/arc/kernel/mcip.c | 10 ++++++++-- arch/arc/kernel/smp.c | 30 ++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/arch/arc/kernel/mcip.c b/arch/arc/kernel/mcip.c index f61a52b..246481d 100644 --- a/arch/arc/kernel/mcip.c +++ b/arch/arc/kernel/mcip.c @@ -89,6 +89,8 @@ static void mcip_ipi_clear(int irq) static void mcip_probe_n_setup(void) { struct mcip_bcr mp; + u32 mcip_mask = 0; + int i; READ_BCR(ARC_REG_MCIP_BCR, mp); @@ -102,9 +104,13 @@ static void mcip_probe_n_setup(void) cpuinfo_arc700[0].extn.gfrc = mp.gfrc; + for (i = 0; i < NR_CPUS; i++) + if (cpu_possible(i)) + mcip_mask |= BIT(i); + if (mp.dbg) { - __mcip_cmd_data(CMD_DEBUG_SET_SELECT, 0, 0xf); - __mcip_cmd_data(CMD_DEBUG_SET_MASK, 0xf, 0xf); + __mcip_cmd_data(CMD_DEBUG_SET_SELECT, 0, mcip_mask); + __mcip_cmd_data(CMD_DEBUG_SET_MASK, 0xf, mcip_mask); } } diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c index efe8b42..ee8b20a 100644 --- a/arch/arc/kernel/smp.c +++ b/arch/arc/kernel/smp.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include @@ -47,6 +49,29 @@ void __init smp_prepare_boot_cpu(void) { } +/* Mark cpu as possible if cpu status is "okay" or status absents */ +void __init smp_init_cpumask(void) +{ + const struct fdt_property *prop; + char fdt_cpu_path[25]; + unsigned int i, oft; + + for (i = 0; i < NR_CPUS; i++) { + sprintf(fdt_cpu_path, "/cpus/cpu@%u", i); + oft = fdt_path_offset(initial_boot_params, fdt_cpu_path); + prop = fdt_get_property(initial_boot_params, oft, "status", NULL); + + /* No status property == status OK */ + if (!prop) { + set_cpu_possible(i, true); + continue; + } + + if (!strcmp("okay", prop->data)) + set_cpu_possible(i, true); + } +} + /* * Called from setup_arch() before calling setup_processor() * @@ -58,10 +83,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); + smp_init_cpumask(); if (plat_smp_ops.init_early_smp) plat_smp_ops.init_early_smp();