plymouth/ply-device-manager-Fix-race-causing-undesired-creati.patch
songnannan b411777e51 init
2019-12-28 09:27:13 +08:00

82 lines
3.7 KiB
Diff

From 059390ac569798cbf40a958ea714b15f313b46a3 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Sat, 10 Nov 2018 16:04:31 +0100
Subject: [PATCH 062/142] ply-device-manager: Fix race causing undesired
creation of non-gfx devs
On systems with working drm/kms devices we still sometimes see:
"Creating non-graphical devices, since there's no suitable graphics hardware"
in the logs (and actually create non-gfx devices).
This is caused by a race where the create_devices_from_udev timeout handler
runs just after the pivot-root, just at the time when the "udev trigger"
from the real root is done.
This causes create_devices_for_subsystem() to hit the "it's not initialized"
code-path for all drm and fb devices, even though before (from the initrd)
drm-devices where already setup successfully.
One way of solving this would be to stop the timer as soon as we successfully
enumerate the first drm device. But we need the timer to enumerate fb devices
so on machines where some outputs only have a fbdev driver (corner case) this
would break support for those outputs.
Instead this commit moves the found_drm_device and found_fb_device to the
global manager state and sets them from create_devices_for_udev_device().
This way they will be set when we check them from the create_devices_from_udev
timeout handler even if create_devices_for_subsystem skips over the devices
because of the udev trigger race.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
src/libply-splash-core/ply-device-manager.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/libply-splash-core/ply-device-manager.c b/src/libply-splash-core/ply-device-manager.c
index b637fb8..dcc9859 100644
--- a/src/libply-splash-core/ply-device-manager.c
+++ b/src/libply-splash-core/ply-device-manager.c
@@ -77,6 +77,8 @@ struct _ply_device_manager
uint32_t serial_consoles_detected : 1;
uint32_t renderers_activated : 1;
uint32_t keyboards_activated : 1;
+ uint32_t found_drm_device : 1;
+ uint32_t found_fb_device : 1;
};
static void
@@ -250,6 +252,12 @@ create_devices_for_udev_device (ply_device_manager_t *manager,
device_path,
terminal,
renderer_type);
+ if (created) {
+ if (renderer_type == PLY_RENDERER_TYPE_DRM)
+ manager->found_drm_device = 1;
+ if (renderer_type == PLY_RENDERER_TYPE_FRAME_BUFFER)
+ manager->found_fb_device = 1;
+ }
}
}
@@ -799,14 +807,12 @@ create_non_graphical_devices (ply_device_manager_t *manager)
static void
create_devices_from_udev (ply_device_manager_t *manager)
{
- bool found_drm_device, found_fb_device;
-
ply_trace ("Timeout elapsed, looking for devices from udev");
- found_drm_device = create_devices_for_subsystem (manager, SUBSYSTEM_DRM);
- found_fb_device = create_devices_for_subsystem (manager, SUBSYSTEM_FRAME_BUFFER);
+ create_devices_for_subsystem (manager, SUBSYSTEM_DRM);
+ create_devices_for_subsystem (manager, SUBSYSTEM_FRAME_BUFFER);
- if (found_drm_device || found_fb_device)
+ if (manager->found_drm_device || manager->found_fb_device)
return;
ply_trace ("Creating non-graphical devices, since there's no suitable graphics hardware");
--
1.8.3.1