Skip to content

Conversation

wangchdo
Copy link
Contributor

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

@github-actions github-actions bot added Arch: arm Issues related to ARM (32-bit) architecture Size: S The size of the change in this PR is small labels Aug 22, 2025

/* Initialize the Generic Interrupt Controller (GIC) for CPU0 */
while (gicd_ready == 0)
Copy link
Contributor

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?

Copy link
Contributor Author

@wangchdo wangchdo Aug 25, 2025

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.

Copy link
Contributor

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.

Copy link
Contributor Author

@wangchdo wangchdo Aug 25, 2025

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

Copy link
Contributor

@xiaoxiang781216 xiaoxiang781216 Aug 25, 2025

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.

Copy link
Contributor Author

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

acassis
acassis previously approved these changes Aug 24, 2025
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.
@wangchdo wangchdo force-pushed the fix_arm_v8_r_gic_init_issue branch from cdc21cf to 1285111 Compare August 25, 2025 05:59

arm_gic_initialize(); /* Initialization common to all CPUs */
arm_gic_secondary_init();
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch: arm Issues related to ARM (32-bit) architecture Size: S The size of the change in this PR is small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants