Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4530875imu; Tue, 8 Jan 2019 01:42:14 -0800 (PST) X-Google-Smtp-Source: ALg8bN6HHLq0AZzOD19YoIGEDqsdBknL9i4z28voq5Xc3kDRe9eBgvUkaRXGbgH2y2zqejmLMf1p X-Received: by 2002:a65:5286:: with SMTP id y6mr864500pgp.439.1546940534750; Tue, 08 Jan 2019 01:42:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546940534; cv=none; d=google.com; s=arc-20160816; b=OYYwmpFtq3YF9kUUZGcjOkW4mpm8O7marKRG5IZK6K5wPHrnS7nHeJL6D+FqiyGmV+ RCpgrTFgwEsItDJ73WbVOmNUTN4tQ4W0PkJaGngDh7L2Lrl9sLjrvdtd3HPbJ9KdUr9C xFFBQdVCi7/Ku0JG5davXEHeeilVOaVehsiXxZB281Hb1SGnTXkgkosKBHrZ51by3tZa h28n0MucW56aNe5mAB3FJpXEIHDduarjVBe+rhqePo5BLWt6pZxLjaTSlMY+L42AK1Ka a3WO0sa58tn+1syN2ysCoyHdSyvKDgBcTyE/x4W7TgoGSo8l9WdP/nTb+68atapR7I1e Xaag== 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:dkim-signature; bh=69uP2KcRR1I/qiHGtLcAiDDk1prn8guJcOzCVz7CvOc=; b=i2bs4fHyFvCKxC2VmTUjfbFy1Q45a7ZD30Yjo2sBX/+WZ5IMghUY19gh0bR4tYQ78X Hi+a15syKWdnKoXoMMJAt96yZXij1Ruk5pZhWf6qsHjuJ2+9OlQ4E80SrniGzI7MGR7+ 5ztHeg4nhJtHGnZBR9r9DF4bqyggjd9Cgv9ie7kROLKQA6D9KyuaJ0W9gExVLXActura nHOAaKVXb2galUpyqO8E853c4jaStff+v4Dau4WYN20dGudkZjRFTCaEN5LDFK6xKnvY TIdsb8slOB+mapieerXsfMIZ+1PA1IYJOghudLcQIm+8zXfbBfcz87Iza9U8+sLhPjAa 8PXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=Qy0t7VHQ; 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=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i62si21274514pfc.17.2019.01.08.01.41.59; Tue, 08 Jan 2019 01:42:14 -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; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=Qy0t7VHQ; 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=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728501AbfAHJiw (ORCPT + 99 others); Tue, 8 Jan 2019 04:38:52 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:8882 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727939AbfAHJir (ORCPT ); Tue, 8 Jan 2019 04:38:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1546940326; x=1578476326; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=+kHLJqXpKvqZKIDRCZJEthrfqa0q8DvX1wCsViqCYIU=; b=Qy0t7VHQCNj9GJ/jlF6XDa+iYk3IEGlzWLjNZa9d6hltcPba/cP6U9X6 ByiHuX0eSYwjlfX60xTkizCw/Z8x7EcIGgi5fH+qnfQuXooN4qPgFHPHI IJFGR7xdu08OsZb/b4S1g/3CykTj/k8EhTjgn3H3sdfjwTw7qR+TiCDq1 Sov3oGFDPFm8A81PX+RJeOYsMVQ7a50N2HnREuWqBHOdh4tivBFs8Hiip 4L8VMYe9yFypmt6m1flgU5iSOLBGU37BKcrI86ZCAFde223dRZDH/q6oI Sc/oygr0wB2OmuH5S1xwwmSENEBhuOdFS4RVWh68PPw/F1lbApPaoql3M w==; X-IronPort-AV: E=Sophos;i="5.56,453,1539619200"; d="scan'208";a="99458402" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 08 Jan 2019 17:38:46 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 08 Jan 2019 01:18:51 -0800 Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip02.wdc.com with ESMTP; 08 Jan 2019 01:38:46 -0800 From: Atish Patra To: linux-riscv@lists.infradead.org Cc: Atish Patra , Alan Kao , Albert Ou , Andreas Schwab , Anup Patel , Daniel Lezcano , Dmitriy Cherkasov , Jason Cooper , linux-kernel@vger.kernel.org, Marc Zyngier , Michael Clark , Palmer Dabbelt , =?UTF-8?q?Patrick=20St=C3=A4hlin?= , Thomas Gleixner , Zong Li Subject: [PATCH v2 2/8] RISC-V: Move cpuid to hartid mapping to SMP. Date: Tue, 8 Jan 2019 01:38:32 -0800 Message-Id: <1546940318-9752-3-git-send-email-atish.patra@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1546940318-9752-1-git-send-email-atish.patra@wdc.com> References: <1546940318-9752-1-git-send-email-atish.patra@wdc.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, logical CPU id to physical hartid mapping is defined for both smp and non-smp configurations. This is not required as we need this only for smp configuration. The mapping function can define directly boot_cpu_hartid for non-smp use case. The reverse mapping function i.e. hartid to cpuid can be called for any valid but not booted harts. So it should return default cpu 0 only if it is a boot hartid. Signed-off-by: Atish Patra Reviewed-by: Anup Patel --- arch/riscv/include/asm/smp.h | 15 ++++++++++++--- arch/riscv/kernel/setup.c | 9 --------- arch/riscv/kernel/smp.c | 9 +++++++++ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/arch/riscv/include/asm/smp.h b/arch/riscv/include/asm/smp.h index 41aa73b4..8f30300f 100644 --- a/arch/riscv/include/asm/smp.h +++ b/arch/riscv/include/asm/smp.h @@ -22,12 +22,13 @@ /* * Mapping between linux logical cpu index and hartid. */ -extern unsigned long __cpuid_to_hartid_map[NR_CPUS]; -#define cpuid_to_hartid_map(cpu) __cpuid_to_hartid_map[cpu] +extern unsigned long boot_cpu_hartid; struct seq_file; #ifdef CONFIG_SMP +extern unsigned long __cpuid_to_hartid_map[NR_CPUS]; +#define cpuid_to_hartid_map(cpu) __cpuid_to_hartid_map[cpu] /* print IPI stats */ void show_ipi_stats(struct seq_file *p, int prec); @@ -58,7 +59,15 @@ static inline void show_ipi_stats(struct seq_file *p, int prec) static inline int riscv_hartid_to_cpuid(int hartid) { - return 0; + if (hartid == boot_cpu_hartid) + return 0; + else + return -1; +} +static inline unsigned long cpuid_to_hartid_map(int cpu) +{ + + return boot_cpu_hartid; } static inline void riscv_cpuid_to_hartid_mask(const struct cpumask *in, diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index fc8006a0..f377add4 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -61,15 +61,6 @@ EXPORT_SYMBOL(empty_zero_page); atomic_t hart_lottery; unsigned long boot_cpu_hartid; -unsigned long __cpuid_to_hartid_map[NR_CPUS] = { - [0 ... NR_CPUS-1] = INVALID_HARTID -}; - -void __init smp_setup_processor_id(void) -{ - cpuid_to_hartid_map(0) = boot_cpu_hartid; -} - #ifdef CONFIG_BLK_DEV_INITRD static void __init setup_initrd(void) { diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c index 57b1383e..e407bd4f 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -34,6 +34,15 @@ enum ipi_message_type { IPI_MAX }; +unsigned long __cpuid_to_hartid_map[NR_CPUS] = { + [0 ... NR_CPUS-1] = INVALID_HARTID +}; + +void __init smp_setup_processor_id(void) +{ + cpuid_to_hartid_map(0) = boot_cpu_hartid; +} + /* A collection of single bit ipi messages. */ static struct { unsigned long stats[IPI_MAX] ____cacheline_aligned; -- 2.7.4