Expand the condition of need_to_wait in buffer_clear. 50/258550/1
authorJoonbum Ko <joonbum.ko@samsung.com>
Tue, 18 May 2021 08:28:29 +0000 (17:28 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Thu, 20 May 2021 05:37:04 +0000 (14:37 +0900)
 - AS-IS : The need_to_wait flags is set to true under
          different conditions according to the use of
          explicit_sync.
 - PROBLEMS : A buffer that is not included in the condition
             may cause thread conflict.
 - TO-BE : The buffers whose status is from ENQUEUED to COMMITTED
          will be cleared after waiting until wl_surface_commit.

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

index 91d6e65..d6f37f2 100755 (executable)
@@ -1463,11 +1463,6 @@ _thread_wl_egl_surface_fini(tpl_wl_egl_surface_t *wl_egl_surface)
                wl_egl_surface->presentation_sync.fd = -1;
        }
 
-       if (wl_egl_surface->vblank && wl_egl_surface->vblank->waiting_buffers) {
-               __tpl_list_free(wl_egl_surface->vblank->waiting_buffers, NULL);
-               wl_egl_surface->vblank->waiting_buffers = NULL;
-       }
-
        tpl_gmutex_unlock(&wl_egl_surface->presentation_sync.mutex);
 
        if (wl_egl_surface->surface_sync) {
@@ -1486,11 +1481,17 @@ _thread_wl_egl_surface_fini(tpl_wl_egl_surface_t *wl_egl_surface)
                wl_egl_surface->tss_flusher = NULL;
        }
 
+       if (wl_egl_surface->vblank && wl_egl_surface->vblank->waiting_buffers) {
+               __tpl_list_free(wl_egl_surface->vblank->waiting_buffers, NULL);
+               wl_egl_surface->vblank->waiting_buffers = NULL;
+       }
+
        if (wl_egl_surface->vblank) {
                __tpl_list_remove_data(wl_egl_display->tdm.surface_vblanks,
                                                           (void *)wl_egl_surface->vblank,
                                                           TPL_FIRST,
                                                           __cb_surface_vblank_free);
+               wl_egl_surface->vblank = NULL;
        }
 
        if (wl_egl_surface->tbm_queue) {
@@ -1947,13 +1948,7 @@ _tpl_wl_egl_surface_buffer_clear(tpl_wl_egl_surface_t *wl_egl_surface)
                        tpl_bool_t need_to_wait  = TPL_FALSE;
                        tpl_result_t wait_result = TPL_ERROR_NONE;
 
-                       if (!wl_egl_display->use_explicit_sync &&
-                               status < WAITING_VBLANK)
-                               need_to_wait = TPL_TRUE;
-
-                       if (wl_egl_display->use_explicit_sync &&
-                               status < COMMITTED)
-                               need_to_wait = TPL_TRUE;
+                       need_to_wait = (status < COMMITTED);
 
                        if (need_to_wait) {
                                tpl_gmutex_unlock(&wl_egl_display->wl_event_mutex);
@@ -2657,7 +2652,6 @@ __thread_func_waiting_source_dispatch(tpl_gsource *gsource, uint64_t message)
 
        tpl_gmutex_lock(&wl_egl_buffer->mutex);
        wl_egl_buffer->status = WAITING_VBLANK;
-       tpl_gcond_signal(&wl_egl_buffer->cond);
        tpl_gmutex_unlock(&wl_egl_buffer->mutex);
 
        tpl_gmutex_lock(&wl_egl_surface->surf_mutex);
@@ -2805,11 +2799,14 @@ __cb_tdm_client_vblank(tdm_client_vblank *vblank, tdm_error error,
        wl_egl_surface->vblank_done = TPL_TRUE;
 
        tpl_gmutex_lock(&wl_egl_surface->surf_mutex);
-       wl_egl_buffer = (tpl_wl_egl_buffer_t *)__tpl_list_pop_front(
-                                               wl_egl_surface->vblank->waiting_buffers,
-                                               NULL);
-       if (wl_egl_buffer)
-               _thread_wl_surface_commit(wl_egl_surface, wl_egl_buffer);
+       if (wl_egl_surface->vblank && wl_egl_surface->vblank->waiting_buffers) {
+               wl_egl_buffer = (tpl_wl_egl_buffer_t *)__tpl_list_pop_front(
+                                                       wl_egl_surface->vblank->waiting_buffers,
+                                                       NULL);
+
+               if (wl_egl_buffer)
+                       _thread_wl_surface_commit(wl_egl_surface, wl_egl_buffer);
+       }
        tpl_gmutex_unlock(&wl_egl_surface->surf_mutex);
 }
 /* -- END -- tdm_client vblank callback function */