diff options
author | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2019-04-30 11:49:12 +0100 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2019-04-30 11:51:06 +0100 |
commit | 703ca74d67d377d8901f94e0ff09320234f6d7c9 (patch) | |
tree | 46250d5c5474b73f32cf26a29cdc52fddfcaa809 /src/lib/ecore_drm2 | |
parent | fd5d87a26cc57ec829310eed7d57a1e5aa4b3b40 (diff) |
ecore drm2 - fix timeout in case case called from thread
so sw rendering make call ecore drm2 calls from a thread - i didnt
know that. so this makes my fix for gl hangs add hangs in sw as a
result. this fixes that. not perfect but better. do need refcoutnts on
outputs to be perfect...
also sometimes the commits fail so retry a few times...
this still leaves us wth another hang that is a separate issue.
@fix
Diffstat (limited to 'src/lib/ecore_drm2')
-rw-r--r-- | src/lib/ecore_drm2/ecore_drm2_fb.c | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/src/lib/ecore_drm2/ecore_drm2_fb.c b/src/lib/ecore_drm2/ecore_drm2_fb.c index aab47956fb..e91cf67ec5 100644 --- a/src/lib/ecore_drm2/ecore_drm2_fb.c +++ b/src/lib/ecore_drm2/ecore_drm2_fb.c | |||
@@ -1,5 +1,7 @@ | |||
1 | #include "ecore_drm2_private.h" | 1 | #include "ecore_drm2_private.h" |
2 | 2 | ||
3 | #define FLIP_TIMEOUT 0.05 | ||
4 | |||
3 | static Eina_Bool | 5 | static Eina_Bool |
4 | _fb2_create(Ecore_Drm2_Fb *fb) | 6 | _fb2_create(Ecore_Drm2_Fb *fb) |
5 | { | 7 | { |
@@ -255,6 +257,15 @@ _ecore_drm2_fb_buffer_release(Ecore_Drm2_Output *output EINA_UNUSED, Ecore_Drm2_ | |||
255 | } | 257 | } |
256 | } | 258 | } |
257 | 259 | ||
260 | static void | ||
261 | _cb_mainloop_async_timer_del(void *data) | ||
262 | { | ||
263 | Ecore_Drm2_Output *output = data; | ||
264 | |||
265 | ecore_timer_del(output->flip_timeout); | ||
266 | output->flip_timeout = NULL; | ||
267 | } | ||
268 | |||
258 | EAPI Eina_Bool | 269 | EAPI Eina_Bool |
259 | ecore_drm2_fb_flip_complete(Ecore_Drm2_Output *output) | 270 | ecore_drm2_fb_flip_complete(Ecore_Drm2_Output *output) |
260 | { | 271 | { |
@@ -265,9 +276,11 @@ ecore_drm2_fb_flip_complete(Ecore_Drm2_Output *output) | |||
265 | 276 | ||
266 | if (output->flip_timeout) | 277 | if (output->flip_timeout) |
267 | { | 278 | { |
268 | ecore_timer_del(output->flip_timeout); | 279 | // XXX: output ref++ |
269 | output->flip_timeout = NULL; | 280 | ecore_main_loop_thread_safe_call_async |
281 | (_cb_mainloop_async_timer_del, output); | ||
270 | } | 282 | } |
283 | if (!output->pending.fb) fprintf(stderr, "XXX--XXX eeeeek pending fb is NULL so current would become null ----------------------------------\n"); | ||
271 | if (output->current.fb && (output->current.fb != output->pending.fb)) | 284 | if (output->current.fb && (output->current.fb != output->pending.fb)) |
272 | _ecore_drm2_fb_buffer_release(output, &output->current); | 285 | _ecore_drm2_fb_buffer_release(output, &output->current); |
273 | 286 | ||
@@ -470,12 +483,20 @@ _cb_flip_timeout(void *data) | |||
470 | Ecore_Drm2_Output *output = data; | 483 | Ecore_Drm2_Output *output = data; |
471 | 484 | ||
472 | output->flip_timeout = NULL; | 485 | output->flip_timeout = NULL; |
473 | ERR("flip event callback timout 0.05sec - try again"); | 486 | ERR("flip event callback timout %0.2fsec - try again", FLIP_TIMEOUT); |
474 | if (_ecore_drm2_use_atomic) _fb_atomic_flip(output); | 487 | if (_ecore_drm2_use_atomic) _fb_atomic_flip(output); |
475 | else _fb_flip(output); | 488 | else _fb_flip(output); |
476 | return EINA_FALSE; | 489 | return EINA_FALSE; |
477 | } | 490 | } |
478 | 491 | ||
492 | static void | ||
493 | _cb_mainloop_async_timer_reset(void *data) | ||
494 | { | ||
495 | Ecore_Drm2_Output *output = data; | ||
496 | if (output->flip_timeout) ecore_timer_del(output->flip_timeout); | ||
497 | output->flip_timeout = ecore_timer_add(FLIP_TIMEOUT, _cb_flip_timeout, output); | ||
498 | } | ||
499 | |||
479 | static int | 500 | static int |
480 | _fb_atomic_flip(Ecore_Drm2_Output *output) | 501 | _fb_atomic_flip(Ecore_Drm2_Output *output) |
481 | { | 502 | { |
@@ -493,9 +514,18 @@ _fb_atomic_flip(Ecore_Drm2_Output *output) | |||
493 | /* Still no req is a bad situation */ | 514 | /* Still no req is a bad situation */ |
494 | EINA_SAFETY_ON_NULL_RETURN_VAL(output->prep.atomic_req, -1); | 515 | EINA_SAFETY_ON_NULL_RETURN_VAL(output->prep.atomic_req, -1); |
495 | 516 | ||
496 | res = | 517 | // sometimes we get a EBUSY ... so try again a few times. |
497 | sym_drmModeAtomicCommit(output->fd, output->prep.atomic_req, flags, | 518 | int i; |
498 | output); | 519 | for (i = 0; i < 10; i++) |
520 | { | ||
521 | res = | ||
522 | sym_drmModeAtomicCommit(output->fd, output->prep.atomic_req, flags, | ||
523 | output); | ||
524 | if (res == 0) break; | ||
525 | else ERR("DRM atomic commit failed - retry #%i", i + 1); | ||
526 | usleep(100); | ||
527 | } | ||
528 | |||
499 | if (res < 0) | 529 | if (res < 0) |
500 | { | 530 | { |
501 | ERR("Failed Atomic Commit: %m"); | 531 | ERR("Failed Atomic Commit: %m"); |
@@ -503,8 +533,9 @@ _fb_atomic_flip(Ecore_Drm2_Output *output) | |||
503 | } | 533 | } |
504 | else | 534 | else |
505 | { | 535 | { |
506 | if (output->flip_timeout) ecore_timer_del(output->flip_timeout); | 536 | // XXX: output ref++ |
507 | output->flip_timeout = ecore_timer_add(0.05, _cb_flip_timeout, output); | 537 | ecore_main_loop_thread_safe_call_async |
538 | (_cb_mainloop_async_timer_reset, output); | ||
508 | } | 539 | } |
509 | 540 | ||
510 | return 0; | 541 | return 0; |
@@ -591,8 +622,9 @@ _fb_flip(Ecore_Drm2_Output *output) | |||
591 | } | 622 | } |
592 | else | 623 | else |
593 | { | 624 | { |
594 | if (output->flip_timeout) ecore_timer_del(output->flip_timeout); | 625 | // XXX: output ref++ |
595 | output->flip_timeout = ecore_timer_add(0.05, _cb_flip_timeout, output); | 626 | ecore_main_loop_thread_safe_call_async |
627 | (_cb_mainloop_async_timer_reset, output); | ||
596 | } | 628 | } |
597 | } | 629 | } |
598 | while (repeat); | 630 | while (repeat); |