-
Notifications
You must be signed in to change notification settings - Fork 1k
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
SMP for Cortex-A MPcore is unstable #207
Comments
I thought the memory corruption issue relates to an IPI (Inter Processor Interrupt) issue. Also, I noticed that there is a global temporary storage called irqtmp in arm_vectors.S. |
Hello @gregory-nutt, What do you think about my comments on irqtmp in armv7-a/arm_vectors.S? |
Hi @masayuki2009 , this week i have guests and we will be at the beach for 3 more days. I have only my cellphone now so I will not be able to do much. From the name, that irqtmo is probably used to handle nested SGI interrupts, but I do not know for sure now. |
I have a vew minutes before we leave. "From the name, that irqtmo is probably used to handle nested SGI interrupts, but I do not know for sure now." No, that little storage area is use during normal interrupt processing. "storage should be protected or should be allocated per CPU." Yes, I think that is true. Also fiqtmp (FIQs are used with TrustZone). These is other *tmp storage, but these are fatal crashes. These need to be redesigned. |
Hi @patacongo , I'm not in hurry so enjoy your holiday. |
Also "They are very basic use-cases and should work with QEMU." It has been awhile since I have used the sabre-6quad, but this historically has not been an issue on real hardware. I wonder if this is just lucky timing on real hardware, or a QEMU emulation difference? |
I think it was lucky. In my experience, QEMU has some differences from a real hardaware.
However, QEMU is very useful for debugging. (You can debug multi cores) |
Hi @patacongo, I also noticed that calling setirqstack in arm_vectors.S destroys $r5 which should be preserved. |
@masayuki2009 "I also noticed that calling setirqstack in arm_vectors.S destroys $r5 which should be preserved." Are you referring to:
it looks like R2 is available. Do you think that should be:
No... a value in R2 is assumed at line 315, but I think r3 is available. |
I don't have a test setup here so I can't verify it. If you approve, I can submit the PR. If you were to document how to use QEMU in your test case, I would try that too. However, I have not used QEMU much (and not for many years), so I am not so interested in that learning curve. |
@masayuki2009 QEMU is very important for automatiton test in the next step, it's great if you can create a basic config for both riscv and arm and README file to describe how to setup the simulator and debuging. |
For the case of the i.MX6 QEMU, this would be appropriate in boards/arm/imx6/sabre-6quad/README.txt |
@xiaoxiang781216 @patacongo I'll add comments on how to run sabre-6quad nuttx image on QEMU later. (FYI, running RISC-V FE310 and K210 images on QEMU is already described) |
@xiaoxiang781216 @patacongo I've just sent a PR #233 |
I don't see any simple way to implement the first issue you mention, that where g_irqtmp would be invalid in the case of nested interrupts. Nested interrupts would occur only in the SMP case where the SGI inter-processor interrupts are non-maskable. I see only two solutions and neither are simple:
|
Hi @patacongo, I just tried the latest upstream code with QEMU and confirmed that $r5 is not destroyed now. However, if I modified defconfig to add a hello application and type free on nsh, it freezed. --- a/boards/arm/imx6/sabre-6quad/configs/smp/defconfig |
@patacongo I found and fixed another bug for armv7-a smp which is a root cause of this issue. |
Thanks. I have merged that. |
@patacongo I've just sent another PR #325 which improves i.mx6 SMP stability. Now ostest works with QEMU (4cores enabled) However, as I commented, nested interrupt issue might happen. (actually not happens when ostest is running) |
To reproduce this issue, more complicated use-cases which generate high frequency interrupts would be needed. For examples, DMA, Ethernet, SDIO ... should be involved but no drivers are implemented so far. |
I found DMA for i.mx6 is not supported in QEMU. |
Sorry, I didn't mean to close this. I hit the wrong button again, apparently. |
@masayuki2009 Should this issue be closed now? You did a lot of work with Cortex-A and got parity with the other architectures, right? |
@patacongo Yes, but I checked SMP for Cortex-A with QMU only. |
Per recommendation of @masayuki2009 |
@masayuki2009 Is it still true that "cpsid i" can't disable IPI interrupt? |
No, "cpsid" ** can *** disable IPI interrupt. Oh, I updated the TODO file but forgot to update the README.txt Anyway, I will create a new PR to update the README.txt |
Ok, I will send PR to remove all related trick. |
Here is the patch: #4094 |
There were several discussions on SMP issues for Cortex-A MPcore in NuttX mailing list before.
Yesterday I tried sabre-6quad:smp configuration with QEMU, and noticed that it's unstable even
if I changed the configuration to use only 2cores instead of 4cores.
Actually, heap memory was sometimes corrupted during booting up the secondary core.
Even if it succeeded to boot, heap memory was corrupted when a new task is created.
They are very basic use-cases and should work with QEMU.
So, I think something is wrong with Cortex-A SMP implementation, because Cortex-M SMP
(e.g. Sony Spresense in dual core mode) and RISC-V SMP (K210 Maix-bit) are much more stable.
The text was updated successfully, but these errors were encountered: