From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maarten Lankhorst Subject: Re: [PATCH v2 0/7] xfree86: Handle drm race condition Date: Tue, 19 Mar 2013 11:02:14 +0100 Message-ID: <514837A6.5010301@canonical.com> References: <1363639911-21239-1-git-send-email-bryce@canonical.com> <20130319092146.GC3872@cantiga.alporthouse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by gabe.freedesktop.org (Postfix) with ESMTP id 77E35E5D30 for ; Tue, 19 Mar 2013 03:02:16 -0700 (PDT) In-Reply-To: <20130319092146.GC3872@cantiga.alporthouse.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: Chris Wilson , Bryce Harrington , intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org Hey, Op 19-03-13 10:21, Chris Wilson schreef: > On Mon, Mar 18, 2013 at 01:51:44PM -0700, Bryce Harrington wrote: >> Update: Squashes a couple commits to avoid potential hang if >> git bisecting. No other changes from v1. > I'd probably drop the last EAGAIN patch as that is part of the libdrm > API, but other than that it looks to be a reasonably self-contained w/a > for this perplexing problem. > > Reviewed-by: Chris Wilson > -Chris > And completely wrong, version I pushed to ubuntu's xorg-server for comparison: >8-- Nacked-by: Maarten Lankhorst --- a/hw/xfree86/os-support/linux/lnx_platform.c +++ b/hw/xfree86/os-support/linux/lnx_platform.c @@ -7,6 +7,7 @@ #include #include #include +#include /* Linux platform device support */ #include "xf86_OSproc.h" @@ -17,23 +18,54 @@ #include "hotplug.h" +static Bool get_drm_master(int fd) +{ + int ret, tries = 400; + + LogMessage(X_INFO, "spinning!\n"); + + while (tries--) { + if (drmSetMaster(fd) >= 0) + return TRUE; + + if (errno != EINVAL) + break; + + usleep(10000); + } + return FALSE; +} + static Bool get_drm_info(struct OdevAttributes *attribs, char *path) { drmSetVersion sv; char *buf; int fd; + int err = 0; fd = open(path, O_RDWR, O_CLOEXEC); if (fd == -1) return FALSE; - sv.drm_di_major = 1; - 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"); + while (1) { + sv.drm_di_major = 1; + sv.drm_di_minor = 4; + sv.drm_dd_major = -1; /* Don't care */ + sv.drm_dd_minor = -1; /* Don't care */ + + err = drmSetInterfaceVersion(fd, &sv); + if (!err) + break; + + if (err == -EACCES) { + if (get_drm_master(fd)) + continue; + ErrorF("drmSetMaster failed with -%i(%m)\n", errno); + } else + ErrorF("drmSetInterfaceVersion failed with %i(%s)\n", err, strerror(-err)); + + close(fd); return FALSE; }