[MIPS] SMTC: <asm/smtc_ipi.h> must include <linux/spinlock.h>
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / asm-mips / smtc_ipi.h
blob360ea6d250c7a7aab3ec8516cffb99413bfe0e66
1 /*
2 * Definitions used in MIPS MT SMTC "Interprocessor Interrupt" code.
3 */
4 #ifndef __ASM_SMTC_IPI_H
5 #define __ASM_SMTC_IPI_H
7 #include <linux/spinlock.h>
9 //#define SMTC_IPI_DEBUG
11 #ifdef SMTC_IPI_DEBUG
12 #include <asm/mipsregs.h>
13 #include <asm/mipsmtregs.h>
14 #endif /* SMTC_IPI_DEBUG */
17 * An IPI "message"
20 struct smtc_ipi {
21 struct smtc_ipi *flink;
22 int type;
23 void *arg;
24 int dest;
25 #ifdef SMTC_IPI_DEBUG
26 int sender;
27 long stamp;
28 #endif /* SMTC_IPI_DEBUG */
32 * Defined IPI Types
35 #define LINUX_SMP_IPI 1
36 #define SMTC_CLOCK_TICK 2
39 * A queue of IPI messages
42 struct smtc_ipi_q {
43 struct smtc_ipi *head;
44 spinlock_t lock;
45 struct smtc_ipi *tail;
46 int depth;
49 static inline void smtc_ipi_nq(struct smtc_ipi_q *q, struct smtc_ipi *p)
51 long flags;
53 spin_lock_irqsave(&q->lock, flags);
54 if (q->head == NULL)
55 q->head = q->tail = p;
56 else
57 q->tail->flink = p;
58 p->flink = NULL;
59 q->tail = p;
60 q->depth++;
61 #ifdef SMTC_IPI_DEBUG
62 p->sender = read_c0_tcbind();
63 p->stamp = read_c0_count();
64 #endif /* SMTC_IPI_DEBUG */
65 spin_unlock_irqrestore(&q->lock, flags);
68 static inline struct smtc_ipi *smtc_ipi_dq(struct smtc_ipi_q *q)
70 struct smtc_ipi *p;
71 long flags;
73 spin_lock_irqsave(&q->lock, flags);
74 if (q->head == NULL)
75 p = NULL;
76 else {
77 p = q->head;
78 q->head = q->head->flink;
79 q->depth--;
80 /* Arguably unnecessary, but leaves queue cleaner */
81 if (q->head == NULL)
82 q->tail = NULL;
84 spin_unlock_irqrestore(&q->lock, flags);
85 return p;
88 static inline void smtc_ipi_req(struct smtc_ipi_q *q, struct smtc_ipi *p)
90 long flags;
92 spin_lock_irqsave(&q->lock, flags);
93 if (q->head == NULL) {
94 q->head = q->tail = p;
95 p->flink = NULL;
96 } else {
97 p->flink = q->head;
98 q->head = p;
100 q->depth++;
101 spin_unlock_irqrestore(&q->lock, flags);
104 static inline int smtc_ipi_qdepth(struct smtc_ipi_q *q)
106 long flags;
107 int retval;
109 spin_lock_irqsave(&q->lock, flags);
110 retval = q->depth;
111 spin_unlock_irqrestore(&q->lock, flags);
112 return retval;
115 extern void smtc_send_ipi(int cpu, int type, unsigned int action);
117 #endif /* __ASM_SMTC_IPI_H */