Treat fence with error as invalid in terms of signal time

Previously, fence with error was treated as pending, resulting in
buffer not being able to be latched. This is especially bad when
GPU hang happened and driver has restored context and states being
able to recover the pipeline, but the whole pipeline is stuck at the
buffer consumer (surfaceflinger) failing to consume the buffer,
essentially because of fence error. Treating fence error as signaled
but fence time as invalid, eliminate the possiblity of such defect
while still sounding the alarm to the rest of the system regarding
signal time of the underlying fence
Also this could be justified by kernel, the status of a dma_fence
is defined as 0 if the fence has not yet been signaled, 1 if the fence
has been signaled without an error condition, or a negtive error code
if the fence has been completed in err (see dma-fence.h). In this sense,
a fence with error should not be treated as *not* signaled either.

Bug: 204919015
Test: Manually trigger a GPU hang, the layer undergoing the GPU hang recovered
from the hang and continuously get rendered as apposed to freezing

Change-Id: Idc8e85f132520576802d1ebc32b2597bfe341be0
diff --git a/libs/ui/Fence.cpp b/libs/ui/Fence.cpp
index 33ab7c4..cc96f83 100644
--- a/libs/ui/Fence.cpp
+++ b/libs/ui/Fence.cpp
@@ -132,9 +132,13 @@
         ALOGE("sync_file_info returned NULL for fd %d", mFenceFd.get());
         return SIGNAL_TIME_INVALID;
     }
+
     if (finfo->status != 1) {
+        const auto status = finfo->status;
+        ALOGE_IF(status < 0, "%s: sync_file_info contains an error: <%d> for fd: <%d>", __func__,
+                 status, mFenceFd.get());
         sync_file_info_free(finfo);
-        return SIGNAL_TIME_PENDING;
+        return status < 0 ? SIGNAL_TIME_INVALID : SIGNAL_TIME_PENDING;
     }
 
     uint64_t timestamp = 0;