From patchwork Mon Apr 25 22:33:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 8933181 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8C257BF29F for ; Mon, 25 Apr 2016 22:35:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 945712011E for ; Mon, 25 Apr 2016 22:35:26 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C1431200DC for ; Mon, 25 Apr 2016 22:35:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 98A416E701; Mon, 25 Apr 2016 22:35:23 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw0-f196.google.com (mail-yw0-f196.google.com [209.85.161.196]) by gabe.freedesktop.org (Postfix) with ESMTPS id AA0016E6CD for ; Mon, 25 Apr 2016 22:34:01 +0000 (UTC) Received: by mail-yw0-f196.google.com with SMTP id u62so1266853ywe.3 for ; Mon, 25 Apr 2016 15:34:01 -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=lYFBgccbXKgknqIuEO2gabNfilWSwv/sPk2qTQcTszY=; b=UmGn60IUpuD2leoW6AuAeqiVYfN5bhLlKbS1/j7LJOrGHdF7ps3mBPbQmm9KJRMzWq Y4aQ1/6Esgt+4I/p5pVw1oazbyTuOHOGK2CO6+dXcU9Y8+21E7zoHzoumSQBoUPRr4ld gWNBIXCyzlRIDj76xmBroaPiU1SO0K7l3mOs1UMSihOuc9Y4Ji7ilE2DQhfG9XytYd+a n9VgWfN0pTz/7MP3R97Di5FD0vI4/KURT4mXCPimQZM1F58Gasqg78seiDiEtaCE+oeZ JubQVgbOpRDYhFhrFklUedZhnCJm9f75BkO5LSJTjoqwX8jMe5hrQj4M8MOkJhQN09pN XYLw== X-Gm-Message-State: AOPr4FXGBcs3nbkP3vA4YyiU89iAeaHTmwCqaX1O6rGsgssB93XSFfCqoSW79jJBHBmZSw== X-Received: by 10.129.121.142 with SMTP id u136mr22924250ywc.269.1461623640219; Mon, 25 Apr 2016 15:34:00 -0700 (PDT) Received: from jade.localdomain ([201.82.24.203]) by smtp.gmail.com with ESMTPSA id r8sm13840742ywb.20.2016.04.25.15.33.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Apr 2016 15:33:59 -0700 (PDT) From: Gustavo Padovan To: Greg Kroah-Hartman Subject: [RFC v2 6/8] drm/fence: add fence to drm_pending_event Date: Mon, 25 Apr 2016 19:33:26 -0300 Message-Id: <1461623608-29538-7-git-send-email-gustavo@padovan.org> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1461623608-29538-1-git-send-email-gustavo@padovan.org> References: <1461623608-29538-1-git-send-email-gustavo@padovan.org> Cc: devel@driverdev.osuosl.org, Daniel Stone , Daniel Vetter , Riley Andrews , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Gustavo Padovan , John Harrison 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=-3.8 required=5.0 tests=BAYES_00, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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. v2: Comments from Daniel Vetter - call fence_signal in drm_send_event_locked() - remove unneeded !e->event check Signed-off-by: Gustavo Padovan --- drivers/gpu/drm/drm_atomic.c | 19 +++++++++++++------ drivers/gpu/drm/drm_fops.c | 8 +++++++- include/drm/drmP.h | 2 ++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 13674c7..5f9d434 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1437,7 +1437,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; @@ -1450,12 +1451,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; } @@ -1682,7 +1688,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..7872635 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c @@ -801,8 +801,14 @@ void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e) { assert_spin_locked(&dev->event_lock); + if (e->fence) { + fence_signal(e->fence); + fence_put(e->fence); + } + if (!e->file_priv) { - e->destroy(e); + if (e->destroy) + e->destroy(e); return; } diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 3c8422c..2ae6d7e 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -56,6 +56,7 @@ #include #include #include +#include #include #include @@ -282,6 +283,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;