lkml.org 
[lkml]   [2000]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: SMP spin_lock...

    > So however buggy the debug versions might be, it would appear the
    > non-debug versions don't work at all on Sparc-32 hardware.

    This should fix non-debug spinlocks on sparc32. I just checked it into vger.

    Cheers,
    Anton

    diff -ru --exclude=CVS linux/include/asm-sparc/asm_offsets.h linux_work/include/asm-sparc/asm_offsets.h
    --- linux/include/asm-sparc/asm_offsets.h Tue Nov 16 13:28:26 1999
    +++ linux_work/include/asm-sparc/asm_offsets.h Sun Feb 27 19:59:17 2000
    @@ -446,24 +446,24 @@
    #define AOFF_task_mm 0x00000668
    #define ASIZ_task_mm 0x00000004
    #define AOFF_task_sigmask_lock 0x0000066c
    -#define ASIZ_task_sigmask_lock 0x00000008
    -#define AOFF_task_sig 0x00000674
    +#define ASIZ_task_sigmask_lock 0x00000001
    +#define AOFF_task_sig 0x00000670
    #define ASIZ_task_sig 0x00000004
    -#define AOFF_task_signal 0x00000678
    +#define AOFF_task_signal 0x00000674
    #define ASIZ_task_signal 0x00000008
    -#define AOFF_task_blocked 0x00000680
    +#define AOFF_task_blocked 0x0000067c
    #define ASIZ_task_blocked 0x00000008
    -#define AOFF_task_sigqueue 0x00000688
    +#define AOFF_task_sigqueue 0x00000684
    #define ASIZ_task_sigqueue 0x00000004
    -#define AOFF_task_sigqueue_tail 0x0000068c
    +#define AOFF_task_sigqueue_tail 0x00000688
    #define ASIZ_task_sigqueue_tail 0x00000004
    -#define AOFF_task_sas_ss_sp 0x00000690
    +#define AOFF_task_sas_ss_sp 0x0000068c
    #define ASIZ_task_sas_ss_sp 0x00000004
    -#define AOFF_task_sas_ss_size 0x00000694
    +#define AOFF_task_sas_ss_size 0x00000690
    #define ASIZ_task_sas_ss_size 0x00000004
    -#define AOFF_task_parent_exec_id 0x00000698
    +#define AOFF_task_parent_exec_id 0x00000694
    #define ASIZ_task_parent_exec_id 0x00000004
    -#define AOFF_task_self_exec_id 0x0000069c
    +#define AOFF_task_self_exec_id 0x00000698
    #define ASIZ_task_self_exec_id 0x00000004
    #define AOFF_mm_mmap 0x00000000
    #define ASIZ_mm_mmap 0x00000004
    diff -ru --exclude=CVS linux/include/asm-sparc/spinlock.h linux_work/include/asm-sparc/spinlock.h
    --- linux/include/asm-sparc/spinlock.h Fri Jun 11 03:13:28 1999
    +++ linux_work/include/asm-sparc/spinlock.h Sun Feb 27 20:23:18 2000
    @@ -57,8 +57,13 @@

    #include <asm/psr.h>

    -/* Define this to use the verbose/debugging versions in arch/sparc/lib/debuglocks.c */
    -#define SPIN_LOCK_DEBUG
    +/*
    + * Define this to use the verbose/debugging versions in
    + * arch/sparc/lib/debuglocks.c
    + *
    + * Be sure to make check_asm whenever changing this option.
    + */
    +#undef SPIN_LOCK_DEBUG

    #ifdef SPIN_LOCK_DEBUG
    struct _spinlock_debug {
    @@ -141,9 +146,13 @@
    typedef unsigned char spinlock_t;
    #define SPIN_LOCK_UNLOCKED 0

    -#define spin_lock_init(lock) (*(lock) = 0)
    +#define spin_lock_init(lock) (*((unsigned char *)(lock)) = 0)
    #define spin_is_locked(lock) (*((volatile unsigned char *)(lock)) != 0)
    -#define spin_unlock_wait(lock) do { barrier(); } while(*(volatile unsigned char *)lock)
    +
    +#define spin_unlock_wait(lock) \
    +do { \
    + barrier(); \
    +} while(*((volatile unsigned char *)lock))

    extern __inline__ void spin_lock(spinlock_t *lock)
    {
    @@ -152,7 +161,7 @@
    orcc %%g2, 0x0, %%g0
    bne,a 2f
    ldub [%0], %%g2
    - .text 2
    + .subsection 2
    2: orcc %%g2, 0x0, %%g0
    bne,a 2b
    ldub [%0], %%g2
    @@ -178,77 +187,13 @@
    __asm__ __volatile__("stb %%g0, [%0]" : : "r" (lock) : "memory");
    }

    -extern __inline__ void spin_lock_irq(spinlock_t *lock)
    -{
    - __asm__ __volatile__("
    - rd %%psr, %%g2
    - or %%g2, %0, %%g2
    - wr %%g2, 0x0, %%psr
    - nop; nop; nop;
    -1: ldstub [%1], %%g2
    - orcc %%g2, 0x0, %%g0
    - bne,a 2f
    - ldub [%1], %%g2
    - .text 2
    -2: orcc %%g2, 0x0, %%g0
    - bne,a 2b
    - ldub [%1], %%g2
    - b,a 1b
    - .previous
    -" : /* No outputs */
    - : "i" (PSR_PIL), "r" (lock)
    - : "g2", "memory", "cc");
    -}
    -
    -extern __inline__ void spin_unlock_irq(spinlock_t *lock)
    -{
    - __asm__ __volatile__("
    - rd %%psr, %%g2
    - andn %%g2, %1, %%g2
    - stb %%g0, [%0]
    - wr %%g2, 0x0, %%psr
    - nop; nop; nop;
    -" : /* No outputs. */
    - : "r" (lock), "i" (PSR_PIL)
    - : "g2", "memory");
    -}
    +#define spin_lock_irqsave(lock, flags) \
    + do { __save_and_cli(flags); spin_lock(lock); } while (0)
    +#define spin_unlock_irqrestore(lock, flags) \
    + do { spin_unlock(lock); __restore_flags(flags); } while (0)

    -#define spin_lock_irqsave(__lock, flags) \
    -do { \
    - register spinlock_t *__lp asm("g1"); \
    - __lp = (__lock); \
    - __asm__ __volatile__( \
    - "rd %%psr, %0\n\t" \
    - "or %0, %1, %%g2\n\t" \
    - "wr %%g2, 0x0, %%psr\n\t" \
    - "nop; nop; nop;\n" \
    - "1:\n\t" \
    - "ldstub [%2], %%g2\n\t" \
    - "orcc %%g2, 0x0, %%g0\n\t" \
    - "bne,a 2f\n\t" \
    - " ldub [%2], %%g2\n\t" \
    - ".text 2\n" \
    - "2:\n\t" \
    - "orcc %%g2, 0x0, %%g0\n\t" \
    - "bne,a 2b\n\t" \
    - " ldub [%2], %%g2\n\t" \
    - "b,a 1b\n\t" \
    - ".previous\n" \
    - : "=r" (flags) \
    - : "i" (PSR_PIL), "r" (__lp) \
    - : "g2", "memory", "cc"); \
    -} while(0)
    -
    -extern __inline__ void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags)
    -{
    - __asm__ __volatile__("
    - stb %%g0, [%0]
    - wr %1, 0x0, %%psr
    - nop; nop; nop;
    -" : /* No outputs. */
    - : "r" (lock), "r" (flags)
    - : "memory", "cc");
    -}
    +#define spin_lock_irq(lock) do { __cli(); spin_lock(lock); } while (0)
    +#define spin_unlock_irq(lock) do { spin_unlock(lock); __sti(); } while (0)

    /* Read-write spinlocks, allowing multiple readers
    * but only one writer.
    @@ -290,7 +235,7 @@
    ldstub [%%g1 + 3], %%g2
    " : /* no outputs */
    : "r" (lp)
    - : "g2", "g4", "g7", "memory", "cc");
    + : "g2", "g4", "memory", "cc");
    }

    #define read_lock(lock) \
    @@ -310,7 +255,7 @@
    ldstub [%%g1 + 3], %%g2
    " : /* no outputs */
    : "r" (lp)
    - : "g2", "g4", "g7", "memory", "cc");
    + : "g2", "g4", "memory", "cc");
    }

    #define read_unlock(lock) \
    @@ -330,7 +275,7 @@
    ldstub [%%g1 + 3], %%g2
    " : /* no outputs */
    : "r" (lp)
    - : "g2", "g4", "g7", "memory", "cc");
    + : "g2", "g4", "memory", "cc");
    }

    #define write_unlock(rw) do { (rw)->lock = 0; } while(0)
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.rutgers.edu
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:56    [W:0.045 / U:0.316 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site