Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp1815634imc; Fri, 22 Feb 2019 11:43:27 -0800 (PST) X-Google-Smtp-Source: AHgI3IYdwgma/Z4MjglIP7ltHTXfTMPZROAKzzd1Y/6zSNkTqLmTOJ9sADozmd9iv9btlQbkWNw2 X-Received: by 2002:a62:41cc:: with SMTP id g73mr5719107pfd.145.1550864607053; Fri, 22 Feb 2019 11:43:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550864607; cv=none; d=google.com; s=arc-20160816; b=B+fwmg/OXoyxX0bxdQA6AEH1WYsQ+wa9PDUIoeSR2lNVl4MH/SMB8xX1oMr69DcyHq wcPDgwfe7uuH3xyHHNctsQbyFkUTfMcDXL6yfP+VUnZNsF8raC8ajoUpzyrabMmjDxes 513XW2Wr9IOe0StBKEhqGH8470s18kbOemaaGJADXpAchI1sekfwEofe1OEtmWJDOnGA ySTndemnWbuse165d0Y0Zo/Y57fHBT4iMeDAx8Y+8V7B/InMtJjeUuv4IszmYXnAibfh IbmgGvLC2637IJWr2PEKqM14Mu/vnk9pnCjvJNYJSW89Ui5a3bLjzWNccZ7vu6TFe3lH otwQ== 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=ON4ytKglFn8TgzkFJMwcUWFjkunc56wFj65BEoiQPVWU0Ucj40ne6SE9E3mNrG4klL xqni+mCM9e69sUV83igHLkX8e6DDvjV3Zn2v6LMy922ihjHAR2t0H0GTmKRnw3bcUzPz sN+btHUO2zavQ7oYgUuWDH5mEZz7+7ss1o/GwntaEh9kI2JpPx8nL7WmmSFq68YdeWQD IM+7LiqH5Ms0xs6fMiPPW3MLJ7CPvIxqvlP4kptJsRE1kM+THuqMg3/xLhRhmViCZBst H/VrEuJ5s49V7NYhb73gWmaai9BvwQB6Fta4x4AXyiH3CfG74H2PRIdp5c8ABC1bXdAz 60oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=E0caRJeq; 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 j16si2138004pgk.441.2019.02.22.11.43.11; Fri, 22 Feb 2019 11:43:27 -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=E0caRJeq; 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 S1726736AbfBVTlp (ORCPT + 99 others); Fri, 22 Feb 2019 14:41:45 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:9380 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725832AbfBVTlo (ORCPT ); Fri, 22 Feb 2019 14:41:44 -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=1550864505; x=1582400505; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=h2fKv5100GvHj+ysLhrtvyrBQOE+5MV8IiW0LUcjPlE=; b=E0caRJeqzgghi2Jr5SK1gvH7wz2bv+HuTo0LyxMhxJgnTDYexZT5nPvk H3xOlbmzzcCebAbJvYiT2MNwsArwtIyiUcMRgA2te/+Aek+RMTqCZg7Pr YhuIv7KOdbR9qhoj39YsWCpTU8Kb2MEtR3hZu9M4V2qr3EPgkqputqWNv e05EVtXUQQdEEZl4HbhBfqYBhO7SLxilL4t5DeTWluCQMRD3J7VDdcj3v mP0O0wPc8CcLHWv2IyZlfxjStOCJecwkR1X+1cYzeRWha8GCDuS9jHLDg bqrASH9KrCPM478TzWW0YufctJjiNyoA6H8heMMxp73OHgjd2eWeCX3wY w==; X-IronPort-AV: E=Sophos;i="5.58,400,1544457600"; d="scan'208";a="103727135" 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; 23 Feb 2019 03:41:45 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 22 Feb 2019 11:22:03 -0800 Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip01.wdc.com with ESMTP; 22 Feb 2019 11:41:44 -0800 From: Atish Patra To: linux-riscv@lists.infradead.org Cc: Atish Patra , Alan Kao , Albert Ou , Andreas Schwab , Anup Patel , Dmitriy Cherkasov , Johan Hovold , linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Thomas Gleixner Subject: [v6 PATCH 2/6] RISC-V: Move cpuid to hartid mapping to SMP. Date: Fri, 22 Feb 2019 11:41:36 -0800 Message-Id: <1550864500-13652-3-git-send-email-atish.patra@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550864500-13652-1-git-send-email-atish.patra@wdc.com> References: <1550864500-13652-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