From d650ecb5e638cf5d9e8d6b789412cb1fb5225a73 Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Wed, 13 Feb 2013 11:39:34 -0800 Subject: [PATCH] If drm device couldn't be opened, keep trying for a sec. The kernel returns EAGAIN on drm open when the drm device is currently unavailable, such as if it is in use by another process (e.g. plymouth), or hasn't finished initializing (e.g. on a really fast SSD). Check for this error code, and if it's hit then block until it either resolved or some other error returned (and in which case, log the appropriate messages to that effect). Signed-off-by: Bryce Harrington --- hw/xfree86/os-support/linux/lnx_platform.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/hw/xfree86/os-support/linux/lnx_platform.c b/hw/xfree86/os-support/linux/lnx_platform.c index 76f5583..32107a9 100644 --- a/hw/xfree86/os-support/linux/lnx_platform.c +++ b/hw/xfree86/os-support/linux/lnx_platform.c @@ -23,6 +23,8 @@ get_drm_info(struct OdevAttributes *attribs, char *path) drmSetVersion sv; char *buf; int fd; + int err = 0; + int counter = 100000; fd = open(path, O_RDWR, O_CLOEXEC); if (fd == -1) @@ -32,9 +34,17 @@ get_drm_info(struct OdevAttributes *attribs, char *path) sv.drm_di_minor = 4; sv.drm_dd_major = -1; /* Don't care */ sv.drm_dd_minor = -1; /* Don't care */ - if (drmSetInterfaceVersion(fd, &sv)) { - ErrorF("setversion 1.4 failed\n"); - return FALSE; + err = drmSetInterfaceVersion(fd, &sv); + while (err!=0 && counter>0) { + /* TODO: Check if it's returning EAGAIN, and only loop on that */ + ErrorF("drm device not ready (%d), sleeping for 20us\n", err); + usleep(20); + err = drmSetInterfaceVersion(fd, &sv); + counter--; + } + if (err) { + ErrorF("setversion 1.4 failed\n"); + return FALSE; } xf86_add_platform_device(attribs); -- 1.7.9.5