summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Michael <cp.michael@samsung.com>2019-05-22 07:57:53 -0400
committerChristopher Michael <cp.michael@samsung.com>2019-05-29 08:41:16 -0400
commit13921d77451e285d083316b745f70a403d8ce6ef (patch)
tree1160681e75983b917c9f4ab549933b4ffa721b25
parent9eb46ed420c2ce57c99751a0a7dd5b2ab756bc64 (diff)
ecore-drm2: Refactor drm2 fb flipping code to avoid NULLsdevs/devilhorns/flip
With certain drivers we end up in a case where output->current, next, and pending FBs all are getting set to NULL which causes freezes/crashes. This patch refactors our ecore_drm2_fb_flip code to avoid that case. @fix
-rw-r--r--src/lib/ecore_drm2/ecore_drm2_fb.c63
-rw-r--r--src/lib/ecore_drm2/ecore_drm2_plane.c4
2 files changed, 33 insertions, 34 deletions
diff --git a/src/lib/ecore_drm2/ecore_drm2_fb.c b/src/lib/ecore_drm2/ecore_drm2_fb.c
index e91cf67ec5..72d9fd5818 100644
--- a/src/lib/ecore_drm2/ecore_drm2_fb.c
+++ b/src/lib/ecore_drm2/ecore_drm2_fb.c
@@ -269,9 +269,6 @@ _cb_mainloop_async_timer_del(void *data)
269EAPI Eina_Bool 269EAPI Eina_Bool
270ecore_drm2_fb_flip_complete(Ecore_Drm2_Output *output) 270ecore_drm2_fb_flip_complete(Ecore_Drm2_Output *output)
271{ 271{
272 Eina_Bool plane_scanout;
273 Ecore_Drm2_Fb *fb;
274
275 EINA_SAFETY_ON_NULL_RETURN_VAL(output, EINA_FALSE); 272 EINA_SAFETY_ON_NULL_RETURN_VAL(output, EINA_FALSE);
276 273
277 if (output->flip_timeout) 274 if (output->flip_timeout)
@@ -280,17 +277,19 @@ ecore_drm2_fb_flip_complete(Ecore_Drm2_Output *output)
280 ecore_main_loop_thread_safe_call_async 277 ecore_main_loop_thread_safe_call_async
281 (_cb_mainloop_async_timer_del, output); 278 (_cb_mainloop_async_timer_del, output);
282 } 279 }
283 if (!output->pending.fb) fprintf(stderr, "XXX--XXX eeeeek pending fb is NULL so current would become null ----------------------------------\n"); 280 /* if (!output->pending.fb) fprintf(stderr, "XXX--XXX eeeeek pending fb is NULL so current would become null ----------------------------------\n"); */
284 if (output->current.fb && (output->current.fb != output->pending.fb)) 281 /* if (output->current.fb && (output->current.fb != output->pending.fb)) */
285 _ecore_drm2_fb_buffer_release(output, &output->current); 282 /* _ecore_drm2_fb_buffer_release(output, &output->current); */
286 283
287 output->current.fb = output->pending.fb; 284 output->current.fb = output->pending.fb;
288 output->pending.fb = NULL; 285 output->pending.fb = NULL;
289 286
290 if (_ecore_drm2_use_atomic) 287 if (_ecore_drm2_use_atomic)
291 { 288 {
289 Ecore_Drm2_Fb *fb;
292 Eina_List *l, *ll; 290 Eina_List *l, *ll;
293 Ecore_Drm2_Plane *plane; 291 Ecore_Drm2_Plane *plane;
292 Eina_Bool plane_scanout;
294 293
295 output->current.atomic_req = output->pending.atomic_req; 294 output->current.atomic_req = output->pending.atomic_req;
296 output->pending.atomic_req = NULL; 295 output->pending.atomic_req = NULL;
@@ -323,9 +322,9 @@ ecore_drm2_fb_flip_complete(Ecore_Drm2_Output *output)
323 } 322 }
324 } 323 }
325 324
326 EINA_LIST_FREE(output->fbs, fb) 325 /* EINA_LIST_FREE(output->fbs, fb) */
327 _ecore_drm2_fb_deref(fb); 326 /* _ecore_drm2_fb_deref(fb); */
328 output->fbs = NULL; 327 /* output->fbs = NULL; */
329 328
330 return !!output->next.fb; 329 return !!output->next.fb;
331} 330}
@@ -522,7 +521,7 @@ _fb_atomic_flip(Ecore_Drm2_Output *output)
522 sym_drmModeAtomicCommit(output->fd, output->prep.atomic_req, flags, 521 sym_drmModeAtomicCommit(output->fd, output->prep.atomic_req, flags,
523 output); 522 output);
524 if (res == 0) break; 523 if (res == 0) break;
525 else ERR("DRM atomic commit failed - retry #%i", i + 1); 524 else ERR("DRM atomic commit failed: %m - retry #%i", i + 1);
526 usleep(100); 525 usleep(100);
527 } 526 }
528 527
@@ -657,43 +656,43 @@ ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output *output)
657 656
658 if (!output->enabled) return -1; 657 if (!output->enabled) return -1;
659 658
660 if (fb) _ecore_drm2_fb_ref(fb);
661
662 if (output->pending.fb) 659 if (output->pending.fb)
663 { 660 {
664 if (output->next.fb) 661 if ((fb) && (output->pending.fb != fb))
665 _ecore_drm2_fb_buffer_release(output, &output->next); 662 {
666 output->next.fb = fb; 663 if (output->next.fb)
667 return 0; 664 _ecore_drm2_fb_buffer_release(output, &output->next);
665 output->next.fb = fb;
666 return 0;
667 }
668 else
669 {
670 return 0;
671 }
668 } 672 }
673
669 if (!fb) 674 if (!fb)
670 { 675 {
671 fb = output->next.fb; 676 if (output->next.fb)
672 output->next.fb = NULL; 677 {
678 fb = output->next.fb;
679 output->next.fb = NULL;
680 }
681 else
682 fb = output->current.fb;
673 } 683 }
674 684
675 /* So we can generate a tick by flipping to the current fb */
676 if (!fb) fb = output->current.fb;
677
678 if (output->next.fb)
679 _ecore_drm2_fb_buffer_release(output, &output->next);
680
681 /* If we don't have an fb to set by now, BAIL! */
682 if (!fb) return -1; 685 if (!fb) return -1;
683 686
684 output->prep.fb = fb; 687 output->prep.fb = fb;
685 688
689 _ecore_drm2_fb_ref(fb);
690
686 if (_ecore_drm2_use_atomic) 691 if (_ecore_drm2_use_atomic)
687 ret = _fb_atomic_flip(output); 692 ret = _fb_atomic_flip(output);
688 else 693 else
689 ret = _fb_flip(output); 694 ret = _fb_flip(output);
690 695
691 if (ret)
692 {
693 if (output->prep.fb != output->current.fb)
694 _ecore_drm2_fb_buffer_release(output, &output->prep);
695 return ret;
696 }
697 output->pending.fb = output->prep.fb; 696 output->pending.fb = output->prep.fb;
698 output->prep.fb = NULL; 697 output->prep.fb = NULL;
699 698
@@ -703,7 +702,7 @@ ecore_drm2_fb_flip(Ecore_Drm2_Fb *fb, Ecore_Drm2_Output *output)
703 output->prep.atomic_req = NULL; 702 output->prep.atomic_req = NULL;
704 } 703 }
705 704
706 return 0; 705 return ret; // 0
707} 706}
708 707
709EAPI Eina_Bool 708EAPI Eina_Bool
diff --git a/src/lib/ecore_drm2/ecore_drm2_plane.c b/src/lib/ecore_drm2/ecore_drm2_plane.c
index ea4d3c1a10..60cbd365c7 100644
--- a/src/lib/ecore_drm2/ecore_drm2_plane.c
+++ b/src/lib/ecore_drm2/ecore_drm2_plane.c
@@ -123,7 +123,7 @@ out:
123 return NULL; 123 return NULL;
124 } 124 }
125 125
126 _ecore_drm2_fb_ref(fb); 126 /* _ecore_drm2_fb_ref(fb); */
127 DBG("FB %d assigned to Plane %d", fb->id, pstate->obj_id); 127 DBG("FB %d assigned to Plane %d", fb->id, pstate->obj_id);
128 128
129 if (fb->status_handler) 129 if (fb->status_handler)
@@ -192,7 +192,7 @@ ecore_drm2_plane_fb_set(Ecore_Drm2_Plane *plane, Ecore_Drm2_Fb *fb)
192 192
193 if (_fb_atomic_flip_test(plane->output)) 193 if (_fb_atomic_flip_test(plane->output))
194 { 194 {
195 _ecore_drm2_fb_ref(fb); 195 /* _ecore_drm2_fb_ref(fb); */
196 196
197 plane->output->fbs = 197 plane->output->fbs =
198 eina_list_append(plane->output->fbs, plane->fb); 198 eina_list_append(plane->output->fbs, plane->fb);