[PATCH v22 02/18] ui/sdl2: Don't disable scanout when display is refreshed

Dmitry Osipenko posted 18 patches 1 month, 1 week ago
Maintainers: Pierrick Bouvier <pierrick.bouvier@linaro.org>, "Michael S. Tsirkin" <mst@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>, Dmitry Osipenko <dmitry.osipenko@collabora.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>
[PATCH v22 02/18] ui/sdl2: Don't disable scanout when display is refreshed
Posted by Dmitry Osipenko 1 month, 1 week ago
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.

Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Alex Bennée <alex.bennee@linaro.org>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Yiwei Zhang <zzyiwei@gmail.com>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
---
 ui/sdl2-gl.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c
index 3be17d1079af..5eca0248233e 100644
--- a/ui/sdl2-gl.c
+++ b/ui/sdl2-gl.c
@@ -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);
-- 
2.52.0


Re: [PATCH v22 02/18] ui/sdl2: Don't disable scanout when display is refreshed
Posted by Stefan Weil via qemu development 4 days, 6 hours ago
Am 03.03.26 um 16:14 schrieb 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.
> 
> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
> Tested-by: Alex Bennée <alex.bennee@linaro.org>
> Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
> Reviewed-by: Yiwei Zhang <zzyiwei@gmail.com>
> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
> ---
>   ui/sdl2-gl.c | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c
> index 3be17d1079af..5eca0248233e 100644
> --- a/ui/sdl2-gl.c
> +++ b/ui/sdl2-gl.c
> @@ -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);

I got a user report that my latest QEMU for Windows no longer supports 
SDL. According to my own test, SDL still worked with git master 
(2026-03-07), but was broken with 11.0.0-rc0 (2026-03-18).

Therefore this patch series might have caused the regression which still 
exists in 11.0.0-rc2. All test installers are available here: 
https://qemu.weilnetz.de/w64/2026/.

Regards
Stefan Weil

Re: [PATCH v22 02/18] ui/sdl2: Don't disable scanout when display is refreshed
Posted by Alex Bennée 4 days, 5 hours ago
Stefan Weil <sw@weilnetz.de> writes:

> Am 03.03.26 um 16:14 schrieb 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.
>> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
>> Acked-by: Michael S. Tsirkin <mst@redhat.com>
>> Tested-by: Alex Bennée <alex.bennee@linaro.org>
>> Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
>> Reviewed-by: Yiwei Zhang <zzyiwei@gmail.com>
>> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
>> ---
>>   ui/sdl2-gl.c | 1 -
>>   1 file changed, 1 deletion(-)
>> diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c
>> index 3be17d1079af..5eca0248233e 100644
>> --- a/ui/sdl2-gl.c
>> +++ b/ui/sdl2-gl.c
>> @@ -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);
>
> I got a user report that my latest QEMU for Windows no longer supports
> SDL. According to my own test, SDL still worked with git master
> (2026-03-07), but was broken with 11.0.0-rc0 (2026-03-18).

This is:

  https://gitlab.com/qemu-project/qemu/-/work_items/3347

Anthony should be posting a patch to the list soon.

>
> Therefore this patch series might have caused the regression which
> still exists in 11.0.0-rc2. All test installers are available here:
> https://qemu.weilnetz.de/w64/2026/.
>
> Regards
> Stefan Weil

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro
Re: [PATCH v22 02/18] ui/sdl2: Don't disable scanout when display is refreshed
Posted by Dmitry Osipenko 3 days, 9 hours ago
On 4/7/26 20:24, Alex Bennée wrote:
> Stefan Weil <sw@weilnetz.de> writes:
> 
>> Am 03.03.26 um 16:14 schrieb 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.
>>> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
>>> Acked-by: Michael S. Tsirkin <mst@redhat.com>
>>> Tested-by: Alex Bennée <alex.bennee@linaro.org>
>>> Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
>>> Reviewed-by: Yiwei Zhang <zzyiwei@gmail.com>
>>> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
>>> ---
>>>   ui/sdl2-gl.c | 1 -
>>>   1 file changed, 1 deletion(-)
>>> diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c
>>> index 3be17d1079af..5eca0248233e 100644
>>> --- a/ui/sdl2-gl.c
>>> +++ b/ui/sdl2-gl.c
>>> @@ -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);
>>
>> I got a user report that my latest QEMU for Windows no longer supports
>> SDL. According to my own test, SDL still worked with git master
>> (2026-03-07), but was broken with 11.0.0-rc0 (2026-03-18).
> 
> This is:
> 
>   https://gitlab.com/qemu-project/qemu/-/work_items/3347
> 
> Anthony should be posting a patch to the list soon.

Thanks a lot for handling the issue!

-- 
Best regards,
Dmitry