Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fbcon: Do not takeover the console from atomic context

Taking over the console involves allocating mem with GFP_KERNEL, talking
to drm drivers, etc. So this should not be done from an atomic context.

But the console-output trigger deferred console takeover may happen from an
atomic context, which leads to "BUG: sleeping function called from invalid
context" errors.

This commit fixes these errors by doing the deferred takeover from a
workqueue.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
[b.zolnierkie: remove unused variable]
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>

authored by

Hans de Goede and committed by
Bartlomiej Zolnierkiewicz
df37e225 4d64c8e0

+15 -4
+15 -4
drivers/video/fbdev/core/fbcon.c
··· 3592 3592 } 3593 3593 3594 3594 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER 3595 + static void fbcon_register_existing_fbs(struct work_struct *work) 3596 + { 3597 + int i; 3598 + 3599 + console_lock(); 3600 + 3601 + for_each_registered_fb(i) 3602 + fbcon_fb_registered(registered_fb[i]); 3603 + 3604 + console_unlock(); 3605 + } 3606 + 3595 3607 static struct notifier_block fbcon_output_nb; 3608 + static DECLARE_WORK(fbcon_deferred_takeover_work, fbcon_register_existing_fbs); 3596 3609 3597 3610 static int fbcon_output_notifier(struct notifier_block *nb, 3598 3611 unsigned long action, void *data) 3599 3612 { 3600 - int i; 3601 - 3602 3613 WARN_CONSOLE_UNLOCKED(); 3603 3614 3604 3615 pr_info("fbcon: Taking over console\n"); ··· 3618 3607 deferred_takeover = false; 3619 3608 logo_shown = FBCON_LOGO_DONTSHOW; 3620 3609 3621 - for_each_registered_fb(i) 3622 - fbcon_fb_registered(registered_fb[i]); 3610 + /* We may get called in atomic context */ 3611 + schedule_work(&fbcon_deferred_takeover_work); 3623 3612 3624 3613 return NOTIFY_OK; 3625 3614 }