Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Conor Dooley <conor@kernel.org>
To: Zhe Qiao <qiaozhe@iscas.ac.cn>
Cc: paul.walmsley@sifive.com, palmer@dabbelt.com,
	aou@eecs.berkeley.edu, conor.dooley@microchip.com,
	samuel.holland@sifive.com, evan@rivosinc.com, tglx@linutronix.de,
	andy.chiu@sifive.com, cleger@rivosinc.com,
	ajones@ventanamicro.com, linux-riscv@lists.infradead.org
Subject: Re: [PATCH] riscv: Report error when repeatedly recording CPU hardware ID
Date: Fri, 23 Aug 2024 13:57:01 +0100	[thread overview]
Message-ID: <20240823-circulate-underarm-13406fd8cc44@spud> (raw)
In-Reply-To: <20240823091100.598162-1-qiaozhe@iscas.ac.cn>


[-- Attachment #1.1: Type: text/plain, Size: 1957 bytes --]

On Fri, Aug 23, 2024 at 05:11:00PM +0800, Zhe Qiao wrote:
> In the of_parse_and_init_cpus() function, when the __cpuid_to_hartid_map[]
> array records the CPU hardware ID, if the same CPU hardware attribute has 
> been recorded, an error report is issued, thereby ensuring the uniqueness
> of the CPU hardware ID recorded in the __cpuid_to_hartid_map[] array.

Why is this actually required? On what system did you encounter this?

> Signed-off-by: Zhe Qiao <qiaozhe@iscas.ac.cn>
> ---
>  arch/riscv/kernel/smpboot.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c
> index 0f8f1c95ac38..698f9fe791f7 100644
> --- a/arch/riscv/kernel/smpboot.c
> +++ b/arch/riscv/kernel/smpboot.c
> @@ -118,6 +118,16 @@ static void __init acpi_parse_and_init_cpus(void)
>  #define acpi_parse_and_init_cpus(...)	do { } while (0)
>  #endif
>  
> +static bool __init is_mpidr_duplicate(unsigned int cpuid, u64 hart)
> +{
> +	unsigned int i;
> +
> +	for (i = 1; (i < cpuid) && (i < NR_CPUS); i++)
> +		if (cpuid_to_hartid_map(i) == hart)
> +			return true;
> +	return false;
> +}
> +
>  static void __init of_parse_and_init_cpus(void)
>  {
>  	struct device_node *dn;
> @@ -131,6 +141,12 @@ static void __init of_parse_and_init_cpus(void)
>  		if (rc < 0)
>  			continue;
>  
> +		if (is_mpidr_duplicate(cpuid, hart)) {
> +			pr_err("%pOF: duplicate cpu reg properties in the DT\n",
> +				dn);
> +			continue;

Why would we continue in this case? If the devicetree is this broken,
why shouldn't we just BUG() and abort immediately?

> +		}
> +
>  		if (hart == cpuid_to_hartid_map(0)) {
>  			BUG_ON(found_boot_cpu);
>  			found_boot_cpu = 1;
> -- 
> 2.43.0
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  parent reply	other threads:[~2024-08-23 12:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-23  9:11 [PATCH] riscv: Report error when repeatedly recording CPU hardware ID Zhe Qiao
2024-08-23 10:08 ` Anup Patel
2024-08-24  2:10   ` qiaozhe
2024-08-23 12:57 ` Conor Dooley [this message]
2024-08-24  2:41   ` qiaozhe
2024-08-26  8:15     ` Conor Dooley
2024-08-27  1:39       ` qiaozhe
2024-08-27  8:27         ` Conor Dooley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240823-circulate-underarm-13406fd8cc44@spud \
    --to=conor@kernel.org \
    --cc=ajones@ventanamicro.com \
    --cc=andy.chiu@sifive.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=cleger@rivosinc.com \
    --cc=conor.dooley@microchip.com \
    --cc=evan@rivosinc.com \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=qiaozhe@iscas.ac.cn \
    --cc=samuel.holland@sifive.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox