From ea74d3b78d607cde17790a7bb83e6f68ffd34cfd Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 16 May 2013 18:03:22 -0700 Subject: [PATCH] make the warning timout of Fence::waitForever() implicit and longer - timeout is now 3 seconds instead of 1 - simplifies the API a bit - allows us to change/tweak this timeout globaly Bug: 8988871 Change-Id: I8d3c6ec43a372f602fb3f29856710339f86c0ec9 --- include/ui/Fence.h | 5 +++-- libs/gui/BufferItemConsumer.cpp | 2 +- libs/gui/CpuConsumer.cpp | 2 +- libs/gui/GLConsumer.cpp | 2 +- libs/gui/Surface.cpp | 4 ++-- libs/ui/Fence.cpp | 3 ++- services/surfaceflinger/DisplayHardware/HWComposer.cpp | 2 +- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/ui/Fence.h b/include/ui/Fence.h index 81d5d0982..60156e7bb 100644 --- a/include/ui/Fence.h +++ b/include/ui/Fence.h @@ -70,9 +70,10 @@ public: // waitForever is a convenience function for waiting forever for a fence to // signal (just like wait(TIMEOUT_NEVER)), but issuing an error to the // system log and fence state to the kernel log if the wait lasts longer - // than warningTimeout. The logname argument should be a string identifying + // than a warning timeout. + // The logname argument should be a string identifying // the caller and will be included in the log message. - status_t waitForever(unsigned int warningTimeout, const char* logname); + status_t waitForever(const char* logname); // merge combines two Fence objects, creating a new Fence object that // becomes signaled when both f1 and f2 are signaled (even if f1 or f2 is diff --git a/libs/gui/BufferItemConsumer.cpp b/libs/gui/BufferItemConsumer.cpp index 90619ab16..7db1b8465 100644 --- a/libs/gui/BufferItemConsumer.cpp +++ b/libs/gui/BufferItemConsumer.cpp @@ -63,7 +63,7 @@ status_t BufferItemConsumer::acquireBuffer(BufferItem *item, bool waitForFence) } if (waitForFence) { - err = item->mFence->waitForever(1000, "BufferItemConsumer::acquireBuffer"); + err = item->mFence->waitForever("BufferItemConsumer::acquireBuffer"); if (err != OK) { BI_LOGE("Failed to wait for fence of acquired buffer: %s (%d)", strerror(-err), err); diff --git a/libs/gui/CpuConsumer.cpp b/libs/gui/CpuConsumer.cpp index 91af78dc6..054364997 100644 --- a/libs/gui/CpuConsumer.cpp +++ b/libs/gui/CpuConsumer.cpp @@ -80,7 +80,7 @@ status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) { int buf = b.mBuf; if (b.mFence.get()) { - err = b.mFence->waitForever(1000, "CpuConsumer::lockNextBuffer"); + err = b.mFence->waitForever("CpuConsumer::lockNextBuffer"); if (err != OK) { CC_LOGE("Failed to wait for fence of acquired buffer: %s (%d)", strerror(-err), err); diff --git a/libs/gui/GLConsumer.cpp b/libs/gui/GLConsumer.cpp index 637a403c7..bec0f9024 100644 --- a/libs/gui/GLConsumer.cpp +++ b/libs/gui/GLConsumer.cpp @@ -821,7 +821,7 @@ status_t GLConsumer::doGLFenceWaitLocked() const { return UNKNOWN_ERROR; } } else { - status_t err = mCurrentFence->waitForever(1000, + status_t err = mCurrentFence->waitForever( "GLConsumer::doGLFenceWaitLocked"); if (err != NO_ERROR) { ST_LOGE("doGLFenceWait: error waiting for fence: %d", err); diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp index 4a5802354..a616c1e41 100644 --- a/libs/gui/Surface.cpp +++ b/libs/gui/Surface.cpp @@ -113,7 +113,7 @@ int Surface::hook_dequeueBuffer_DEPRECATED(ANativeWindow* window, int fenceFd = -1; int result = c->dequeueBuffer(&buf, &fenceFd); sp fence(new Fence(fenceFd)); - int waitResult = fence->waitForever(1000, "dequeueBuffer_DEPRECATED"); + int waitResult = fence->waitForever("dequeueBuffer_DEPRECATED"); if (waitResult != OK) { ALOGE("dequeueBuffer_DEPRECATED: Fence::wait returned an error: %d", waitResult); @@ -734,7 +734,7 @@ status_t Surface::lock( sp backBuffer(GraphicBuffer::getSelf(out)); sp fence(new Fence(fenceFd)); - err = fence->waitForever(1000, "Surface::lock"); + err = fence->waitForever("Surface::lock"); if (err != OK) { ALOGE("Fence::wait failed (%s)", strerror(-err)); cancelBuffer(out, fenceFd); diff --git a/libs/ui/Fence.cpp b/libs/ui/Fence.cpp index b9e0f00fb..464ee86c8 100644 --- a/libs/ui/Fence.cpp +++ b/libs/ui/Fence.cpp @@ -54,11 +54,12 @@ status_t Fence::wait(unsigned int timeout) { return err < 0 ? -errno : status_t(NO_ERROR); } -status_t Fence::waitForever(unsigned int warningTimeout, const char* logname) { +status_t Fence::waitForever(const char* logname) { ATRACE_CALL(); if (mFenceFd == -1) { return NO_ERROR; } + unsigned int warningTimeout = 3000; int err = sync_wait(mFenceFd, warningTimeout); if (err < 0 && errno == ETIME) { ALOGE("%s: fence %d didn't signal in %u ms", logname, mFenceFd, diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp index f0f746392..a9afbe53c 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp +++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp @@ -750,7 +750,7 @@ int HWComposer::fbPost(int32_t id, if (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) { return setFramebufferTarget(id, acquireFence, buffer); } else { - acquireFence->waitForever(1000, "HWComposer::fbPost"); + acquireFence->waitForever("HWComposer::fbPost"); return mFbDev->post(mFbDev, buffer->handle); } }