Skip to content

Fix misc issues and enable v8r64 FPU #58056

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

Merged

Conversation

povergoing
Copy link
Member

@povergoing povergoing commented May 19, 2023

This PR fixes some issues and enables the FPU for v8R AArch64

  • Fix text exception by increasing the stack size

  • Remove LOG print before MPU is enabled to avoid the potential un-alignment instruction called before MPU is enabled.

  • Fix the STACK_INIT during the reset

  • Add cpu_map to have a correct mapping of CPU id and MPID

  • Fix a deadlock case when using FPU in the spin-locked section (this workaround fixes modified the spinlock, RFC)
    Using FPU with FPU sharing in a spin-locked critical section might cause a 'deadlock'. When core 0 got a spinlock that other cores are waiting for, it will 'deadlock' if the core 0 current threads' FPU context is living in another one that is waiting for the spinlock but never receives the FPU IPI. CC @npitre
    fix possible deadlock with FPU sharing on ARM64 and RISC-V #58086 fixed the deadlock issue

  • Enable FPU and FPU_SHARING for v8r aarch64

Tested on all runnable Arm64 platforms including fvp_baser_aemv8r and fvp_baser_aemv8r_smp

Comment on lines 156 to 159
#if defined(CONFIG_ARM64) && defined(CONFIG_FPU_SHARING)
extern void z_arm64_flush_local_fpu_proactive(void);
z_arm64_flush_local_fpu_proactive();
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

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

uhm, this could raise some eyebrows. Can you detach this from this PR and make a standalone PR only for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I will, and I also expect there is a better way to fix the issue

@povergoing
Copy link
Member Author

povergoing commented May 19, 2023

This PR depends on #58058. I will rebase this when we get a solution

@npitre
Copy link
Collaborator

npitre commented May 19, 2023

@povergoing: The deadlock is a very interesting one.

… size

The test case will show an unexpected exception in the idle thread after
all test cases pass. The issue is caused by the main thread
stackoverflow.

Increase the main stack configured in this test case to fix the issue.

Signed-off-by: Jaxson Han <[email protected]>
LOG system has unalignment access instruction which will cause an
alignment exception before MPU is enabled. Remove the LOG print before
MPU is enabled to avoid this issue.

Signed-off-by: Jaxson Han <[email protected]>
Each core should init their own stack during the reset when SMP enabled,
but do not touch others. The current init results in each core starting
init the stack from the same address which will break others.

Fix the issue by setting a correct start address.

Signed-off-by: Jaxson Han <[email protected]>
cpu_node_list does not hold the corrent mapping of cpu id and mpid when
core booting sequence does not follow the DTS cpu node sequence. This
will cause an issue that sgi cannot deliver to the right target.

Add the cpu_map array to hold the corrent mapping between cpu id and
mpid.

Signed-off-by: Jaxson Han <[email protected]>
This commit is to enable FPU and FPU_SHARING for v8r aarch64.

Signed-off-by: Jaxson Han <[email protected]>
@povergoing povergoing force-pushed the fix_misc_and_enable_v8r64_fpu branch from 7ad8e46 to dbace5c Compare May 25, 2023 08:39
@povergoing
Copy link
Member Author

I think this is ready for review :)

@carlescufi carlescufi merged commit 08791d5 into zephyrproject-rtos:main May 30, 2023
@povergoing povergoing deleted the fix_misc_and_enable_v8r64_fpu branch May 30, 2023 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ARM64 ARM (64-bit) Architecture area: Kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants