diff options
author | Nathan Lynch <ntl@pobox.com> | 2012-11-05 09:20:31 -0500 |
---|---|---|
committer | Bryan Wu <roc@roc-samos.(none)> | 2012-11-11 15:09:43 -0500 |
commit | 0b8728d6f140dc20690384286ade47c956edc999 (patch) | |
tree | 52a1c8a4e0b3b39396f2967e8478acf9464ca0c5 /drivers/leds/ledtrig-cpu.c | |
parent | 77b67063bb6bce6d475e910d3b886a606d0d91f7 (diff) |
ledtrig-cpu: kill useless mutex to fix sleep in atomic context
Seeing the following every time the CPU enters or leaves idle on a
Beagleboard:
BUG: sleeping function called from invalid context at kernel/mutex.c:269
in_atomic(): 1, irqs_disabled(): 0, pid: 0, name: swapper/0
no locks held by swapper/0/0.
[<c001659c>] (unwind_backtrace+0x0/0xf8) from [<c05aaa7c>] (mutex_lock_nested+0x24/0x380)
[<c05aaa7c>] (mutex_lock_nested+0x24/0x380) from [<c043bd1c>] (ledtrig_cpu+0x38/0x88)
[<c043bd1c>] (ledtrig_cpu+0x38/0x88) from [<c000f4b0>] (cpu_idle+0xf4/0x120)
[<c000f4b0>] (cpu_idle+0xf4/0x120) from [<c07e47c8>] (start_kernel+0x2bc/0x30c)
Miles Lane has reported seeing similar splats during system suspend.
The mutex in struct led_trigger_cpu appears to have no function: it
resides in a per-cpu data structure which never changes after the
trigger is registered. So just remove it.
Reported-by: Miles Lane <miles.lane@gmail.com>
Signed-off-by: Nathan Lynch <ntl@pobox.com>
Signed-off-by: Bryan Wu <roc@roc-samos.(none)>
Diffstat (limited to 'drivers/leds/ledtrig-cpu.c')
-rw-r--r-- | drivers/leds/ledtrig-cpu.c | 21 |
1 files changed, 0 insertions, 21 deletions
diff --git a/drivers/leds/ledtrig-cpu.c b/drivers/leds/ledtrig-cpu.c index b312056da14d..4239b3955ff0 100644 --- a/drivers/leds/ledtrig-cpu.c +++ b/drivers/leds/ledtrig-cpu.c | |||
@@ -33,8 +33,6 @@ | |||
33 | struct led_trigger_cpu { | 33 | struct led_trigger_cpu { |
34 | char name[MAX_NAME_LEN]; | 34 | char name[MAX_NAME_LEN]; |
35 | struct led_trigger *_trig; | 35 | struct led_trigger *_trig; |
36 | struct mutex lock; | ||
37 | int lock_is_inited; | ||
38 | }; | 36 | }; |
39 | 37 | ||
40 | static DEFINE_PER_CPU(struct led_trigger_cpu, cpu_trig); | 38 | static DEFINE_PER_CPU(struct led_trigger_cpu, cpu_trig); |
@@ -50,12 +48,6 @@ void ledtrig_cpu(enum cpu_led_event ledevt) | |||
50 | { | 48 | { |
51 | struct led_trigger_cpu *trig = &__get_cpu_var(cpu_trig); | 49 | struct led_trigger_cpu *trig = &__get_cpu_var(cpu_trig); |
52 | 50 | ||
53 | /* mutex lock should be initialized before calling mutex_call() */ | ||
54 | if (!trig->lock_is_inited) | ||
55 | return; | ||
56 | |||
57 | mutex_lock(&trig->lock); | ||
58 | |||
59 | /* Locate the correct CPU LED */ | 51 | /* Locate the correct CPU LED */ |
60 | switch (ledevt) { | 52 | switch (ledevt) { |
61 | case CPU_LED_IDLE_END: | 53 | case CPU_LED_IDLE_END: |
@@ -75,8 +67,6 @@ void ledtrig_cpu(enum cpu_led_event ledevt) | |||
75 | /* Will leave the LED as it is */ | 67 | /* Will leave the LED as it is */ |
76 | break; | 68 | break; |
77 | } | 69 | } |
78 | |||
79 | mutex_unlock(&trig->lock); | ||
80 | } | 70 | } |
81 | EXPORT_SYMBOL(ledtrig_cpu); | 71 | EXPORT_SYMBOL(ledtrig_cpu); |
82 | 72 | ||
@@ -117,14 +107,9 @@ static int __init ledtrig_cpu_init(void) | |||
117 | for_each_possible_cpu(cpu) { | 107 | for_each_possible_cpu(cpu) { |
118 | struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu); | 108 | struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu); |
119 | 109 | ||
120 | mutex_init(&trig->lock); | ||
121 | |||
122 | snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu); | 110 | snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu); |
123 | 111 | ||
124 | mutex_lock(&trig->lock); | ||
125 | led_trigger_register_simple(trig->name, &trig->_trig); | 112 | led_trigger_register_simple(trig->name, &trig->_trig); |
126 | trig->lock_is_inited = 1; | ||
127 | mutex_unlock(&trig->lock); | ||
128 | } | 113 | } |
129 | 114 | ||
130 | register_syscore_ops(&ledtrig_cpu_syscore_ops); | 115 | register_syscore_ops(&ledtrig_cpu_syscore_ops); |
@@ -142,15 +127,9 @@ static void __exit ledtrig_cpu_exit(void) | |||
142 | for_each_possible_cpu(cpu) { | 127 | for_each_possible_cpu(cpu) { |
143 | struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu); | 128 | struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu); |
144 | 129 | ||
145 | mutex_lock(&trig->lock); | ||
146 | |||
147 | led_trigger_unregister_simple(trig->_trig); | 130 | led_trigger_unregister_simple(trig->_trig); |
148 | trig->_trig = NULL; | 131 | trig->_trig = NULL; |
149 | memset(trig->name, 0, MAX_NAME_LEN); | 132 | memset(trig->name, 0, MAX_NAME_LEN); |
150 | trig->lock_is_inited = 0; | ||
151 | |||
152 | mutex_unlock(&trig->lock); | ||
153 | mutex_destroy(&trig->lock); | ||
154 | } | 133 | } |
155 | 134 | ||
156 | unregister_syscore_ops(&ledtrig_cpu_syscore_ops); | 135 | unregister_syscore_ops(&ledtrig_cpu_syscore_ops); |