hwc: add some logging
We are seeing errors where a device's hwcVsyncThread is not present for some
reason. The surface flinger has not crashed, so either the thread never got
created, or it exited withouth throwing an error. This patch adds some more
verbose on-error logging to the HWC as an attempt to verify the theory that the
thread does not get created, or fails in pthread_create. While we're at it, we
add the same logging at pthread_create() for hwcUeventThread, as well.
Also, replace the lseek()+read() with a pread() combo in the vsync thread.
Change-Id: I555d786a7d66ff4ef1dbfd95947a7d9341e56f11
related-to-bug: 7305728
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index 620506d..1e66235 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -62,6 +62,7 @@
static void hwc_registerProcs(struct hwc_composer_device_1* dev,
hwc_procs_t const* procs)
{
+ ALOGI("%s", __FUNCTION__);
hwc_context_t* ctx = (hwc_context_t*)(dev);
if(!ctx) {
ALOGE("%s: Invalid context", __FUNCTION__);
diff --git a/libhwcomposer/hwc_uevents.cpp b/libhwcomposer/hwc_uevents.cpp
index ef43f62..a7f58ea 100644
--- a/libhwcomposer/hwc_uevents.cpp
+++ b/libhwcomposer/hwc_uevents.cpp
@@ -29,6 +29,8 @@
namespace qhwc {
+#define HWC_UEVENT_THREAD_NAME "hwcUeventThread"
+
const char* MSMFB_HDMI_NODE = "fb1";
static void handle_uevent(hwc_context_t* ctx, const char* udata, int len)
@@ -67,7 +69,7 @@
int len = 0;
static char udata[PAGE_SIZE];
hwc_context_t * ctx = reinterpret_cast<hwc_context_t *>(param);
- char thread_name[64] = "hwcUeventThread";
+ char thread_name[64] = HWC_UEVENT_THREAD_NAME;
prctl(PR_SET_NAME, (unsigned long) &thread_name, 0, 0, 0);
setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY);
uevent_init();
@@ -83,7 +85,14 @@
void init_uevent_thread(hwc_context_t* ctx)
{
pthread_t uevent_thread;
- pthread_create(&uevent_thread, NULL, uevent_loop, (void*) ctx);
+ int ret;
+
+ ALOGI("Initializing UEVENT Thread");
+ ret = pthread_create(&uevent_thread, NULL, uevent_loop, (void*) ctx);
+ if (ret) {
+ ALOGE("%s: failed to create %s: %s", __FUNCTION__,
+ HWC_UEVENT_THREAD_NAME, strerror(ret));
+ }
}
}; //namespace
diff --git a/libhwcomposer/hwc_vsync.cpp b/libhwcomposer/hwc_vsync.cpp
index d4afd78..28ac86d 100644
--- a/libhwcomposer/hwc_vsync.cpp
+++ b/libhwcomposer/hwc_vsync.cpp
@@ -34,6 +34,8 @@
namespace qhwc {
+#define HWC_VSYNC_THREAD_NAME "hwcVsyncThread"
+
static void *vsync_loop(void *param)
{
const char* vsync_timestamp_fb0 = "/sys/class/graphics/fb0/vsync_event";
@@ -42,7 +44,7 @@
hwc_context_t * ctx = reinterpret_cast<hwc_context_t *>(param);
- char thread_name[64] = "hwcVsyncThread";
+ char thread_name[64] = HWC_VSYNC_THREAD_NAME;
prctl(PR_SET_NAME, (unsigned long) &thread_name, 0, 0, 0);
setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY +
android::PRIORITY_MORE_FAVORABLE);
@@ -100,11 +102,9 @@
}
}
- // Open success - read now
- lseek(fd_timestamp, 0, SEEK_SET);
for(int i = 0; i < MAX_RETRY_COUNT; i++) {
- len = read(fd_timestamp, vdata, MAX_DATA);
- if(len < 0 && errno == EAGAIN) {
+ len = pread(fd_timestamp, vdata, MAX_DATA, 0);
+ if(len < 0 && (errno == EAGAIN || errno == EINTR)) {
ALOGW("%s: vsync read: EAGAIN, retry (%d/%d).",
__FUNCTION__, i, MAX_RETRY_COUNT);
continue;
@@ -113,7 +113,7 @@
}
}
- if (len < 0){
+ if (len < 0) {
ALOGE ("FATAL:%s:not able to read file:%s, %s", __FUNCTION__,
vsync_timestamp_fb0, strerror(errno));
close (fd_timestamp);
@@ -143,9 +143,14 @@
void init_vsync_thread(hwc_context_t* ctx)
{
+ int ret;
pthread_t vsync_thread;
ALOGI("Initializing VSYNC Thread");
- pthread_create(&vsync_thread, NULL, vsync_loop, (void*) ctx);
+ ret = pthread_create(&vsync_thread, NULL, vsync_loop, (void*) ctx);
+ if (ret) {
+ ALOGE("%s: failed to create %s: %s", __FUNCTION__,
+ HWC_VSYNC_THREAD_NAME, strerror(ret));
+ }
}
}; //namespace