From patchwork Tue Sep 12 20:43:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWFyZWsgT2zFocOhaw==?= X-Patchwork-Id: 9950089 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 2FCA2602C9 for ; Tue, 12 Sep 2017 20:43:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21925290C1 for ; Tue, 12 Sep 2017 20:43:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15D2B290C0; Tue, 12 Sep 2017 20:43:32 +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.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 BE4F3290C0 for ; Tue, 12 Sep 2017 20:43:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3AF396E710; Tue, 12 Sep 2017 20:43:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x235.google.com (mail-wr0-x235.google.com [IPv6:2a00:1450:400c:c0c::235]) by gabe.freedesktop.org (Postfix) with ESMTPS id DF1346E701; Tue, 12 Sep 2017 20:43:28 +0000 (UTC) Received: by mail-wr0-x235.google.com with SMTP id 108so25031151wra.5; Tue, 12 Sep 2017 13:43:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZG8u/G0uP3Cwm33CywX02QElVfpQYGISQtv3nttv2ng=; b=TlVX3M+ioOhIbZLIq67rA8+jfME00hnS2+p8eapG0vc4kDYdfK+hHgVquYZghbUOwF zjJWRUypaMBWTJNJDgX1bDzBj5WeCQNY/E3K3ZFWFYbU9vRa60RNszMK4OBBWesLiyQq afj+qWjXHxzPRvvjwiyTfvXy6rQ3O7IQAPfLYnTP+MqMGGeC7lP6O5/XGGwnxT/X15HI yn1kf2CVZRz4rpiFSfUNvCXfTCnfxIcOdfDjKWFobMAAMnnINzVIY6dWDUpaxBcUItw/ T+iUjYNQJmadt68QOtMSQyYBUl1Aw8vvOptTEAVCxTB7ATXOj7ASRzauoALlOzb1aLXe Zvrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZG8u/G0uP3Cwm33CywX02QElVfpQYGISQtv3nttv2ng=; b=Gbd0CKJjU/vnqeP3lB/afhV7sB1TKxojbwe7ARE8QSr7elFWu+sMcPI9eWglfEzrMu K6jZ9oh6u2GO3qItojRKFJQ33ZORmc/shGghmWS+F2TXzMndcnBIXMCk49IQTD6o1wvS ZGNk9FdW2UiBDLk8NveqmCRzu4N2t7gDsOhi05V//Yx6ozcA6bVtd+wrYXJkMowJBCv9 lXR3Aiokdj8+UoDkpmLYcjswDhvsHgeq+z2eI8Azt9dIxe09N0E9HuIuDGpS1rdJEUoO EIPiHR5ilv/+lmWps2Tu9fokPZ5zivzxunTd7qjolETlrVQexGLOrcxnQ5COQdgv3112 xwww== X-Gm-Message-State: AHPjjUhA406UN06OWq2oQYbud+bdvzFpmjmEerJa2SEbKwQmEaaRVZhu 2ckYByJqYCV9LLqW X-Google-Smtp-Source: ADKCNb6ecuITficgX9UatTQfbfHK57KVEpxjf2ZaXFfp+LQmOhOwlaOt5re+py4xnPLDk+47AJvfTg== X-Received: by 10.223.143.14 with SMTP id p14mr12923916wrb.133.1505249007286; Tue, 12 Sep 2017 13:43:27 -0700 (PDT) Received: from localhost.localdomain (ip-78-102-146-217.net.upcbroadband.cz. [78.102.146.217]) by smtp.gmail.com with ESMTPSA id d9sm8216141wrd.37.2017.09.12.13.43.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Sep 2017 13:43:26 -0700 (PDT) From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH libdrm 2/4] drm: add drmSyncobjWait wrapper Date: Tue, 12 Sep 2017 22:43:10 +0200 Message-Id: <1505248992-1898-2-git-send-email-maraeo@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505248992-1898-1-git-send-email-maraeo@gmail.com> References: <1505248992-1898-1-git-send-email-maraeo@gmail.com> MIME-Version: 1.0 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Marek Olšák --- include/drm/drm.h | 24 ++++++++++++++++++++++++ xf86drm.c | 22 ++++++++++++++++++++++ xf86drm.h | 3 +++ 3 files changed, 49 insertions(+) diff --git a/include/drm/drm.h b/include/drm/drm.h index bf3674a..4da1667 100644 --- a/include/drm/drm.h +++ b/include/drm/drm.h @@ -694,6 +694,7 @@ struct drm_prime_handle { struct drm_syncobj_create { __u32 handle; +#define DRM_SYNCOBJ_CREATE_SIGNALED (1 << 0) __u32 flags; }; @@ -712,6 +713,24 @@ struct drm_syncobj_handle { __u32 pad; }; +#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0) +#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1) +struct drm_syncobj_wait { + __u64 handles; + /* absolute timeout */ + __s64 timeout_nsec; + __u32 count_handles; + __u32 flags; + __u32 first_signaled; /* only valid when not waiting all */ + __u32 pad; +}; + +struct drm_syncobj_array { + __u64 handles; + __u32 count_handles; + __u32 pad; +}; + #if defined(__cplusplus) } #endif @@ -834,6 +853,9 @@ extern "C" { #define DRM_IOCTL_SYNCOBJ_DESTROY DRM_IOWR(0xC0, struct drm_syncobj_destroy) #define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD DRM_IOWR(0xC1, struct drm_syncobj_handle) #define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE DRM_IOWR(0xC2, struct drm_syncobj_handle) +#define DRM_IOCTL_SYNCOBJ_WAIT DRM_IOWR(0xC3, struct drm_syncobj_wait) +#define DRM_IOCTL_SYNCOBJ_RESET DRM_IOWR(0xC4, struct drm_syncobj_array) +#define DRM_IOCTL_SYNCOBJ_SIGNAL DRM_IOWR(0xC5, struct drm_syncobj_array) /** * Device specific ioctls should only be in their respective headers @@ -876,6 +898,7 @@ struct drm_event_vblank { }; /* typedef area */ +#ifndef __KERNEL__ typedef struct drm_clip_rect drm_clip_rect_t; typedef struct drm_drawable_info drm_drawable_info_t; typedef struct drm_tex_region drm_tex_region_t; @@ -917,6 +940,7 @@ typedef struct drm_agp_binding drm_agp_binding_t; typedef struct drm_agp_info drm_agp_info_t; typedef struct drm_scatter_gather drm_scatter_gather_t; typedef struct drm_set_version drm_set_version_t; +#endif #if defined(__cplusplus) } diff --git a/xf86drm.c b/xf86drm.c index 6ea0112..8a32717 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -4225,3 +4225,25 @@ int drmSyncobjExportSyncFile(int fd, uint32_t handle, int *sync_file_fd) *sync_file_fd = args.fd; return 0; } + +int drmSyncobjWait(int fd, uint32_t *handles, unsigned num_handles, + int64_t timeout_nsec, unsigned flags, + uint32_t *first_signaled) +{ + struct drm_syncobj_wait args; + int ret; + + memclear(args); + args.handles = (intptr_t)handles; + args.timeout_nsec = timeout_nsec; + args.count_handles = num_handles; + args.flags = flags; + + ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_WAIT, &args); + if (ret < 0) + return ret; + + if (first_signaled) + *first_signaled = args.first_signaled; + return ret; +} diff --git a/xf86drm.h b/xf86drm.h index 2855a3e..ea650ef 100644 --- a/xf86drm.h +++ b/xf86drm.h @@ -860,6 +860,9 @@ extern int drmSyncobjFDToHandle(int fd, int obj_fd, uint32_t *handle); extern int drmSyncobjImportSyncFile(int fd, uint32_t handle, int sync_file_fd); extern int drmSyncobjExportSyncFile(int fd, uint32_t handle, int *sync_file_fd); +extern int drmSyncobjWait(int fd, uint32_t *handles, unsigned num_handles, + int64_t timeout_nsec, unsigned flags, + uint32_t *first_signaled); #if defined(__cplusplus) }