-
Notifications
You must be signed in to change notification settings - Fork 1.5k
arch/arm/armv8-r: fix multicore gicv3 init issue #16892
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
base: master
Are you sure you want to change the base?
Conversation
arch/arm/src/armv8-r/arm_doirq.c
Outdated
|
||
/* Initialize the Generic Interrupt Controller (GIC) for CPU0 */ | ||
while (gicd_ready == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but why the secondary cpu start without waiting the primary cpu command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some SoC may release all the cpus simultaneously after power on, while let the software to do the synchronization.
By the way, gic init is called by nuttx kernel in nx_start, which is also probably called by some cpus simultaneously while cpu0 is doing it, because cpu0 tend to do more stuff in initialization after releasing other cpus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, this is a general problem. not only GIC need this special process, but also the global variables and other shared resource need finish the initialization in the boot cpu before other cpu boot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, for this general problem, I think, on the one hand, app should take care of the app specific global variable and shared resource init sequence and sync in multicore system.
On the other hand, for other global variables or shared resource in multicore system, i would call them default one, not app specific, they should be initialzed by system, before any app starts, like bss clear or data copy, and it is the system that should take care of their initialzaiton sequence or sync . I think GIC is this kind of shared resource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The coordination of initialization should be done in the common layer, not specific in GIC, so all system components could get sync. @hujun260 will provide a similar patch for review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, I removed the sync in gic init
eba2985
to
cdc21cf
Compare
In multicore situation, it is cpu0 to call arm_gic_initialize to init global GICD and percpu GICRD/GIC cpu interface; other cpus only need to call arm_gic_secondary_init to int percpu GICRD/GIC cpu interface. The current code may int GICD multiple times in multicore situation which is a bug.
cdc21cf
to
1285111
Compare
|
||
arm_gic_initialize(); /* Initialization common to all CPUs */ | ||
arm_gic_secondary_init(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but up_irqinitialize is designed to be called on primary cpu, other cpu should call arm_gic_secondary_init directly. Please search how arm64_gic_secondary_init get called.
In multicore situation, it is cpu0 to call arm_gic_initialize to init global GICD and percpu GICRD/GIC cpu interface; other cpus only need to call arm_gic_secondary_init to int percpu GICRD/GIC cpu interface. The current code may int GICD multiple times in multicore situation which is a bug.
Note: Please adhere to Contributing Guidelines.
Summary
Cpu0 call arm_gic_initialize, other Cpus call arm_gic_secondary_init
Impact
Fix bugs about GIC initialization in multicore situation
Testing
This was tested in our own multicore arm cortex-r52 board