Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARM64 SMP support #30676

Merged
merged 12 commits into from Mar 6, 2021
Merged

ARM64 SMP support #30676

merged 12 commits into from Mar 6, 2021

Conversation

MrVan
Copy link
Collaborator

@MrVan MrVan commented Dec 13, 2020

This patchset includes the PR of #29736, after the PR merged, I'll rebase this PR.

arch/arm/core/aarch64/mmu/arm_mmu.c Outdated Show resolved Hide resolved
arch/arm/core/aarch64/switch.S Outdated Show resolved Hide resolved
arch/arm/core/aarch64/Kconfig Outdated Show resolved Hide resolved
arch/arm/core/aarch64/cache.S Outdated Show resolved Hide resolved
arch/arm/core/aarch64/cache.S Outdated Show resolved Hide resolved
arch/arm/include/aarch64/smccc.h Outdated Show resolved Hide resolved
arch/arm/include/aarch64/psci.h Outdated Show resolved Hide resolved
arch/arm/core/aarch64/reset.S Outdated Show resolved Hide resolved
arch/arm/core/aarch64/reset.S Outdated Show resolved Hide resolved
arch/arm/core/aarch64/reset.S Outdated Show resolved Hide resolved
@carlocaione
Copy link
Collaborator

This breaks when we disable ARMV8_A_NS:

/home/carlo/work/proj/intel/zephyr/zephyr/arch/arm/core/aarch64/reset.S:188: undefined reference to `arm64_cpu_sp'
/home/carlo/work/proj/intel/zephyr/zephyr/arch/arm/core/aarch64/reset.S:188:(.text._reset_section+0x178): relocation truncated to fit: R_AARCH64_ADR_PREL_LO21 against undefined symbol `arm64_cpu_sp'
/home/carlo/work/proj/intel/sdk/aarch64-zephyr-elf/bin/../lib/gcc/aarch64-zephyr-elf/10.2.0/../../../../aarch64-zephyr-elf/bin/ld: zephyr/arch/arch/arm/core/aarch64/libarch__arm__core__aarch64.a(prep_c.c.obj): in function `z_arm64_secondary_prep_c':
/home/carlo/work/proj/intel/zephyr/zephyr/arch/arm/core/aarch64/prep_c.c:41: undefined reference to `z_arm64_secondary_start'
/home/carlo/work/proj/intel/zephyr/zephyr/arch/arm/core/aarch64/prep_c.c:41:(.text.z_arm64_secondary_prep_c+0x8): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `z_arm64_secondary_start'
/home/carlo/work/proj/intel/sdk/aarch64-zephyr-elf/bin/../lib/gcc/aarch64-zephyr-elf/10.2.0/../../../../aarch64-zephyr-elf/bin/ld: zephyr/kernel/libkernel.a(sched.c.obj): in function `ready_thread':
/home/carlo/work/proj/intel/zephyr/zephyr/kernel/sched.c:429: undefined reference to `arch_sched_ipi'
/home/carlo/work/proj/intel/zephyr/zephyr/kernel/sched.c:429:(.text.ready_thread+0x74): relocation truncated to fit: R_AARCH64_JUMP26 against undefined symbol `arch_sched_ipi'
/home/carlo/work/proj/intel/sdk/aarch64-zephyr-elf/bin/../lib/gcc/aarch64-zephyr-elf/10.2.0/../../../../aarch64-zephyr-elf/bin/ld: zephyr/kernel/libkernel.a(sched.c.obj): in function `z_sched_abort':
/home/carlo/work/proj/intel/zephyr/zephyr/kernel/sched.c:1415: undefined reference to `arch_sched_ipi'
/home/carlo/work/proj/intel/zephyr/zephyr/kernel/sched.c:1415:(.text.z_sched_abort+0x38): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `arch_sched_ipi'
/home/carlo/work/proj/intel/sdk/aarch64-zephyr-elf/bin/../lib/gcc/aarch64-zephyr-elf/10.2.0/../../../../aarch64-zephyr-elf/bin/ld: zephyr/kernel/libkernel.a(smp.c.obj): in function `z_smp_init':
/home/carlo/work/proj/intel/zephyr/zephyr/kernel/smp.c:87: undefined reference to `arch_start_cpu'
/home/carlo/work/proj/intel/zephyr/zephyr/kernel/smp.c:87:(.text.z_smp_init+0x38): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `arch_start_cpu'

@carlocaione
Copy link
Collaborator

tagging @vladimir-podbrezsky as well

@carlocaione carlocaione mentioned this pull request Dec 19, 2020
@sandeepbrcm
Copy link
Collaborator

sandeepbrcm commented Dec 21, 2020

Overall changes looks functionally complete. Covers almost all base aspect of SMP from core arch.
However we need to do a more detailed review as debugging any minor bug here would wreak havoc.
I will try to review during this week. Thanks.

@MrVan
Copy link
Collaborator Author

MrVan commented Dec 25, 2020

@carlocaione https://github.com/MrVan/zephyr/tree/qemu-smp-v2 I pushed a branch to my github. This branch is based on you #30911 and #30398 PR.

@carlocaione
Copy link
Collaborator

@carlocaione https://github.com/MrVan/zephyr/tree/qemu-smp-v2 I pushed a branch to my github. This branch is based on you #30911 and #30398 PR.

Can you force push on this PR instead? So we can give it another round of reviews.

@MrVan
Copy link
Collaborator Author

MrVan commented Mar 1, 2021

all the dependings PRs have been merged, rebased.

@MrVan
Copy link
Collaborator Author

MrVan commented Mar 3, 2021

@carlocaione @sandeepbrcm @jharris-intel @npitre Could I get your R-b? If there are still small issues, I would start a new PR for resolving small issues. If no critical issues, I would prefer to have this PR in. Thanks.

@sandeepbrcm
Copy link
Collaborator

Re, #30676 (comment)
There is little more to think about the coherency management here. The core invalidating its own cache is safe. But I am not sure if the range invalidate can cause a data loss by invalidating a line in cache hierarchy out side of cores scope.

Copy link
Collaborator

@sandeepbrcm sandeepbrcm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MrVan arch: arm: aarch64: add SMP support seems good in its current scope.
Few minor comments to complete this from my side.

kernel/Kconfig Outdated Show resolved Hide resolved
include/arch/arm/aarch64/cpu.h Outdated Show resolved Hide resolved
drivers/timer/arm_arch_timer.c Show resolved Hide resolved
include/arch/arm/aarch64/arch_inlines.h Outdated Show resolved Hide resolved
arch/arm/core/aarch64/cache.S Show resolved Hide resolved
@carlocaione
Copy link
Collaborator

@MrVan before merging this I'd like to see a new issue with a list of the (minor?) open points to be addressed later, otherwise they are going to be lost.

Save old_thread to switch_handle for wait_for_thread usage

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Export z_arm64_mmu_init for SMP usage

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Add SMP support.
Note: there is still limitation that we rely on NUM CPUs.
And all cpus must be from 0,1,2 and ....

Signed-off-by: Peng Fan <peng.fan@nxp.com>
To take the usage of arm arch counter 64bit capability, implement
custom arch_busy_wait

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Implement smp_timer_init to initialize arch timer of secondary cores.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
@MrVan
Copy link
Collaborator Author

MrVan commented Mar 5, 2021

@MrVan before merging this I'd like to see a new issue with a list of the (minor?) open points to be addressed later, otherwise they are going to be lost.

@carlocaione #32964

Following other ARCHs, add arch_curr_cpu in arch_inlines.h

Signed-off-by: Peng Fan <peng.fan@nxp.com>
With _kernel_offset_to_nested, we only able to access the nested counter
of the first cpu. Since we are going to support SMP, we need accessing
nested from per cpu.

To get the current cpu, introduce z_arm64_curr_cpu for asm usage,
because arch_curr_cpu could not be compiled in asm code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Add arch_dcache_range to support flush and invalidate

Signed-off-by: Peng Fan <peng.fan@nxp.com>
With timer/gic/cache added, we could add the SMP support.
Bringup cores

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Add cpu1 node

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Select SCHED_IPI_SUPPORTED when SMP enabled.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Support SMP and switch to booting from NS world

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Copy link
Collaborator

@sandeepbrcm sandeepbrcm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have any other functional comment at the moment considering this is base support.

@nashif nashif requested review from carlocaione and removed request for andrewboie March 5, 2021 12:39
@carlocaione
Copy link
Collaborator

@jharris-intel can you ACK / NACK this? AFAIK you are the only one besides @MrVan that is actually using these patches on real hardware.

@jharris-intel
Copy link
Contributor

@jharris-intel can you ACK / NACK this? AFAIK you are the only one besides @MrVan that is actually using these patches on real hardware.

That's somewhat surprising to me, but sure, I'll take another look.

(By the way, if you're looking for a relatively cheap / common dev vehicle, booting bare metal on the Raspberry Pi may not be a bad choice.)

@nashif nashif merged commit 842ed37 into zephyrproject-rtos:master Mar 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs area: ARM ARM (32-bit) Architecture area: Boards area: Devicetree area: Interrupt Controller area: Kernel area: Tests Issues related to a particular existing or missing test area: Timer Timer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SMP support on ARM64 platform
8 participants