Skip to content

Commit 873eb3b

Browse files
fbdev: Disable sysfb device registration when removing conflicting FBs
The platform devices registered by sysfb match with firmware-based DRM or fbdev drivers, that are used to have early graphics using a framebuffer provided by the system firmware. DRM or fbdev drivers later are probed and remove conflicting framebuffers, leading to these platform devices for generic drivers to be unregistered. But the current solution has a race, since the sysfb_init() function could be called after a DRM or fbdev driver is probed and request to unregister the devices for drivers with conflicting framebuffes. To prevent this, disable any future sysfb platform device registration by calling sysfb_disable(), if a driver requests to remove the conflicting framebuffers. Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20220607182338.344270-4-javierm@redhat.com
1 parent bc82492 commit 873eb3b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/video/fbdev/core/fbmem.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/kernel.h>
2020
#include <linux/major.h>
2121
#include <linux/slab.h>
22+
#include <linux/sysfb.h>
2223
#include <linux/mm.h>
2324
#include <linux/mman.h>
2425
#include <linux/vt.h>
@@ -1764,6 +1765,17 @@ int remove_conflicting_framebuffers(struct apertures_struct *a,
17641765
do_free = true;
17651766
}
17661767

1768+
/*
1769+
* If a driver asked to unregister a platform device registered by
1770+
* sysfb, then can be assumed that this is a driver for a display
1771+
* that is set up by the system firmware and has a generic driver.
1772+
*
1773+
* Drivers for devices that don't have a generic driver will never
1774+
* ask for this, so let's assume that a real driver for the display
1775+
* was already probed and prevent sysfb to register devices later.
1776+
*/
1777+
sysfb_disable();
1778+
17671779
mutex_lock(&registration_lock);
17681780
do_remove_conflicting_framebuffers(a, name, primary);
17691781
mutex_unlock(&registration_lock);

0 commit comments

Comments
 (0)