[PATCH xserver 1/2] config: wait for DRM device to be successful initiated

Liwei Song liwei.song at windriver.com
Thu Apr 12 02:49:43 UTC 2018


On my CoffeeLake machine, when build i915 driver as kernel module,
will got following error message in Xorg.0.log:
(EE) /dev/dri/card0: failed to set DRM interface version 1.4: Permission denied

When compile i915 as kernel module, drm device won't be initiated
after rootfs was mounted. This may led Xorg access DRM device failed,
since DRM  was not successful created by i915 driver yet.
Then the set version process will not be done in InitOutput(),
and it will be delayed to InitInput(), when came into InitInput()
DRM device already maped to memory, So through ioctl set DRM interface
version will failed, then print the error message in Xorg.0.log.

To avoid the timing problem between i915.ko and Xorg,  we need make
sure DRM device was created and no process hold it, because nobody
hold it in InitOutput(), then the rest work is to ensure DRM was
created successful. So add a loop method to wait DRM device are
available.

Signed-off-by: Liwei Song <liwei.song at windriver.com>
---
 config/udev.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/config/udev.c b/config/udev.c
index 3a73189e2558..2398603cd87b 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -486,8 +486,11 @@ config_udev_odev_probe(config_odev_probe_proc_ptr probe_callback)
     struct udev *udev;
     struct udev_enumerate *enumerate;
     struct udev_list_entry *devices, *device;
+    int loop = 0;
 
     udev = udev_monitor_get_udev(udev_monitor);
+
+retry:
     enumerate = udev_enumerate_new(udev);
     if (!enumerate)
         return;
@@ -500,6 +503,12 @@ config_udev_odev_probe(config_odev_probe_proc_ptr probe_callback)
 #endif
     udev_enumerate_scan_devices(enumerate);
     devices = udev_enumerate_get_list_entry(enumerate);
+    if (!devices && loop++ <= 10){
+	usleep(100000);
+	udev_enumerate_unref(enumerate);
+	goto retry;
+    }
+
     udev_list_entry_foreach(device, devices) {
         const char *syspath = udev_list_entry_get_name(device);
         struct udev_device *udev_device = udev_device_new_from_syspath(udev, syspath);
-- 
2.7.4



More information about the xorg-devel mailing list