Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2210333imu; Sat, 5 Jan 2019 18:15:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vp4/XwqPDbjeSQ4AtrS5ha45PjIuko8s9/104QlJgyLCkm3nEOZEKymgb5YWIuYUr4LaFh X-Received: by 2002:a62:4886:: with SMTP id q6mr59681022pfi.182.1546740950094; Sat, 05 Jan 2019 18:15:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546740950; cv=none; d=google.com; s=arc-20160816; b=e0/3MGtK64IJkER6V322xRWcjHNVnjGd1ML9UNKCKiyhxP0aCDMkOyMmH3mEWQuwle fmstzoOVNIujbdDGbIpnmgcBxw3ennj8UjxEp+Zc9Qq1eVzk/MEq6yCbXs2gRS7fSZC5 Jp+aWv4jOpj87mfaHJyf6mgZdrvQsvMd51viKwN5DkLccYJLyIcvUwxZ56TS2vRpx2WO wZRrQ0umYQoON/zsTbrRhVQwUegZkSHpZIoBXcdeEWsqAQI33VGh88GgVg5zzDvZFIct Mbh2MZRdDGdbyARPEpyk0WCCfyMIAcegRmhAD15aU6glDFl3ZWyY/shVrNWTRyOtXhsf 6txQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=WWiSDRzKD2AzKChiOb7T/MpDn4NVstPT5LhBz9aKqe4=; b=PaD4n0ylsrBVct716ObH5ZqGg6m+blC1S41qbkBhZXRhxhg9C7v+Q7NfqLI3jQw1++ 3c6wSLqaBR9HX+DItL6YMVC2AbDFfP9hSCLZIu5tFjsVLhlLYtt+5YcLpuFl7rPlYGVM T8FGRdF0aneXDQw8gukLVSjf0/7VyUuwqgKZSDs04nqkdo1OKkF8XXjZzKrgyEDTkwgy R1Zq6C+UI8X+iYjGml+7fkCCiBTESadCSzC3HNVZPXjq84pzUfrYFw94t1Nhofl7DXFo hSsr6LQtOynyy3kypV7skc2Q2VCXBFO++PFhQ79SYjbIxiDKT7YfvpRqDvtEVmur0+67 xx6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=iTeBba9q; 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 1si7587675plp.114.2019.01.05.18.15.24; Sat, 05 Jan 2019 18:15:50 -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=iTeBba9q; 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 S1726389AbfAFCNe (ORCPT + 99 others); Sat, 5 Jan 2019 21:13:34 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:34701 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726368AbfAFCNd (ORCPT ); Sat, 5 Jan 2019 21:13: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=1546740813; x=1578276813; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=o2HBpe4wq5YXplrB4SjcP/RF2pycF8MBcWWFBeXrrOk=; b=iTeBba9qTNqLDFQ+osZpufJGJ4HdJaBIxbQpwhfm6tdd60t8BSBFf3oO jjYfXjX+AYUiU14djLYngt4/GvvrHwitbK6kVkRlOAVP38W171eSHptC8 ZK33gk9R+HNs2z65/Nh9LVjSD3wc8aMdlS3J2DgAOvRYMTy8L+BzgUJCE vZv6JfkPhAJ8WbD+2BeNW9LOZhu46ecHK1LgevfhaFM5CymSBJOa22CXF GAUDYcACyPI6Jk4w6L6hv7yWX/k8VPHgaahBw5Lk7fIcj7El/5dPb44Q6 Ebg/MYbd5dkAza02uqqdlSErZ25OKX/d3DJ1a1S6415aKkvYe4uSW7HVP A==; X-IronPort-AV: E=Sophos;i="5.56,445,1539619200"; d="scan'208";a="99279234" 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; 06 Jan 2019 10:13:33 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 05 Jan 2019 17:53:41 -0800 Received: from usa003333.ad.shared (HELO [10.86.60.238]) ([10.86.60.238]) by uls-op-cesaip02.wdc.com with ESMTP; 05 Jan 2019 18:13:32 -0800 Subject: Re: [PATCH 2/3] RISC-V: Move cpuid to hartid mapping to SMP. To: Anup Patel Cc: "linux-riscv@lists.infradead.org" , Albert Ou , Daniel Lezcano , Dmitriy Cherkasov , Jason Cooper , "linux-kernel@vger.kernel.org List" , Marc Zyngier , Michael Clark , Palmer Dabbelt , =?UTF-8?Q?Patrick_St=c3=a4hlin?= , Rob Herring , Thomas Gleixner , Damien Le Moal References: <1545865741-22795-1-git-send-email-atish.patra@wdc.com> <1545865741-22795-3-git-send-email-atish.patra@wdc.com> From: Atish Patra Message-ID: <4800edf7-5963-c472-affa-b6fdc58ba602@wdc.com> Date: Sat, 5 Jan 2019 18:13:31 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.3.3 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/26/18 7:38 PM, Anup Patel wrote: > On Thu, Dec 27, 2018 at 4:39 AM Atish Patra wrote: >> >> 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 > > Please move __cpuid_to_hartid_map[] and smp_setup_processor_id() > to arch/riscv/kernel/smp.c > Will do. Thanks for the review. > Otherwise, looks good to me. > > Reviewed-by: Anup Patel > Regards, Atish