From patchwork Wed Jun 21 23:16:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Engestrom X-Patchwork-Id: 9803145 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 25BCF600C5 for ; Wed, 21 Jun 2017 23:18:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C5C628533 for ; Wed, 21 Jun 2017 23:18:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00B1E2853C; Wed, 21 Jun 2017 23:18:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 87FAD28533 for ; Wed, 21 Jun 2017 23:18:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DA0006E596; Wed, 21 Jun 2017 23:18:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0E2256E09C for ; Wed, 21 Jun 2017 23:18:31 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id x23so68265wrb.0 for ; Wed, 21 Jun 2017 16:18:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+sWRJJjgRxWQGIwcbyxPca+q3PxhasvyECHhrFiu2c8=; b=HvgCu6HpJEvkAeGs9qVIifhHVShP1QLeK3Jt7qzd7sTD0210KbEjv+ELIMj2/+O2KV Dh5AwA+T0VZ7HIj0/uJgo7Am/Xs+rqxYGyibsMWF/0xRXljnYbgDf2vvSQpodHztKKS1 Uco40gDzOhczEi2v/8TMMcbi/wlo2RvAPdgW5b5nJ2tO0FcDSLNxGNkKEOlJ/ggnqA2o o3RI0dtc3iqVb9695dHNhuz1ta89RXgI+QIKwOCxDrsROxGHfqGsfu8mPJ8JU/ZJF1zf Z4wJmhmFNd4gmgl8AY81664CuLmSEmB4up9t3TjpzIf8WYnxsjvZtcpN/yf3Icx+Moju fKvg== X-Gm-Message-State: AKS2vOwQxL3ja0S9kwE8+jU3lXJ/cBGyLNWhOCBHvSG0qtD2rWGBDK9A 0gaqc98gwWpR9M5EkCE= X-Received: by 10.28.172.4 with SMTP id v4mr152096wme.72.1498087109458; Wed, 21 Jun 2017 16:18:29 -0700 (PDT) Received: from localhost.localdomain ([5.80.129.103]) by smtp.gmail.com with ESMTPSA id t70sm26821580wmd.1.2017.06.21.16.18.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 16:18:28 -0700 (PDT) From: Eric Engestrom To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 2/2] xf86drm: introduce drmIoctl2() Date: Thu, 22 Jun 2017 00:16:13 +0100 Message-Id: <20170621231613.20619-2-eric@engestrom.ch> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20170621231613.20619-1-eric@engestrom.ch> References: <20170621231613.20619-1-eric@engestrom.ch> Cc: Chad Versace X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Basically ripped off of [1] by Chris Wilson, which I thought should live in libdrm too (even though it's needed in Mesa anyway). [1] https://lists.freedesktop.org/archives/mesa-dev/2017-June/159894.html Signed-off-by: Chris Wilson Signed-off-by: Eric Engestrom --- xf86drm.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/xf86drm.h b/xf86drm.h index aeed543f..eb75b944 100644 --- a/xf86drm.h +++ b/xf86drm.h @@ -38,6 +38,9 @@ #include #include #include +#if defined(__linux__) && defined(__GNUC__) && defined (__x86_64__) +#include +#endif #include #include @@ -135,6 +138,30 @@ drmIoctl(int fd, unsigned long request, void *arg) return ret; } +/** + * Call ioctl, restarting if it is interupted, and return the error. + */ +static inline int +drmIoctl2(int fd, unsigned long request, void *arg) +{ + int result; + + do { +#if defined(__linux__) && defined(__GNUC__) && defined (__x86_64__) + __asm__("syscall" + : "=a" (result) + : "0" (__NR_ioctl), "D" (fd), "S" (request), "d" (arg) + : "cc", "rcx", "r11", "memory"); +#else + result = ioctl(fd, request, arg); + if (result == -1) + result = -errno; +#endif + } while (result == -EINTR || result == -EAGAIN); + + return result; +} + extern void *drmGetHashTable(void); extern drmHashEntry *drmGetEntry(int fd);