- Update Xen patches to 3.3-rc5 and c/s 1157.
[linux-flexiantxendom0-3.2.10.git] / arch / x86 / include / mach-xen / asm / spinlock_types.h
1 #ifndef _ASM_X86_SPINLOCK_TYPES_H
2 #define _ASM_X86_SPINLOCK_TYPES_H
3
4 #ifndef __LINUX_SPINLOCK_TYPES_H
5 # error "please don't include this file directly"
6 #endif
7
8 #include <linux/types.h>
9
10 #ifdef CONFIG_XEN_SPINLOCK_ACQUIRE_NESTING
11 /*
12  * On Xen we support CONFIG_XEN_SPINLOCK_ACQUIRE_NESTING levels of
13  * interrupt re-enabling per IRQ-safe lock. Hence we can have
14  * (CONFIG_XEN_SPINLOCK_ACQUIRE_NESTING + 1) times as many outstanding
15  * tickets. Thus the cut-off for using byte register pairs must be at
16  * a sufficiently smaller number of CPUs.
17  */
18 #if (CONFIG_XEN_SPINLOCK_ACQUIRE_NESTING + 1) * CONFIG_NR_CPUS < 256
19 typedef u8  __ticket_t;
20 # define TICKET_SHIFT 8
21 typedef u16 __ticketpair_t;
22 #else
23 typedef u16 __ticket_t;
24 # define TICKET_SHIFT 16
25 typedef u32 __ticketpair_t;
26 #endif
27
28 typedef union {
29         __ticketpair_t head_tail;
30         struct {
31                 struct __raw_tickets {
32                         __ticket_t head, tail;
33                 } tickets;
34 #if CONFIG_NR_CPUS <= 256
35                 u8 owner;
36 #else
37                 u16 owner;
38 #endif
39         };
40 #else /* ndef CONFIG_XEN_SPINLOCK_ACQUIRE_NESTING */
41 typedef struct {
42 /*
43  * This differs from the pre-2.6.24 spinlock by always using xchgb
44  * rather than decb to take the lock; this allows it to use a
45  * zero-initialized lock structure.  It also maintains a 1-byte
46  * contention counter, so that we can implement
47  * __byte_spin_is_contended.
48  */
49         u8 lock;
50 #if CONFIG_NR_CPUS < 256
51         u8 spinners;
52 #else
53 # error NR_CPUS >= 256 not implemented
54 #endif
55 #endif /* def CONFIG_XEN_SPINLOCK_ACQUIRE_NESTING */
56 } arch_spinlock_t;
57
58 #define __ARCH_SPIN_LOCK_UNLOCKED       { 0 }
59
60 #include <asm/rwlock.h>
61
62 #endif /* _ASM_X86_SPINLOCK_TYPES_H */