From patchwork Sat Apr 21 22:50:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schake X-Patchwork-Id: 10354371 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 7D0AC6019C for ; Sat, 21 Apr 2018 22:51:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75CB32891A for ; Sat, 21 Apr 2018 22:51:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AA4828924; Sat, 21 Apr 2018 22:51:09 +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=-5.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, 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 123422891A for ; Sat, 21 Apr 2018 22:51:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 922B76E102; Sat, 21 Apr 2018 22:51:03 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id CC68D6E0F3 for ; Sat, 21 Apr 2018 22:50:58 +0000 (UTC) Received: by mail-wr0-x242.google.com with SMTP id u18-v6so4259027wrg.3 for ; Sat, 21 Apr 2018 15:50:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dyzSTugPEmCAoh0rrhAj8glRFkPa/p211yTukK+xaRs=; b=UMer+65Luap+vfKpEdQN1+gnWNFWv/cSZdh6T1XYO910DXeAjlKsWlyOcEVlXYhnsl nlfo0KLAH62Mhy2P3I7Vq+8RPRm1dO1zqk49gKgIE9eUPKj9r2apxLGUuP/bFkKIyJd7 WJ0b0y1EoYHIHfhLXdl8B71gvei15coORS+hyzTZljcHjFFF3Q5lZSpvU0JzDjxxhvka if1WBk1OqHvbOIbUTfoCcr++x6ZpLyd69UHROp2kYt+xZBBo614dTB45VsVAlnbNVRjU axDKbkhbiIuKe/cT7Dy6Zjh4t+EE56gGCtrbe5yaYdJCNV2xeACuqk8aHO8Lqv78k+rT d4dg== 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=dyzSTugPEmCAoh0rrhAj8glRFkPa/p211yTukK+xaRs=; b=WzIWkj3qHas60UIPk30vtYI2smAvOk1hb1dP+2vHn5Y4q7aFnx4sXDMP17l0SvB7Vp hP4S0v0BawmB8bF4TTFRJq9uMidkSyeGNX4mAAhF3wTI1YU1hljjfezBfh02wAaBUCoP 9tiK/gpIVcI9J4PMCpgSMNIbTYNIx5TD64qQVHUK1IHxR2xghQAu0VlEt85oo31smNtg DU8xdS7ePf/TseOr4LaP1xZbeNMAf384C9TSV7SF0fIuxTG2yWR5CgQg1NuNKq4bvpcG 4YGGeGLq/spz9EsRfg7ktVWQhwkSU/hKbaU+IIntJ/ihQNIq4j8exzkEcq4ndhNsX7RW 6tiA== X-Gm-Message-State: ALQs6tAadH2levjO3LM5SFTcCXgRs4Hq3ajyIU6iBcgihG3TNMuWg0cZ DBe81KWUPWUbbSjNDr7Eips= X-Google-Smtp-Source: AIpwx48zCWUBetynZfbUM69I50kXeZK/eZhvyiL0aATeGLXSbcf3bJyDt+KQ432/5DfrUjJCXYtchg== X-Received: by 10.28.190.15 with SMTP id o15mr2026767wmf.104.1524351057289; Sat, 21 Apr 2018 15:50:57 -0700 (PDT) Received: from localhost.localdomain (ip-88-153-118-32.hsi04.unitymediagroup.de. [88.153.118.32]) by smtp.gmail.com with ESMTPSA id 55-v6sm18528098wrw.52.2018.04.21.15.50.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Apr 2018 15:50:56 -0700 (PDT) From: Stefan Schake To: eric@anholt.net Subject: [PATCH 2/4] drm/vc4: Syncobj import support Date: Sat, 21 Apr 2018 15:50:20 -0700 Message-Id: <20180421225022.7592-3-stschake@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180421225022.7592-1-stschake@gmail.com> References: <20180421225022.7592-1-stschake@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: airlied@linux.ie, linux-rpi-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, Stefan Schake MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Allow userland to specify a syncobj that is waited on before a render job starts processing. Signed-off-by: Stefan Schake --- drivers/gpu/drm/vc4/vc4_drv.h | 2 ++ drivers/gpu/drm/vc4/vc4_gem.c | 33 +++++++++++++++++++++++++++------ include/uapi/drm/vc4_drm.h | 9 +++++---- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h index 4288615b66a2..3105df99cb12 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.h +++ b/drivers/gpu/drm/vc4/vc4_drv.h @@ -10,6 +10,8 @@ #include #include #include +#include + #include "uapi/drm/vc4_drm.h" diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c index 2107b0daf8ef..232363488125 100644 --- a/drivers/gpu/drm/vc4/vc4_gem.c +++ b/drivers/gpu/drm/vc4/vc4_gem.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "uapi/drm/vc4_drm.h" #include "vc4_drv.h" @@ -1115,21 +1116,18 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data, struct drm_vc4_submit_cl *args = data; struct vc4_exec_info *exec; struct ww_acquire_ctx acquire_ctx; + struct dma_fence *in_fence; int ret = 0; if ((args->flags & ~(VC4_SUBMIT_CL_USE_CLEAR_COLOR | VC4_SUBMIT_CL_FIXED_RCL_ORDER | VC4_SUBMIT_CL_RCL_ORDER_INCREASING_X | - VC4_SUBMIT_CL_RCL_ORDER_INCREASING_Y)) != 0) { + VC4_SUBMIT_CL_RCL_ORDER_INCREASING_Y | + VC4_SUBMIT_CL_IMPORT_SYNCOBJ)) != 0) { DRM_DEBUG("Unknown flags: 0x%02x\n", args->flags); return -EINVAL; } - if (args->pad2 != 0) { - DRM_DEBUG("->pad2 must be set to zero\n"); - return -EINVAL; - } - exec = kcalloc(1, sizeof(*exec), GFP_KERNEL); if (!exec) { DRM_ERROR("malloc failure on exec struct\n"); @@ -1164,6 +1162,29 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data, } } + if (args->flags & VC4_SUBMIT_CL_IMPORT_SYNCOBJ) { + ret = drm_syncobj_find_fence(file_priv, args->in_sync, + &in_fence); + if (ret) + goto fail; + + /* When the fence (or fence array) is exclusively from our + * context we can skip the wait since jobs are executed in + * order of their submission through this ioctl and this can + * only have fences from a prior job. + */ + if (!dma_fence_match_context(in_fence, + vc4->dma_fence_context)) { + ret = dma_fence_wait(in_fence, true); + if (ret) { + dma_fence_put(in_fence); + goto fail; + } + } + + dma_fence_put(in_fence); + } + if (exec->args->bin_cl_size != 0) { ret = vc4_get_bcl(dev, exec); if (ret) diff --git a/include/uapi/drm/vc4_drm.h b/include/uapi/drm/vc4_drm.h index b95a0e11cb07..389f21931c25 100644 --- a/include/uapi/drm/vc4_drm.h +++ b/include/uapi/drm/vc4_drm.h @@ -173,6 +173,7 @@ struct drm_vc4_submit_cl { #define VC4_SUBMIT_CL_FIXED_RCL_ORDER (1 << 1) #define VC4_SUBMIT_CL_RCL_ORDER_INCREASING_X (1 << 2) #define VC4_SUBMIT_CL_RCL_ORDER_INCREASING_Y (1 << 3) +#define VC4_SUBMIT_CL_IMPORT_SYNCOBJ (1 << 4) __u32 flags; /* Returned value of the seqno of this render job (for the @@ -183,11 +184,11 @@ struct drm_vc4_submit_cl { /* ID of the perfmon to attach to this job. 0 means no perfmon. */ __u32 perfmonid; - /* Unused field to align this struct on 64 bits. Must be set to 0. - * If one ever needs to add an u32 field to this struct, this field - * can be used. + /* Syncobj handle to wait on. Set together with IMPORT_SYNCOBJ flag. + * If set, processing of this render job will not start until the + * syncobj is signalled. */ - __u32 pad2; + __u32 in_sync; }; /**