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 all 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 driver is probed and requested to unregister devices for drivers with conflicting framebuffes. To prevent this, disable any future sysfb platform device registration by calling sysfb_disable(), if either a framebuffer device or a DRM device is registered. Since in that case a display will already be present. Suggested-by: Daniel Vetter <daniel.vetter@xxxxxxxx> Signed-off-by: Javier Martinez Canillas <javierm@xxxxxxxxxx> --- (no changes since v3) Changes in v3: - Call sysfb_disable() when a DRM device is registered rather than when conflicting framebuffers are removed (Thomas Zimmermann). drivers/gpu/drm/drm_drv.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 8214a0b1ab7f..e577c42861c6 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -34,6 +34,7 @@ #include <linux/pseudo_fs.h> #include <linux/slab.h> #include <linux/srcu.h> +#include <linux/sysfb.h> #include <drm/drm_cache.h> #include <drm/drm_client.h> @@ -913,6 +914,17 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags) out_unlock: if (drm_dev_needs_global_mutex(dev)) mutex_unlock(&drm_global_mutex); + + /* + * If a driver registers a DRM device, then it can be assumed that a + * display will be present and there is no need for a generic driver + * using the firmware setup system framebuffer. + * + * Disable sysfb and prevent registering simple framebuffer devices. + */ + if (!drm_core_check_feature(dev, DRIVER_FIRMWARE)) + sysfb_disable(); + return ret; } EXPORT_SYMBOL(drm_dev_register); -- 2.35.1