MIPS: Ingenic: Allow assembler reordering in the XBurst secondary entry
PATCH 1/1 MIPS: Ingenic: Allow assembler reordering in the XBurst secondary entry
Remove .set noreorder and the two explicit delay-slot nops from the XBurst secondary CPU reset entry. GNU as emits identical reset-entry instructions with reordering enabled in both the CI20 and generic MIPS64r2 Ingenic SMP builds.
On CI20, two baseline and three updated cold boots brought both CPUs online. Each boot passed the CPU affinity check and 100 cross-core idle-wakeup round trips in each direction. Codex assisted with the assembly comparison and hardware test campaign.
---
Thomas, feel free to fixup into "MIPS: Ingenic: Add XBurst SMP support" if that is simpler. Thanks!
arch/mips/ingenic/ingenic-smp-entry.S | 3 --- 1 file changed, 3 deletions(-)
arch/mips/ingenic/ingenic-smp-entry.S +0 -3
@@ -16,7 +16,6 @@ /* The CP0 REIM register only stores the upper 16 address bits. */ .section .text.smp-entry, "ax" .balign 0x10000 - .set noreorder LEAF(xburst_secondary_cpu_entry) mtc0 zero, CP0_CAUSE li t0, ST0_CU0
@@ -32,7 +31,6 @@ LEAF(xburst_secondary_cpu_entry) cache Index_Store_Tag_D, 0(t0) addiu t0, t0, CACHE_LINESIZE bne t0, t1, 1b - nop mfc0 t0, CP0_CONFIG li t1, ~CONF_CM_CMASK
@@ -50,5 +48,4 @@ LEAF(xburst_secondary_cpu_entry) PTR_LA t0, smp_bootstrap jr t0 - nop END(xburst_secondary_cpu_entry)
Signature · 1 line
2.53.0
Quoted 10 lines · Florian Fainelli
Remove .set noreorder and the two explicit delay-slot nops from the XBurst secondary CPU reset entry. GNU as emits identical reset-entry instructions with reordering enabled in both the CI20 and generic MIPS64r2 Ingenic SMP builds.
On CI20, two baseline and three updated cold boots brought both CPUs online. Each boot passed the CPU affinity check and 100 cross-core idle-wakeup round trips in each direction. Codex assisted with the assembly comparison and hardware test campaign.
Quoted 5 lines
Suggested-by Maciej W. Rozycki <[email protected]>Signed-off-by Florian Fainelli <[email protected]>---
Thomas, feel free to fixup into "MIPS: Ingenic: Add XBurst SMP support" if that is simpler. Thanks!
Have you compared objects produced to be the same with and without the
change applied? If they are, then:
Thanks for this follow-up cleanup.
Maciej
Quoted 12 lines · Maciej W. Rozycki
Quoted 10 lines · Florian Fainelli
Remove .set noreorder and the two explicit delay-slot nops from the XBurst secondary CPU reset entry. GNU as emits identical reset-entry instructions with reordering enabled in both the CI20 and generic MIPS64r2 Ingenic SMP builds.
On CI20, two baseline and three updated cold boots brought both CPUs online. Each boot passed the CPU affinity check and 100 cross-core idle-wakeup round trips in each direction. Codex assisted with the assembly comparison and hardware test campaign.
Quoted 8 lines
Quoted 5 lines
Suggested-by Maciej W. Rozycki <[email protected]>Signed-off-by Florian Fainelli <[email protected]>---
Thomas, feel free to fixup into "MIPS: Ingenic: Add XBurst SMP support" if that is simpler. Thanks!Have you compared objects produced to be the same with and without the
change applied? If they are, then:
Yes I did and they were the same.
Quoted 4 lines
Reviewed-by Maciej W. Rozycki <[email protected]>Thanks for this follow-up cleanup.
Of course, thanks for all of your excellent feedback as usual!
Signature · 1 line
Florian
Quoted 4 lines · On Thu, 19 Nov 2026 21:08:26 -0800 Florian Fainelli <[email protected]>…
Remove .set noreorder and the two explicit delay-slot nops from the XBurst secondary CPU reset entry. GNU as emits identical reset-entry instructions with reordering enabled in both the CI20 and generic MIPS64r2 Ingenic SMP builds.
If the ordering actually mattered then the fact that the current toolchain doesn't break thinks isn't enough to guarantee that a future version won't find some way of generating invalid code.
The explicit nop in the delay slots might even be there because there is another reason for the .set noreorder.
If nothing else the commit message is misleading.
David
Quoted 41 lines
On CI20, two baseline and three updated cold boots brought both CPUs online. Each boot passed the CPU affinity check and 100 cross-core idle-wakeup round trips in each direction. Codex assisted with the assembly comparison and hardware test campaign.
Suggested-by Maciej W. Rozycki <[email protected]>Signed-off-by Florian Fainelli <[email protected]>---
Thomas, feel free to fixup into "MIPS: Ingenic: Add XBurst SMP support" if that is simpler. Thanks!arch/mips/ingenic/ingenic-smp-entry.S | 3 --- 1 file changed, 3 deletions(-)arch/mips/ingenic/ingenic-smp-entry.S +0
-3@@ -16,7 +16,6 @@ /* The CP0 REIM register only stores the upper 16 address bits. */ .section .text.smp-entry, "ax" .balign 0x10000 - .set noreorder LEAF(xburst_secondary_cpu_entry) mtc0 zero, CP0_CAUSE li t0, ST0_CU0@@ -32,7 +31,6 @@ LEAF(xburst_secondary_cpu_entry) cache Index_Store_Tag_D, 0(t0) addiu t0, t0, CACHE_LINESIZE bne t0, t1, 1b - nop mfc0 t0, CP0_CONFIG li t1, ~CONF_CM_CMASK@@ -50,5 +48,4 @@ LEAF(xburst_secondary_cpu_entry) PTR_LA t0, smp_bootstrap jr t0 - nop END(xburst_secondary_cpu_entry)
Quoted 8 lines · David Laight
Quoted 4 lines
Remove .set noreorder and the two explicit delay-slot nops from the XBurst secondary CPU reset entry. GNU as emits identical reset-entry instructions with reordering enabled in both the CI20 and generic MIPS64r2 Ingenic SMP builds.
If the ordering actually mattered then the fact that the current toolchain doesn't break thinks isn't enough to guarantee that a future version won't find some way of generating invalid code.
Nope, unless there is an explicit need to prevent GAS from ensuring that
pipeline hazards are taken care of user code is expected to use the standard `reorder' mode.
Legitimate examples are scheduling a branch delay slot when there is a
data dependency (the vast majority of cases, e.g. writing to a register the branch reads from) or when you do want to exploit a pipeline hazard for some reason (RFE in a branch delay slot comes to mind).
Otherwise the assembler ensures code semantics as written. If that is
not the case, then it is a bug in the tool that needs to be fixed. You can't write code in a specific way "because there may be a bug in a future version of a tool that could trigger if I wrote this differently," that's ridiculous.
From experience people tend to use `noreorder' when there's a missed
optimisation opportunity and they can't be bothered to file a bug against GAS. Or they take code produced by a compiler and tweak it by hand not bothering to rewrite it for `reorder' mode. This has caused real damage and hard to chase bugs.
Quoted 2 lines
The explicit nop in the delay slots might even be there because there is another reason for the .set noreorder.
Then `noreorder' blocks are supposed to wrap actual instruction sequences
that require manual scheduling and not the whole function, and the reason for the individual `noreorder' blocks needs to be documented within the code.
Conversely I had to fix code many times when someone used `noreorder'
needlessly and didn't take pipeline hazards into account of processors they didn't care of. That's just the wrong use of the tool.
And yes, I did put a lot of effort into GAS to get many missed scheduling
optimisations fixed. Most recently over the last weekend, concerning the HI/LO accumulator registers. At worst you'll get an extraneous NOP or a couple. In the vast majority of cases this is not a big deal and in all cases it's better than an unsatisfied pipeline hazard.
Maciej