v7 version of tas for ARM fails on BeagleBone Black
The tas code fails (in canlock) on ARMv7 under Linux arm 3.8.13-bone54.1 #2 SMP Tue Jun 10 23:53:06 EST 2014 armv7l GNU/Linux .
I wrote a version based on the ARM Reference example and all seems fine. I have attached my implementation.
Comments (4)
-
-
reporter What actually goes wrong in your case?
emu immediately crashes with the following diagnostic: SYS: process main faults: dereference of nil
I have had the code I submitted (plus memory barrier instructs) running on an iMX6 multi-core unit for several months and have not experienced any problems
-
reporter r4 is not a scratch reg on the linaro version of gcc. The following fixes the problems. I also added a clrex instruction as suggested
.file "arm-tas-v7.S" #ifndef ARMv7 #define DMB mcr p15, 0, r0, c7, c10, 5 #else #define DMB dmb #endif .align 2 .global _tas .type _tas, %function _tas: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 @ link register save eliminated. @ lr needed for prologue DMB mov r1, r0 mov r2, #0xaa tas1: ldrex r0, [r1] cmp r0, #0 bne lockbusy strex r3, r2, [r1] cmp r3, #0 bne tas1 DMB bx lr lockbusy: clrex bx lr .size _tas, .-_tas
-
Of course. I had tested it, but evidently was lucky in the test environment. I've applied the change and should have a chance to test it shortly. I wonder whether the short-circuit is really worthwhile.
- Log in to comment
It's certainly a mistake not to use clrex if the initial ldrex says not busy. Also, for real ARM mp usage several dmb memory barriers are needed. It looks as if it predated work on the mp arm kernels.
What actually goes wrong in your case?