Skip to content

Conversation

@masayuki2009
Copy link
Contributor

Summary

  • During the stress test with sabre-6quad:smp (QEMU), I noticed
    that sometimes prefetch abort happens.
  • Finally, I found that g_irqtmp is corrupted.
  • This commit fixes this issue with the following changes
    • Allocate g_irqtmp for all CPUs
    • Load g_irqtmp only once in arm_vectorirq()
    • In SMP mode, the IRQ mode stack is set in arm_start_handler()
    • Also, access to the g_irqtmp is adjusted in arm_vectorirq()

Impact

  • IRQ handling for armv7-a

Testing

  • Tested with the following configs
    • sabre-6quad:smp (QEMU, dev board)
    • sabre-6quad:netnsh (QEMU)

@Donny9
Copy link
Contributor

Donny9 commented Apr 1, 2021

armv7-a/arm_vectors.S: Assembler messages:
armv7-a/arm_vectors.S:204: Error: bad instruction `cpuindex r1'
Makefile:151: recipe for target 'armv7-a/arm_vectors.o' failed

armv7-a/arm_vectors.S: Line 108, This marco "cpuindex" don't used when enable CONFIG_SMP
#if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 7
.macro cpuindex, index
.mov \index, #0
.endm
#endif

@masayuki2009
Copy link
Contributor Author

@Donny9

Which configuration are you using?

@Donny9
Copy link
Contributor

Donny9 commented Apr 1, 2021

@Donny9

Which configuration are you using?

In our own project, it used A7 SMP. and apply this patch, the compile is broken.

@masayuki2009
Copy link
Contributor Author

In our own project, it used A7 SMP. and apply this patch, the compile is broken.

@Donny9

Perhaps, your project does not set CONFIG_ARCH_INTERRUPTSTACK.
Is my understanding correct?

@Donny9
Copy link
Contributor

Donny9 commented Apr 1, 2021

In our own project, it used A7 SMP. and apply this patch, the compile is broken.

@Donny9

Perhaps, your project does not set CONFIG_ARCH_INTERRUPTSTACK.
Is my understanding correct?

Yes, we set CONFIG_ARCH_INTERRUPTSTACK=0, and CONFIG_SMP=y, and this cpuindex don't find.

@masayuki2009
Copy link
Contributor Author

Yes, we set CONFIG_ARCH_INTERRUPTSTACK=0, and CONFIG_SMP=y, and this cpuindex don't find.

@Donny9

OK, I've just fixed for imx6 case.
Please apply the patch to your board.

@Donny9
Copy link
Contributor

Donny9 commented Apr 1, 2021

Yes, we set CONFIG_ARCH_INTERRUPTSTACK=0, and CONFIG_SMP=y, and this cpuindex don't find.

@Donny9

OK, I've just fixed for imx6 case.
Please apply the patch to your board.

Yes, i try it. Thank you.

@jerpelea jerpelea self-requested a review April 1, 2021 11:17
Copy link
Contributor

@jerpelea jerpelea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


/* Set IRQ mode stack for this CPU */

set_irqstack((uintptr_t)&g_irqtmp + (8 * this_cpu()));
Copy link
Contributor

@xiaoxiang781216 xiaoxiang781216 Apr 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not move to arm_vectors.S?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiaoxiang781216

Because it's difficult to write the same thing in assembler at the beginning of arm_vectorirq().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will study the code tonight to find wether can fix the bug in assemble code, will give the feedback tomorrow.

@Donny9
Copy link
Contributor

Donny9 commented Apr 1, 2021

@masayuki2009 I enable ARM_THUMB, complie break:

{standard input}: Assembler messages:
{standard input}:69: Error: Thumb encoding does not support an immediate here -- `msr cpsr_c,#18'
Makefile:154: recipe for target 'armv7-a/arm_cpustart.o' failed

ldr r0, .Lirqtmp /* Points to temp storage */

#ifdef CONFIG_SMP
cpuindex r1 /* r1 = cpuindex */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible directly get cpuindex?
mrc CP15_MPIDR(r1) /* Get R1=MPIDR /
and r1, r1, #MPIDR_CPUID_MASK
mov r1, r1, lsl #MPIDR_CPUID_SHIFT /
r1 = cpuindex */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Donny9

