GTK/SDL fixes for a black screen displayed by virtio-gpu
cover GTK/SDL fixes for a black screen displayed by virtio-gpu
Hi,
This patchset fixes black screen displayed by Qemu using virtio-gpu. There is a race condition bug with a timer that disables display output after it has been enabled by virtio-gpu. The problem is reproducible by running Qemu with a disabled GL vsync. Note vsync is disabled for SDL display by default.
Dmitry Osipenko (2):
ui/sdl2: Don't disable scanout when display is refreshed ui/gtk: Don't disable scanout when display is refreshed
ui/gtk-egl.c | 1 - ui/gtk-gl-area.c | 1 - ui/sdl2-gl.c | 1 - 3 files changed, 3 deletions(-)
Signature · 1 line
2.46.0
PATCH 1/2 ui/sdl2: Don't disable scanout when display is refreshed
Display refreshment is invoked by a timer and it erroneously disables the active scanout if it happens to be invoked after scanout has been enabled. This offending scanout-disable race condition with a timer can be easily hit when Qemu runs with a disabled vsync by using SDL or GTK displays (with vblank_mode=0 for GTK). Refreshment of display's content shouldn't disable the active display. Fix it by keeping the scanout's state unchanged when display is redrawn.
--- ui/sdl2-gl.c | 1 - 1 file changed, 1 deletion(-)
ui/sdl2-gl.c +0 -1
@@ -51,7 +51,6 @@ static void sdl2_gl_render_surface(struct sdl2_console *scon)int ww, wh;SDL_GL_MakeCurrent (scon->real_window, scon->winctx); -sdl2_set_scanout_mode (scon, false);SDL_GetWindowSize (scon->real_window, &ww, &wh);surface_gl_setup_viewport (scon->gls, scon->surface, ww, wh);
Signature · 1 line
2.46.0
Re: [PATCH v1 1/2] ui/sdl2: Don't disable scanout when display is refreshed
Quoted 9 lines · Dmitry Osipenko
Display refreshment is invoked by a timer and it erroneously disables the active scanout if it happens to be invoked after scanout has been enabled. This offending scanout-disable race condition with a timer can be easily hit when Qemu runs with a disabled vsync by using SDL or GTK displays (with vblank_mode=0 for GTK). Refreshment of display's content shouldn't disable the active display. Fix it by keeping the scanout's state unchanged when display is redrawn.
Signed-off-by Dmitry Osipenko <[email protected]>
Quoted 16 lines
--- ui/sdl2-gl.c | 1 - 1 file changed, 1 deletion(-)ui/sdl2-gl.c +0
-1@@ -51,7 +51,6 @@ static void sdl2_gl_render_surface(struct sdl2_console *scon)int ww, wh;SDL_GL_MakeCurrent (scon->real_window, scon->winctx); -sdl2_set_scanout_mode (scon, false);SDL_GetWindowSize (scon->real_window, &ww, &wh);surface_gl_setup_viewport (scon->gls, scon->surface, ww, wh);
Bernhard Beschow
Tested-byRe: [PATCH v1 1/2] ui/sdl2: Don't disable scanout when display is refreshed
Am 7. Oktober 2024 18:15:11 UTC schrieb Akihiko Odaki <[email protected]>:
Quoted 9 lines · Dmitry Osipenko
Quoted 8 lines
Display refreshment is invoked by a timer and it erroneously disables the active scanout if it happens to be invoked after scanout has been enabled. This offending scanout-disable race condition with a timer can be easily hit when Qemu runs with a disabled vsync by using SDL or GTK displays (with vblank_mode=0 for GTK). Refreshment of display's content shouldn't disable the active display. Fix it by keeping the scanout's state unchanged when display is redrawn.
Quoted 3 lines
Quoted 1 line
Signed-off-by Dmitry Osipenko <[email protected]>Reviewed-by Akihiko Odaki <[email protected]>
Quoted 17 lines
Quoted 15 lines
--- ui/sdl2-gl.c | 1 - 1 file changed, 1 deletion(-)ui/sdl2-gl.c +0
-1@@ -51,7 +51,6 @@ static void sdl2_gl_render_surface(struct sdl2_console *scon)int ww, wh;SDL_GL_MakeCurrent (scon->real_window, scon->winctx); -sdl2_set_scanout_mode (scon, false);SDL_GetWindowSize (scon->real_window, &ww, &wh);surface_gl_setup_viewport (scon->gls, scon->surface, ww, wh);
Re: [PATCH v1 1/2] ui/sdl2: Don't disable scanout when display is refreshed
In reply to Akihiko OdakiQuoted 9 lines · Akihiko Odaki
Quoted 8 lines · Dmitry Osipenko
Display refreshment is invoked by a timer and it erroneously disables the active scanout if it happens to be invoked after scanout has been enabled. This offending scanout-disable race condition with a timer can be easily hit when Qemu runs with a disabled vsync by using SDL or GTK displays (with vblank_mode=0 for GTK). Refreshment of display's content shouldn't disable the active display. Fix it by keeping the scanout's state unchanged when display is redrawn.
Quoted 7 lines
Quoted 1 line
Signed-off-by Dmitry Osipenko <[email protected]>Reviewed-by Akihiko Odaki <[email protected]>Quoted 3 lines
---
ui/sdl2-gl.c| 1 -1 file changed, 1 deletion(-)
Is anyone willing to apply this patchset? Maybe Alex? Thanks in advance!
Signature · 2 lines
Best regards, Dmitry
PATCH 2/2 ui/gtk: Don't disable scanout when display is refreshed
In reply to Dmitry OsipenkoDisplay refreshment is invoked by a timer and it erroneously disables the active scanout if it happens to be invoked after scanout has been enabled. This offending scanout-disable race condition with a timer can be easily hit when Qemu runs with a disabled vsync by using SDL or GTK displays (with vblank_mode=0 for GTK). Refreshment of display's content shouldn't disable the active display. Fix it by keeping the scanout's state unchanged when display is redrawn.
--- ui/gtk-egl.c | 1 - ui/gtk-gl-area.c | 1 - 2 files changed, 2 deletions(-)
ui/gtk-egl.c +0 -1
@@ -179,7 +179,6 @@ void gd_egl_refresh(DisplayChangeListener *dcl)if (vc->gfx.glupdates) { vc->gfx.glupdates =0 ; -gtk_egl_set_scanout_mode (vc, false);gd_egl_draw (vc); } }
ui/gtk-gl-area.c +0 -1
@@ -148,7 +148,6 @@ void gd_gl_area_refresh(DisplayChangeListener *dcl)if (vc->gfx.glupdates) { vc->gfx.glupdates =0 ; -gtk_gl_area_set_scanout_mode (vc, false);gtk_gl_area_queue_render (GTK_GL_AREA (vc->gfx.drawing_area)); } }
Signature · 1 line
2.46.0
Re: [PATCH v1 2/2] ui/gtk: Don't disable scanout when display is refreshed
Quoted 9 lines · Dmitry Osipenko
Display refreshment is invoked by a timer and it erroneously disables the active scanout if it happens to be invoked after scanout has been enabled. This offending scanout-disable race condition with a timer can be easily hit when Qemu runs with a disabled vsync by using SDL or GTK displays (with vblank_mode=0 for GTK). Refreshment of display's content shouldn't disable the active display. Fix it by keeping the scanout's state unchanged when display is redrawn.
Signed-off-by Dmitry Osipenko <[email protected]>
Quoted 29 lines
--- ui/gtk-egl.c | 1 - ui/gtk-gl-area.c | 1 - 2 files changed, 2 deletions(-)ui/gtk-egl.c +0
-1@@ -179,7 +179,6 @@ void gd_egl_refresh(DisplayChangeListener *dcl)if (vc->gfx.glupdates) { vc->gfx.glupdates =0 ; -gtk_egl_set_scanout_mode (vc, false);gd_egl_draw (vc); } }ui/gtk-gl-area.c +0
-1@@ -148,7 +148,6 @@ void gd_gl_area_refresh(DisplayChangeListener *dcl)if (vc->gfx.glupdates) { vc->gfx.glupdates =0 ; -gtk_gl_area_set_scanout_mode (vc, false);gtk_gl_area_queue_render (GTK_GL_AREA (vc->gfx.drawing_area)); } }
Quoted 11 lines · Dmitry Osipenko
Hi,
This patchset fixes black screen displayed by Qemu using virtio-gpu. There is a race condition bug with a timer that disables display output after it has been enabled by virtio-gpu. The problem is reproducible by running Qemu with a disabled GL vsync. Note vsync is disabled for SDL display by default.
Dmitry Osipenko (2):
ui/sdl2: Don't disable scanout when display is refreshed ui/gtk: Don't disable scanout when display is refreshed
Is it a -stable material? Myself I haven't seen this prob so far, so it might be not worth the effort. Also, any idea when the prob has been introduced (or since when it has become real)?
Thanks,
/mjt
Quoted 9 lines · Michael Tokarev
Quoted 8 lines · Dmitry Osipenko
Hi,
This patchset fixes black screen displayed by Qemu using virtio-gpu. There is a race condition bug with a timer that disables display output after it has been enabled by virtio-gpu. The problem is reproducible by running Qemu with a disabled GL vsync. Note vsync is disabled for SDL display by default.
Quoted 7 lines
Quoted 3 lines
Dmitry Osipenko (2):
ui/sdl2: Don't disable scanout when display is refreshed ui/gtk: Don't disable scanout when display is refreshedIs it a -stable material? Myself I haven't seen this prob so far, so it might be not worth the effort. Also, any idea when the prob has been introduced (or since when it has become real)?
The problem is reproducible with a stable Qemu. With SDL display it may require many retries to repro, but with GTK display + vblank_mode=0 it happens all the time. Don't know when exactly it was introduced, but will become much easier to hit it with the upcoming changes to Qemu. Judging by the git blame, problem always existed, perhaps nobody payed attention to it in the past. Up to maintainers to decide whether it's worth having these patches in stable, to me it's not worthwhile because normally nobody would run Qemu with vblank_mode=0. And you won't notice the problem if you're running desktop session in the guest because it will re-enable scanout on startup.
Signature · 2 lines
Best regards, Dmitry
Quoted 5 lines · Dmitry Osipenko
Quoted 3 lines
Is it a -stable material? Myself I haven't seen this prob so far, so it might be not worth the effort. Also, any idea when the prob has been introduced (or since when it has become real)?
The problem is reproducible with a stable Qemu. With SDL display it may
Which stable qemu do you mean? We've 4 currently active/supported stable series - 7.2.x, 8.2.x, 9.0.x, 9.1.x :)
Quoted 3 lines
require many retries to repro, but with GTK display + vblank_mode=0 it happens all the time. Don't know when exactly it was introduced, but will become much easier to hit it with the upcoming changes to Qemu.
what is vblank_mode=0 anyway, how to turn it on/off ?
Do you mean setting this variable in environment when launching qemu?
Thanks,
/mjt
Quoted 9 lines · Michael Tokarev
Quoted 5 lines · Dmitry Osipenko
Quoted 3 lines
Is it a -stable material? Myself I haven't seen this prob so far, so it might be not worth the effort. Also, any idea when the prob has been introduced (or since when it has become real)?
The problem is reproducible with a stable Qemu. With SDL display it may
Which stable qemu do you mean? We've 4 currently active/supported stable series - 7.2.x, 8.2.x, 9.0.x, 9.1.x :)
I check only the v8, v7 shouldn't differ from v8 in regards to the display code, AFAICT.
Quoted 7 lines
Quoted 3 lines
require many retries to repro, but with GTK display + vblank_mode=0 it happens all the time. Don't know when exactly it was introduced, but will become much easier to hit it with the upcoming changes to Qemu.
what is vblank_mode=0 anyway, how to turn it on/off ?
Do you mean setting this variable in environment when launching qemu?
Yes, you'll need to set this env var
Signature · 2 lines
Best regards, Dmitry