platform: generic: Optimize extensions_init() to parse ISA extensions once

Instead of parsing ISA extensions separately for each hart in the
generic_extensions_init() function, it is better to parse ISA extensions
for all available harts in the cold boot path. Also, this allows us
to remove fdt_isa_bitmap from scratch space and directly initialize
"extensions" in struct sbi_hart_features for each hart.

Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260521082625.1520870-3-anup.patel@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Anup Patel
2026-05-21 13:56:25 +05:30
committed by Anup Patel
parent a62385ab80
commit ecc92e87a9
13 changed files with 37 additions and 64 deletions
+5 -2
View File
@@ -12,6 +12,7 @@
#include <sbi/sbi_bitops.h>
#include <sbi/sbi_ecall_interface.h>
#include <sbi/sbi_error.h>
#include <sbi/sbi_hart.h>
#include <sbi/sbi_hsm.h>
#include <sbi/sbi_platform.h>
#include <sbi/sbi_pmu.h>
@@ -197,11 +198,12 @@ static int sun20i_d1_final_init(bool cold_boot)
return generic_final_init(cold_boot);
}
static int sun20i_d1_extensions_init(struct sbi_hart_features *hfeatures)
static int sun20i_d1_extensions_init(bool cold_boot)
{
struct sbi_hart_features *hfeatures;
int rc;
rc = generic_extensions_init(hfeatures);
rc = generic_extensions_init(cold_boot);
if (rc)
return rc;
@@ -209,6 +211,7 @@ static int sun20i_d1_extensions_init(struct sbi_hart_features *hfeatures)
/* auto-detection doesn't work on t-head c9xx cores */
/* D1 has 29 mhpmevent csrs, but only 3-9,13-17 have valid value */
hfeatures = sbi_hart_features_ptr(sbi_scratch_thishart_ptr());
hfeatures->mhpm_mask = 0x0003e3f8;
hfeatures->mhpm_bits = 64;
+3 -2
View File
@@ -9,6 +9,7 @@
#include <andes/andes_pmu.h>
#include <sbi/sbi_bitops.h>
#include <sbi/sbi_error.h>
#include <sbi/sbi_hart.h>
#include <sbi/sbi_pmu.h>
#include <libfdt.h>
#include <platform_override.h>
@@ -58,12 +59,12 @@ static struct sbi_pmu_device andes_pmu = {
.hw_counter_filter_mode = andes_hw_counter_filter_mode
};
int andes_pmu_extensions_init(struct sbi_hart_features *hfeatures)
int andes_pmu_extensions_init(bool cold_boot)
{
struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
int rc;
rc = generic_extensions_init(hfeatures);
rc = generic_extensions_init(cold_boot);
if (rc)
return rc;
+1
View File
@@ -10,6 +10,7 @@
#include <sbi/sbi_console.h>
#include <sbi/sbi_system.h>
#include <sbi/sbi_math.h>
#include <sbi/sbi_hart.h>
#include <sbi/sbi_hart_pmp.h>
#include <sbi/sbi_hart_protection.h>
#include <eswin/eic770x.h>
+2 -2
View File
@@ -7,9 +7,9 @@
#ifndef _RISCV_ANDES_PMU_H
#define _RISCV_ANDES_PMU_H
#include <sbi/sbi_hart.h>
#include <sbi/sbi_types.h>
int andes_pmu_init(void);
int andes_pmu_extensions_init(struct sbi_hart_features *hfeatures);
int andes_pmu_extensions_init(bool cold_boot);
#endif /* _RISCV_ANDES_PMU_H */
+1 -2
View File
@@ -10,7 +10,6 @@
#ifndef __PLATFORM_OVERRIDE_H__
#define __PLATFORM_OVERRIDE_H__
#include <sbi/sbi_hart.h>
#include <sbi/sbi_platform.h>
#include <sbi/sbi_types.h>
#include <sbi_utils/fdt/fdt_driver.h>
@@ -19,7 +18,7 @@ bool generic_cold_boot_allowed(u32 hartid);
int generic_nascent_init(void);
int generic_early_init(bool cold_boot);
int generic_final_init(bool cold_boot);
int generic_extensions_init(struct sbi_hart_features *hfeatures);
int generic_extensions_init(bool cold_boot);
int generic_domains_init(void);
int generic_pmu_init(void);
uint64_t generic_pmu_xlate_to_mhpmevent(uint32_t event_idx, uint64_t data);
+5 -3
View File
@@ -253,11 +253,13 @@ int generic_final_init(bool cold_boot)
return 0;
}
int generic_extensions_init(struct sbi_hart_features *hfeatures)
int generic_extensions_init(bool cold_boot)
{
if (!cold_boot)
return 0;
/* Parse the ISA string from FDT and enable the listed extensions */
return fdt_parse_isa_extensions(fdt_get_address(), current_hartid(),
hfeatures->extensions);
return fdt_parse_isa_extensions_all_harts(fdt_get_address());
}
int generic_domains_init(void)
+2 -2
View File
@@ -49,11 +49,11 @@ static int sophgo_sg2042_early_init(bool cold_boot)
return 0;
}
static int sophgo_sg2042_extensions_init(struct sbi_hart_features *hfeatures)
static int sophgo_sg2042_extensions_init(bool cold_boot)
{
int rc;
rc = generic_extensions_init(hfeatures);
rc = generic_extensions_init(cold_boot);
if (rc)
return rc;
+1
View File
@@ -12,6 +12,7 @@
#include <platform_override.h>
#include <sbi/sbi_error.h>
#include <sbi/sbi_bitops.h>
#include <sbi/sbi_hart.h>
#include <sbi/sbi_system.h>
#include <sbi/sbi_console.h>
#include <sbi/sbi_timer.h>
+2 -2
View File
@@ -26,11 +26,11 @@ static int thead_tlb_flush_early_init(bool cold_boot)
return generic_early_init(cold_boot);
}
static int thead_pmu_extensions_init(struct sbi_hart_features *hfeatures)
static int thead_pmu_extensions_init(bool cold_boot)
{
int rc;
rc = generic_extensions_init(hfeatures);
rc = generic_extensions_init(cold_boot);
if (rc)
return rc;