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 <[email protected]> > +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. > --- 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
