[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdX1ECG44BMOb5zK_N1cZCpjoKmms2p_80+_F72HH0NBEA@mail.gmail.com>
Date: Wed, 26 Jul 2023 14:04:13 +0200
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Javier Martinez Canillas <javierm@...hat.com>
Cc: linux-kernel@...r.kernel.org,
Thomas Zimmermann <tzimmermann@...e.de>,
Daniel Vetter <daniel.vetter@...ll.ch>,
Maxime Ripard <mripard@...nel.org>,
Daniel Vetter <daniel@...ll.ch>,
David Airlie <airlied@...il.com>,
dri-devel@...ts.freedesktop.org
Subject: Re: [PATCH v5 2/2] drm/ssd130x: Allocate buffer in the plane's
.atomic_check() callback
Hi Javier,
On Wed, Jul 26, 2023 at 12:55 PM Javier Martinez Canillas
<javierm@...hat.com> wrote:
> Drivers are not allowed to fail after drm_atomic_helper_swap_state() has
> been called and the new atomic state is stored into the current sw state.
>
> Since the struct ssd130x_device .data_array is allocated in the encoder's
> .atomic_enable callback, the operation can fail and this is after the new
> state has been stored. So it can break an atomic mode settings assumption.
>
> Fix this by having custom helpers to allocate, duplicate and destroy the
> plane state, that will take care of allocating and freeing these buffers.
>
> Suggested-by: Maxime Ripard <mripard@...nel.org>
> Signed-off-by: Javier Martinez Canillas <javierm@...hat.com>
> Acked-by: Maxime Ripard <mripard@...nel.org>
> Tested-by: Geert Uytterhoeven <geert@...ux-m68k.org>
> ---
>
> Changes in v5:
> - Add collected tags from Maxime and Geert.
> - Update commit message to not mention the kernel oops (Geert Uytterhoeven).
> - Drop Reported-by and Fixes tags (Geert Uytterhoeven).
> - Update comment about buffer and data_array fields (Geert Uytterhoeven).
> - Remove superfluous NULL check in ssd130x_fb_blit_rect() (Geert Uytterhoeven).
> - Reset .buffer to NULL if .data_array allocation fails (Geert Uytterhoeven).
> - Inline buffer alloc/free helper functions (Geert Uytterhoeven).
Thanks for the update!
> --- a/drivers/gpu/drm/solomon/ssd130x.c
> +++ b/drivers/gpu/drm/solomon/ssd130x.c
> @@ -535,7 +550,8 @@ static int ssd130x_update_rect(struct ssd130x_device *ssd130x, struct drm_rect *
> return ret;
> }
>
> -static void ssd130x_clear_screen(struct ssd130x_device *ssd130x)
> +static void ssd130x_clear_screen(struct ssd130x_device *ssd130x,
> + struct ssd130x_plane_state *ssd130x_state)
> {
> struct drm_rect fullscreen = {
> .x1 = 0,
> @@ -544,21 +560,21 @@ static void ssd130x_clear_screen(struct ssd130x_device *ssd130x)
> .y2 = ssd130x->height,
> };
>
> - ssd130x_update_rect(ssd130x, &fullscreen);
> + ssd130x_update_rect(ssd130x, ssd130x_state, &fullscreen);
I've just realized another issue: since 49d7d581ceaf4cf8 ("drm/ssd130x:
Don't allocate buffers on each plane update"). this no longer
clears the screens, but just updates the hardware with the data in
ssd130x_device.buffer, i.e. with the last image shown.
So this should at least clear all of ssd130x_device.buffer before
calling ssd130x_update_rect().
As it's a bit pointless to transpose a black image, a better fix would
be to just clear ssd130x.data_array, and call the low-level hardware
functions like ssd130x_update_rect() does.
> }
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Powered by blists - more mailing lists