-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
z_cstart bug #32444
Comments
any progress on that so far? Maybe my problem is related to that (#32261) |
@hongshui3000 : Interrupt is disabled when it enters z_cstart and gets enabled only when it enters main thread through bg_thread_main. Also, could you give some more information on how this is encountered and which platform its encountered on? |
Looking at the bug it doesn't look to be related. But will look into it further and get back in here. |
@yerabolu my issue is happens at the start up of zephyr when the main function is executed and a task switch happens. Its highly probable that it is triggered through an ISR. |
and file: uart_mcux.c
If you use them, then the interrupt may be enabled before the interrupt stack is initialized. At least in the xtensa architecture I don’t see interrupts being turned off.If log is turned on, I feel that the interrupt will also be enabled in advance. In the xtensa architecture, if I deliberately reduce the value of CYC_PER_TICK (such as 0 or 1), then the interrupt will be generated before entering bg_thread_main I feel that this should involve all the drivers started by _SYS_INIT_LEVEL_PRE_KERNEL_2 and _SYS_INIT_LEVEL_PRE_KERNEL_1 and whether the architecture will be enabled to interrupt. Our system does not make it clear that interrupts cannot be enabled in this place. So I feel that there may be potential problems at present or in the future. |
Thank You for the info. Investigating further to see which drivers are started by _SYS_INIT_LEVEL_PRE_KERNEL_2 and _SYS_INIT_LEVEL_PRE_KERNEL_1. Will update on it by EOD. |
@hongshui3000: Ran the below test to see if the irq_lock() and irq_unlock() are setting correctly and ran the tests. All the tests passed. Could you try it on your end as well and see if there is any issue.
|
@yerabolu |
@hongshui3000 When you mention "Do you suspect that the execution of "irq_lock" in my code failed?" - Are there are any new additions/changes to the above code that you are working on ? |
@yerabolu When the "_SYS_INIT_LEVEL_PRE_KERNEL_2" driver is initialized, some drivers enable interrupts. These drivers are initialized before entering main thread. Whether an interrupt occurs depends on the processor interrupt architecture and the implementation of irq_lock. It's just that what I see in the interrupt architecture of xtensa is like this, not the interrupt architecture of the finished chip (the interrupt controller that increases the hardware may control the global interrupt) I put this question here, the main purpose is to think that in a system without global interrupt control, the timing of the interrupt enable may cause problems. |
@hongshui3000 : Unfortunately i am not able to see this issue on my end and without a way to reproducing it in some way i will not be able to figure out if it is actually causing problems with the timing of enabling interrupts. But on the Zephyr master i don't see any issue. Adding @andyross to take a look on this. |
Honestly this sounds like a platform bug. The way this design is supposed to work:
(And on the SMP CPUs the process is similar, they start with interrupts masked and only enable them once switching into user/idle threads) [1] In the sense of arch_irq_lock(). Note that arch_irq_enable(int) is a separate API designed to selectively mask specific interrupts for the purpose of device control. An interrupt that is "enabled" will still not be delivered if it is globally masked by irq_lock(). On Xtensa, "enabled" corresponds to a bit set in the INTENABLE special register, while irq_lock() works by setting the INTLEVEL field in the bottom bits of PS to XCHAL_EXCM_LEVEL. |
Describe the bug
file:init.c
If the interrupt is enabled when the driver is initialized, and the interrupt is entered before the interrupt stack is initialized, the software will generate a bug.
If I understand it correctly, the initialization of the interrupt stack will always occur after the interrupt is enabled .
When the interrupt is enabled, an interrupt is generated immediately, and the interrupt stack is not ready yet, then the bug I said will appear.
interrupt en:
interrupt stack:
I found this problem when I debugged my systemtick
The text was updated successfully, but these errors were encountered: