[PATCH 8/8] drm/ssd130x: Preallocate xfrm buffer in plane's atomic_check

Thomas Zimmermann tzimmermann at suse.de
Wed Sep 20 11:30:26 UTC 2023



Am 20.09.23 um 13:10 schrieb Thomas Zimmermann:
[...]
>   	if (!fi)
> @@ -619,6 +629,15 @@ static int ssd130x_primary_plane_helper_atomic_check(struct drm_plane *plane,
>   
>   	pitch = drm_format_info_min_pitch(fi, 0, ssd130x->width);
>   
> +	if (new_plane_state->fb->format != fi) {
> +		void *buf;
> +
> +		/* format conversion necessary; reserve buffer */
> +		buf = drm_xfrm_buf_reserve(&ssd130x->xfrm, pitch, GFP_KERNEL);
> +		if (!buf)
> +			return -ENOMEM;
> +	}

Grrr! Right in the moment I sent this patch, I realized that this code 
would run concurrently with atomic_update. Hence, it cannot realloc the 
temporary buffer.

I think drivers could also pre-allocate in the device's probe function 
after calling drmm_xfrm_buf_init(). It's just enough memory for a single 
scanline.


> +
>   	ssd130x_state->buffer = kcalloc(pitch, ssd130x->height, GFP_KERNEL);
>   	if (!ssd130x_state->buffer)
>   		return -ENOMEM;

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20230920/d915ab41/attachment.sig>


More information about the dri-devel mailing list