From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA0C333D6D4; Fri, 19 Dec 2025 14:55:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766156121; cv=none; b=upRfK6xgiWWPXzTwidHA3KrenXJSjXWyfw6Smoy8e5+a41tAz3Eb7nUknGT/OFnhsSS95lSh++kPvpHKPye77t19xBlAO9oeuyG2Jl6obAAxb28tcAlcfYocLNtEYrQxnjv5Q83pUyWTC0dCvbI9ZQr6ReIEyIgdsx3aKlS3GcQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766156121; c=relaxed/simple; bh=OpiQEgEi0WQX9tN4Wlnz3qHZlw3e0oUHYG+9HsjwIJg=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:Cc:To:From: References:In-Reply-To; b=e23LwOrcj/Ce7hej405GhQdVEfzgGRseKr7s4p5lf2UEwqNsYnxrMHDg0H1Jq4SzTp6fZtJx94DDvsMb3vM7rdMM0h03SkRJP3j8FFMWky+fwRFuA/gyrkd8a49nw8e74i1T3y7RKaHDgN2kzCkxgSz4lExykW+oP7HiLeR13n4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=rSZSLSSj; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="rSZSLSSj" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id DA13C4E41C87; Fri, 19 Dec 2025 14:55:14 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id AA7DD6071D; Fri, 19 Dec 2025 14:55:14 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 58568102F0B7F; Fri, 19 Dec 2025 15:55:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1766156110; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=GV9S+xc9D71Uwlbo2vNh/GdtKzweopawR08NIo0wto4=; b=rSZSLSSj61Ppq8s5mGApSpZT2fEpy5KklEyIXMQ7Z9kXpAN8YnfHpsq3dVgctjiKk3AAFq d/cQIW/kSKd89pVlQaxXtTt2ddv/67W29RJ+tjMWIwCjODjiN0Dlv/72H1V9Kl0aa9WINQ t08JcxDeU/m2WnXkNz7AaW1OVCm9EQr5CVvfoAizlmOocRtc/H+yljTe6HB1+9DiHCBiVA U6AUV55ome4WuGFMoSXBVMYFQrXWJ5SHTzHx38iG8Dn44QFbQBnsLBbk7tI7eFz/Bjm9rL Z2m98of2PcG109M9rL7WOWK1Akukb7j+U9cNTSeYsuLF64/Qr3b6RvtGe5iOUA== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 19 Dec 2025 15:55:03 +0100 Message-Id: Subject: Re: [PATCH RESEND v2 16/32] drm/vkms: Introduce config for plane format Cc: , , , , , To: "Louis Chauvet" , "Haneen Mohammed" , "Simona Vetter" , "Melissa Wen" , "Maarten Lankhorst" , "Maxime Ripard" , "Thomas Zimmermann" , "David Airlie" , , "Jonathan Corbet" From: "Luca Ceresoli" X-Mailer: aerc 0.20.1 References: <20251029-vkms-all-config-v2-0-a49a2d4cba26@bootlin.com> <20251029-vkms-all-config-v2-16-a49a2d4cba26@bootlin.com> In-Reply-To: <20251029-vkms-all-config-v2-16-a49a2d4cba26@bootlin.com> X-Last-TLS-Session-Version: TLSv1.3 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 > +int __must_check vkms_config_plane_add_format(struct vkms_config_plane *= plane_cfg, u32 drm_format) > +{ > + bool found =3D false; > + > + for (int i =3D 0; i < ARRAY_SIZE(vkms_supported_plane_formats); i++) { > + if (vkms_supported_plane_formats[i] =3D=3D drm_format) { > + found =3D true; > + break; > + } > + } > + > + if (!found) > + return -EINVAL; > + for (unsigned int i =3D 0; i < plane_cfg->supported_formats_count; i++)= { > + if (plane_cfg->supported_formats[i] =3D=3D drm_format) > + return 0; > + } > + u32 *new_ptr =3D 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 =3D new_ptr; > + plane_cfg->supported_formats[plane_cfg->supported_formats_count] =3D dr= m_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 pla= ne > + * @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 plan= e formats Luca -- Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com