v7 version of tas for ARM fails on BeagleBone Black

Issue #342 new
Graham Gallagher created an issue

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)

  1. Charles Forsyth

    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?

  2. Graham Gallagher 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

  3. Graham Gallagher 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
    
  4. Charles Forsyth

    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.

  5. Log in to comment