Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6097478imu; Wed, 26 Dec 2018 15:10:44 -0800 (PST) X-Google-Smtp-Source: ALg8bN5VARPWazS48y75ONM/f+NmT7WzoaYScjZUCYsf/DVFZC1NM++CrwHkui54TCIO37ZymFYd X-Received: by 2002:a17:902:43e4:: with SMTP id j91mr21036413pld.147.1545865844403; Wed, 26 Dec 2018 15:10:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545865844; cv=none; d=google.com; s=arc-20160816; b=0QEfO6i7aD5mT9Q0DcY60frYdWIIoookskrbeCOC3FpXzT1bB+MSdbf0AzhywQ2Z0R zqGhLShFs44MBdE8HMcAXi5pHw8Bp5MsRD84Pw+LecT+3CcydSSAYu6OQeirJnVAxZ5B /ZaBZlT6/iGWRaqTkKgctWcWN6WlXLeByj6Tpq4jfNcAsOXd0Kr0mhkt7513bHRdRQGS Ikr2nsIPhd+NT1AEdHvZHY0goGP933CjIbMy7AyFzzmQ5DLGXbgHrqzgLzgVFc9uvJ9q cLQVwc+47e0BWyGZoq4I6Pjr9FbmodYV/QPI9X70smJG+PaiRWVsje7r8g62PadYEX0X 9i1Q== 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=tJ2Oh6aZWRa0Q1BfSawGNF8D5+xSDQr4X98UVFjPJTU=; b=Hxb7ZGl9XfaHJ2zNdRfOhf8WP4FN2tz5o0DcKVQYduaZjsvA9gL2iCOmCCnSVXZm2F 8UOtsdi2JNyQN+UozKPjxEQKWIh8PNaM4AHe5+FNLg5665JQrc+MPSo3zVDE4olvonmu zfvfGSmjc6mFlEV09iCqTqZPozZfsaIkSoE5g8lM4Mz3SnTnydjis4Q62qECxmEXF8VC HNW2SLVObendFj74WX/cc1hP4cajl0hd5Z6Y7ziYgUmm5DEUjR6YLV0nlVGDyWzW4zCJ tb62BNmlo6wzSbQQTi+1bClAVg1OqZZIXxmpFsCe2RLhjrANTpx93FAExpf6NFBoKz4F +7Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=F7wd+7JA; 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 c6si33210403plr.414.2018.12.26.15.10.29; Wed, 26 Dec 2018 15:10:44 -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=F7wd+7JA; 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 S1728203AbeLZXJY (ORCPT + 99 others); Wed, 26 Dec 2018 18:09:24 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:20034 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727770AbeLZXJV (ORCPT ); Wed, 26 Dec 2018 18:09:21 -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=1545865762; x=1577401762; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=meu8IE2Cb35XRAORiR9qLyyfGNjZhzm1rUp8PRNo5pE=; b=F7wd+7JAp93SOLAthSRi23ujC4mGscwvU8IccENO9xkEp85PLe6i0J0y 0YCNlB/S3YxUQZwsAm7r2ZkRZU9yVmVQc3EfyYgK+nLlJb+Z+kCV0G6AP 7FUvS5bp09ciu5MpJQ6Vc7ktqfgY2Mu9sgw25A4JIGAZgufYf5K9HPTnu Q52qjlU3ovglu7DJfRx1gfo1gU+aw4TFyGYKkdPrzcRpoyr7ZObj40dHE ojj1iPlle8Pw4zZInBaXJqRSn0MfbqRnVouI77z53MftDazSqZt5mPHir VB+sfMMjLeR8z+whlzW+5NwWCMRQCxZ/QEaLZqZYgRna5JzL1I7LFh6// Q==; X-IronPort-AV: E=Sophos;i="5.56,401,1539619200"; d="scan'208";a="98702979" 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; 27 Dec 2018 07:09:07 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 26 Dec 2018 14:49: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; 26 Dec 2018 15:09:07 -0800 From: Atish Patra To: linux-riscv@lists.infradead.org Cc: Atish Patra , Albert Ou , 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?= , Rob Herring , Thomas Gleixner , Damien Le Moal Subject: [PATCH 2/3] RISC-V: Move cpuid to hartid mapping to SMP. Date: Wed, 26 Dec 2018 15:09:00 -0800 Message-Id: <1545865741-22795-3-git-send-email-atish.patra@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545865741-22795-1-git-send-email-atish.patra@wdc.com> References: <1545865741-22795-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 usecase. 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 --- arch/riscv/include/asm/smp.h | 13 +++++++++++-- arch/riscv/kernel/setup.c | 2 ++ 2 files changed, 13 insertions(+), 2 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) { + 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 2c290e6a..bd4d7b85 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -83,6 +83,7 @@ EXPORT_SYMBOL(empty_zero_page); atomic_t hart_lottery; unsigned long boot_cpu_hartid; +#ifdef CONFIG_SMP unsigned long __cpuid_to_hartid_map[NR_CPUS] = { [0 ... NR_CPUS-1] = INVALID_HARTID }; @@ -91,6 +92,7 @@ void __init smp_setup_processor_id(void) { cpuid_to_hartid_map(0) = boot_cpu_hartid; } +#endif #ifdef CONFIG_BLK_DEV_INITRD static void __init setup_initrd(void) -- 2.7.4