mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
sched: Enable might_sleep before initializing drivers.
This allows detection of init bugs in built-in drivers. Signed-off-by: Arve Hjønnevåg <arve@android.com>
This commit is contained in:
committed by
Colin Cross
parent
dcb99fd9b0
commit
bbe594b835
@@ -6942,13 +6942,24 @@ static inline int preempt_count_equals(int preempt_offset)
|
||||
return (nested == preempt_offset);
|
||||
}
|
||||
|
||||
static int __might_sleep_init_called;
|
||||
int __init __might_sleep_init(void)
|
||||
{
|
||||
__might_sleep_init_called = 1;
|
||||
return 0;
|
||||
}
|
||||
early_initcall(__might_sleep_init);
|
||||
|
||||
void __might_sleep(const char *file, int line, int preempt_offset)
|
||||
{
|
||||
static unsigned long prev_jiffy; /* ratelimiting */
|
||||
|
||||
rcu_sleep_check(); /* WARN_ON_ONCE() by default, no rate limit reqd. */
|
||||
if ((preempt_count_equals(preempt_offset) && !irqs_disabled()) ||
|
||||
system_state != SYSTEM_RUNNING || oops_in_progress)
|
||||
oops_in_progress)
|
||||
return;
|
||||
if (system_state != SYSTEM_RUNNING &&
|
||||
(!__might_sleep_init_called || system_state != SYSTEM_BOOTING))
|
||||
return;
|
||||
if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user