From 13c17b879a406df92da78719fcbc7050cc5ee008 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 6 Aug 2018 18:22:19 +0200 Subject: Add one more FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER bugfix patch --- ...t-takeover-the-console-from-atomic-contex.patch | 67 ++++++++++++++++++++++ kernel.spec | 4 ++ 2 files changed, 71 insertions(+) create mode 100644 0010-fbcon-Do-not-takeover-the-console-from-atomic-contex.patch diff --git a/0010-fbcon-Do-not-takeover-the-console-from-atomic-contex.patch b/0010-fbcon-Do-not-takeover-the-console-from-atomic-contex.patch new file mode 100644 index 000000000..815c66073 --- /dev/null +++ b/0010-fbcon-Do-not-takeover-the-console-from-atomic-contex.patch @@ -0,0 +1,67 @@ +From 8f571bbfc621fd0826bbc7a8924c811f3a3167c9 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Mon, 6 Aug 2018 16:32:27 +0200 +Subject: [PATCH] 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 when the notifier runs from an atomic context. + +Signed-off-by: Hans de Goede +--- + drivers/video/fbdev/core/fbcon.c | 21 +++++++++++++++++++-- + 1 file changed, 19 insertions(+), 2 deletions(-) + +diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c +index a3fd510..f812891 100644 +--- a/drivers/video/fbdev/core/fbcon.c ++++ b/drivers/video/fbdev/core/fbcon.c +@@ -3596,7 +3596,22 @@ static int fbcon_init_device(void) + } + + #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER ++static void fbcon_register_existing_fbs(struct work_struct *work) ++{ ++ int i; ++ ++ console_lock(); ++ ++ for (i = 0; i < FB_MAX; i++) { ++ if (registered_fb[i]) ++ fbcon_fb_registered(registered_fb[i]); ++ } ++ ++ console_unlock(); ++} ++ + static struct notifier_block fbcon_output_nb; ++static DECLARE_WORK(fbcon_deferred_takeover_work, fbcon_register_existing_fbs); + + static int fbcon_output_notifier(struct notifier_block *nb, + unsigned long action, void *data) +@@ -3611,9 +3626,13 @@ static int fbcon_output_notifier(struct notifier_block *nb, + deferred_takeover = false; + logo_shown = FBCON_LOGO_DONTSHOW; + +- for (i = 0; i < FB_MAX; i++) { +- if (registered_fb[i]) +- fbcon_fb_registered(registered_fb[i]); ++ if (in_atomic() || irqs_disabled()) { ++ schedule_work(&fbcon_deferred_takeover_work); ++ } else { ++ for (i = 0; i < FB_MAX; i++) { ++ if (registered_fb[i]) ++ fbcon_fb_registered(registered_fb[i]); ++ } + } + + return NOTIFY_OK; +-- +2.18.0 + diff --git a/kernel.spec b/kernel.spec index 3a2ed4244..01c0e198c 100644 --- a/kernel.spec +++ b/kernel.spec @@ -646,6 +646,7 @@ Patch527: 0007-efifb-BGRT-Do-not-copy-the-boot-graphics-for-non-nat.patch Patch528: 0008-console-dummycon-export-dummycon_-un-register_output.patch # Deferred fbcon takeover bugfix, pending upstream Patch529: 0009-fbcon-Only-defer-console-takeover-if-the-current-con.patch +Patch530: 0010-fbcon-Do-not-takeover-the-console-from-atomic-contex.patch # END OF PATCH DEFINITIONS @@ -1906,6 +1907,9 @@ fi # # %changelog +* Mon Aug 06 2018 Hans de Goede +- Add one more FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER bugfix patch + * Mon Aug 06 2018 Laura Abbott - 4.18.0-0.rc8.git0.1 - Linux v4.18-rc8 -- cgit