summaryrefslogtreecommitdiffstats
path: root/include/asm-sparc64/spinlock.h
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1999-06-17 13:25:08 +0000
committerRalf Baechle <ralf@linux-mips.org>1999-06-17 13:25:08 +0000
commit59223edaa18759982db0a8aced0e77457d10c68e (patch)
tree89354903b01fa0a447bffeefe00df3044495db2e /include/asm-sparc64/spinlock.h
parentdb7d4daea91e105e3859cf461d7e53b9b77454b2 (diff)
Merge with Linux 2.3.6. Sorry, this isn't tested on silicon, I don't
have a MIPS box at hand.
Diffstat (limited to 'include/asm-sparc64/spinlock.h')
-rw-r--r--include/asm-sparc64/spinlock.h53
1 files changed, 50 insertions, 3 deletions
diff --git a/include/asm-sparc64/spinlock.h b/include/asm-sparc64/spinlock.h
index 1d3b35020..d0c25a965 100644
--- a/include/asm-sparc64/spinlock.h
+++ b/include/asm-sparc64/spinlock.h
@@ -20,6 +20,14 @@ typedef unsigned char spinlock_t;
#define spin_unlock(lock) do { } while(0)
#define spin_lock_irq(lock) cli()
#define spin_unlock_irq(lock) sti()
+#define spin_lock_bh(lock) \
+do { local_bh_count++; \
+ barrier(); \
+} while(0)
+#define spin_unlock_bh(lock) \
+do { barrier(); \
+ local_bh_count--; \
+} while(0)
#define spin_lock_irqsave(lock, flags) save_and_cli(flags)
#define spin_unlock_irqrestore(lock, flags) restore_flags(flags)
@@ -43,9 +51,28 @@ typedef unsigned long rwlock_t;
#define write_unlock(lock) do { } while(0)
#define read_lock_irq(lock) cli()
#define read_unlock_irq(lock) sti()
+#define read_lock_bh(lock) \
+do { local_bh_count++; \
+ barrier(); \
+} while(0)
+#define read_unlock_bh(lock) \
+do { barrier(); \
+ local_bh_count--; \
+} while(0)
+
#define write_lock_irq(lock) cli()
#define write_unlock_irq(lock) sti()
+#define write_lock_bh(lock) \
+do { local_bh_count++; \
+ barrier(); \
+} while(0)
+
+#define write_unlock_bh(lock) \
+do { barrier(); \
+ local_bh_count--; \
+} while(0)
+
#define read_lock_irqsave(lock, flags) save_and_cli(flags)
#define read_unlock_irqrestore(lock, flags) restore_flags(flags)
#define write_lock_irqsave(lock, flags) save_and_cli(flags)
@@ -149,6 +176,16 @@ extern __inline__ void spin_unlock_irq(spinlock_t *lock)
: "memory");
}
+#define spin_lock_bh(__lock) \
+do { local_bh_count++; \
+ spin_lock(__lock); \
+} while(0)
+
+#define spin_unlock_bh(__lock) \
+do { spin_unlock(__lock); \
+ local_bh_count--; \
+} while(0)
+
#define spin_lock_irqsave(__lock, flags) \
do { register spinlock_t *__lp asm("g1"); \
__lp = (__lock); \
@@ -186,11 +223,11 @@ typedef struct {
unsigned char lock;
unsigned int owner_pc, owner_cpu;
} spinlock_t;
-#define SPIN_LOCK_UNLOCKED (spinlock_t) { 0, 0, NO_PROC_ID }
+#define SPIN_LOCK_UNLOCKED (spinlock_t) { 0, 0, 0xff }
#define spin_lock_init(__lock) \
do { (__lock)->lock = 0; \
(__lock)->owner_pc = 0; \
- (__lock)->owner_cpu = NO_PROC_ID; \
+ (__lock)->owner_cpu = 0xff; \
} while(0)
#define spin_is_locked(__lock) (*((volatile unsigned char *)(&((__lock)->lock))) != 0)
#define spin_unlock_wait(__lock) \
@@ -205,9 +242,11 @@ extern int _spin_trylock (spinlock_t *lock);
#define spin_trylock(lp) _spin_trylock(lp)
#define spin_lock(lock) _do_spin_lock(lock, "spin_lock")
#define spin_lock_irq(lock) do { __cli(); _do_spin_lock(lock, "spin_lock_irq"); } while(0)
+#define spin_lock_bh(lock) do { local_bh_count++; _do_spin_lock(lock, "spin_lock_bh"); } while(0)
#define spin_lock_irqsave(lock, flags) do { __save_and_cli(flags); _do_spin_lock(lock, "spin_lock_irqsave"); } while(0)
#define spin_unlock(lock) _do_spin_unlock(lock)
#define spin_unlock_irq(lock) do { _do_spin_unlock(lock); __sti(); } while(0)
+#define spin_unlock_bh(lock) do { _do_spin_unlock(lock); local_bh_count--; } while(0)
#define spin_unlock_irqrestore(lock, flags) do { _do_spin_unlock(lock); __restore_flags(flags); } while(0)
#endif /* SPIN_LOCK_DEBUG */
@@ -303,8 +342,12 @@ extern __inline__ void write_unlock(rwlock_t *rw)
#define read_lock_irq(lock) do { __cli(); read_lock(lock); } while (0)
#define read_unlock_irq(lock) do { read_unlock(lock); __sti(); } while (0)
+#define read_lock_bh(lock) do { local_bh_count++; read_lock(lock); } while (0)
+#define read_unlock_bh(lock) do { read_unlock(lock); local_bh_count--; } while (0)
#define write_lock_irq(lock) do { __cli(); write_lock(lock); } while (0)
#define write_unlock_irq(lock) do { write_unlock(lock); __sti(); } while (0)
+#define write_lock_bh(lock) do { local_bh_count++; write_lock(lock); } while (0)
+#define write_unlock_bh(lock) do { write_unlock(lock); local_bh_count--; } while (0)
#define read_lock_irqsave(lock, flags) \
do { __save_and_cli(flags); read_lock(lock); } while (0)
@@ -322,7 +365,7 @@ typedef struct {
unsigned int writer_pc, writer_cpu;
unsigned int reader_pc[4];
} rwlock_t;
-#define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0, NO_PROC_ID, { 0, 0, 0, 0 } }
+#define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0, 0xff, { 0, 0, 0, 0 } }
extern void _do_read_lock(rwlock_t *rw, char *str);
extern void _do_read_unlock(rwlock_t *rw, char *str);
@@ -336,6 +379,7 @@ do { unsigned long flags; \
__restore_flags(flags); \
} while(0)
#define read_lock_irq(lock) do { __cli(); _do_read_lock(lock, "read_lock_irq"); } while(0)
+#define read_lock_bh(lock) do { local_bh_count++; _do_read_lock(lock, "read_lock_bh"); } while(0)
#define read_lock_irqsave(lock, flags) do { __save_and_cli(flags); _do_read_lock(lock, "read_lock_irqsave"); } while(0)
#define read_unlock(lock) \
@@ -345,6 +389,7 @@ do { unsigned long flags; \
__restore_flags(flags); \
} while(0)
#define read_unlock_irq(lock) do { _do_read_unlock(lock, "read_unlock_irq"); __sti() } while(0)
+#define read_unlock_bh(lock) do { _do_read_unlock(lock, "read_unlock_bh"); local_bh_count--; } while(0)
#define read_unlock_irqrestore(lock, flags) do { _do_read_unlock(lock, "read_unlock_irqrestore"); __restore_flags(flags); } while(0)
#define write_lock(lock) \
@@ -354,6 +399,7 @@ do { unsigned long flags; \
__restore_flags(flags); \
} while(0)
#define write_lock_irq(lock) do { __cli(); _do_write_lock(lock, "write_lock_irq"); } while(0)
+#define write_lock_bh(lock) do { local_bh_count++; _do_write_lock(lock, "write_lock_bh"); } while(0)
#define write_lock_irqsave(lock, flags) do { __save_and_cli(flags); _do_write_lock(lock, "write_lock_irqsave"); } while(0)
#define write_unlock(lock) \
@@ -363,6 +409,7 @@ do { unsigned long flags; \
__restore_flags(flags); \
} while(0)
#define write_unlock_irq(lock) do { _do_write_unlock(lock); __sti(); } while(0)
+#define write_unlock_bh(lock) do { _do_write_unlock(lock); local_bh_count--; } while(0)
#define write_unlock_irqrestore(lock, flags) do { _do_write_unlock(lock); __restore_flags(flags); } while(0)
#endif /* SPIN_LOCK_DEBUG */