From patchwork Tue Mar 19 10:02:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 2301771 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 3600E3FC8A for ; Tue, 19 Mar 2013 15:31:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 33309E6516 for ; Tue, 19 Mar 2013 08:31:22 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org 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) Received: from 5ed48cef.cm-7-5c.dynamic.ziggo.nl ([94.212.140.239] helo=[192.168.1.128]) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1UHtN1-0001br-1N; Tue, 19 Mar 2013 10:02:15 +0000 Message-ID: <514837A6.5010301@canonical.com> Date: Tue, 19 Mar 2013 11:02:14 +0100 From: Maarten Lankhorst User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: Chris Wilson , Bryce Harrington , intel-gfx@lists.freedesktop.org References: <1363639911-21239-1-git-send-email-bryce@canonical.com> <20130319092146.GC3872@cantiga.alporthouse.com> In-Reply-To: <20130319092146.GC3872@cantiga.alporthouse.com> X-Mailman-Approved-At: Tue, 19 Mar 2013 08:31:07 -0700 Subject: Re: [Intel-gfx] [PATCH v2 0/7] xfree86: Handle drm race condition X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@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; }