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: use lock_fb_info in fbcon_open/release

Now we get to the real motiviation, because fbmem.c insists that
that's the right lock for these.

Ofc fbcon.c has a lot more places where it probably should call
lock_fb_info(). But looking at fbmem.c at least most of these seem to
be protected by console_lock() too, which is probably what papers over
any issues.

Note that this means we're shuffling around a bit the locking sections
for some of the console takeover and unbind paths, but not all:
- console binding/unbinding from the console layer never with
lock_fb_info
- unbind (as opposed to unlink) never bother with lock_fb_info

Also the real serialization against set_par and set_pan are still
doing by wrapping the entire ioctl code in console_lock(). So this
shuffling shouldn't be worse than what we had from a "can you trigger
races?" pov, but it's at least clearer.

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

+5 -4
+5
drivers/video/fbdev/core/fbcon.c
··· 684 684 685 685 static void fbcon_release(struct fb_info *info) 686 686 { 687 + lock_fb_info(info); 687 688 if (info->fbops->fb_release) 688 689 info->fbops->fb_release(info, 0); 690 + unlock_fb_info(info); 689 691 690 692 module_put(info->fbops->owner); 691 693 } ··· 699 697 if (!try_module_get(info->fbops->owner)) 700 698 return -ENODEV; 701 699 700 + lock_fb_info(info); 702 701 if (info->fbops->fb_open && 703 702 info->fbops->fb_open(info, 0)) { 703 + unlock_fb_info(info); 704 704 module_put(info->fbops->owner); 705 705 return -ENODEV; 706 706 } 707 + unlock_fb_info(info); 707 708 708 709 ops = kzalloc(sizeof(struct fbcon_ops), GFP_KERNEL); 709 710 if (!ops) {
-4
drivers/video/fbdev/core/fbmem.c
··· 1670 1670 console_lock(); 1671 1671 else 1672 1672 atomic_inc(&ignore_console_lock_warning); 1673 - lock_fb_info(fb_info); 1674 1673 ret = fbcon_fb_registered(fb_info); 1675 - unlock_fb_info(fb_info); 1676 1674 1677 1675 if (!lockless_register_fb) 1678 1676 console_unlock(); ··· 1687 1689 return; 1688 1690 1689 1691 console_lock(); 1690 - lock_fb_info(fb_info); 1691 1692 fbcon_fb_unbind(fb_info); 1692 - unlock_fb_info(fb_info); 1693 1693 console_unlock(); 1694 1694 } 1695 1695