# SDL: kmsdrm: If async page flip fails, try again without the async flag.

**URL:** <https://discourse.libsdl.org/t/sdl-kmsdrm-if-async-page-flip-fails-try-again-without-the-async-flag/69543>\
**Category:** SDL Commits\
**Created:** [October 12, 2026, 7:53pm UTC](https://discourse.libsdl.org/t/sdl-kmsdrm-if-async-page-flip-fails-try-again-without-the-async-flag/69543 "2026-10-12T19:53:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [October 12, 2026, 7:53pm UTC](https://discourse.libsdl.org/t/sdl-kmsdrm-if-async-page-flip-fails-try-again-without-the-async-flag/69543/1 "2026-10-12T19:53:41Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/69dd29eec2fc12d02e8a05b2fbba2d1cd03c1531>
>
> Fixes #16174.

```diff
From 69dd29eec2fc12d02e8a05b2fbba2d1cd03c1531 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 12 Oct 2026 15:50:28 -0400
Subject: [PATCH] kmsdrm: If async page flip fails, try again without the async
 flag.

Fixes #16174.
---
 src/video/kmsdrm/SDL_kmsdrmopengles.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c
index ad8314beec915..d827a563bb1dd 100644
--- a/src/video/kmsdrm/SDL_kmsdrmopengles.c
+++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c
@@ -473,6 +473,13 @@ static bool KMSDRM_GLES_SwapWindowLegacy(SDL_VideoDevice *_this, SDL_Window *win
         ret = KMSDRM_drmModePageFlip(viddata->drm_fd, dispdata->crtc.crtc->crtc_id,
                                      fb_info->fb_id, flip_flags, &windata->waiting_for_flip);
 
+ // some drivers apparently claim they can do async page flip but can't (or have intermittent problems),
+ // so in this specific case just retry without the async flag. If it still fails after that, oh well.
+ if ((ret == -EINVAL) && (flip_flags & DRM_MODE_PAGE_FLIP_ASYNC)) {
+ flip_flags &= ~DRM_MODE_PAGE_FLIP_ASYNC;
+ ret = KMSDRM_drmModePageFlip(viddata->drm_fd, dispdata->crtc->crtc_id, fb_info->fb_id, flip_flags, &windata->waiting_for_flip);
+ }
+
         if (ret == 0) {
             windata->waiting_for_flip = true;
         } else {

```
