From patchwork Wed Feb 21 09:40:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 876023 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=2607:7c80:54:e::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="lGLDv4Zp"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="ZYnMDJhz"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::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 3zmYvc47Mmz9ryJ for ; Wed, 21 Feb 2018 21:42:04 +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=qtuZ7T0TAnd0b3pjHd7HmnhQXZN81LuDm/cBLokgUWU=; b=lGL Dv4ZpT0vgA4anHjb4JIq4ek1xDJsdGCmiNycD0lGQiC1Tct1mV0kNnE7LW6es5/sMBpvu3+11aVjx L2qbIb0q6P1T0lVLmLmc/g8m7GZyBFzRnRKz26hyV2Gx1EB9h08Vf4J/4tTZ2CHeC7TuKYsOkcdko BNUvHajfx3f1tO0oZ3u9EMr700b6pJmbCDHHDgs/UPcgOhIW5b3JpjAxZ/BKCz+dMdE5Qh1dmn9qB Gx13zB+ldgag2rFGIhGhw6+p2NbbzDa+3K3m7VaFIl0Rcx/reygsC1c5DHYxkHfy3MOCJcKLlNrtP XsgAabFpMFjVqkrbtjiE1tbviITncFw==; 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 1eoRqZ-0002Fu-DT; Wed, 21 Feb 2018 10:41:59 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eoRqE-000258-LR for linux-snps-arc@bombadil.infradead.org; Wed, 21 Feb 2018 10:41:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=DLL5bHmfRtD8a71kDx8KDrJnqu8+0bKqYyCbngcgkmk=; b=ZYnMDJhzHMxPP/s9Wqbt6ZfI7 B6QL2ot9/0nsd9j+qDu+zvvg7C8MQmbFGsClS55CQMPhP82P9axh9RNPja6k8UD6OV0nKiAZK5c8C a7vOxbTONOLnqHtbWCOWmjcjoZgckHgRp0B8m9ClTu9UqS6xVdeolu8s7a2LDVEegagDvGFS5pYFe vbP+T0vz6FUU5bOYH6bXRLAAugiOunt4tmytOxt7CnPi1IxgOkj/aJjX0+1Qcrh9u2tfu6i7Inod/ fz/l1p3X/YMhpaD9uhTJrB7IHQvqaUfqNEvcUFU59fM8tqXSYcYOaQv9k7yTGcVL2uk2xvMHgXGlL 0ShZTDS/Q==; Received: from smtprelay2.synopsys.com ([198.182.60.111] helo=smtprelay.synopsys.com) by merlin.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eoQtX-00070o-4z for linux-snps-arc@lists.infradead.org; Wed, 21 Feb 2018 09:41:00 +0000 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 70AAC10C10D2; Wed, 21 Feb 2018 01:40:43 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 5D5383411; Wed, 21 Feb 2018 01:40:43 -0800 (PST) Received: from localhost.internal.synopsys.com (unknown [10.121.3.43]) by mailhost.synopsys.com (Postfix) with ESMTP id 034FB3409; Wed, 21 Feb 2018 01:40:41 -0800 (PST) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org Subject: [PATCH 1/3] ARC: mcip: halt GFRC together with ARC cores Date: Wed, 21 Feb 2018 12:40:25 +0300 Message-Id: <20180221094027.12674-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-20180221_044059_265280_B442FC71 X-CRM114-Status: GOOD ( 10.48 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-1.9 points) 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 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [198.182.60.111 listed in wl.mailspike.net] -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] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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 MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Currently GFRC is running regardless state of ARC cores in the SMP cluster. That means even if ARC cores are halted when doing JTAG debugging GFRC [our source of wall-time] continues to run giving us unexpected warnings once we allow ARC cores to run due to some tasks being stuck for too long. Starting from ARC HS v3.0 it's possible to tie GFRC to state of up-to 4 ARC cores with help of GFRC's CORE register where we set a mask for cores which state we need to rely on. Signed-off-by: Eugeniy Paltsev Signed-off-by: Alexey Brodkin --- NOTE: with this patch previous patch is not required: http://patchwork.ozlabs.org/patch/875091/ arch/arc/kernel/mcip.c | 23 +++++++++++++++++++++++ include/soc/arc/mcip.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/arch/arc/kernel/mcip.c b/arch/arc/kernel/mcip.c index f61a52b..e87a4ea 100644 --- a/arch/arc/kernel/mcip.c +++ b/arch/arc/kernel/mcip.c @@ -22,10 +22,33 @@ static DEFINE_RAW_SPINLOCK(mcip_lock); static char smp_cpuinfo_buf[128]; +/* + * Set mask to halt GFRC if any online core in SMP cluster is halted. + * Only works for ARC HS v3.0+, on earlier versions has no effect. + */ +static void mcip_update_gfrc_halt_mask(int cpu) +{ + struct mcip_bcr mp; + u32 gfrc_halt_mask; + + READ_BCR(ARC_REG_MCIP_BCR, mp); + + if (!mp.gfrc) + return; + + __mcip_cmd(CMD_GFRC_READ_CORE, 0); + gfrc_halt_mask = read_aux_reg(ARC_REG_MCIP_READBACK); + gfrc_halt_mask |= BIT(cpu); + __mcip_cmd_data(CMD_GFRC_SET_CORE, 0, gfrc_halt_mask); +} + static void mcip_setup_per_cpu(int cpu) { smp_ipi_irq_setup(cpu, IPI_IRQ); smp_ipi_irq_setup(cpu, SOFTIRQ_IRQ); + + /* Update GFRC halt mask as new CPU came online */ + mcip_update_gfrc_halt_mask(cpu); } static void mcip_ipi_send(int cpu) diff --git a/include/soc/arc/mcip.h b/include/soc/arc/mcip.h index c2d1b15..a156fa5 100644 --- a/include/soc/arc/mcip.h +++ b/include/soc/arc/mcip.h @@ -40,6 +40,8 @@ struct mcip_cmd { #define CMD_GFRC_READ_LO 0x42 #define CMD_GFRC_READ_HI 0x43 +#define CMD_GFRC_SET_CORE 0x47 +#define CMD_GFRC_READ_CORE 0x48 #define CMD_IDU_ENABLE 0x71 #define CMD_IDU_DISABLE 0x72 From patchwork Wed Feb 21 09:40:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 876024 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=2607:7c80:54:e::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="X30adMEE"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="q52WTUIB"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::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 3zmYvf1Dgsz9ryl for ; Wed, 21 Feb 2018 21:42: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:References: In-Reply-To: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:List-Owner; bh=wLsPmtj3vAn5dRwVtAFzwOXH3P2mp0NC69vXcTkJ4kQ=; b=X30adMEEVYID4tUTifZEy0QX56 H+21S1T6Uq+wnBMXRNPEwFWvWoz99Pw66pBaO9RpgDI8NkPJUlhwJEqjGS6Yr9v3pKF4S5NZanw2H ItsXveK9YeIhSTaLesz+FLGRNWrYf54D8/mbQHWn5FE1aQ10vNKDDMC46Y+C8rKLnkZGLdWKA7zcF bCs6A+v9UaaARDuiYm8ofRJV98abo72tibZyHHy/L3qjFBjriWnER1FhoZG7LiMXZdWYNhEtb5mpt lF+3rwLrlcnCv1LUfHVZfq0A7UVpQswnxX396EoF9t06YEpQHv5u2NaZOqCo65WO+llHUHJYyPaqr ak6IMfQQ==; 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 1eoRqa-0002GV-DB; Wed, 21 Feb 2018 10:42:00 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eoRqG-000258-5C for linux-snps-arc@bombadil.infradead.org; Wed, 21 Feb 2018 10:41:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To: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:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ioC9EylXNFgVt6edcI4+mJP/6jlhE+dzyaeQLyF21vw=; b=q52WTUIByM9GymJrQ6EMuPyWs bvDZaNnW1hrvgD+q3TSO+nlj/+CzZHjDYAbbzKduIv2XHzYV7WnuWDOjraHjU77YCm8ocK4MdShMb PzMdiDvPNfe1uQfg45LVssadSDJViNoCDMsGcSjkdowP/QiWU3WTzifN+tdcecsNC2VwtrNkErJCW tumwt3iSSlG+5thSsSz+ijHbwqyVZhHkSl+oxhg6lmVSOK3J5/UoJXZHFWBjbOdX5TtYEbkz4pDIu ZfOOLORfjRXJRCdcGepaoRtZQN+GHqx6haUS+oWTyknv7GrfSWaHiW5Ke5RLrFS9LjZaUO8s2JZRv YhHh8kHpw==; Received: from smtprelay.synopsys.com ([198.182.47.9]) by merlin.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eoQtX-00070q-9H for linux-snps-arc@lists.infradead.org; Wed, 21 Feb 2018 09:41:00 +0000 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 670E624E135A; Wed, 21 Feb 2018 01:40:46 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 53A80342B; Wed, 21 Feb 2018 01:40:46 -0800 (PST) Received: from localhost.internal.synopsys.com (unknown [10.121.3.43]) by mailhost.synopsys.com (Postfix) with ESMTP id E0F35341E; Wed, 21 Feb 2018 01:40:44 -0800 (PST) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org Subject: [PATCH 2/3] ARC: mcip: setup MCIP debug mask according to cpu possible mask Date: Wed, 21 Feb 2018 12:40:26 +0300 Message-Id: <20180221094027.12674-2-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180221_044059_406415_6F8B5CB4 X-CRM114-Status: UNSURE ( 7.00 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.47.9 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [198.182.47.9 listed in wl.mailspike.net] -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] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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 MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Setup MCIP debug mask according cpu possible mask instead of use hardcoded one. Signed-off-by: Eugeniy Paltsev --- arch/arc/kernel/mcip.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/arc/kernel/mcip.c b/arch/arc/kernel/mcip.c index e87a4ea..da73258 100644 --- a/arch/arc/kernel/mcip.c +++ b/arch/arc/kernel/mcip.c @@ -112,6 +112,7 @@ static void mcip_ipi_clear(int irq) static void mcip_probe_n_setup(void) { struct mcip_bcr mp; + u32 i, mcip_mask = 0; READ_BCR(ARC_REG_MCIP_BCR, mp); @@ -126,8 +127,16 @@ static void mcip_probe_n_setup(void) cpuinfo_arc700[0].extn.gfrc = mp.gfrc; if (mp.dbg) { - __mcip_cmd_data(CMD_DEBUG_SET_SELECT, 0, 0xf); - __mcip_cmd_data(CMD_DEBUG_SET_MASK, 0xf, 0xf); + for_each_possible_cpu(i) + mcip_mask |= BIT(i); + + __mcip_cmd_data(CMD_DEBUG_SET_SELECT, 0, mcip_mask); + /* + * Parameter specified halt cause: + * STATUS32[H]/actionpoint/breakpoint/self-halt + * We choose all of them (0xF). + */ + __mcip_cmd_data(CMD_DEBUG_SET_MASK, 0xF, mcip_mask); } } From patchwork Wed Feb 21 09:40:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 876007 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=2607:7c80:54:e::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="VM1xk3du"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="Uf9gzcTF"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::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 3zmXjh2kYMz9s7T for ; Wed, 21 Feb 2018 20:48:24 +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:References: In-Reply-To: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:List-Owner; bh=Aotxpqz9y31KvMb7oC5j2mkJQ0lDcHNPGRdyhGvKRdw=; b=VM1xk3du6NIPwphBPd2VzKVM5g rdrFCLrlVUeQE7cpJDVP7i9CxoTmes04aAFF8oBkW2ZMUA7VIts5ebUdFR7boJBmSLjRmY8Ci73mT VOUWTl4fLVw8CGao9pgjAkhv8kO/R7wCgT2XHaKLrMoIj3N3E8FGZtFUlM0CUaWo5hhJwOkSXDfjm d5a+czaXIZMHkvI9hc3teMwlBSWax2YCqiaT9savXoetHKQP1b1JHPTBoCYe2ItR4N9vH+We/9e8e loXazKEjTshM7y3Tzl50stH7wZZKkgrMQFgC0HRVnO5D7y+2l+AF3Uv5VUv0pNzRlfRM5nWZDcINX obraLuKA==; 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 1eoR0f-00051Q-RE; Wed, 21 Feb 2018 09:48:22 +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 1eoR0e-0004xm-4u for linux-snps-arc@bombadil.infradead.org; Wed, 21 Feb 2018 09:48:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To: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:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=uI9EcizkrySobXnofDFBg58X2Si++6SOix1PDpv/Uck=; b=Uf9gzcTFgEaStusfvlrbkCLat O+khv7fPzjcCnOMQnNbhImFjvw37HxkI0D0XFWBZQh6WDTbsRKguklXv0UZpDDlb1cjBeTGroBLxh fAEnI0f7xzygBwfA8CKyXRgYfrC4/yTFz64IvmR9OQwHERdUfHepmInnx6+cq5qSJK2Q10Phi6tWX 7+x3dlNx/3HAIGNfVUxaeF5FaqbpW0CPnlnHvrovglmeMkOGJoKjdTLVCQC1SSFwm00bB0QwGagv3 86t6qjC+Ftr42pBrjnFPobqK06hoCy4xIgEo08uuJfTVKcFEz+zO+ymTtItsEsrgIYVJ/3cqvfXPw Esy9B5fqA==; Received: from smtprelay.synopsys.com ([198.182.47.9]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eoQtf-0003de-8q for linux-snps-arc@lists.infradead.org; Wed, 21 Feb 2018 09:41:09 +0000 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180221_094107_442004_3037357B X-CRM114-Status: GOOD ( 14.89 ) 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.47.9 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] -0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [198.182.47.9 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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 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 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)