All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Foss <robert.foss@collabora.com>
To: dri-devel@lists.freedesktop.org, robh@kernel.org,
	salidoa@google.com, seanpaul@chromium.org, zachr@google.com
Cc: Robert Foss <robert.foss@collabora.com>
Subject: [PATCH hwc v3 5/6] drm_hwcomposer: Add out-fence support
Date: Thu, 28 Sep 2017 18:40:30 +0200	[thread overview]
Message-ID: <20170928164031.29720-6-robert.foss@collabora.com> (raw)
In-Reply-To: <20170928164031.29720-1-robert.foss@collabora.com>

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 <robert.foss@collabora.com>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
---

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<DrmHwcLayer> 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<DrmCompositionRegion> &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<const uint32_t, DrmHwcTwo::HwcLayer *> &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();
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2017-09-28 16:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-28 16:40 [PATCH hwc v3 0/6] Implement fencing Robert Foss
2017-09-28 16:40 ` [PATCH hwc v3 1/6] drm_hwcomposer: Add support for IN_FENCE_FD property to DrmPlane Robert Foss
2017-09-28 16:40 ` [PATCH hwc v3 2/6] drm_hwcomposer: Submit in-fence to DRM Robert Foss
2017-09-28 16:40 ` [PATCH hwc v3 3/6] drm_hwcomposer: Add FENCE_OUT_PTR property to DrmCrtc Robert Foss
2017-09-28 16:40 ` [PATCH hwc v3 4/6] drm_hwcomposer: Add crtc() fetcher to DrmResources Robert Foss
2017-09-28 16:40 ` Robert Foss [this message]
2017-09-28 16:40 ` [PATCH hwc v3 6/6] drm_hwcomposer: Remove threading Robert Foss
2017-10-02  8:42 ` [PATCH hwc v3 0/6] Implement fencing Robert Foss

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170928164031.29720-6-robert.foss@collabora.com \
    --to=robert.foss@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=robh@kernel.org \
    --cc=salidoa@google.com \
    --cc=seanpaul@chromium.org \
    --cc=zachr@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.