Why do you want not to use the macro?

@acassis acassis marked this pull request as draft April 1, 2021 18:07
@acassis
Copy link
Contributor

acassis commented Apr 1, 2021

Converted to Draft, waiting until @xiaoxiang781216 verify if it can be fixed in assembly code

@masayuki2009
Copy link
Contributor Author

{standard input}:69: Error: Thumb encoding does not support an immediate here -- `msr cpsr_c,#18'

@Donny9

I've just fixed the compile error in thumb2 mode.

@masayuki2009 masayuki2009 marked this pull request as ready for review April 1, 2021 21:49
@masayuki2009
Copy link
Contributor Author

Hmmm, Lint failed...

error pulling image configuration: received unexpected HTTP status: 503 No healthy IP available for the backend
Warning: Docker pull failed with exit code 1, back off 1.046 seconds before retry.
/usr/bin/docker pull ghcr.io/github/super-linter:v3.15.5

@masayuki2009
Copy link
Contributor Author

Hmm,

Download action repository 'actions/download-artifact@v1'
Warning: Failed to download action 'https://api.github.com/repos/actions/download-artifact/tarball/18f0f591fbc635562c815484d73b6e8e3980482e'. Error: Resource temporarily unavailable
Warning: Back off 23.69 seconds before retry.
Warning: Failed to download action 'https://api.github.com/repos/actions/download-artifact/tarball/18f0f591fbc635562c815484d73b6e8e3980482e'. Error: Resource temporarily unavailable
Warning: Back off 13.689 seconds before retry.
Error: Resource temporarily unavailable

@acassis
Copy link
Contributor

acassis commented Apr 4, 2021

@xiaoxiang781216 @Donny9 is it working now? May we merge it?

@xiaoxiang781216
Copy link
Contributor

xiaoxiang781216 commented Apr 4, 2021

I am working on this, and will provide a update tonight or tomorrow morning.

@masayuki2009
Copy link
Contributor Author

I rebased the branch and fixed conflicts.

@masayuki2009
Copy link
Contributor Author

Refactor the inline assembly code in the set_irqstack()

@xiaoxiang781216
Copy link
Contributor

@masayuki2009 , I will take a look tonight.


.globl g_irqtmp

g_irqtmp:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we avoid use the temporary storage? so SMP get resolved automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiaoxiang781216

Hmm, I also tried to remove the temporary storage but I was not able to find how to do that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have an idea that:

  1. Switch to SVC mode directly in the entry point
  2. Save some registers to stack
  3. Switch back IRQ/FIQ/ABT/UND mode
  4. Read LR/SPRS register
  5. Switch to SVC mode again

Step 4 should has enough free registers saved at step 2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have an idea that:

@xiaoxiang781216

Can you create a new PR for it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will try this afternoon. We hit the same issue on dual Cortex-A7 SoC.

Summary:
- During the stress test with sabre-6quad:smp (QEMU), I noticed
  that sometimes prefetch abort happens.
- Finally, I found that g_irqtmp is corrupted.
- This commit fixes this issue with the following changes
  - Allocate g_irqtmp for all CPUs
  - Load g_irqtmp only once in arm_vectorirq()
  - In SMP mode, the IRQ mode stack is set in arm_start_handler()
  - Also, access to the g_irqtmp is adjusted in arm_vectorirq()
  - Apply the same logic to FIQ/ABORT/UNDEF stacks

Impact:
- IRQ/FIQ/ABORT/UNDEF handling for armv7-a

Testing:
- Tested with the following configs
  - sabre-6quad:smp (QEMU, dev board)
  - sabre-6quad:netnsh (QEMU)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
…ACK=0

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
@xiaoxiang781216
Copy link
Contributor

@masayuki2009 could you try this patch #3451?

@masayuki2009
Copy link
Contributor Author

#3451 resolved this issue.
So close this PR.

@masayuki2009 masayuki2009 deleted the armv7-a branch April 8, 2021 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants