From patchwork Fri Apr 15 01:29:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 8844141 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D4E6C9F3D1 for ; Fri, 15 Apr 2016 01:29:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D711920377 for ; Fri, 15 Apr 2016 01:29:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4993920373 for ; Fri, 15 Apr 2016 01:29:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 097F06EB59; Fri, 15 Apr 2016 01:29:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-f173.google.com (mail-pf0-f173.google.com [209.85.192.173]) by gabe.freedesktop.org (Postfix) with ESMTPS id CB31A6EB59 for ; Fri, 15 Apr 2016 01:29:51 +0000 (UTC) Received: by mail-pf0-f173.google.com with SMTP id n1so51462821pfn.2 for ; Thu, 14 Apr 2016 18:29:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rZZSu8vzjQ3OpsO/dG67rqmz6TJuSbb48+OYrI2ty4Q=; b=OjZFU6xdm8mP8ZqziiRBd6QsvPPqTFWX/Wn+3ScK+SBpT0f0auH7UsSBmZqDXWVDhR 5jqoYNlWyZcmGA2Yb9Y5vDloe8ONgAzzdEP9j1ZlyRFBuCHDUn3EXEvbuq++AA+tX1/+ 1F/wdZCAQO5w4xwBcGZwFpGs3gOrUa/FQ2NXAA5jvFK0gpMopWSSs1AOrTTp+0+T1gZp GC8jgE1MQ0s5bar+QdQhzYDxwX12UzYSb/B+zzeSNq8QJhITJnZi3S/zoODtJNiPjvkI 0ZZybxmkFpCJZEh+o7jjh9oYM5yTdEceunmJsOUWnZc9fwYb7BgGLy9XOx8sYq9kxKz1 vLpw== X-Gm-Message-State: AOPr4FXHOD3nCbqVri/BVYDNQjxk51xsNd6wib+MPlj6T7nLoZ9aWVLD5o1mG4dmXY4wiA== X-Received: by 10.98.52.5 with SMTP id b5mr6989998pfa.9.1460683791319; Thu, 14 Apr 2016 18:29:51 -0700 (PDT) Received: from jade.localdomain (c-73-241-147-137.hsd1.ca.comcast.net. [73.241.147.137]) by smtp.gmail.com with ESMTPSA id 132sm10740538pfw.35.2016.04.14.18.29.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Apr 2016 18:29:50 -0700 (PDT) From: Gustavo Padovan To: dri-devel@lists.freedesktop.org Subject: [RFC 5/8] drm/fence: add fence to drm_pending_event Date: Thu, 14 Apr 2016 18:29:38 -0700 Message-Id: <1460683781-22535-6-git-send-email-gustavo@padovan.org> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1460683781-22535-1-git-send-email-gustavo@padovan.org> References: <1460683781-22535-1-git-send-email-gustavo@padovan.org> Cc: marcheu@google.com, Daniel Stone , seanpaul@google.com, Daniel Vetter , =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , linux-kernel@vger.kernel.org, Riley Andrews , laurent.pinchart@ideasonboard.com, Gustavo Padovan , John Harrison , m.chehab@samsung.com 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-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Gustavo Padovan Now a drm_pending_event can either send a real drm_event or signal a fence, or both. It allow us to signal via fences when the buffer is displayed on the screen. Which in turn means that the previous buffer is not in use anymore and can be freed or sent back to another driver for processing. Signed-off-by: Gustavo Padovan --- drivers/gpu/drm/drm_atomic.c | 19 +++++++++++++------ drivers/gpu/drm/drm_fops.c | 5 +++-- drivers/gpu/drm/drm_irq.c | 7 +++++++ include/drm/drmP.h | 1 + 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 6702502..0b95526 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1431,7 +1431,8 @@ EXPORT_SYMBOL(drm_atomic_async_commit); */ static struct drm_pending_vblank_event *create_vblank_event( - struct drm_device *dev, struct drm_file *file_priv, uint64_t user_data) + struct drm_device *dev, struct drm_file *file_priv, + struct fence *fence, uint64_t user_data) { struct drm_pending_vblank_event *e = NULL; int ret; @@ -1444,12 +1445,17 @@ static struct drm_pending_vblank_event *create_vblank_event( e->event.base.length = sizeof(e->event); e->event.user_data = user_data; - ret = drm_event_reserve_init(dev, file_priv, &e->base, &e->event.base); - if (ret) { - kfree(e); - return NULL; + if (file_priv) { + ret = drm_event_reserve_init(dev, file_priv, &e->base, + &e->event.base); + if (ret) { + kfree(e); + return NULL; + } } + e->base.fence = fence; + return e; } @@ -1676,7 +1682,8 @@ retry: for_each_crtc_in_state(state, crtc, crtc_state, i) { struct drm_pending_vblank_event *e; - e = create_vblank_event(dev, file_priv, arg->user_data); + e = create_vblank_event(dev, file_priv, NULL, + arg->user_data); if (!e) { ret = -ENOMEM; goto out; diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index aeef58e..38def49 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c @@ -801,8 +801,9 @@ void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e) { assert_spin_locked(&dev->event_lock); - if (!e->file_priv) { - e->destroy(e); + if (!e->file_priv || !e->event) { + if (e->destroy) + e->destroy(e); return; } diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 3c1a6f1..0c5d7cb 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -41,6 +41,7 @@ #include #include +#include /* Access macro for slots in vblank timestamp ringbuffer. */ #define vblanktimestamp(dev, pipe, count) \ @@ -1124,6 +1125,12 @@ void drm_send_vblank_event(struct drm_device *dev, unsigned int pipe, now = get_drm_timestamp(); } e->pipe = pipe; + + if (e->base.fence) { + fence_signal(e->base.fence); + fence_put(e->base.fence); + } + send_vblank_event(dev, e, seq, &now); } EXPORT_SYMBOL(drm_send_vblank_event); diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 3c8422c..8f83c2a 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -282,6 +282,7 @@ struct drm_ioctl_desc { /* Event queued up for userspace to read */ struct drm_pending_event { struct drm_event *event; + struct fence *fence; struct list_head link; struct list_head pending_link; struct drm_file *file_priv;