From patchwork Fri Apr 7 12:06:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Zabel X-Patchwork-Id: 9669377 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 1B94F60364 for ; Fri, 7 Apr 2017 12:07:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CE5A26E3A for ; Fri, 7 Apr 2017 12:07:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01CCC2816B; Fri, 7 Apr 2017 12:06:59 +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 8602126E3A for ; Fri, 7 Apr 2017 12:06:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D65106EAF0; Fri, 7 Apr 2017 12:06:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id B90F86E207 for ; Fri, 7 Apr 2017 12:06:55 +0000 (UTC) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7] helo=dude.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.84_2) (envelope-from ) id 1cwSfG-00038D-96; Fri, 07 Apr 2017 14:06:54 +0200 From: Philipp Zabel To: dri-devel@lists.freedesktop.org, etnaviv@lists.freedesktop.org Subject: [PATCH libdrm v2 2/2] etnaviv: add fence fd support Date: Fri, 7 Apr 2017 14:06:44 +0200 Message-Id: <20170407120644.405-2-p.zabel@pengutronix.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170407120644.405-1-p.zabel@pengutronix.de> References: <20170407120644.405-1-p.zabel@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org Cc: Emil Velikov 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 Add etna_cmd_stream_flush2 with in-fence fd and out-fence fd support for explicit fencing. Signed-off-by: Philipp Zabel Reviewed-by: Eric Engestrom Reviewed-by: Christian Gmeiner --- v2: renamed etna_cmd_stream_flush_explicit to etna_cmd_stream_flush2 --- etnaviv/etnaviv_cmd_stream.c | 33 +++++++++++++++++++++++++++++---- etnaviv/etnaviv_drmif.h | 2 ++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/etnaviv/etnaviv_cmd_stream.c b/etnaviv/etnaviv_cmd_stream.c index 9ce3f363..3c7b0ed6 100644 --- a/etnaviv/etnaviv_cmd_stream.c +++ b/etnaviv/etnaviv_cmd_stream.c @@ -177,7 +177,8 @@ static uint32_t bo2idx(struct etna_cmd_stream *stream, struct etna_bo *bo, return idx; } -static void flush(struct etna_cmd_stream *stream) +static void flush(struct etna_cmd_stream *stream, int in_fence_fd, + int *out_fence_fd) { struct etna_cmd_stream_priv *priv = etna_cmd_stream_priv(stream); int ret, id = priv->pipe->id; @@ -194,8 +195,22 @@ static void flush(struct etna_cmd_stream *stream) .stream_size = stream->offset * 4, /* in bytes */ }; + if (in_fence_fd != -1) { + req.flags |= ETNA_SUBMIT_FENCE_FD_IN | ETNA_SUBMIT_NO_IMPLICIT; + req.fence_fd = in_fence_fd; + } + + if (out_fence_fd) + req.flags |= ETNA_SUBMIT_FENCE_FD_OUT; + + /* + * Pass the complete submit structure only if flags are set. Otherwise, + * only pass the fields up to, but not including the flags field for + * backwards compatiblity with older kernels. + */ ret = drmCommandWriteRead(gpu->dev->fd, DRM_ETNAVIV_GEM_SUBMIT, - &req, sizeof(req)); + &req, req.flags ? sizeof(req) : + offsetof(struct drm_etnaviv_gem_submit, flags)); if (ret) ERROR_MSG("submit failed: %d (%s)", ret, strerror(errno)); @@ -208,11 +223,21 @@ static void flush(struct etna_cmd_stream *stream) bo->current_stream = NULL; etna_bo_del(bo); } + + if (out_fence_fd) + *out_fence_fd = req.fence_fd; } void etna_cmd_stream_flush(struct etna_cmd_stream *stream) { - flush(stream); + flush(stream, -1, NULL); + reset_buffer(stream); +} + +void etna_cmd_stream_flush2(struct etna_cmd_stream *stream, int in_fence_fd, + int *out_fence_fd) +{ + flush(stream, in_fence_fd, out_fence_fd); reset_buffer(stream); } @@ -220,7 +245,7 @@ void etna_cmd_stream_finish(struct etna_cmd_stream *stream) { struct etna_cmd_stream_priv *priv = etna_cmd_stream_priv(stream); - flush(stream); + flush(stream, -1, NULL); etna_pipe_wait(priv->pipe, priv->last_timestamp, 5000); reset_buffer(stream); } diff --git a/etnaviv/etnaviv_drmif.h b/etnaviv/etnaviv_drmif.h index 8119baad..87704acd 100644 --- a/etnaviv/etnaviv_drmif.h +++ b/etnaviv/etnaviv_drmif.h @@ -142,6 +142,8 @@ struct etna_cmd_stream *etna_cmd_stream_new(struct etna_pipe *pipe, uint32_t siz void etna_cmd_stream_del(struct etna_cmd_stream *stream); uint32_t etna_cmd_stream_timestamp(struct etna_cmd_stream *stream); void etna_cmd_stream_flush(struct etna_cmd_stream *stream); +void etna_cmd_stream_flush2(struct etna_cmd_stream *stream, int in_fence_fd, + int *out_fence_fd); void etna_cmd_stream_finish(struct etna_cmd_stream *stream); static inline uint32_t etna_cmd_stream_avail(struct etna_cmd_stream *stream)