OSDN Git Service

drm_hwcomposer: Set timeouts for fence waits
authorSean Paul <seanpaul@chromium.org>
Tue, 29 Sep 2015 04:56:00 +0000 (00:56 -0400)
committerSean Paul <seanpaul@chromium.org>
Tue, 29 Sep 2015 18:27:01 +0000 (14:27 -0400)
Instead of waiting forever for fences, set some reasonable timeouts
so we can move on with life if a fence doesn't signal.

BUG=chrome-os-partner:45868
TEST=Tested on smaug with osmos, recovered from fence timeouts

Change-Id: I7f18d684d483d789f228cbad8d5a3e43ac898a43
Signed-off-by: Sean Paul <seanpaul@chromium.org>
drmdisplaycompositor.cpp
drmdisplaycompositor.h
drmframebuffer.h

index 6ee145f..82da4f2 100644 (file)
@@ -174,7 +174,7 @@ int DrmDisplayCompositor::ApplyPreComposite(
 
   const DrmMode &mode = connector->active_mode();
   DrmFramebuffer &fb = framebuffers_[framebuffer_index_];
-  ret = fb.WaitReleased(-1);
+  ret = fb.WaitReleased(fb.kReleaseWaitTimeoutMs);
   if (ret) {
     ALOGE("Failed to wait for framebuffer release %d", ret);
     return ret;
@@ -244,7 +244,7 @@ int DrmDisplayCompositor::ApplyFrame(DrmDisplayComposition *display_comp) {
   for (DrmCompositionLayer &layer : *layers) {
     int acquire_fence = layer.acquire_fence.get();
     if (acquire_fence >= 0) {
-      ret = sync_wait(acquire_fence, -1);
+      ret = sync_wait(acquire_fence, kAcquireWaitTimeoutMs);
       if (ret) {
         ALOGE("Failed to wait for acquire %d/%d", acquire_fence, ret);
         drmModePropertySetFree(pset);
index 50109b3..4aadc68 100644 (file)
@@ -51,6 +51,10 @@ class DrmDisplayCompositor {
  private:
   DrmDisplayCompositor(const DrmDisplayCompositor &) = delete;
 
+  // Set to 50ms which is somewhere between a reasonable amount of time to
+  // wait for a long render and a small enough delay to limit jank.
+  static const int kAcquireWaitTimeoutMs = 50;
+
   int ApplyPreComposite(DrmDisplayComposition *display_comp);
   int ApplyFrame(DrmDisplayComposition *display_comp);
   int ApplyDpms(DrmDisplayComposition *display_comp);
index 6f078d9..897589c 100644 (file)
@@ -58,7 +58,8 @@ struct DrmFramebuffer {
         return true;
 
       if (release_fence_fd_ >= 0) {
-        if (sync_wait(release_fence_fd_, -1) != 0) {
+        if (sync_wait(release_fence_fd_, kReleaseWaitTimeoutMs) != 0) {
+          ALOGE("Wait for release fence failed\n");
           return false;
         }
       }
@@ -93,6 +94,10 @@ struct DrmFramebuffer {
     return ret;
   }
 
+  // Somewhat arbitrarily chosen, but wanted to stay below 3000ms, which is the
+  // system timeout
+  static const int kReleaseWaitTimeoutMs = 1500;
+
  private:
   sp<GraphicBuffer> buffer_;
   int release_fence_fd_;