ecore_drm2: Replace plane state release flag with plane dead flag
authorDerek Foreman <derekf@osg.samsung.com>
Thu, 4 May 2017 21:28:10 +0000 (16:28 -0500)
committerDerek Foreman <derekf@osg.samsung.com>
Fri, 5 May 2017 17:53:25 +0000 (12:53 -0500)
The release flag is actually less useful than the existing in_use flag
for determining if a plane is unused.  If a new plane is assigned before
the next flip cleans up released planes, then it can point to a released
plane state, and both it and the previous user will be freed on the next
commit, leaking a plane.

Putting the flag in the plane structure fixes this while still allowing us
to keep released planes around to ensure a recently released plane is
cleared from atomic state.

src/lib/ecore_drm2/ecore_drm2_fb.c
src/lib/ecore_drm2/ecore_drm2_plane.c
src/lib/ecore_drm2/ecore_drm2_private.h

index 04af3b1..ea20bb2 100644 (file)
@@ -240,7 +240,7 @@ ecore_drm2_fb_flip_complete(Ecore_Drm2_Output *output)
 
    EINA_LIST_FOREACH_SAFE(output->planes, l, ll, plane)
      {
-        if (!plane->state->release) continue;
+        if (!plane->dead) continue;
         output->planes = eina_list_remove_list(output->planes, l);
         free(plane);
      }
@@ -283,7 +283,7 @@ _fb_atomic_flip_test(Ecore_Drm2_Output *output)
      {
         pstate = plane->state;
 
-        if (pstate->release)
+        if (!pstate->in_use)
           {
              pstate->cid.value = 0;
              pstate->fid.value = 0;
index aa07594..52f6bfd 100644 (file)
@@ -130,8 +130,8 @@ ecore_drm2_plane_release(Ecore_Drm2_Plane *plane)
 {
    EINA_SAFETY_ON_NULL_RETURN(plane);
 
+   plane->dead = EINA_TRUE;
    plane->state->in_use = EINA_FALSE;
-   plane->state->release = EINA_TRUE;
    _fb_atomic_flip_test(plane->output);
 }
 
index f73f8bc..860bb70 100644 (file)
@@ -652,7 +652,7 @@ typedef struct _Ecore_Drm2_Plane_State
    uint32_t num_formats;
    uint32_t *formats;
 
-   Eina_Bool in_use, release;
+   Eina_Bool in_use;
 } Ecore_Drm2_Plane_State;
 
 struct _Ecore_Drm2_Atomic_State
@@ -712,6 +712,7 @@ struct _Ecore_Drm2_Plane
    int type;
    Ecore_Drm2_Plane_State *state;
    Ecore_Drm2_Output *output;
+   Eina_Bool dead;
 };
 
 struct _Ecore_Drm2_Output_Mode