Skip to content

Commit ee7a69a

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 bde376e commit ee7a69a

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>
@@ -1752,6 +1753,17 @@ int remove_conflicting_framebuffers(struct apertures_struct *a,
17521753
do_free = true;
17531754
}
17541755

1756+
/*
1757+
* If a driver asked to unregister a platform device registered by
1758+
* sysfb, then can be assumed that this is a driver for a display
1759+
* that is set up by the system firmware and has a generic driver.
1760+
*
1761+
* Drivers for devices that don't have a generic driver will never
1762+
* ask for this, so let's assume that a real driver for the display
1763+
* was already probed and prevent sysfb to register devices later.
1764+
*/
1765+
sysfb_disable();
1766+
17551767
mutex_lock(&registration_lock);
17561768
do_remove_conflicting_framebuffers(a, name, primary);
17571769
mutex_unlock(&registration_lock);

0 commit comments

Comments
 (0)