[PATCH v1 1/2] ui/sdl2: Don't disable scanout when display is refreshed

Dmitry Osipenko posted 2 patches 1 month, 2 weeks ago
[PATCH v1 1/2] ui/sdl2: Don't disable scanout when display is refreshed
Posted by Dmitry Osipenko 1 month, 2 weeks 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.

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 e01d9ab0c7bf..4975d923db38 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.46.0
Re: [PATCH v1 1/2] ui/sdl2: Don't disable scanout when display is refreshed
Posted by Akihiko Odaki 1 month, 2 weeks ago
On 2024/10/07 8:43, Dmitry Osipenko wrote:
> 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 <dmitry.osipenko@collabora.com>

Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>

> ---
>   ui/sdl2-gl.c | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c
> index e01d9ab0c7bf..4975d923db38 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);
Re: [PATCH v1 1/2] ui/sdl2: Don't disable scanout when display is refreshed
Posted by Dmitry Osipenko 5 days, 6 hours ago
On 10/7/24 21:15, Akihiko Odaki wrote:
> On 2024/10/07 8:43, Dmitry Osipenko wrote:
>> 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 <dmitry.osipenko@collabora.com>
> 
> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> 
>> ---
>>   ui/sdl2-gl.c | 1 -
>>   1 file changed, 1 deletion(-)

Is anyone willing to apply this patchset? Maybe Alex? Thanks in advance!

-- 
Best regards,
Dmitry

Re: [PATCH v1 1/2] ui/sdl2: Don't disable scanout when display is refreshed
Posted by Bernhard Beschow 1 month, 2 weeks ago

Am 7. Oktober 2024 18:15:11 UTC schrieb Akihiko Odaki <akihiko.odaki@daynix.com>:
>On 2024/10/07 8:43, Dmitry Osipenko wrote:
>> 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 <dmitry.osipenko@collabora.com>
>
>Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>

Tested-by: Bernhard Beschow <shentey@gmail.com>

>
>> ---
>>   ui/sdl2-gl.c | 1 -
>>   1 file changed, 1 deletion(-)
>> 
>> diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c
>> index e01d9ab0c7bf..4975d923db38 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);
>
>