lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1abba8b4-4eba-4a38-bb99-33c6181f9ff2@bootlin.com>
Date: Fri, 19 Dec 2025 19:31:09 +0100
From: Louis Chauvet <louis.chauvet@...tlin.com>
To: Luca Ceresoli <luca.ceresoli@...tlin.com>,
 Haneen Mohammed <hamohammed.sa@...il.com>, Simona Vetter <simona@...ll.ch>,
 Melissa Wen <melissa.srw@...il.com>,
 Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
 Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
 David Airlie <airlied@...il.com>, jose.exposito89@...il.com,
 Jonathan Corbet <corbet@....net>
Cc: victoria@...tem76.com, sebastian.wick@...hat.com,
 thomas.petazzoni@...tlin.com, dri-devel@...ts.freedesktop.org,
 linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org
Subject: Re: [PATCH RESEND v2 16/32] drm/vkms: Introduce config for plane
 format



On 12/19/25 15:55, Luca Ceresoli wrote:
> Hi Louis,
> 
> On Wed Oct 29, 2025 at 3:36 PM CET, Louis Chauvet wrote:
>> VKMS driver supports all the pixel formats for planes, but for testing it
>> can be useful to only advertise few of them. This new configuration
>> interface will allow configuring the pixel format per planes.
> 
> [...]
> 
>> Signed-off-by: Louis Chauvet <louis.chauvet@...tlin.com>
>> +int __must_check vkms_config_plane_add_format(struct vkms_config_plane *plane_cfg, u32 drm_format)
>> +{
>> +	bool found = false;
>> +
>> +	for (int i = 0; i < ARRAY_SIZE(vkms_supported_plane_formats); i++) {
>> +		if (vkms_supported_plane_formats[i] == drm_format) {
>> +			found = true;
>> +			break;
>> +		}
>> +	}
>> +
>> +	if (!found)
>> +		return -EINVAL;
>> +	for (unsigned int i = 0; i < plane_cfg->supported_formats_count; i++) {
>> +		if (plane_cfg->supported_formats[i] == drm_format)
>> +			return 0;
>> +	}
>> +	u32 *new_ptr = krealloc_array(plane_cfg->supported_formats,
>> +				      plane_cfg->supported_formats_count + 1,
>> +				      sizeof(*plane_cfg->supported_formats), GFP_KERNEL);
>> +	if (!new_ptr)
>> +		return -ENOMEM;
>> +
>> +	plane_cfg->supported_formats = new_ptr;
>> +	plane_cfg->supported_formats[plane_cfg->supported_formats_count] = drm_format;
>> +	plane_cfg->supported_formats_count++;
>> +
>> +	return 0;
>> +}
> 
> This whole logic appears quite complex for what you need here. I suspect
> using the facilities in linux/bitmap.h would make your code simpler by
> allocating a (multi-)ulong array of
> ARRAY_SIZE(vkms_supported_plane_formats) bits. This would surely use less
> memory and avoid all reallocations, too.

I agree this look complex, but I need an array anyway to interface with 
DRM core. If I use a bitmap, I would have to manage a mapping bit <=> 
fourcc value, which would not be really simpler I think.

I will simplify it a little bit by extracting some helpers for v2:

int __must_check vkms_config_plane_add_format(struct vkms_config_plane 
*plane_cfg, u32 drm_format) {
	if (!supported_format(drm_format))
		return -EINVAL;
	if (already_present(drm_format))
		return 0;
	new_ptr = krealloc
	[...]
}

If this is not sufficient, I will take a look at bitfield next year.

>> --- a/drivers/gpu/drm/vkms/vkms_config.h
>> +++ b/drivers/gpu/drm/vkms/vkms_config.h
> 
>> +/**
>> + * vkms_config_plane_remove_format - Remove a specific format from a plane
>> + * @plane_cfg: Plane to remove the format to
>> + * @drm_format: Format to remove
>> + */
>> +void vkms_config_plane_remove_format(struct vkms_config_plane *plane_cfg, u32 drm_format);
>> +
>> +/**
>> + * vkms_config_plane_remove_all_formats - Remove all formast from a plane
>                                                          formats
> 
> Luca
> 
> --
> Luca Ceresoli, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