Skip to content

Commit 0e429c9

Browse files
Liang Chenrkhuangtao
authored andcommitted
ANDROID: power: wakeup_reason: convert wakeup_reason_lock to raw_spinlock_t for PREEMPT_RT
<3>[ 141.648698][ C0] BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:970 <3>[ 141.648723][ C0] in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 0, name: swapper/0 <4>[ 141.648739][ C0] INFO: lockdep is turned off. <4>[ 141.648745][ C0] irq event stamp: 22142 <4>[ 141.648751][ C0] hardirqs last enabled at (22141): [<ffffffc010139a98>] tick_nohz_idle_exit+0x90/0x134 <4>[ 141.648785][ C0] hardirqs last disabled at (22142): [<ffffffc01139fdd8>] __schedule+0x80/0x6d4 <4>[ 141.648812][ C0] softirqs last enabled at (2818): [<ffffffc010056c20>] __local_bh_enable_ip+0x1f4/0x258 <4>[ 141.648840][ C0] softirqs last disabled at (2812): [<ffffffc01015f654>] local_bh_disable+0x4/0x30 <3>[ 141.648867][ C0] Preemption disabled at: <3>[ 141.648872][ C0] [<ffffffc0113a0570>] schedule_preempt_disabled+0x20/0x2c <4>[ 141.648900][ C0] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W 5.10.66-rt53 #6 <4>[ 141.648918][ C0] Hardware name: Rockchip RK3588 EVB1 LP4 V10 Board (DT) <4>[ 141.648927][ C0] Call trace: <4>[ 141.648932][ C0] dump_backtrace+0x0/0x1c4 <4>[ 141.648956][ C0] show_stack+0x18/0x24 <4>[ 141.648977][ C0] dump_stack_lvl+0xec/0x148 <4>[ 141.648993][ C0] dump_stack+0x18/0x64 <4>[ 141.649008][ C0] ___might_sleep+0x1b4/0x1c4 <4>[ 141.649030][ C0] rt_spin_lock+0x70/0xd8 <4>[ 141.649046][ C0] log_abnormal_wakeup_reason+0x64/0xd8 <4>[ 141.649066][ C0] handle_fasteoi_irq+0x224/0x228 <4>[ 141.649084][ C0] __handle_domain_irq+0xb0/0x11c <4>[ 141.649105][ C0] gic_handle_irq+0x74/0x14c <4>[ 141.649123][ C0] el1_irq+0xd0/0x1c0 <4>[ 141.649138][ C0] cpuidle_enter_state+0x184/0x2d0 <4>[ 141.649156][ C0] cpuidle_enter+0x38/0x50 <4>[ 141.649170][ C0] cpuidle_idle_call+0x188/0x278 <4>[ 141.649189][ C0] do_idle+0xb8/0x10c <4>[ 141.649205][ C0] cpu_startup_entry+0x24/0x28 <4>[ 141.649222][ C0] rest_init+0x1ec/0x1fc <4>[ 141.649240][ C0] arch_call_rest_init+0x10/0x1c <4>[ 141.649260][ C0] start_kernel+0x3f0/0x524 Signed-off-by: Liang Chen <cl@rock-chips.com> Change-Id: I383164b2a646250d34dc7c085e7a1d297889581e
1 parent c1ea5ca commit 0e429c9

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

kernel/power/wakeup_reason.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ enum wakeup_reason_flag {
4848
RESUME_ABNORMAL,
4949
};
5050

51-
static DEFINE_SPINLOCK(wakeup_reason_lock);
51+
static DEFINE_RAW_SPINLOCK(wakeup_reason_lock);
5252

5353
static LIST_HEAD(leaf_irqs); /* kept in ascending IRQ sorted order */
5454
static LIST_HEAD(parent_irqs); /* unordered */
@@ -152,22 +152,22 @@ void log_irq_wakeup_reason(int irq)
152152
{
153153
unsigned long flags;
154154

155-
spin_lock_irqsave(&wakeup_reason_lock, flags);
155+
raw_spin_lock_irqsave(&wakeup_reason_lock, flags);
156156
if (wakeup_reason == RESUME_ABNORMAL || wakeup_reason == RESUME_ABORT) {
157-
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
157+
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
158158
return;
159159
}
160160

161161
if (!capture_reasons) {
162-
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
162+
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
163163
return;
164164
}
165165

166166
if (find_node_in_list(&parent_irqs, irq) == NULL)
167167
add_sibling_node_sorted(&leaf_irqs, irq);
168168

169169
wakeup_reason = RESUME_IRQ;
170-
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
170+
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
171171
}
172172

