History

fbcon: Remove fbcon_has_exited

This is unused code since commit 6104c37094e729f3d4ce65797002112735d49cd1 Author: Daniel Vetter <daniel.vetter@ffwll.ch> Date: Tue Aug 1 17:32:07 2017 +0200 fbcon: Make fbcon a built-time depency for fbdev when fbcon was made a compile-time static dependency of fbdev. We can't exit fbcon anymore without exiting fbdev first, which only works if all fbdev drivers have unloaded already. Hence this is all dead code. v2: I missed that fbcon_exit is also called from con_deinit stuff, and there fbcon_has_exited prevents double-cleanup. But we can fix that by properly resetting con2fb_map[] to all -1, which is used everywhere else to indicate "no fb_info allocate to this console". With that change the double-cleanup (which resulted in a module refcount underflow, among other things) is prevented. Aside: con2fb_map is a signed char, so don't register more than 128 fb_info or hilarity will ensue. v3: CI showed me that I still didn't fully understand what's going on here. The leaked references in con2fb_map have been used upon rebinding the fb console in fbcon_init. It worked because fbdev unregistering still cleaned out con2fb_map, and reset it to info_idx. If the last fbdev driver unregistered, then it also reset info_idx, and unregistered the fbcon driver. Imo that's all a bit fragile, so let's keep the con2fb_map reset to -1, and in fbcon_init pick info_idx if we're starting fresh. That means unbinding and rebinding will cleanse the mapping, but why are you doing that if you want to retain the mapping, so should be fine. Also, I think info_idx == -1 is impossible in fbcon_init - we unregister the fbcon in that case. So catch&warn about that. v4: Drop unecessary assignment - I forgot to delete the first assignment of info in fbcon_init.

Daniel Vetter committed 7 years ago

Commit 1f4ed2f1 parent 50233391 file · +7 −34Browse files

Unified · Split

drivers/video/fbdev/core/fbcon.c+7−34
@@ -112,7 +112,6 @@ static int softback_lines; · 111 unmodified lines
112112 static int first_fb_vc;
113113 static int last_fb_vc = MAX_NR_CONSOLES - 1;
114114 static int fbcon_is_default = 1;
115−static int fbcon_has_exited;
116115 static int primary_device = -1;
117116 static int fbcon_has_console_bind;
118117
@@ -1050,13 +1049,12 @@ static const char *fbcon_startup(void) · 931 unmodified lines
10501049 info->var.bits_per_pixel);
10511050
10521051 fbcon_add_cursor_timer(info);
1053− fbcon_has_exited = 0;
10541052 return display_desc;
10551053 }
10561054
10571055 static void fbcon_init(struct vc_data *vc, int init)
10581056 {
1059− struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1057+ struct fb_info *info;
10601058 struct fbcon_ops *ops;
10611059 struct vc_data **default_mode = vc->vc_display_fg;
10621060 struct vc_data *svc = *default_mode;
@@ -1064,9 +1062,13 @@ static void fbcon_init(struct vc_data *vc, int init) · 1 unmodified line
10641062 int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256;
10651063 int cap, ret;
10661064
1067− if (info_idx == -1 || info == NULL)
1065+ if (WARN_ON(info_idx == -1))
10681066 return;
10691067
1068+ if (con2fb_map[vc->vc_num] == -1)
1069+ con2fb_map[vc->vc_num] = info_idx;
1070+
1071+ info = registered_fb[con2fb_map[vc->vc_num]];
10701072 cap = info->flags;
10711073
10721074 if (logo_shown < 0 && console_loglevel <= CONSOLE_LOGLEVEL_QUIET)
@@ -3336,14 +3338,6 @@ static int fbcon_event_notify(struct notifier_block *self, · 2263 unmodified lines
33363338 struct fb_blit_caps *caps;
33373339 int idx, ret = 0;
33383340
3339− /*
3340− * ignore all events except driver registration and deregistration
3341− * if fbcon is not active
3342− */
3343− if (fbcon_has_exited && !(action == FB_EVENT_FB_REGISTERED ||
3344− action == FB_EVENT_FB_UNREGISTERED))
3345− goto done;
3346−
33473341 switch(action) {
33483342 case FB_EVENT_SUSPEND:
33493343 fbcon_suspended(info);
@@ -3396,7 +3390,6 @@ static int fbcon_event_notify(struct notifier_block *self, · 46 unmodified lines
33963390 fbcon_remap_all(idx);
33973391 break;
33983392 }
3399−done:
34003393 return ret;
34013394 }
34023395
@@ -3443,9 +3436,6 @@ static ssize_t store_rotate(struct device *device, · 40 unmodified lines
34433436 int rotate, idx;
34443437 char **last = NULL;
34453438
3446− if (fbcon_has_exited)
3447− return count;
3448−
34493439 console_lock();
34503440 idx = con2fb_map[fg_console];
34513441
@@ -3468,9 +3458,6 @@ static ssize_t store_rotate_all(struct device *device, · 16 unmodified lines
34683458 int rotate, idx;
34693459 char **last = NULL;
34703460
3471− if (fbcon_has_exited)
3472− return count;
3473−
34743461 console_lock();
34753462 idx = con2fb_map[fg_console];
34763463
@@ -3491,9 +3478,6 @@ static ssize_t show_rotate(struct device *device, · 14 unmodified lines
34913478 struct fb_info *info;
34923479 int rotate = 0, idx;
34933480
3494− if (fbcon_has_exited)
3495− return 0;
3496−
34973481 console_lock();
34983482 idx = con2fb_map[fg_console];
34993483
@@ -3514,9 +3498,6 @@ static ssize_t show_cursor_blink(struct device *device, · 14 unmodified lines
35143498 struct fbcon_ops *ops;
35153499 int idx, blink = -1;
35163500
3517− if (fbcon_has_exited)
3518− return 0;
3519−
35203501 console_lock();
35213502 idx = con2fb_map[fg_console];
35223503
@@ -3543,9 +3524,6 @@ static ssize_t store_cursor_blink(struct device *device, · 20 unmodified lines
35433524 int blink, idx;
35443525 char **last = NULL;
35453526
3546− if (fbcon_has_exited)
3547− return count;
3548−
35493527 console_lock();
35503528 idx = con2fb_map[fg_console];
35513529
@@ -3668,9 +3646,6 @@ static void fbcon_exit(void) · 116 unmodified lines
36683646 struct fb_info *info;
36693647 int i, j, mapped;
36703648
3671− if (fbcon_has_exited)
3672− return;
3673−
36743649 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER
36753650 if (deferred_takeover) {
36763651 dummycon_unregister_output_notifier(&fbcon_output_nb);
@@ -3695,7 +3670,7 @@ static void fbcon_exit(void) · 18 unmodified lines
36953670 for (j = first_fb_vc; j <= last_fb_vc; j++) {
36963671 if (con2fb_map[j] == i) {
36973672 mapped = 1;
3698− break;
3673+ con2fb_map[j] = -1;
36993674 }
37003675 }
37013676
@@ -3718,8 +3693,6 @@ static void fbcon_exit(void) · 16 unmodified lines
37183693 info->queue.func = NULL;
37193694 }
37203695 }
3721−
3722− fbcon_has_exited = 1;
37233696 }
37243697
37253698 void __init fb_console_init(void)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t