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: Move console_lock for register/unlink/unregister

Ideally console_lock becomes an implementation detail of fbcon.c and
doesn't show up anywhere in fbmem.c. We're still pretty far from that,
but at least the register/unregister code is there now.

With this the do_fb_ioctl() handler is the only code in fbmem.c still
calling console_lock().

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Du Cheng <ducheng2@gmail.com>
Cc: Claudio Suarez <cssk@net-c.es>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Zheyu Ma <zheyuma97@gmail.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Zhen Lei <thunder.leizhen@huawei.com>
Cc: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Link: https://patchwork.freedesktop.org/patch/msgid/20220405210335.3434130-15-daniel.vetter@ffwll.ch

+29 -27
+27 -6
drivers/video/fbdev/core/fbcon.c
··· 2756 2756 int i, new_idx = -1; 2757 2757 int idx = info->node; 2758 2758 2759 - WARN_CONSOLE_UNLOCKED(); 2759 + console_lock(); 2760 2760 2761 - if (!fbcon_has_console_bind) 2761 + if (!fbcon_has_console_bind) { 2762 + console_unlock(); 2762 2763 return; 2764 + } 2763 2765 2764 2766 for (i = first_fb_vc; i <= last_fb_vc; i++) { 2765 2767 if (con2fb_map[i] != idx && ··· 2796 2794 } 2797 2795 fbcon_unbind(); 2798 2796 } 2797 + 2798 + console_unlock(); 2799 2799 } 2800 2800 2801 2801 /* called with console_lock held */ ··· 2805 2801 { 2806 2802 int i, idx; 2807 2803 2808 - WARN_CONSOLE_UNLOCKED(); 2804 + console_lock(); 2809 2805 2810 - if (deferred_takeover) 2806 + if (deferred_takeover) { 2807 + console_unlock(); 2811 2808 return; 2809 + } 2812 2810 2813 2811 idx = info->node; 2814 2812 for (i = first_fb_vc; i <= last_fb_vc; i++) { ··· 2839 2833 2840 2834 if (!num_registered_fb) 2841 2835 do_unregister_con_driver(&fb_con); 2836 + console_unlock(); 2842 2837 } 2843 2838 2844 2839 void fbcon_remap_all(struct fb_info *info) ··· 2897 2890 } 2898 2891 #endif /* CONFIG_FRAMEBUFFER_DETECT_PRIMARY */ 2899 2892 2893 + static bool lockless_register_fb; 2894 + module_param_named_unsafe(lockless_register_fb, lockless_register_fb, bool, 0400); 2895 + MODULE_PARM_DESC(lockless_register_fb, 2896 + "Lockless framebuffer registration for debugging [default=off]"); 2897 + 2900 2898 /* called with console_lock held */ 2901 2899 int fbcon_fb_registered(struct fb_info *info) 2902 2900 { 2903 2901 int ret = 0, i, idx; 2904 2902 2905 - WARN_CONSOLE_UNLOCKED(); 2903 + if (!lockless_register_fb) 2904 + console_lock(); 2905 + else 2906 + atomic_inc(&ignore_console_lock_warning); 2906 2907 2907 2908 idx = info->node; 2908 2909 fbcon_select_primary(info); 2909 2910 2910 2911 if (deferred_takeover) { 2911 2912 pr_info("fbcon: Deferring console take-over\n"); 2912 - return 0; 2913 + goto out; 2913 2914 } 2914 2915 2915 2916 if (info_idx == -1) { ··· 2936 2921 set_con2fb_map(i, idx, 0); 2937 2922 } 2938 2923 } 2924 + 2925 + out: 2926 + if (!lockless_register_fb) 2927 + console_unlock(); 2928 + else 2929 + atomic_dec(&ignore_console_lock_warning); 2939 2930 2940 2931 return ret; 2941 2932 }
+2 -21
drivers/video/fbdev/core/fbmem.c
··· 1590 1590 } 1591 1591 } 1592 1592 1593 - static bool lockless_register_fb; 1594 - module_param_named_unsafe(lockless_register_fb, lockless_register_fb, bool, 0400); 1595 - MODULE_PARM_DESC(lockless_register_fb, 1596 - "Lockless framebuffer registration for debugging [default=off]"); 1597 - 1598 1593 static int do_register_framebuffer(struct fb_info *fb_info) 1599 1594 { 1600 - int i, ret; 1595 + int i; 1601 1596 struct fb_videomode mode; 1602 1597 1603 1598 if (fb_check_foreignness(fb_info)) ··· 1661 1666 } 1662 1667 #endif 1663 1668 1664 - if (!lockless_register_fb) 1665 - console_lock(); 1666 - else 1667 - atomic_inc(&ignore_console_lock_warning); 1668 - ret = fbcon_fb_registered(fb_info); 1669 - 1670 - if (!lockless_register_fb) 1671 - console_unlock(); 1672 - else 1673 - atomic_dec(&ignore_console_lock_warning); 1674 - return ret; 1669 + return fbcon_fb_registered(fb_info); 1675 1670 } 1676 1671 1677 1672 static void unbind_console(struct fb_info *fb_info) ··· 1671 1686 if (WARN_ON(i < 0 || i >= FB_MAX || registered_fb[i] != fb_info)) 1672 1687 return; 1673 1688 1674 - console_lock(); 1675 1689 fbcon_fb_unbind(fb_info); 1676 - console_unlock(); 1677 1690 } 1678 1691 1679 1692 static void unlink_framebuffer(struct fb_info *fb_info) ··· 1714 1731 fb_notifier_call_chain(FB_EVENT_FB_UNREGISTERED, &event); 1715 1732 } 1716 1733 #endif 1717 - console_lock(); 1718 1734 fbcon_fb_unregistered(fb_info); 1719 - console_unlock(); 1720 1735 1721 1736 /* this may free fb info */ 1722 1737 put_fb_info(fb_info);