forked from luckasfb/kernel_mtk6577
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmutex.h
134 lines (126 loc) · 4.09 KB
/
mutex.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* Mutexes: blocking mutual exclusion locks
*
* started by Ingo Molnar:
*
* Copyright (C) 2004, 2005, 2006 Red Hat, Inc., Ingo Molnar <[email protected]>
*
* This file contains mutex debugging related internal prototypes, for the
* !CONFIG_DEBUG_MUTEXES case. Most of them are NOPs:
*/
#include <linux/ftrace.h>
#include <linux/aee.h>
#define spin_lock_mutex(lock, flags) \
do { spin_lock(lock); (void)(flags); } while (0)
#define spin_unlock_mutex(lock, flags) \
do { spin_unlock(lock); (void)(flags); } while (0)
#define mutex_remove_waiter(lock, waiter, ti) \
__list_del((waiter)->list.prev, (waiter)->list.next)
#ifdef CONFIG_SMP
static inline void mutex_set_owner(struct mutex *lock)
{
#ifdef CONFIG_MT_LOCK_DEBUG
unsigned long flags;
char aee_str[40];
preempt_disable();
local_irq_save(flags);
if(lock->owner == current)
{
printk("[Warning!Recursive MutexLock!][%d:%s], lock:%s\n", current->pid, current->comm, lock->mutex_name);
sprintf( aee_str, "Recursive MutexLock:%s\n", current->comm);
aee_kernel_warning( aee_str,"mtlock debugger\n");
dump_stack();
}
lock->owner = current;
lock->caller = (void*)CALLER_ADDR0;
if(¤t->mutex_head == NULL || lock == NULL){
printk("[%d:%s][mutex_debug] warning, 0x%x:0x%x\n", current->pid, current->comm, (unsigned long)¤t->mutex_head, (unsigned long)lock);
local_irq_restore(flags);
preempt_enable();
return;
}
/* This condition check is for kernel init, first process, maybe */
if(current->mutex_head.prev == 0 )
INIT_LIST_HEAD(¤t->mutex_head);
if(list_empty(¤t->mutex_head))
INIT_LIST_HEAD(&lock->mutex_list);
list_add(&lock->mutex_list, ¤t->mutex_head);
local_irq_restore(flags);
preempt_enable();
#else
lock->owner = current;
#endif
}
static inline void mutex_clear_owner(struct mutex *lock)
{
#ifdef CONFIG_MT_LOCK_DEBUG
unsigned long flags;
preempt_disable();
local_irq_save(flags);
lock->caller = NULL;
lock->owner = NULL;
list_del(&lock->mutex_list);
INIT_LIST_HEAD(&lock->mutex_list);
local_irq_restore(flags);
preempt_enable();
#else
lock->owner = NULL;
#endif
}
#else
static inline void mutex_set_owner(struct mutex *lock)
{
#ifdef CONFIG_MT_LOCK_DEBUG
unsigned long flags;
char aee_str[40];
if(lock->owner == current)
{
printk("[Warning!Recursive Lock!][%d:%s], mutex lock:%s\n", current->pid, current->comm, lock->mutex_name);
sprintf( aee_str, "Recursive MutexLock:%s\n", current->comm);
aee_kernel_warning( aee_str,"mtlock debugger\n");
dump_stack();
}
preempt_disable();
local_irq_save(flags);
lock->owner = current;
lock->caller = CALLER_ADDR0;
if(current->mutex_head == NULL || lock == NULL){
printk("[%d:%s][mutex_debug] warning, 0x%x:0x%x\n", current->pid, current->comm, ¤t->mutex_head, &lock->mutex_list);
local_irq_restore(flags);
preempt_enable();
return;
}
/* This condition check is for kernel init, first process, maybe */
if(current->mutex_head.prev == 0 )
INIT_LIST_HEAD(¤t->mutex_head);
if(list_empty(¤t->mutex_head))
INIT_LIST_HEAD(&lock->mutex_list);
list_add(&lock->mutex_list, ¤t->mutex_head);
local_irq_restore(flags);
preempt_enable();
#endif
}
static inline void mutex_clear_owner(struct mutex *lock)
{
#ifdef CONFIG_MT_LOCK_DEBUG
unsigned long flags;
preempt_disable();
local_irq_save(flags);
lock->caller = NULL;
lock->owner = NULL;
list_del(&lock->mutex_list);
INIT_LIST_HEAD(&lock->mutex_list);
local_irq_restore(flags);
preempt_enable();
#endif
}
#endif
#define debug_mutex_wake_waiter(lock, waiter) do { } while (0)
#define debug_mutex_free_waiter(waiter) do { } while (0)
#define debug_mutex_add_waiter(lock, waiter, ti) do { } while (0)
#define debug_mutex_unlock(lock) do { } while (0)
#define debug_mutex_init(lock, name, key) do { } while (0)
static inline void
debug_mutex_lock_common(struct mutex *lock, struct mutex_waiter *waiter)
{
}