[PATCH v4 1/3] LoongArch: Modify acpi_parse_processor() for non-SMP

Tiezhu Yang posted 3 patches 1 year, 9 months ago
[PATCH v4 1/3] LoongArch: Modify acpi_parse_processor() for non-SMP
Posted by Tiezhu Yang 1 year, 9 months ago
When CONFIG_SMP is disabled, mapping won't be created for all cpus.
CPUs more than num_possible_cpus will be ignored. This is preparation
for later patch.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 arch/loongarch/kernel/acpi.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c
index 5cf59c617126..ccfa90faf0ea 100644
--- a/arch/loongarch/kernel/acpi.c
+++ b/arch/loongarch/kernel/acpi.c
@@ -98,8 +98,15 @@ acpi_parse_processor(union acpi_subtable_headers *header, const unsigned long en
 		return -EINVAL;
 
 	acpi_table_print_madt_entry(&header->common);
+
+	/*
+	 * When CONFIG_SMP is disabled, mapping won't be created for all cpus.
+	 * CPUs more than num_possible_cpus will be ignored.
+	 */
+	if (processor->core_id >= 0 && processor->core_id < num_possible_cpus())
+		acpi_core_pic[processor->core_id] = *processor;
+
 #ifdef CONFIG_SMP
-	acpi_core_pic[processor->core_id] = *processor;
 	set_processor_mask(processor->core_id, processor->flags);
 #endif
 
-- 
2.42.0
Re: [PATCH v4 1/3] LoongArch: Modify acpi_parse_processor() for non-SMP
Posted by Huacai Chen 1 year, 9 months ago
Hi, Tiezhu,

On Wed, Apr 17, 2024 at 6:00 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> When CONFIG_SMP is disabled, mapping won't be created for all cpus.
> CPUs more than num_possible_cpus will be ignored. This is preparation
> for later patch.
This patch makes no sense, don't "fix" anything unless it is broken.

Huacai

>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>  arch/loongarch/kernel/acpi.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c
> index 5cf59c617126..ccfa90faf0ea 100644
> --- a/arch/loongarch/kernel/acpi.c
> +++ b/arch/loongarch/kernel/acpi.c
> @@ -98,8 +98,15 @@ acpi_parse_processor(union acpi_subtable_headers *header, const unsigned long en
>                 return -EINVAL;
>
>         acpi_table_print_madt_entry(&header->common);
> +
> +       /*
> +        * When CONFIG_SMP is disabled, mapping won't be created for all cpus.
> +        * CPUs more than num_possible_cpus will be ignored.
> +        */
> +       if (processor->core_id >= 0 && processor->core_id < num_possible_cpus())
> +               acpi_core_pic[processor->core_id] = *processor;
> +
>  #ifdef CONFIG_SMP
> -       acpi_core_pic[processor->core_id] = *processor;
>         set_processor_mask(processor->core_id, processor->flags);
>  #endif
>
> --
> 2.42.0
>
>