aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2017-08-01 11:32:07 -0400
committerBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>2017-08-01 11:32:07 -0400
commit6104c37094e729f3d4ce65797002112735d49cd1 (patch)
treecc0c38d8d2268109ff38a156c017fe556b207ab5
parent52e2fecf6868099359f5dea2f72f8572661d4462 (diff)
fbcon: Make fbcon a built-time depency for fbdev
There's a bunch of folks who're trying to make printk less contended and faster, but there's a problem: printk uses the console_lock, and the console lock has become the BKL for all things fbdev/fbcon, which in turn pulled in half the drm subsystem under that lock. That's awkward. There reasons for that is probably just a historical accident: - fbcon is a runtime option of fbdev, i.e. at runtime you can pick whether your fbdev driver instances are used as kernel consoles. Unfortunately this wasn't implemented with some module option, but through some module loading magic: As long as you don't load fbcon.ko, there's no fbdev console support, but loading it (in any order wrt fbdev drivers) will create console instances for all fbdev drivers. - This was implemented through a notifier chain. fbcon.ko enumerates all fbdev instances at load time and also registers itself as listener in the fbdev notifier. The fbdev core tries to register new fbdev instances with fbcon using the notifier. - On top of that the modifier chain is also used at runtime by the fbdev subsystem to e.g. control backlights for panels. - The problem is that the notifier puts a mutex locking context between fbdev and fbcon, which mixes up the locking contexts for both the runtime usage and the register time usage to notify fbcon. And at runtime fbcon (through the fbdev core) might call into the notifier from a printk critical section while console_lock is held. - This means console_lock must be an outer lock for the entire fbdev subsystem, which also means it must be acquired when registering a new framebuffer driver as the outermost lock since we might call into fbcon (through the notifier) which would result in a locking inversion if fbcon would acquire the console_lock from its notifier callback (which it needs to register the console). - console_lock can be held anywhere, since printk can be called anywhere, and through the above story, plus drm/kms being an fbdev driver, we pull in a shocking amount of locking hiercharchy underneath the console_lock. Which makes cleaning up printk really hard (not even splitting console_lock into an rwsem is all that useful due to this). There's various ways to address this, but the cleanest would be to make fbcon a compile-time option, where fbdev directly calls the fbcon register functions from register_framebuffer, or dummy static inline versions if fbcon is disabled. Maybe augmented with a runtime knob to disable fbcon, if that's needed (for debugging perhaps). But this could break some users who rely on the magic "loading fbcon.ko enables/disables fbdev framebuffers at runtime" thing, even if that's unlikely. Hence we must be careful: 1. Create a compile-time dependency between fbcon and fbdev in the least minimal way. This is what this patch does. 2. Wait at least 1 year to give possible users time to scream about how we broke their setup. Unlikely, since all distros make fbcon compile-in, and embedded platforms only compile stuff they know they need anyway. But still. 3. Convert the notifier to direct functions calls, with dummy static inlines if fbcon is disabled. We'll still need the fb notifier for the other uses (like backlights), but we can probably move it into the fb core (atm it must be built-into vmlinux). 4. Push console_lock down the call-chain, until it is down in console_register again. 5. Finally start to clean up and rework the printk/console locking. For context of this saga see commit 50e244cc793d511b86adea24972f3a7264cae114 Author: Alan Cox <alan@linux.intel.com> Date: Fri Jan 25 10:28:15 2013 +1000 fb: rework locking to fix lock ordering on takeover plus the pile of commits on top that tried to make this all work without terminally upsetting lockdep. We've uncovered all this when console_lock lockdep annotations where added in commit daee779718a319ff9f83e1ba3339334ac650bb22 Author: Daniel Vetter <daniel.vetter@ffwll.ch> Date: Sat Sep 22 19:52:11 2012 +0200 console: implement lockdep support for console_lock On the patch itself: - Switch CONFIG_FRAMEBUFFER_CONSOLE to be a boolean, using the overall CONFIG_FB tristate to decided whether it should be a module or built-in. - At first I thought I could force the build depency with just a dummy symbol that fbcon.ko exports and fb.ko uses. But that leads to a module depency cycle (it works fine when built-in). Since this tight binding is the entire goal the simplest solution is to move all the fbcon modules (and there's a bunch of optinal source-files which are each modules of their own, for no good reason) into the overall fb.ko core module. That's a bit more than what I would have liked to do in this patch, but oh well. Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Reviewed-by: Sean Paul <seanpaul@chromium.org> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
-rw-r--r--drivers/video/console/Kconfig2
-rw-r--r--drivers/video/console/Makefile8
-rw-r--r--drivers/video/fbdev/core/Makefile11
-rw-r--r--drivers/video/fbdev/core/bitblit.c (renamed from drivers/video/console/bitblit.c)4
-rw-r--r--drivers/video/fbdev/core/fbcon.c (renamed from drivers/video/console/fbcon.c)13
-rw-r--r--drivers/video/fbdev/core/fbcon.h (renamed from drivers/video/console/fbcon.h)0
-rw-r--r--drivers/video/fbdev/core/fbcon_ccw.c (renamed from drivers/video/console/fbcon_ccw.c)4
-rw-r--r--drivers/video/fbdev/core/fbcon_cw.c (renamed from drivers/video/console/fbcon_cw.c)4
-rw-r--r--drivers/video/fbdev/core/fbcon_rotate.c (renamed from drivers/video/console/fbcon_rotate.c)4
-rw-r--r--drivers/video/fbdev/core/fbcon_rotate.h (renamed from drivers/video/console/fbcon_rotate.h)0
-rw-r--r--drivers/video/fbdev/core/fbcon_ud.c (renamed from drivers/video/console/fbcon_ud.c)4
-rw-r--r--drivers/video/fbdev/core/fbmem.c6
-rw-r--r--drivers/video/fbdev/core/softcursor.c (renamed from drivers/video/console/softcursor.c)4
-rw-r--r--drivers/video/fbdev/core/tileblit.c (renamed from drivers/video/console/tileblit.c)5
-rw-r--r--include/linux/fbcon.h12
15 files changed, 33 insertions, 48 deletions
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
index 2111d06f8c81..7f1f1fbcef9e 100644
--- a/drivers/video/console/Kconfig
+++ b/drivers/video/console/Kconfig
@@ -117,7 +117,7 @@ config DUMMY_CONSOLE_ROWS
117 Select 25 if you use a 640x480 resolution by default. 117 Select 25 if you use a 640x480 resolution by default.
118 118
119config FRAMEBUFFER_CONSOLE 119config FRAMEBUFFER_CONSOLE
120 tristate "Framebuffer Console support" 120 bool "Framebuffer Console support"
121 depends on FB && !UML 121 depends on FB && !UML
122 select VT_HW_CONSOLE_BINDING 122 select VT_HW_CONSOLE_BINDING
123 select CRC32 123 select CRC32
diff --git a/drivers/video/console/Makefile b/drivers/video/console/Makefile
index 43bfa485db96..eb2cbec52643 100644
--- a/drivers/video/console/Makefile
+++ b/drivers/video/console/Makefile
@@ -7,13 +7,5 @@ obj-$(CONFIG_SGI_NEWPORT_CONSOLE) += newport_con.o
7obj-$(CONFIG_STI_CONSOLE) += sticon.o sticore.o 7obj-$(CONFIG_STI_CONSOLE) += sticon.o sticore.o
8obj-$(CONFIG_VGA_CONSOLE) += vgacon.o 8obj-$(CONFIG_VGA_CONSOLE) += vgacon.o
9obj-$(CONFIG_MDA_CONSOLE) += mdacon.o 9obj-$(CONFIG_MDA_CONSOLE) += mdacon.o
10obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += fbcon.o bitblit.o softcursor.o
11ifeq ($(CONFIG_FB_TILEBLITTING),y)
12obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += tileblit.o
13endif
14ifeq ($(CONFIG_FRAMEBUFFER_CONSOLE_ROTATION),y)
15obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += fbcon_rotate.o fbcon_cw.o fbcon_ud.o \
16 fbcon_ccw.o
17endif
18 10
19obj-$(CONFIG_FB_STI) += sticore.o 11obj-$(CONFIG_FB_STI) += sticore.o
diff --git a/drivers/video/fbdev/core/Makefile b/drivers/video/fbdev/core/Makefile
index 9e3ddf225393..0214b863ac3f 100644
--- a/drivers/video/fbdev/core/Makefile
+++ b/drivers/video/fbdev/core/Makefile
@@ -4,6 +4,17 @@ obj-$(CONFIG_FB) += fb.o
4fb-y := fbmem.o fbmon.o fbcmap.o fbsysfs.o \ 4fb-y := fbmem.o fbmon.o fbcmap.o fbsysfs.o \
5 modedb.o fbcvt.o 5 modedb.o fbcvt.o
6fb-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o 6fb-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o
7
8ifeq ($(CONFIG_FRAMEBUFFER_CONSOLE),y)
9fb-y += fbcon.o bitblit.o softcursor.o
10ifeq ($(CONFIG_FB_TILEBLITTING),y)
11fb-y += tileblit.o
12endif
13ifeq ($(CONFIG_FRAMEBUFFER_CONSOLE_ROTATION),y)
14fb-y += fbcon_rotate.o fbcon_cw.o fbcon_ud.o \
15 fbcon_ccw.o
16endif
17endif
7fb-objs := $(fb-y) 18fb-objs := $(fb-y)
8 19
9obj-$(CONFIG_FB_CFB_FILLRECT) += cfbfillrect.o 20obj-$(CONFIG_FB_CFB_FILLRECT) += cfbfillrect.o
diff --git a/drivers/video/console/bitblit.c b/drivers/video/fbdev/core/bitblit.c
index dbfe4eecf12e..99f3a1c3d093 100644
--- a/drivers/video/console/bitblit.c
+++ b/drivers/video/fbdev/core/bitblit.c
@@ -416,7 +416,3 @@ void fbcon_set_bitops(struct fbcon_ops *ops)
416 416
417EXPORT_SYMBOL(fbcon_set_bitops); 417EXPORT_SYMBOL(fbcon_set_bitops);
418 418
419MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>");
420MODULE_DESCRIPTION("Bit Blitting Operation");
421MODULE_LICENSE("GPL");
422
diff --git a/drivers/video/console/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index 12ded23f1aaf..86b3bcbd01a8 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -68,6 +68,7 @@
68#include <linux/kd.h> 68#include <linux/kd.h>
69#include <linux/slab.h> 69#include <linux/slab.h>
70#include <linux/fb.h> 70#include <linux/fb.h>
71#include <linux/fbcon.h>
71#include <linux/vt_kern.h> 72#include <linux/vt_kern.h>
72#include <linux/selection.h> 73#include <linux/selection.h>
73#include <linux/font.h> 74#include <linux/font.h>
@@ -3606,7 +3607,7 @@ static void fbcon_exit(void)
3606 fbcon_has_exited = 1; 3607 fbcon_has_exited = 1;
3607} 3608}
3608 3609
3609static int __init fb_console_init(void) 3610void __init fb_console_init(void)
3610{ 3611{
3611 int i; 3612 int i;
3612 3613
@@ -3628,11 +3629,8 @@ static int __init fb_console_init(void)
3628 3629
3629 console_unlock(); 3630 console_unlock();
3630 fbcon_start(); 3631 fbcon_start();
3631 return 0;
3632} 3632}
3633 3633
3634fs_initcall(fb_console_init);
3635
3636#ifdef MODULE 3634#ifdef MODULE
3637 3635
3638static void __exit fbcon_deinit_device(void) 3636static void __exit fbcon_deinit_device(void)
@@ -3647,7 +3645,7 @@ static void __exit fbcon_deinit_device(void)
3647 } 3645 }
3648} 3646}
3649 3647
3650static void __exit fb_console_exit(void) 3648void __exit fb_console_exit(void)
3651{ 3649{
3652 console_lock(); 3650 console_lock();
3653 fb_unregister_client(&fbcon_event_notifier); 3651 fb_unregister_client(&fbcon_event_notifier);
@@ -3657,9 +3655,4 @@ static void __exit fb_console_exit(void)
3657 do_unregister_con_driver(&fb_con); 3655 do_unregister_con_driver(&fb_con);
3658 console_unlock(); 3656 console_unlock();
3659} 3657}
3660
3661module_exit(fb_console_exit);
3662
3663#endif 3658#endif
3664
3665MODULE_LICENSE("GPL");
diff --git a/drivers/video/console/fbcon.h b/drivers/video/fbdev/core/fbcon.h
index 7aaa4eabbba0..7aaa4eabbba0 100644
--- a/drivers/video/console/fbcon.h
+++ b/drivers/video/fbdev/core/fbcon.h
diff --git a/drivers/video/console/fbcon_ccw.c b/drivers/video/fbdev/core/fbcon_ccw.c
index 5a3cbf6dff4d..2eeefa97bd4a 100644
--- a/drivers/video/console/fbcon_ccw.c
+++ b/drivers/video/fbdev/core/fbcon_ccw.c
@@ -418,7 +418,3 @@ void fbcon_rotate_ccw(struct fbcon_ops *ops)
418 ops->update_start = ccw_update_start; 418 ops->update_start = ccw_update_start;
419} 419}
420EXPORT_SYMBOL(fbcon_rotate_ccw); 420EXPORT_SYMBOL(fbcon_rotate_ccw);
421
422MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>");
423MODULE_DESCRIPTION("Console Rotation (270 degrees) Support");
424MODULE_LICENSE("GPL");
diff --git a/drivers/video/console/fbcon_cw.c b/drivers/video/fbdev/core/fbcon_cw.c
index e7ee44db4e98..c321f7c59e5c 100644
--- a/drivers/video/console/fbcon_cw.c
+++ b/drivers/video/fbdev/core/fbcon_cw.c
@@ -401,7 +401,3 @@ void fbcon_rotate_cw(struct fbcon_ops *ops)
401 ops->update_start = cw_update_start; 401 ops->update_start = cw_update_start;
402} 402}
403EXPORT_SYMBOL(fbcon_rotate_cw); 403EXPORT_SYMBOL(fbcon_rotate_cw);
404
405MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>");
406MODULE_DESCRIPTION("Console Rotation (90 degrees) Support");
407MODULE_LICENSE("GPL");
diff --git a/drivers/video/console/fbcon_rotate.c b/drivers/video/fbdev/core/fbcon_rotate.c
index db6528f2d3f2..8a51e4d95cc5 100644
--- a/drivers/video/console/fbcon_rotate.c
+++ b/drivers/video/fbdev/core/fbcon_rotate.c
@@ -110,7 +110,3 @@ void fbcon_set_rotate(struct fbcon_ops *ops)
110 } 110 }
111} 111}
112EXPORT_SYMBOL(fbcon_set_rotate); 112EXPORT_SYMBOL(fbcon_set_rotate);
113
114MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>");
115MODULE_DESCRIPTION("Console Rotation Support");
116MODULE_LICENSE("GPL");
diff --git a/drivers/video/console/fbcon_rotate.h b/drivers/video/fbdev/core/fbcon_rotate.h
index e233444cda66..e233444cda66 100644
--- a/drivers/video/console/fbcon_rotate.h
+++ b/drivers/video/fbdev/core/fbcon_rotate.h
diff --git a/drivers/video/console/fbcon_ud.c b/drivers/video/fbdev/core/fbcon_ud.c
index 19e3714abfe8..c0b605d49cb3 100644
--- a/drivers/video/console/fbcon_ud.c
+++ b/drivers/video/fbdev/core/fbcon_ud.c
@@ -446,7 +446,3 @@ void fbcon_rotate_ud(struct fbcon_ops *ops)
446 ops->update_start = ud_update_start; 446 ops->update_start = ud_update_start;
447} 447}
448EXPORT_SYMBOL(fbcon_rotate_ud); 448EXPORT_SYMBOL(fbcon_rotate_ud);
449
450MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>");
451MODULE_DESCRIPTION("Console Rotation (180 degrees) Support");
452MODULE_LICENSE("GPL");
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 7a42238db446..231bb7e48c0d 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -32,6 +32,7 @@
32#include <linux/device.h> 32#include <linux/device.h>
33#include <linux/efi.h> 33#include <linux/efi.h>
34#include <linux/fb.h> 34#include <linux/fb.h>
35#include <linux/fbcon.h>
35 36
36#include <asm/fb.h> 37#include <asm/fb.h>
37 38
@@ -1880,6 +1881,9 @@ fbmem_init(void)
1880 fb_class = NULL; 1881 fb_class = NULL;
1881 goto err_class; 1882 goto err_class;
1882 } 1883 }
1884
1885 fb_console_init();
1886
1883 return 0; 1887 return 0;
1884 1888
1885err_class: 1889err_class:
@@ -1894,6 +1898,8 @@ module_init(fbmem_init);
1894static void __exit 1898static void __exit
1895fbmem_exit(void) 1899fbmem_exit(void)
1896{ 1900{
1901 fb_console_exit();
1902
1897 remove_proc_entry("fb", NULL); 1903 remove_proc_entry("fb", NULL);
1898 class_destroy(fb_class); 1904 class_destroy(fb_class);
1899 unregister_chrdev(FB_MAJOR, "fb"); 1905 unregister_chrdev(FB_MAJOR, "fb");
diff --git a/drivers/video/console/softcursor.c b/drivers/video/fbdev/core/softcursor.c
index 46dd8f5d2e9e..fc93f254498e 100644
--- a/drivers/video/console/softcursor.c
+++ b/drivers/video/fbdev/core/softcursor.c
@@ -76,7 +76,3 @@ int soft_cursor(struct fb_info *info, struct fb_cursor *cursor)
76} 76}
77 77
78EXPORT_SYMBOL(soft_cursor); 78EXPORT_SYMBOL(soft_cursor);
79
80MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>");
81MODULE_DESCRIPTION("Generic software cursor");
82MODULE_LICENSE("GPL");
diff --git a/drivers/video/console/tileblit.c b/drivers/video/fbdev/core/tileblit.c
index 15e8e1a89c45..4636a6110c27 100644
--- a/drivers/video/console/tileblit.c
+++ b/drivers/video/fbdev/core/tileblit.c
@@ -152,8 +152,3 @@ void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info)
152} 152}
153 153
154EXPORT_SYMBOL(fbcon_set_tileops); 154EXPORT_SYMBOL(fbcon_set_tileops);
155
156MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>");
157MODULE_DESCRIPTION("Tile Blitting Operation");
158MODULE_LICENSE("GPL");
159
diff --git a/include/linux/fbcon.h b/include/linux/fbcon.h
new file mode 100644
index 000000000000..0fac6305d51c
--- /dev/null
+++ b/include/linux/fbcon.h
@@ -0,0 +1,12 @@
1#ifndef _LINUX_FBCON_H
2#define _LINUX_FBCON_H
3
4#ifdef CONFIG_FRAMEBUFFER_CONSOLE
5void __init fb_console_init(void);
6void __exit fb_console_exit(void);
7#else
8static void fb_console_init(void) {}
9static void fb_console_exit(void) {}
10#endif
11
12#endif /* _LINUX_FBCON_H */