From: Bryce Harrington Subject: [PATCH v2 5/7] xfree86: Fix race condition failure opening drm. Date: Mon, 18 Mar 2013 13:51:49 -0700 Message-ID: <1363639911-21239-6-git-send-email-bryce@canonical.com> References: <1363639911-21239-1-git-send-email-bryce@canonical.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from smtp.outflux.net (smtp.outflux.net [198.145.64.163]) by gabe.freedesktop.org (Postfix) with ESMTP id AAB74E631B for ; Mon, 18 Mar 2013 13:52:15 -0700 (PDT) In-Reply-To: <1363639911-21239-1-git-send-email-bryce@canonical.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: intel-gfx@lists.freedesktop.org, Chris Wilson Cc: Maarten Lankhorst List-Id: intel-gfx@lists.freedesktop.org If other processes have had drm open previously, xserver may attempt to open the device too early and fail, with xserver error exit "Cannot run in framebuffer mode" or Xorg.0.log messages about "setversion 1.4 failed". In this situation, we're receiving back -EACCES from libdrm. To address this we need to re-set ourselves as the drm master, and keep trying to set the interface until it works (or until we give up). See https://bugs.launchpad.net/ubuntu/+source/libdrm/+bug/982889 Signed-off-by: Bryce Harrington --- hw/xfree86/os-support/linux/lnx_platform.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/xfree86/os-support/linux/lnx_platform.c b/hw/xfree86/os-support/linux/lnx_platform.c index 4094866..bb76d90 100644 --- a/hw/xfree86/os-support/linux/lnx_platform.c +++ b/hw/xfree86/os-support/linux/lnx_platform.c @@ -43,8 +43,14 @@ get_drm_info(struct OdevAttributes *attribs, char *path) if (tries > 1) LogMessage(X_INFO, "setversion 1.4 succeeded on try #%d\n", tries); break; + } if (err != -EACCES) { + break; } + usleep(1000); + + if (!drmSetMaster(fd)) + LogMessage(X_INFO, "drmSetMaster succeeded\n"); } if (err) { ErrorF("setversion 1.4 failed: %s\n", strerror(-err)); -- 1.7.9.5