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
112static int first_fb_vc;112static int first_fb_vc;
113static int last_fb_vc = MAX_NR_CONSOLES - 1;113static int last_fb_vc = MAX_NR_CONSOLES - 1;
114static int fbcon_is_default = 1; 114static int fbcon_is_default = 1;
115static int fbcon_has_exited;
116static int primary_device = -1;115static int primary_device = -1;
117static int fbcon_has_console_bind;116static int fbcon_has_console_bind;
118 117
@@ -1050,13 +1049,12 @@ static const char *fbcon_startup(void) · 931 unmodified lines
1050 info->var.bits_per_pixel);1049 info->var.bits_per_pixel);
1051 1050
1052 fbcon_add_cursor_timer(info);1051 fbcon_add_cursor_timer(info);
1053 fbcon_has_exited = 0;
1054 return display_desc;1052 return display_desc;
1055}1053}
1056 1054
1057static void fbcon_init(struct vc_data *vc, int init)1055static void fbcon_init(struct vc_data *vc, int init)
1058{1056{
1059 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];1057 struct fb_info *info;
1060 struct fbcon_ops *ops;1058 struct fbcon_ops *ops;
1061 struct vc_data **default_mode = vc->vc_display_fg;1059 struct vc_data **default_mode = vc->vc_display_fg;
1062 struct vc_data *svc = *default_mode;1060 struct vc_data *svc = *default_mode;
@@ -1064,9 +1062,13 @@ static void fbcon_init(struct vc_data *vc, int init) · 1 unmodified line
1064 int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256;1062 int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256;
1065 int cap, ret;1063 int cap, ret;
1066 1064
1067 if (info_idx == -1 || info == NULL)1065 if (WARN_ON(info_idx == -1))
1068 return;1066 return;
1069 1067
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]];
1070 cap = info->flags;1072 cap = info->flags;
1071 1073
1072 if (logo_shown < 0 && console_loglevel <= CONSOLE_LOGLEVEL_QUIET)1074 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
3336 struct fb_blit_caps *caps;3338 struct fb_blit_caps *caps;
3337 int idx, ret = 0;3339 int idx, ret = 0;
3338 3340
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
3347 switch(action) {3341 switch(action) {
3348 case FB_EVENT_SUSPEND:3342 case FB_EVENT_SUSPEND:
3349 fbcon_suspended(info);3343 fbcon_suspended(info);
@@ -3396,7 +3390,6 @@ static int fbcon_event_notify(struct notifier_block *self, · 46 unmodified lines
3396 fbcon_remap_all(idx);3390 fbcon_remap_all(idx);
3397 break;3391 break;
3398 }3392 }
3399done:
3400 return ret;3393 return ret;
3401}3394}
3402 3395
@@ -3443,9 +3436,6 @@ static ssize_t store_rotate(struct device *device, · 40 unmodified lines
3443 int rotate, idx;3436 int rotate, idx;
3444 char **last = NULL;3437 char **last = NULL;
3445 3438
3446 if (fbcon_has_exited)
3447 return count;
3448
3449 console_lock();3439 console_lock();
3450 idx = con2fb_map[fg_console];3440 idx = con2fb_map[fg_console];
3451 3441
@@ -3468,9 +3458,6 @@ static ssize_t store_rotate_all(struct device *device, · 16 unmodified lines
3468 int rotate, idx;3458 int rotate, idx;
3469 char **last = NULL;3459 char **last = NULL;
3470 3460
3471 if (fbcon_has_exited)
3472 return count;
3473
3474 console_lock();3461 console_lock();
3475 idx = con2fb_map[fg_console];3462 idx = con2fb_map[fg_console];
3476 3463
@@ -3491,9 +3478,6 @@ static ssize_t show_rotate(struct device *device, · 14 unmodified lines
3491 struct fb_info *info;3478 struct fb_info *info;
3492 int rotate = 0, idx;3479 int rotate = 0, idx;
3493 3480
3494 if (fbcon_has_exited)
3495 return 0;
3496
3497 console_lock();3481 console_lock();
3498 idx = con2fb_map[fg_console];3482 idx = con2fb_map[fg_console];
3499 3483
@@ -3514,9 +3498,6 @@ static ssize_t show_cursor_blink(struct device *device, · 14 unmodified lines
3514 struct fbcon_ops *ops;3498 struct fbcon_ops *ops;
3515 int idx, blink = -1;3499 int idx, blink = -1;
3516 3500
3517 if (fbcon_has_exited)
3518 return 0;
3519
3520 console_lock();3501 console_lock();
3521 idx = con2fb_map[fg_console];3502 idx = con2fb_map[fg_console];
3522 3503
@@ -3543,9 +3524,6 @@ static ssize_t store_cursor_blink(struct device *device, · 20 unmodified lines
3543 int blink, idx;3524 int blink, idx;
3544 char **last = NULL;3525 char **last = NULL;
3545 3526
3546 if (fbcon_has_exited)
3547 return count;
3548
3549 console_lock();3527 console_lock();
3550 idx = con2fb_map[fg_console];3528 idx = con2fb_map[fg_console];
3551 3529
@@ -3668,9 +3646,6 @@ static void fbcon_exit(void) · 116 unmodified lines
3668 struct fb_info *info;3646 struct fb_info *info;
3669 int i, j, mapped;3647 int i, j, mapped;
3670 3648
3671 if (fbcon_has_exited)
3672 return;
3673
3674#ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER3649#ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER
3675 if (deferred_takeover) {3650 if (deferred_takeover) {
3676 dummycon_unregister_output_notifier(&fbcon_output_nb);3651 dummycon_unregister_output_notifier(&fbcon_output_nb);
@@ -3695,7 +3670,7 @@ static void fbcon_exit(void) · 18 unmodified lines
3695 for (j = first_fb_vc; j <= last_fb_vc; j++) {3670 for (j = first_fb_vc; j <= last_fb_vc; j++) {
3696 if (con2fb_map[j] == i) {3671 if (con2fb_map[j] == i) {
3697 mapped = 1;3672 mapped = 1;
3698 break;3673 con2fb_map[j] = -1;
3699 }3674 }
3700 }3675 }
3701 3676
@@ -3718,8 +3693,6 @@ static void fbcon_exit(void) · 16 unmodified lines
3718 info->queue.func = NULL;3693 info->queue.func = NULL;
3719 }3694 }
3720 }3695 }
3721
3722 fbcon_has_exited = 1;
3723}3696}
3724 3697
3725void __init fb_console_init(void)3698void __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