From patchwork Tue Apr 24 22:03:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schake X-Patchwork-Id: 10361133 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 09ADF602D6 for ; Tue, 24 Apr 2018 22:04:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E981228DCC for ; Tue, 24 Apr 2018 22:04:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBC6928E3D; Tue, 24 Apr 2018 22:04:27 +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 8940A28DCC for ; Tue, 24 Apr 2018 22:04:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7957C6E4D0; Tue, 24 Apr 2018 22:04:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 357136E4CC for ; Tue, 24 Apr 2018 22:04:14 +0000 (UTC) Received: by mail-wr0-x241.google.com with SMTP id v15-v6so33299783wrm.10 for ; Tue, 24 Apr 2018 15:04:14 -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=w+5aDcCWDzSpF3+Hw58+M5HwLEZHi+aQy6EJBMZkRTs=; b=kZuzWrSst4etoLsuoN8vjbCB2Jg+LWSAsrxBzrbvI7LTtTBlYK0ZgOjQeXfF9V/GDv 1GBAItQ8FkOk46RMhRnncOW59EcPUGJBZS7jzlprt4ouIohnMLrivMpaokGGDFprP4ZB TNtqqVHzGwD4ej+EMVjyVtE23qzP4t43LzltDREhW6XxIYYzLwZSckGp6IsGh2tVSakA U1xVaO8orDxyqQGS49H9yoFHSTCN92qasHn8Ba1TKDBZelzsrtUsHQe/LLBh+KkLn3F2 0Lu+w2X0anfgBdu23dsc9F+HLC8ovahTXLz1sgxee+zWLBhRhAHAKF8kRul++DxvOyVH Z5Sw== 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=w+5aDcCWDzSpF3+Hw58+M5HwLEZHi+aQy6EJBMZkRTs=; b=YCLpFyJOuVjvLwvKs+ptpt/v1CDH7jHrhdRPE3fCMHW0zVaU6yHnvwXKy4v9SLW3oF ZHya+uCkATHA/Nf2oOhq985Cunp9xpdJwhfcgihddFkryu6E9RGZJ0px7mkRXWkXBpcj OgflWDp/sICFzHIo6q9mkV22IpTF5kLjMEST2djl9+30pDQURXOJmVOX3OxqehylWUmN Aqf9yMqC0GY8vTcTZ4P5FATc8GIBxcsta91jNEu7mlneS5KxaTqxaH2oTw4YM6qlHd1p KMjbLpnYEoRRXC9EqSMrSU34aLsQF0bfBwd+I33t0NKzba05sNvYbLOCEkUgz1Kcptxt 1ukA== X-Gm-Message-State: ALQs6tAEK6j+dJs/NMeTymkN7Jbtr16d4J+g+myAABt6TvjiRiWJEiZt sAS16rQh/UyHxvOJRY9I8YQ= X-Google-Smtp-Source: AIpwx48zWpRU0x033+zHpABsB2BWy6ziJto+utYQf+KxufNiEHLAHT27EF5YixEORN0j5hCGGFOKXA== X-Received: by 2002:adf:b2f5:: with SMTP id g108-v6mr22079494wrd.147.1524607452673; Tue, 24 Apr 2018 15:04:12 -0700 (PDT) Received: from localhost.localdomain (x5ce41b1e.dyn.telefonica.de. [92.228.27.30]) by smtp.gmail.com with ESMTPSA id x189sm6192236wmg.0.2018.04.24.15.04.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Apr 2018 15:04:11 -0700 (PDT) From: Stefan Schake To: eric@anholt.net Subject: [PATCH v2 2/3] drm/vc4: Export fence through syncobj Date: Wed, 25 Apr 2018 00:03:46 +0200 Message-Id: <1524607427-12876-3-git-send-email-stschake@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524607427-12876-1-git-send-email-stschake@gmail.com> References: <1524607427-12876-1-git-send-email-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. v2: Use 0 as invalid syncobj to drop flag (Eric) Don't reintroduce the padding (Eric) Signed-off-by: Stefan Schake --- drivers/gpu/drm/vc4/vc4_gem.c | 30 ++++++++++++++++++++++++++++-- include/uapi/drm/vc4_drm.h | 6 ++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c index e305ccde..a4c4be3 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; @@ -1201,12 +1206,33 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data, if (ret) goto fail; + if (args->out_sync) { + 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 d97065b..2be4fe3 100644 --- a/include/uapi/drm/vc4_drm.h +++ b/include/uapi/drm/vc4_drm.h @@ -187,6 +187,12 @@ struct drm_vc4_submit_cl { * will not start until the syncobj is signaled. 0 means ignore. */ __u32 in_sync; + + /* Syncobj handle to export fence to. If set, the fence in the syncobj + * will be replaced with a fence that signals upon completion of this + * render job. 0 means ignore. + */ + __u32 out_sync; }; /**