ANDROID: power: wakeup_reason: convert wakeup_reason_lock to raw_spinlock_t for PREEMPT_RT

[   87.220277] BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:974
[   87.220282] in_atomic(): 1, irqs_disabled(): 128, pid: 0, name: swapper/1
[   87.220284] INFO: lockdep is turned off.
[   87.220287] irq event stamp: 11238
[   87.220300] hardirqs last  enabled at (11237): [<ffffff8008183dec>] tick_nohz_idle_enter+0x74/0xc0
[   87.220307] hardirqs last disabled at (11238): [<ffffff80080fef74>] do_idle+0xbc/0x290
[   87.220314] softirqs last  enabled at (0): [<ffffff80080b2cc8>] copy_process.isra.5.part.6+0x328/0x1c90
[   87.220317] softirqs last disabled at (0): [<0000000000000000>]           (null)
[   87.220319] Preemption disabled at:
[   87.220325] [<ffffff8008099168>] secondary_start_kernel+0xb8/0x1e8
[   87.220333] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G        W         4.19.232-rt104 #68
[   87.220335] Hardware name: Rockchip RK3568 EVB1 DDR4 V10 Board (DT)
[   87.220338] Call trace:
[   87.220343]  dump_backtrace+0x0/0x180
[   87.220347]  show_stack+0x14/0x20
[   87.220352]  dump_stack+0xa4/0xd8
[   87.220357]  ___might_sleep+0x1cc/0x228
[   87.220362]  rt_spin_lock+0xa0/0xe8
[   87.220367]  __log_abort_or_abnormal_wake+0x30/0xb8
[   87.220370]  log_abnormal_wakeup_reason+0x68/0x88
[   87.220374]  irq_may_run+0x98/0xb0
[   87.220379]  handle_fasteoi_irq+0x30/0x1b8
[   87.220382]  generic_handle_irq+0x24/0x38
[   87.220386]  __handle_domain_irq+0x84/0xf8
[   87.220389]  gic_handle_irq+0xc4/0x184
[   87.220392]  el1_irq+0xec/0x1ac
[   87.220398]  cpuidle_enter_state+0xb8/0x3d8
[   87.220401]  cpuidle_enter+0x18/0x20
[   87.220405]  call_cpuidle+0x24/0x48
[   87.220408]  do_idle+0x230/0x290
[   87.220411]  cpu_startup_entry+0x24/0x28
[   87.220415]  secondary_start_kernel+0x150/0x1e8

Signed-off-by: Liang Chen <cl@rock-chips.com>
Change-Id: I383164b2a646250d34dc7c085e7a1d297889581e
This commit is contained in:
Liang Chen
2022-09-01 09:34:57 +08:00
parent 793d4b55ca
commit 46d6c6285d

View File

@@ -44,7 +44,7 @@ struct wakeup_irq_node {
const char *irq_name;
};
static DEFINE_SPINLOCK(wakeup_reason_lock);
static DEFINE_RAW_SPINLOCK(wakeup_reason_lock);
static LIST_HEAD(leaf_irqs); /* kept in ascending IRQ sorted order */
static LIST_HEAD(parent_irqs); /* unordered */
@@ -149,17 +149,17 @@ void log_irq_wakeup_reason(int irq)
{
unsigned long flags;
spin_lock_irqsave(&wakeup_reason_lock, flags);
raw_spin_lock_irqsave(&wakeup_reason_lock, flags);
if (!capture_reasons) {
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
return;
}
if (find_node_in_list(&parent_irqs, irq) == NULL)
add_sibling_node_sorted(&leaf_irqs, irq);
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
}
void log_threaded_irq_wakeup_reason(int irq, int parent_irq)
@@ -177,10 +177,10 @@ void log_threaded_irq_wakeup_reason(int irq, int parent_irq)
if (!capture_reasons)
return;
spin_lock_irqsave(&wakeup_reason_lock, flags);
raw_spin_lock_irqsave(&wakeup_reason_lock, flags);
if (!capture_reasons || (find_node_in_list(&leaf_irqs, irq) != NULL)) {
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
return;
}
@@ -196,7 +196,7 @@ void log_threaded_irq_wakeup_reason(int irq, int parent_irq)
}
}
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
}
static void __log_abort_or_abnormal_wake(bool abort, const char *fmt,
@@ -204,11 +204,11 @@ static void __log_abort_or_abnormal_wake(bool abort, const char *fmt,
{
unsigned long flags;
spin_lock_irqsave(&wakeup_reason_lock, flags);
raw_spin_lock_irqsave(&wakeup_reason_lock, flags);
/* Suspend abort or abnormal wake reason has already been logged. */
if (suspend_abort || abnormal_wake) {
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
return;
}
@@ -216,7 +216,7 @@ static void __log_abort_or_abnormal_wake(bool abort, const char *fmt,
abnormal_wake = !abort;
vsnprintf(non_irq_wake_reason, MAX_SUSPEND_ABORT_LEN, fmt, args);
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
}
void log_suspend_abort_reason(const char *fmt, ...)
@@ -241,7 +241,7 @@ void clear_wakeup_reasons(void)
{
unsigned long flags;
spin_lock_irqsave(&wakeup_reason_lock, flags);
raw_spin_lock_irqsave(&wakeup_reason_lock, flags);
delete_list(&leaf_irqs);
delete_list(&parent_irqs);
@@ -249,7 +249,7 @@ void clear_wakeup_reasons(void)
abnormal_wake = false;
capture_reasons = true;
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
}
static void print_wakeup_sources(void)
@@ -257,13 +257,13 @@ static void print_wakeup_sources(void)
struct wakeup_irq_node *n;
unsigned long flags;
spin_lock_irqsave(&wakeup_reason_lock, flags);
raw_spin_lock_irqsave(&wakeup_reason_lock, flags);
capture_reasons = false;
if (suspend_abort) {
pr_info("Abort: %s\n", non_irq_wake_reason);
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
return;
}
@@ -276,7 +276,7 @@ static void print_wakeup_sources(void)
else
pr_info("Resume cause unknown\n");
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
}
static ssize_t last_resume_reason_show(struct kobject *kobj,
@@ -286,12 +286,12 @@ static ssize_t last_resume_reason_show(struct kobject *kobj,
struct wakeup_irq_node *n;
unsigned long flags;
spin_lock_irqsave(&wakeup_reason_lock, flags);
raw_spin_lock_irqsave(&wakeup_reason_lock, flags);
if (suspend_abort) {
buf_offset = scnprintf(buf, PAGE_SIZE, "Abort: %s",
non_irq_wake_reason);
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
return buf_offset;
}
@@ -304,7 +304,7 @@ static ssize_t last_resume_reason_show(struct kobject *kobj,
buf_offset = scnprintf(buf, PAGE_SIZE, "-1 %s",
non_irq_wake_reason);
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
raw_spin_unlock_irqrestore(&wakeup_reason_lock, flags);
return buf_offset;
}