From patchwork Wed Oct 26 08:55:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Starkey X-Patchwork-Id: 9396353 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 52F1660236 for ; Wed, 26 Oct 2016 08:56:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1009128A32 for ; Wed, 26 Oct 2016 08:56:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 045BF28B86; Wed, 26 Oct 2016 08:56:00 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 7C9C4283F2 for ; Wed, 26 Oct 2016 08:55:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 18B4E6E828; Wed, 26 Oct 2016 08:55:41 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by gabe.freedesktop.org (Postfix) with ESMTP id 87AEF6E81D for ; Wed, 26 Oct 2016 08:55:38 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6E2A51576; Wed, 26 Oct 2016 01:55:38 -0700 (PDT) Received: from e106950-lin.cambridge.arm.com (e106950-lin.cambridge.arm.com [10.2.133.193]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AEE163F220; Wed, 26 Oct 2016 01:55:37 -0700 (PDT) From: Brian Starkey To: dri-devel@lists.freedesktop.org Subject: [RFC PATCH v2 9/9] drm: mali-dp: Add writeback out-fence support Date: Wed, 26 Oct 2016 09:55:08 +0100 Message-Id: <1477472108-27222-10-git-send-email-brian.starkey@arm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1477472108-27222-1-git-send-email-brian.starkey@arm.com> References: <1477472108-27222-1-git-send-email-brian.starkey@arm.com> Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org 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-Virus-Scanned: ClamAV using ClamSMTP If userspace has asked for an out-fence for the writeback, we add a fence to malidp_mw_job, to be signaled when the writeback job has completed. Signed-off-by: Brian Starkey --- drivers/gpu/drm/arm/malidp_hw.c | 5 ++++- drivers/gpu/drm/arm/malidp_mw.c | 18 +++++++++++++++++- drivers/gpu/drm/arm/malidp_mw.h | 3 +++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/arm/malidp_hw.c b/drivers/gpu/drm/arm/malidp_hw.c index 1689547..3032226 100644 --- a/drivers/gpu/drm/arm/malidp_hw.c +++ b/drivers/gpu/drm/arm/malidp_hw.c @@ -707,8 +707,11 @@ static irqreturn_t malidp_se_irq(int irq, void *arg) unsigned long irqflags; /* * We can't unreference the framebuffer here, so we queue it - * up on our threaded handler. + * up on our threaded handler. However, signal the fence + * as soon as possible */ + malidp_mw_job_signal(drm, malidp->current_mw, 0); + spin_lock_irqsave(&malidp->mw_lock, irqflags); list_add_tail(&malidp->current_mw->list, &malidp->finished_mw_jobs); diff --git a/drivers/gpu/drm/arm/malidp_mw.c b/drivers/gpu/drm/arm/malidp_mw.c index 69e423c..05880b1 100644 --- a/drivers/gpu/drm/arm/malidp_mw.c +++ b/drivers/gpu/drm/arm/malidp_mw.c @@ -34,11 +34,24 @@ struct malidp_mw_connector_state { u8 n_planes; }; +void malidp_mw_job_signal(struct drm_device *drm, + struct malidp_mw_job *job, int status) +{ + DRM_DEV_DEBUG_DRIVER(drm->dev, "MW job signal %p\n", job); + + if (!job->fence) + return; + + job->fence->status = status; + fence_signal(job->fence); +} + void malidp_mw_job_cleanup(struct drm_device *drm, struct malidp_mw_job *job) { DRM_DEV_DEBUG_DRIVER(drm->dev, "MW job cleanup %p\n", job); drm_framebuffer_unreference(job->fb); + fence_put(job->fence); kfree(job); } @@ -107,8 +120,10 @@ static void malidp_mw_connector_destroy_state(struct drm_connector *connector, struct malidp_mw_connector_state *mw_state = to_mw_state(state); __drm_atomic_helper_connector_destroy_state(&mw_state->base); - if (mw_state->job) + if (mw_state->job) { + malidp_mw_job_signal(connector->dev, mw_state->job, -EPIPE); malidp_mw_job_cleanup(connector->dev, mw_state->job); + } kfree(mw_state); } @@ -177,6 +192,7 @@ malidp_mw_encoder_atomic_check(struct drm_encoder *encoder, /* We can take ownership of the framebuffer reference in the job. */ mw_state->job->fb = conn_state->fb; conn_state->fb = NULL; + mw_state->job->fence = fence_get(conn_state->out_fence); return 0; } diff --git a/drivers/gpu/drm/arm/malidp_mw.h b/drivers/gpu/drm/arm/malidp_mw.h index db7b2b0..5d0bd1d 100644 --- a/drivers/gpu/drm/arm/malidp_mw.h +++ b/drivers/gpu/drm/arm/malidp_mw.h @@ -15,11 +15,14 @@ struct malidp_mw_job { struct list_head list; struct drm_framebuffer *fb; + struct fence *fence; }; int malidp_mw_connector_init(struct drm_device *drm); void malidp_mw_atomic_commit(struct drm_device *drm, struct drm_atomic_state *old_state); +void malidp_mw_job_signal(struct drm_device *drm, + struct malidp_mw_job *job, int status); void malidp_mw_job_cleanup(struct drm_device *drm, struct malidp_mw_job *job); #endif