173173
void log_threaded_irq_wakeup_reason(int irq, int parent_irq)
@@ -185,15 +185,15 @@ void log_threaded_irq_wakeup_reason(int irq, int parent_irq)
185185
if (!capture_reasons)
186186
return;
187187

188-
spin_lock_irqsave(&wakeup_reason_lock, flags);
188+
raw_spin_lock_irqsave(&wakeup_reason_lock, flags);
189189

190190
if (wakeup_reason == RESUME_ABNORMAL || wakeup_reason == RESUME_ABORT) {
191-
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
191+
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
192192
return;
193193
}
194194

195195
if (!capture_reasons || (find_node_in_list(&leaf_irqs, irq) != NULL)) {
196-
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
196+
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
197197
return;
198198
}
199199

@@ -209,7 +209,7 @@ void log_threaded_irq_wakeup_reason(int irq, int parent_irq)
209209
}
210210
}
211211

212-
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
212+
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
213213
}
214214
EXPORT_SYMBOL_GPL(log_threaded_irq_wakeup_reason);
215215

@@ -218,11 +218,11 @@ static void __log_abort_or_abnormal_wake(bool abort, const char *fmt,
218218
{
219219
unsigned long flags;
220220

221-
spin_lock_irqsave(&wakeup_reason_lock, flags);
221+
raw_spin_lock_irqsave(&wakeup_reason_lock, flags);
222222

223223
/* Suspend abort or abnormal wake reason has already been logged. */
224224
if (wakeup_reason != RESUME_NONE) {
225-
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
225+
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
226226
return;
227227
}
228228

@@ -233,7 +233,7 @@ static void __log_abort_or_abnormal_wake(bool abort, const char *fmt,
233233

234234
vsnprintf(non_irq_wake_reason, MAX_SUSPEND_ABORT_LEN, fmt, args);
235235

236-
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
236+
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
237237
}
238238

239239
void log_suspend_abort_reason(const char *fmt, ...)
@@ -260,28 +260,28 @@ void clear_wakeup_reasons(void)
260260
{
261261
unsigned long flags;
262262

263-
spin_lock_irqsave(&wakeup_reason_lock, flags);
263+
raw_spin_lock_irqsave(&wakeup_reason_lock, flags);
264264

265265
delete_list(&leaf_irqs);
266266
delete_list(&parent_irqs);
267267
wakeup_reason = RESUME_NONE;
268268
capture_reasons = true;
269269

270-
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
270+
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
271271
}
272272

273273
static void print_wakeup_sources(void)
274274
{
275275
struct wakeup_irq_node *n;
276276
unsigned long flags;
277277

278-
spin_lock_irqsave(&wakeup_reason_lock, flags);
278+
raw_spin_lock_irqsave(&wakeup_reason_lock, flags);
279279

280280
capture_reasons = false;
281281

282282
if (wakeup_reason == RESUME_ABORT) {
283283
pr_info("Abort: %s\n", non_irq_wake_reason);
284-
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
284+
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
285285
return;
286286
}
287287

@@ -294,7 +294,7 @@ static void print_wakeup_sources(void)
294294
else
295295
pr_info("Resume cause unknown\n");
296296

297-
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
297+
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
298298
}
299299

300300
static ssize_t last_resume_reason_show(struct kobject *kobj,
@@ -304,12 +304,12 @@ static ssize_t last_resume_reason_show(struct kobject *kobj,
304304
struct wakeup_irq_node *n;
305305
unsigned long flags;
306306

307-
spin_lock_irqsave(&wakeup_reason_lock, flags);
307+
raw_spin_lock_irqsave(&wakeup_reason_lock, flags);
308308

309309
if (wakeup_reason == RESUME_ABORT) {
310310
buf_offset = scnprintf(buf, PAGE_SIZE, "Abort: %s",
311311
non_irq_wake_reason);
312-
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
312+
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
313313
return buf_offset;
314314
}
315315

@@ -322,7 +322,7 @@ static ssize_t last_resume_reason_show(struct kobject *kobj,
322322
buf_offset = scnprintf(buf, PAGE_SIZE, "-1 %s",
323323
non_irq_wake_reason);
324324

325-
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
325+
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
326326

327327
return buf_offset;
328328
}

0 commit comments

Comments
 (0)