• Daniel Vetter's avatar
    fbdev: lock_fb_info cannot fail · cf4a3ae4
    Daniel Vetter authored
    Ever since
    
    commit c47747fd
    Author: Linus Torvalds <torvalds@linux-foundation.org>
    Date:   Wed May 11 14:58:34 2011 -0700
    
        fbmem: make read/write/ioctl use the frame buffer at open time
    
    fbdev has gained proper refcounting for the fbinfo attached to any
    open files, which means that the backing driver (stored in
    fb_info->fbops) cannot untimely disappear anymore.
    
    The only thing that can happen is that the entire device just outright
    disappears and gets unregistered, but file_fb_info does check for
    that. Except that it's racy - it only checks once at the start of a
    file_ops, there's no guarantee that the underlying fbdev won't
    untimely disappear. Aside: A proper way to fix that race is probably
    to replicate the srcu trickery we've rolled out in drm.
    
    But given that this race has existed since forever it's probably not
    one we need to fix right away. do_unregister_framebuffer also nowhere
    clears fb_info->fbops, hence the check in lock_fb_info can't possible
    catch a disappearing fbdev later on.
    
    Long story short: Ever since the above commit the fb_info->fbops
    checks have essentially become dead code. Remove this all.
    
    Aside from the file_ops callbacks, and stuff called from there
    there's only register/unregister code left. If that goes wrong a driver
    managed to register/unregister a device instance twice or in the wrong
    order.  That's just a driver bug.
    
    v2:
    - fb_mmap had an open-coded version of the fbinfo->fops check, because
      it doesn't need the fbinfo->lock. Delete that too.
    - Use the wrapper function in fb_open/release now, since no difference
      anymore.
    Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
    Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
    Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
    Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
    Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
    Cc: Hans de Goede <hdegoede@redhat.com>
    Cc: Yisheng Xie <ysxie@foxmail.com>
    Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
    Cc: "Noralf Trønnes" <noralf@tronnes.org>
    Cc: Peter Rosin <peda@axentia.se>
    Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
    Cc: Mikulas Patocka <mpatocka@redhat.com>
    Cc: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
    Cc: linux-fbdev@vger.kernel.org
    Link: https://patchwork.freedesktop.org/patch/msgid/20190528090304.9388-17-daniel.vetter@ffwll.ch
    cf4a3ae4
fbcon.c 90.3 KB