wl_egl: subdivided the buffer_status 52/318752/1
authorJoonbum Ko <joonbum.ko@samsung.com>
Mon, 30 Sep 2024 06:03:15 +0000 (15:03 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Tue, 8 Oct 2024 01:14:28 +0000 (10:14 +0900)
 subdivided status below
 1. WAITING_SIGNALED ~ WAITING_VBLANK
  -> WAITING_SIGNALED ~ SIGNALED / SIGNALED ~ WAITING_VBLANK
 2. WAITING_VBLANK ~ COMMITTED
  -> WAITING_VBLANK ~ VBLANK_DONE / VBLANK_DONE ~ COMMITTED

Change-Id: I19acb9deba8221e6b18056fc9a0d01f7dd5c737f
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/tpl_wl_egl_thread.c

index a514131883cbc41001180bc7689bf4730704a67a..f8929af945cb87cfafee13309d53a41d03481cef 100755 (executable)
@@ -181,18 +181,25 @@ typedef enum buffer_status {
        ENQUEUED,                 // 2
        ACQUIRED,                 // 3
        WAITING_SIGNALED,         // 4
-       WAITING_VBLANK,           // 5
-       COMMITTED,                // 6
+       SIGNALED,                 // 5
+       WAITING_VBLANK,           // 6
+       VBLANK_DONE,              // 7
+       COMMITTED,                // 8
 } buffer_status_t;
 
-static const char *status_to_string[7] = {
-       "RELEASED",                 // 0
-       "DEQUEUED",                 // 1
-       "ENQUEUED",                 // 2
-       "ACQUIRED",                 // 3
-       "WAITING_SIGNALED",         // 4
-       "WAITING_VBLANK",           // 5
-       "COMMITTED",                // 6
+static struct buffer_status_info {
+       const char status_str[20];
+       uint32_t threshold_ms; /* The time limit takes to reach this status */
+} buffer_status_info[9] = {
+       { "RELEASED", UINT32_MAX }, /* COMMITTED ~ RELEASE will be not traced */
+       { "DEQUEUED", UINT32_MAX }, /* RELEASED ~ DEQUEUED will be not traced */
+       { "ENQEUEUD", 20 },
+       { "ACQUIRED", 10 },
+       { "WAIT_SIG", 10 },
+       { "SIGNALED", 20 },
+       { "WAIT_VBL", 10 },
+       { "DONE_VBL", 20 },
+       { "COMMITTED", 10 }
 };
 
 struct _tpl_wl_egl_buffer {
@@ -306,16 +313,6 @@ __cb_surface_vblank_free(void *data);
 static void
 _buffers_force_release(tpl_wl_egl_surface_t *wl_egl_surface);
 
-#define REL_TO_DEQ 30
-#define DEQ_TO_ENQ 20
-#define DEQ_TO_CAN 20
-#define ENQ_TO_ACQ 20
-#define ACQ_TO_SIG 10
-#define ACQ_TO_VBL 10
-#define SIG_TO_VBL 30
-#define VBL_TO_CMT 20
-#define CMT_TO_REL 50
-
 #define RELEASE_FROM_LAST_COMMIT 20
 #define DEQUEUE_FROM_LAST_RELEASE 20
 
@@ -336,8 +333,8 @@ _elapsed_between_status(tpl_wl_egl_buffer_t *wl_egl_buffer, long threshold)
        if (wl_egl_buffer->begin_status != COMMITTED && gap > threshold) {
                TPL_ERR("bo_name(%d) | %s ~ %s | takes too long time %ld > %ld",
                                 wl_egl_buffer->bo_name,
-                                status_to_string[wl_egl_buffer->begin_status],
-                                status_to_string[wl_egl_buffer->status],
+                                buffer_status_info[wl_egl_buffer->begin_status].status_str,
+                                buffer_status_info[wl_egl_buffer->status].status_str,
                                 gap, threshold);
        }
        wl_egl_buffer->begin.tv_sec = end.tv_sec;
@@ -2251,8 +2248,8 @@ _buffers_force_release(tpl_wl_egl_surface_t *wl_egl_surface)
 
                TPL_INFO("[FORCE_RELEASE]", "wl_egl_buffer(%p) status(%s -> %s)",
                                 wl_egl_buffer,
-                                status_to_string[status],
-                                status_to_string[RELEASED]);
+                                buffer_status_info[status].status_str,
+                                buffer_status_info[RELEASED].status_str);
 
                tpl_gmutex_unlock(&wl_egl_buffer->mutex);
 
@@ -2305,7 +2302,7 @@ __idle_cb_buffers_finalize(void *data)
                if (status > DEQUEUED && status < COMMITTED) {
                        if (!wl_egl_buffer->release_pending) {
                                TPL_INFO("[RELEASE_PENDING]", "wl_egl_surface(%p) wl_egl_buffer(%p) status(%s)",
-                                                wl_egl_surface, wl_egl_buffer, status_to_string[status]);
+                                                wl_egl_surface, wl_egl_buffer, buffer_status_info[status].status_str);
                                TPL_INFO("[RELEASE_PENDING]", "tbm_surface(%p) bo(%d)",
                                                 wl_egl_buffer->tbm_surface, wl_egl_buffer->bo_name);
                                wl_egl_buffer->release_pending = TPL_TRUE;
@@ -2344,8 +2341,8 @@ __idle_cb_buffers_finalize(void *data)
 
                TPL_INFO("[RELEASE]", "wl_egl_buffer(%p) status(%s -> %s)",
                                 wl_egl_buffer,
-                                status_to_string[status],
-                                status_to_string[RELEASED]);
+                                buffer_status_info[status].status_str,
+                                buffer_status_info[RELEASED].status_str);
 
                wl_egl_buffer->status = RELEASED;
 
@@ -2950,7 +2947,7 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns,
 
        tpl_gmutex_lock(&wl_egl_buffer->mutex);
        wl_egl_buffer->status = DEQUEUED;
-       _elapsed_between_status(wl_egl_buffer, REL_TO_DEQ);
+       _elapsed_between_status(wl_egl_buffer, buffer_status_info[wl_egl_buffer->status].threshold_ms);
        _elapsed_from_last_release(wl_egl_surface, wl_egl_buffer->bo_name);
 
        /* If wl_egl_buffer->release_fence_fd is -1,
@@ -3016,7 +3013,7 @@ __tpl_wl_egl_surface_cancel_buffer(tpl_surface_t *surface,
        if (wl_egl_buffer) {
                tpl_gmutex_lock(&wl_egl_buffer->mutex);
                wl_egl_buffer->status = RELEASED;
-               _elapsed_between_status(wl_egl_buffer, DEQ_TO_ENQ);
+               _elapsed_between_status(wl_egl_buffer, buffer_status_info[wl_egl_buffer->status].threshold_ms);
                tpl_gmutex_unlock(&wl_egl_buffer->mutex);
        }
 
@@ -3157,7 +3154,7 @@ __tpl_wl_egl_surface_enqueue_buffer(tpl_surface_t *surface,
        tpl_gmutex_unlock(&wl_egl_surface->commit_sync.mutex);
 
        wl_egl_buffer->status = ENQUEUED;
-       _elapsed_between_status(wl_egl_buffer, DEQ_TO_ENQ);
+       _elapsed_between_status(wl_egl_buffer, buffer_status_info[wl_egl_buffer->status].threshold_ms);
        TPL_LOG_T("WL_EGL",
                          "[ENQ] wl_egl_buffer(%p) tbm_surface(%p) bo(%d) fence(%d)",
                          wl_egl_buffer, tbm_surface, bo_name, acquire_fence);
@@ -3203,8 +3200,8 @@ __thread_func_waiting_source_dispatch(tpl_gsource *gsource, uint64_t message)
        tpl_gmutex_lock(&wl_egl_surface->surf_mutex);
        tpl_gmutex_lock(&wl_egl_buffer->mutex);
 
-       wl_egl_buffer->status = WAITING_VBLANK;
-       _elapsed_between_status(wl_egl_buffer, SIG_TO_VBL);
+       wl_egl_buffer->status = SIGNALED;
+       _elapsed_between_status(wl_egl_buffer, buffer_status_info[wl_egl_buffer->status].threshold_ms);
 
        TPL_LOG_D("[FINALIZE]", "wl_egl_surface(%p) wl_egl_buffer(%p) wait_source(%p) fence_fd(%d)",
                          wl_egl_surface, wl_egl_buffer, wl_egl_buffer->waiting_source,
@@ -3216,6 +3213,7 @@ __thread_func_waiting_source_dispatch(tpl_gsource *gsource, uint64_t message)
        if (!wl_egl_surface->vblank_enable || wl_egl_surface->vblank_done) {
                _thread_wl_surface_commit(wl_egl_surface, wl_egl_buffer);
        } else {
+               wl_egl_buffer->status = WAITING_VBLANK;
                tpl_gmutex_lock(&wl_egl_surface->vblank->mutex);
                __tpl_list_push_back(wl_egl_surface->vblank->waiting_buffers,
                                                         wl_egl_buffer);
@@ -3270,7 +3268,7 @@ _thread_surface_queue_acquire(tpl_wl_egl_surface_t *wl_egl_surface)
                tpl_gmutex_lock(&wl_egl_buffer->mutex);
 
                wl_egl_buffer->status = ACQUIRED;
-               _elapsed_between_status(wl_egl_buffer, ENQ_TO_ACQ);
+               _elapsed_between_status(wl_egl_buffer, buffer_status_info[wl_egl_buffer->status].threshold_ms);
 
                TPL_LOG_T("WL_EGL", "[ACQ] wl_egl_buffer(%p) tbm_surface(%p) bo(%d)",
                                  wl_egl_buffer, tbm_surface,
@@ -3294,7 +3292,7 @@ _thread_surface_queue_acquire(tpl_wl_egl_surface_t *wl_egl_surface)
                                                                           FD_TYPE_FENCE, &buffer_funcs,
                                                                           SOURCE_TYPE_DISPOSABLE);
                                wl_egl_buffer->status = WAITING_SIGNALED;
-                               _elapsed_between_status(wl_egl_buffer, ACQ_TO_SIG);
+                               _elapsed_between_status(wl_egl_buffer, buffer_status_info[wl_egl_buffer->status].threshold_ms);
 
                                TRACE_ASYNC_BEGIN(wl_egl_buffer->acquire_fence_fd, "FENCE WAIT fd(%d)",
                                                                  wl_egl_buffer->acquire_fence_fd);
@@ -3310,7 +3308,7 @@ _thread_surface_queue_acquire(tpl_wl_egl_surface_t *wl_egl_surface)
                                ready_to_commit = TPL_TRUE;
                        else {
                                wl_egl_buffer->status = WAITING_VBLANK;
-                               _elapsed_between_status(wl_egl_buffer, ACQ_TO_VBL);
+                               _elapsed_between_status(wl_egl_buffer, buffer_status_info[wl_egl_buffer->status].threshold_ms);
                                tpl_gmutex_lock(&wl_egl_surface->vblank->mutex);
                                __tpl_list_push_back(wl_egl_surface->vblank->waiting_buffers, wl_egl_buffer);
                                tpl_gmutex_unlock(&wl_egl_surface->vblank->mutex);
@@ -3358,6 +3356,8 @@ __cb_tdm_client_vblank(tdm_client_vblank *vblank, tdm_error error,
                        if (!wl_egl_buffer) break;
 
                        tpl_gmutex_lock(&wl_egl_buffer->mutex);
+                       wl_egl_buffer->status = VBLANK_DONE;
+                       _elapsed_between_status(wl_egl_buffer, buffer_status_info[wl_egl_buffer->status].threshold_ms);
                        _thread_wl_surface_commit(wl_egl_surface, wl_egl_buffer);
                        tpl_gmutex_unlock(&wl_egl_buffer->mutex);
 
@@ -3399,7 +3399,7 @@ __cb_buffer_fenced_release(void *data,
 
                        wl_egl_buffer->release_fence_fd = fence;
                        wl_egl_buffer->status = RELEASED;
-                       _elapsed_between_status(wl_egl_buffer, CMT_TO_REL);
+                       _elapsed_between_status(wl_egl_buffer, buffer_status_info[wl_egl_buffer->status].threshold_ms);
                        wl_egl_surface->last_release_bo = wl_egl_buffer->bo_name;
                        _elapsed_from_last_commit(wl_egl_surface, wl_egl_buffer->bo_name);
                        _update_last_release_time(wl_egl_surface);
@@ -3455,7 +3455,7 @@ __cb_buffer_immediate_release(void *data,
 
                        wl_egl_buffer->release_fence_fd = -1;
                        wl_egl_buffer->status = RELEASED;
-                       _elapsed_between_status(wl_egl_buffer, CMT_TO_REL);
+                       _elapsed_between_status(wl_egl_buffer, buffer_status_info[wl_egl_buffer->status].threshold_ms);
                        wl_egl_surface->last_release_bo = wl_egl_buffer->bo_name;
                        _elapsed_from_last_commit(wl_egl_surface, wl_egl_buffer->bo_name);
                        _update_last_release_time(wl_egl_surface);
@@ -3516,7 +3516,7 @@ __cb_wl_buffer_release(void *data, struct wl_proxy *wl_buffer)
                                TPL_ERR("tbm_surface(%p) tsq_err(%d)", tbm_surface, tsq_err);
 
                        wl_egl_buffer->status = RELEASED;
-                       _elapsed_between_status(wl_egl_buffer, CMT_TO_REL);
+                       _elapsed_between_status(wl_egl_buffer, buffer_status_info[wl_egl_buffer->status].threshold_ms);
                        wl_egl_surface->last_release_bo = wl_egl_buffer->bo_name;
                        _elapsed_from_last_commit(wl_egl_surface, wl_egl_buffer->bo_name);
                        _update_last_release_time(wl_egl_surface);
@@ -3855,7 +3855,7 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface,
 
        wl_egl_buffer->need_to_commit   = TPL_FALSE;
        wl_egl_buffer->status           = COMMITTED;
-       _elapsed_between_status(wl_egl_buffer, VBL_TO_CMT);
+       _elapsed_between_status(wl_egl_buffer, buffer_status_info[wl_egl_buffer->status].threshold_ms);
        _update_last_commit_time(wl_egl_surface);
 
        wl_egl_surface->last_commit_bo = wl_egl_buffer->bo_name;
@@ -4063,7 +4063,7 @@ _print_buffer_lists(tpl_wl_egl_surface_t *wl_egl_surface)
                                 "[%d/%d] wl_egl_surface(%p), wl_egl_buffer(%p) tbm_surface(%p) bo(%d) | status(%s)",
                                 ++idx, buffer_cnt, wl_egl_surface, wl_egl_buffer,
                                 wl_egl_buffer->tbm_surface, wl_egl_buffer->bo_name,
-                                status_to_string[wl_egl_buffer->status]);
+                                buffer_status_info[wl_egl_buffer->status].status_str);
        } while ((node = __tpl_list_node_next(node)));
        tpl_gmutex_rec_unlock(&wl_egl_surface->buffers_mutex);
 }