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

Configure Feed

Select the types of activity you want to include in your feed.

fbcon: untangle fbcon_exit

There's a bunch of confusions going on here:
- The deferred fbcon setup notifier should only be cleaned up from
fb_console_exit(), to be symmetric with fb_console_init()
- We also need to make sure we don't race with the work, which means
temporarily dropping the console lock (or we can deadlock)
- That also means no point in clearing deferred_takeover, we are
unloading everything anyway.
- Finally rename fbcon_exit to fbcon_release_all and move it, since
that's what's it doing when being called from consw->con_deinit
through fbcon_deinit.

To answer a question from Sam just quoting my own reply:

> We loose the call to fbcon_release_all() here [in fb_console_exit()].
> We have part of the old fbcon_exit() above, but miss the release parts.

Ah yes that's the entire point of this change. The release_all in the
fbcon exit path was only needed when fbcon was a separate module
indepedent from core fb.ko. Which means it was possible to unload fbcon
while having fbdev drivers registered.

But since we've merged them that has become impossible, so by the time the
fb.ko module can be unloaded, there's guaranteed to be no fbdev drivers
left. And hence removing them is pointless.

v2: Explain the why better (Sam)

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Claudio Suarez <cssk@net-c.es>
Cc: Du Cheng <ducheng2@gmail.com>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Link: https://patchwork.freedesktop.org/patch/msgid/20220405210335.3434130-17-daniel.vetter@ffwll.ch

+32 -31
+32 -31
drivers/video/fbdev/core/fbcon.c
··· 187 187 int line, int count, int dy); 188 188 static void fbcon_modechanged(struct fb_info *info); 189 189 static void fbcon_set_all_vcs(struct fb_info *info); 190 - static void fbcon_exit(void); 191 190 192 191 static struct device *fbcon_device; 193 192 ··· 1145 1146 1146 1147 static void set_vc_hi_font(struct vc_data *vc, bool set); 1147 1148 1149 + static void fbcon_release_all(void) 1150 + { 1151 + struct fb_info *info; 1152 + int i, j, mapped; 1153 + 1154 + for_each_registered_fb(i) { 1155 + mapped = 0; 1156 + info = registered_fb[i]; 1157 + 1158 + for (j = first_fb_vc; j <= last_fb_vc; j++) { 1159 + if (con2fb_map[j] == i) { 1160 + mapped = 1; 1161 + con2fb_map[j] = -1; 1162 + } 1163 + } 1164 + 1165 + if (mapped) 1166 + fbcon_release(info); 1167 + } 1168 + } 1169 + 1148 1170 static void fbcon_deinit(struct vc_data *vc) 1149 1171 { 1150 1172 struct fbcon_display *p = &fb_display[vc->vc_num]; ··· 1205 1185 set_vc_hi_font(vc, false); 1206 1186 1207 1187 if (!con_is_bound(&fb_con)) 1208 - fbcon_exit(); 1188 + fbcon_release_all(); 1209 1189 1210 1190 if (vc->vc_num == logo_shown) 1211 1191 logo_shown = FBCON_LOGO_CANSHOW; ··· 3316 3296 #endif 3317 3297 } 3318 3298 3319 - static void fbcon_exit(void) 3320 - { 3321 - struct fb_info *info; 3322 - int i, j, mapped; 3323 - 3324 - #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER 3325 - if (deferred_takeover) { 3326 - dummycon_unregister_output_notifier(&fbcon_output_nb); 3327 - deferred_takeover = false; 3328 - } 3329 - #endif 3330 - 3331 - for_each_registered_fb(i) { 3332 - mapped = 0; 3333 - info = registered_fb[i]; 3334 - 3335 - for (j = first_fb_vc; j <= last_fb_vc; j++) { 3336 - if (con2fb_map[j] == i) { 3337 - mapped = 1; 3338 - con2fb_map[j] = -1; 3339 - } 3340 - } 3341 - 3342 - if (mapped) 3343 - fbcon_release(info); 3344 - } 3345 - } 3346 - 3347 3299 void __init fb_console_init(void) 3348 3300 { 3349 3301 int i; ··· 3355 3363 3356 3364 void __exit fb_console_exit(void) 3357 3365 { 3366 + #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER 3367 + console_lock(); 3368 + if (deferred_takeover) 3369 + dummycon_unregister_output_notifier(&fbcon_output_nb); 3370 + console_unlock(); 3371 + 3372 + cancel_work_sync(&fbcon_deferred_takeover_work); 3373 + #endif 3374 + 3358 3375 console_lock(); 3359 3376 fbcon_deinit_device(); 3360 3377 device_destroy(fb_class, MKDEV(0, 0)); 3361 - fbcon_exit(); 3378 + 3362 3379 do_unregister_con_driver(&fb_con); 3363 3380 console_unlock(); 3364 3381 }