arch/arm64: get_cpu_id according to the correct affinity level

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
This commit is contained in:
zhangyuan21 2023-04-23 21:58:17 +08:00 committed by Xiang Xiao
parent f2dc9402f6
commit dc55205ee5
7 changed files with 55 additions and 16 deletions

View file

@ -54,4 +54,17 @@
#define CONFIG_LOAD_BASE 0x40080000
/****************************************************************************
* Assembly Macros
****************************************************************************/
#ifdef __ASSEMBLY__
.macro get_cpu_id xreg0
mrs \xreg0, mpidr_el1
ubfx \xreg0, \xreg0, #0, #8
.endm
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM64_INCLUDE_A64_CHIP_H */

View file

@ -27,6 +27,10 @@
#include <nuttx/config.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Number of bytes in @p x kibibytes/mebibytes/gibibytes */
#define KB(x) ((x) << 10)
@ -73,4 +77,17 @@
#endif
/****************************************************************************
* Assembly Macros
****************************************************************************/
#ifdef __ASSEMBLY__
.macro get_cpu_id xreg0
mrs \xreg0, mpidr_el1
ubfx \xreg0, \xreg0, #0, #8
.endm
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM64_INCLUDE_FVP_V8R_CHIP_H */

View file

@ -27,6 +27,10 @@
#include <nuttx/config.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Number of bytes in @p x kibibytes/mebibytes/gibibytes */
#define KB(x) ((x) << 10)
@ -63,4 +67,17 @@
#endif
/****************************************************************************
* Assembly Macros
****************************************************************************/
#ifdef __ASSEMBLY__
.macro get_cpu_id xreg0
mrs \xreg0, mpidr_el1
ubfx \xreg0, \xreg0, #0, #8
.endm
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM64_INCLUDE_QEMU_CHIP_H */

View file

@ -58,7 +58,7 @@ typedef void (*arm64_cpustart_t)(void *data);
struct arm64_boot_params
{
uint64_t mpid;
uint64_t cpuid;
char *boot_sp;
arm64_cpustart_t func;
void *arg;
@ -69,7 +69,7 @@ struct arm64_boot_params
volatile struct arm64_boot_params aligned_data(L1_CACHE_BYTES)
cpu_boot_params =
{
.mpid = -1,
.cpuid = -1,
.boot_sp = (char *)g_cpu_idlestackalloc[0],
};
@ -142,9 +142,9 @@ static void arm64_smp_init_top(void *arg)
static void arm64_start_cpu(int cpu_num, char *stack, int stack_sz,
arm64_cpustart_t fn)
{
uint64_t cpu_mpid;
cpu_mpid = arm64_get_mpid(cpu_num);
#ifdef CONFIG_ARCH_HAVE_PSCI
uint64_t cpu_mpid = arm64_get_mpid(cpu_num);
#endif
#ifdef CONFIG_SCHED_INSTRUMENTATION
@ -164,7 +164,7 @@ static void arm64_start_cpu(int cpu_num, char *stack, int stack_sz,
/* store mpid last as this is our synchronization point */
cpu_boot_params.mpid = cpu_mpid;
cpu_boot_params.cpuid = cpu_num;
flush_boot_params();

View file

@ -25,6 +25,7 @@
#include <nuttx/config.h>
#include <arch/chip/chip.h>
#include "arm64_arch.h"
#include "arm64_internal.h"
#include "arm64_macro.inc"

View file

@ -25,16 +25,6 @@
#ifndef __ARCH_ARM64_SRC_COMMON_ARM64_MACRO_INC
#define __ARCH_ARM64_SRC_COMMON_ARM64_MACRO_INC
/*
* Get CPU id
*/
.macro get_cpu_id xreg0
mrs \xreg0, mpidr_el1
/* FIMXME: aff3 not taken into consideration */
ubfx \xreg0, \xreg0, #0, #24
.endm
.macro switch_el, xreg, el3_label, el2_label, el1_label
mrs \xreg, CurrentEL
cmp \xreg, 0xc

View file

@ -24,6 +24,7 @@
#include <nuttx/config.h>
#include <arch/chip/chip.h>
#include "arch/syscall.h"
#include "arm64_macro.inc"
#include "arch/irq.h"