From patchwork Sat Apr 21 22:50:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schake X-Patchwork-Id: 10354369 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 A5ED46019C for ; Sat, 21 Apr 2018 22:51:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DD142891A for ; Sat, 21 Apr 2018 22:51:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9230D28924; Sat, 21 Apr 2018 22:51:04 +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 3636F2891A for ; Sat, 21 Apr 2018 22:51:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3F8666E0D7; Sat, 21 Apr 2018 22:51:02 +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 3DA036E0F3 for ; Sat, 21 Apr 2018 22:51:00 +0000 (UTC) Received: by mail-wr0-x242.google.com with SMTP id q3-v6so21493885wrj.6 for ; Sat, 21 Apr 2018 15:51:00 -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=dNsrzJkwQ2c1yzq35z0o1CDSDS2l2RJu+fnzLzhJoC8=; b=agXxZQ5VHnD+NTD+Y8XKfnzi9MJDtk9eD60h7UgL/n83AO4PVL9BMma2A6T4faqSim /ggxS/T+s0L9SD6sxJ8JWdyNGo7ghvhyEyKWVCtOEmIhsAL3DKlZab+tQMJ3LIrspIPP LIX2tfoGDYyRYWcwj/L1MhAtcJAgcqMOVJLASmHV9U5G0+K9A6gfgEVpPwY1PPoz149D cUWrpkZe7nTVtzZeGwgO6/9iOe5EhgSjhpe22G3Tb6j4mxz71IxyfDlmAA9mWdt6v0CG vlDMKQfKC/PyLhYWR52Wxbx70sttAhqwM6v2OgvAplzMmSCWNMw7lpxTzj/9L/f4WCJn V/ig== 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=dNsrzJkwQ2c1yzq35z0o1CDSDS2l2RJu+fnzLzhJoC8=; b=C2NCUlJ2oaYV3cQyg8D+287OMfYV+5ovpzsD+tBxEnJ/JxRLXtEawujh1cB3W+P5cF A6aFJKF0GauIWDB2iN9P3R/RL2B7XyVJCtfuazRk5EQzVsNMDMKdYwgl1E5hguusWY3Q +VqfWsaYvB3nJK7AN/OZivMrsxqexeIF7BITlnOZ3qu8qxzau/vc2zST93CVTvgabCfV kFmwPBp3NpHk9hZYlelAcpHB/+EpBHmnyFwsrKqNWKuP7TPdY7nj4o6psESXsk8Ii9B/ nGOem35zvu0IMfuubTEV4aTCXXFQeRkiax0JeEoXhA6HnYKA+O+HyXYuG44wljY5D8ri btlw== X-Gm-Message-State: ALQs6tDGi8iQZ4UnYbHQxazzg/Tp/QYye5yc3nl623ZAkgNBDqYZLhjQ JlGOhc09O/u2ur+/SffKgHA= X-Google-Smtp-Source: AIpwx4/ifkV7cCPW2oYJYVJ1BoMIQCmxcHSgu/34n7SwfgSwifRf0KOJ+19DY5ACjnTB5+hUmpR5AQ== X-Received: by 10.28.136.4 with SMTP id k4mr5457439wmd.133.1524351058751; Sat, 21 Apr 2018 15:50:58 -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.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Apr 2018 15:50:57 -0700 (PDT) From: Stefan Schake To: eric@anholt.net Subject: [PATCH 3/4] drm/vc4: Export fence through syncobj Date: Sat, 21 Apr 2018 15:50:21 -0700 Message-Id: <20180421225022.7592-4-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 specifying a syncobj on render job submission where we store the fence for the job. This gives userland flexible access to the fence. Signed-off-by: Stefan Schake --- drivers/gpu/drm/vc4/vc4_gem.c | 38 +++++++++++++++++++++++++++++++++++--- include/uapi/drm/vc4_drm.h | 13 +++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c index 232363488125..b39515a4ddcb 100644 --- a/drivers/gpu/drm/vc4/vc4_gem.c +++ b/drivers/gpu/drm/vc4/vc4_gem.c @@ -656,7 +656,8 @@ vc4_lock_bo_reservations(struct drm_device *dev, */ static int vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec, - struct ww_acquire_ctx *acquire_ctx) + struct ww_acquire_ctx *acquire_ctx, + struct drm_syncobj *out_sync) { struct vc4_dev *vc4 = to_vc4_dev(dev); struct vc4_exec_info *renderjob; @@ -679,6 +680,9 @@ vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec, fence->seqno = exec->seqno; exec->fence = &fence->base; + if (out_sync) + drm_syncobj_replace_fence(out_sync, exec->fence); + vc4_update_bo_seqnos(exec, seqno); vc4_unlock_bo_reservations(dev, exec, acquire_ctx); @@ -1114,6 +1118,7 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data, struct vc4_dev *vc4 = to_vc4_dev(dev); struct vc4_file *vc4file = file_priv->driver_priv; struct drm_vc4_submit_cl *args = data; + struct drm_syncobj *out_sync = NULL; struct vc4_exec_info *exec; struct ww_acquire_ctx acquire_ctx; struct dma_fence *in_fence; @@ -1123,11 +1128,17 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data, VC4_SUBMIT_CL_FIXED_RCL_ORDER | VC4_SUBMIT_CL_RCL_ORDER_INCREASING_X | VC4_SUBMIT_CL_RCL_ORDER_INCREASING_Y | - VC4_SUBMIT_CL_IMPORT_SYNCOBJ)) != 0) { + VC4_SUBMIT_CL_IMPORT_SYNCOBJ | + VC4_SUBMIT_CL_EXPORT_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"); @@ -1202,12 +1213,33 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data, if (ret) goto fail; + if (args->flags & VC4_SUBMIT_CL_EXPORT_SYNCOBJ) { + out_sync = drm_syncobj_find(file_priv, args->out_sync); + if (!out_sync) { + ret = -EINVAL; + goto fail; + } + + /* We replace the fence in out_sync in vc4_queue_submit since + * the render job could execute immediately after that call. + * If it finishes before our ioctl processing resumes the + * render job fence could already have been freed. + */ + } + /* Clear this out of the struct we'll be putting in the queue, * since it's part of our stack. */ exec->args = NULL; - ret = vc4_queue_submit(dev, exec, &acquire_ctx); + ret = vc4_queue_submit(dev, exec, &acquire_ctx, out_sync); + + /* The syncobj isn't part of the exec data and we need to free our + * reference even if job submission failed. + */ + if (out_sync) + drm_syncobj_put(out_sync); + if (ret) goto fail; diff --git a/include/uapi/drm/vc4_drm.h b/include/uapi/drm/vc4_drm.h index 389f21931c25..3a2ef9b5b60b 100644 --- a/include/uapi/drm/vc4_drm.h +++ b/include/uapi/drm/vc4_drm.h @@ -174,6 +174,7 @@ struct drm_vc4_submit_cl { #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) +#define VC4_SUBMIT_CL_EXPORT_SYNCOBJ (1 << 5) __u32 flags; /* Returned value of the seqno of this render job (for the @@ -189,6 +190,18 @@ struct drm_vc4_submit_cl { * syncobj is signalled. */ __u32 in_sync; + + /* Syncobj handle to export fence to. Set together with EXPORT_SYNCOBJ + * flag. If set, the fence in the syncobj will be replaced with a fence + * that signals upon completion of this render job. + */ + __u32 out_sync; + + /* 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. + */ + __u32 pad2; }; /**