Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3713110imj; Tue, 12 Feb 2019 03:28:06 -0800 (PST) X-Google-Smtp-Source: AHgI3IYjQXM7ykIqKl9DbnHfgCTTMfwM1ADbmOPIKO50us+B1M/BfeFY2gWbO41d1vWwZZHTxhb2 X-Received: by 2002:a17:902:9683:: with SMTP id n3mr3562325plp.333.1549970886558; Tue, 12 Feb 2019 03:28:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549970886; cv=none; d=google.com; s=arc-20160816; b=VmKaRtczYk4pytJfFgAp5GS3f9O/OUoFop7G8yX/RJoXYKh9XUesXGT84EBuLazuH3 g9xmBPpYJW0G/qekZue/X8rjcE31ODRYpgWFOli/g2r8aTbDgehrbKvYyidc2ZOBwvfn xmcGR/Fe3ZKfINl4/Rq1W3hrN+gXbxyYLCa49XJXeHFUJDLXOcNT52lGUx4A2FHUuZAz KGLRtbOSp22UQwk3g02nb6RBPuZfDSQIVjINUpCpC/0NxpPAEBZhcVqDq9Day+fwsroJ m3l3uUHyjDWgyvv/XiK2+CScNXSr48aXC+uXHWE/fyEviTnNcMEPtOKHXAQJp989bn0K NXDw== 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=SZUGZIlV5l/Evm30wRau416TROSNpD9AGoNvpViboWs=; b=eFEWHHe4whCqRtKXS1tZaIxkpx9QkHfE9caJ0E1f2lebJyTzrfjq6Q+cBAMNHiv7qp /+8RIiy/U4uWGIJ9S9r24qTvbrzYYrnpfr+GdhoUyrNy6paelUbaC6+XDi3luXmcEghT G+BdlKEa+Neak4bM1hQRcXT7tbftKYiZOscsSRf5CP9hbYaJbZaHHO23or4jEf5RcSTT Rv/5XEW9EHpbijVyF5XZF8UuSYEc6fNyw/dLuJI+Fk1a3soFHvLy2dsdr+AcryiMODgh CknHAryFYKbcU2LambOglkyPgyEzHNtE6X/KpvcBa5KsA0uHbVTwNJ9eP7t3EEWq9WEE H42Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=cST1RwLo; 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 127si12579834pfg.173.2019.02.12.03.27.51; Tue, 12 Feb 2019 03:28:06 -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=cST1RwLo; 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 S1729390AbfBLLLA (ORCPT + 99 others); Tue, 12 Feb 2019 06:11:00 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:42874 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729251AbfBLLKd (ORCPT ); Tue, 12 Feb 2019 06:10:33 -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=1549969889; x=1581505889; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=h2fKv5100GvHj+ysLhrtvyrBQOE+5MV8IiW0LUcjPlE=; b=cST1RwLoGm3++Dtf9ojBkwOSgeNpjpnWeM8DANiAlWPdKJYIFfmHKuBN SsQUHxGpkuhXZ7Isr+YtCSk8yE15JObzoo/9s8Pp5clFXYaIj/xZ9C01G /SnJorimdzBe00XwM7wgJbOxUhPaZ24owqYrcXH64rS+qFtqLidPqpADr nYfj/nPpHv60C5ZgHBcuer+6DPUtoFVpLStQYg++yZSFrtzjHMt7BtSA7 4XkBliKaxklmwmAcfitgio2UHQnr62OcBz+X64cX4TLu6s2bVmZD6rXIm t2wfOzbAZyt5ksrgVyOeg9B26V7FyaIcPYCxK2HGEU0qDCtydaBCbWybz A==; X-IronPort-AV: E=Sophos;i="5.58,361,1544457600"; d="scan'208";a="199201828" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 12 Feb 2019 19:11:10 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 12 Feb 2019 02:50:57 -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; 12 Feb 2019 03:10:21 -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 , Johan Hovold , linux-kernel@vger.kernel.org, Marc Zyngier , Palmer Dabbelt , Paul Walmsley , Rob Herring , Thomas Gleixner Subject: [v4 PATCH 2/8] RISC-V: Move cpuid to hartid mapping to SMP. Date: Tue, 12 Feb 2019 03:10:06 -0800 Message-Id: <1549969812-22502-3-git-send-email-atish.patra@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549969812-22502-1-git-send-email-atish.patra@wdc.com> References: <1549969812-22502-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 Reviewed-by: Christoph Hellwig --- arch/riscv/include/asm/smp.h | 18 +++++++++++++----- arch/riscv/kernel/setup.c | 9 --------- arch/riscv/kernel/smp.c | 9 +++++++++ 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/arch/riscv/include/asm/smp.h b/arch/riscv/include/asm/smp.h index 41aa73b4..636a934f 100644 --- a/arch/riscv/include/asm/smp.h +++ b/arch/riscv/include/asm/smp.h @@ -19,16 +19,17 @@ #include #define INVALID_HARTID ULONG_MAX + +struct seq_file; +extern unsigned long boot_cpu_hartid; + +#ifdef CONFIG_SMP /* * 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] -struct seq_file; - -#ifdef CONFIG_SMP - /* print IPI stats */ void show_ipi_stats(struct seq_file *p, int prec); @@ -58,7 +59,14 @@ 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; + + 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 fb09e013..61c81616 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 246635ea..b69883c6 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -36,6 +36,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