From patchwork Thu Sep 28 16:40:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foss X-Patchwork-Id: 9976381 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 CA1B26034B for ; Thu, 28 Sep 2017 16:40:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC64B296CB for ; Thu, 28 Sep 2017 16:40:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADFBA296F1; Thu, 28 Sep 2017 16:40:56 +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 CC263296E6 for ; Thu, 28 Sep 2017 16:40:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A9AAE6E9AC; Thu, 28 Sep 2017 16:40:46 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by gabe.freedesktop.org (Postfix) with ESMTPS id 72F7A6E994 for ; Thu, 28 Sep 2017 16:40:42 +0000 (UTC) Received: from localhost.localdomain (unknown [IPv6:2a02:8109:9a3f:ee3b:c7ab:3df6:4b82:1a62]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: robertfoss) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 0254D26D4E8; Thu, 28 Sep 2017 17:40:40 +0100 (BST) From: Robert Foss To: dri-devel@lists.freedesktop.org, robh@kernel.org, salidoa@google.com, seanpaul@chromium.org, zachr@google.com Subject: [PATCH hwc v3 5/6] drm_hwcomposer: Add out-fence support Date: Thu, 28 Sep 2017 18:40:30 +0200 Message-Id: <20170928164031.29720-6-robert.foss@collabora.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170928164031.29720-1-robert.foss@collabora.com> References: <20170928164031.29720-1-robert.foss@collabora.com> Cc: Robert Foss 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 Add support for out-fences through the OUT_FENCE_PTR property. Out-fences signal when their associated buffer may be read by a device. Signed-off-by: Robert Foss Reviewed-by: Sean Paul --- Changes since v2: Sean Paul: - Removed dup() and subsequent close() call - Added r-b Emil Velikov: - Moved code around to allow for "Remove threading" patch to be last of series Changes since v1: Sergi Granell: - Set atomic property to be out_fences[crtc->pipe()] not out_fences[0] drmdisplaycomposition.h | 9 +++++++++ drmdisplaycompositor.cpp | 15 +++++++++++++++ drmhwctwo.cpp | 9 ++------- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/drmdisplaycomposition.h b/drmdisplaycomposition.h index 13da19d..470bf7e 100644 --- a/drmdisplaycomposition.h +++ b/drmdisplaycomposition.h @@ -179,6 +179,14 @@ class DrmDisplayComposition { return planner_; } + int take_out_fence() { + return out_fence_.Release(); + } + + void set_out_fence(int out_fence) { + out_fence_.Set(out_fence); + } + void Dump(std::ostringstream *out) const; private: @@ -205,6 +213,7 @@ class DrmDisplayComposition { int timeline_current_ = 0; int timeline_squash_done_ = 0; int timeline_pre_comp_done_ = 0; + UniqueFd out_fence_ = -1; bool geometry_changed_; std::vector layers_; diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp index 75c1a7c..8936d08 100644 --- a/drmdisplaycompositor.cpp +++ b/drmdisplaycompositor.cpp @@ -602,6 +602,7 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp, display_comp->composition_planes(); std::vector &pre_comp_regions = display_comp->pre_comp_regions(); + uint64_t out_fences[drm_->crtcs().size()]; DrmConnector *connector = drm_->GetConnectorForDisplay(display_); if (!connector) { @@ -620,6 +621,16 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp, return -ENOMEM; } + if (crtc->out_fence_ptr_property().id() != 0) { + ret = drmModeAtomicAddProperty(pset, crtc->id(), crtc->out_fence_ptr_property().id(), + (uint64_t) &out_fences[crtc->pipe()]); + if (ret < 0) { + ALOGE("Failed to add OUT_FENCE_PTR property to pset: %d", ret); + drmModeAtomicFree(pset); + return ret; + } + } + if (mode_.needs_modeset) { ret = drmModeAtomicAddProperty(pset, crtc->id(), crtc->mode_property().id(), mode_.blob_id) < 0 || @@ -818,6 +829,10 @@ out: mode_.needs_modeset = false; } + if (crtc->out_fence_ptr_property().id()) { + display_comp->set_out_fence((int) out_fences[crtc->pipe()]); + } + return ret; } diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp index 8c853f4..00bedd0 100644 --- a/drmhwctwo.cpp +++ b/drmhwctwo.cpp @@ -557,19 +557,14 @@ HWC2::Error DrmHwcTwo::HwcDisplay::PresentDisplay(int32_t *retire_fence) { i = overlay_planes.erase(i); } + AddFenceToRetireFence(composition->take_out_fence()); + ret = compositor_.QueueComposition(std::move(composition)); if (ret) { ALOGE("Failed to apply the frame composition ret=%d", ret); return HWC2::Error::BadParameter; } - // Now that the release fences have been generated by the compositor, make - // sure they're managed properly - for (std::pair &l : z_map) { - l.second->manage_release_fence(); - AddFenceToRetireFence(l.second->release_fence()); - } - // The retire fence returned here is for the last frame, so return it and // promote the next retire fence *retire_fence = retire_fence_.Release();