mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Louis Chauvet <louis.chauvet@bootlin.com>
To: "José Expósito" <jose.exposito89@gmail.com>
Cc: Haneen Mohammed <hamohammed.sa@gmail.com>,
	Simona Vetter <simona@ffwll.ch>,
	Melissa Wen <melissa.srw@gmail.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>,
	Jonathan Corbet <corbet@lwn.net>,
	victoria@system76.com, sebastian.wick@redhat.com,
	thomas.petazzoni@bootlin.com, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH RESEND v2 05/32] drm/vkms: Introduce config for plane name
Date: Mon, 17 Nov 2025 14:12:17 +0000	[thread overview]
Message-ID: <5da5b38f-1f34-4a1e-88a3-f7a90753e094@bootlin.com> (raw)
In-Reply-To: <aRXolNJJ5caay_H1@fedora>



On 11/13/25 14:17, José Expósito wrote:
> On Wed, Oct 29, 2025 at 03:36:42PM +0100, Louis Chauvet wrote:
>> As planes can have a name in DRM, prepare VKMS to configure it using
>> ConfigFS.
>>
>> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
>> ---
>>   drivers/gpu/drm/vkms/vkms_config.c |  4 ++++
>>   drivers/gpu/drm/vkms/vkms_config.h | 26 ++++++++++++++++++++++++++
>>   drivers/gpu/drm/vkms/vkms_drv.h    |  5 +++--
>>   drivers/gpu/drm/vkms/vkms_output.c |  6 +-----
>>   drivers/gpu/drm/vkms/vkms_plane.c  |  6 ++++--
>>   5 files changed, 38 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
>> index 858bec2d1312..bfafb5d2504d 100644
>> --- a/drivers/gpu/drm/vkms/vkms_config.c
>> +++ b/drivers/gpu/drm/vkms/vkms_config.c
>> @@ -352,6 +352,8 @@ static int vkms_config_show(struct seq_file *m, void *data)
>>   		seq_puts(m, "plane:\n");
>>   		seq_printf(m, "\ttype=%s\n",
>>   			   drm_get_plane_type_name(vkms_config_plane_get_type(plane_cfg)));
>> +		seq_printf(m, "\tname=%s\n",
>> +			   vkms_config_plane_get_name(plane_cfg));
> 
> I discovered this while working on some basic IGT tests to validate
> your changes.
> 
> I think that this triggers undefined behavior. printf() and friends
> expect a non NULL value for %s:
> https://stackoverflow.com/a/11589479
> 
> In my Fedora system, this prints "name=(null)", instead of an empty
> string.
> 
> The same happens with the ConfigFS API:
> 
> $ cat /sys/kernel/config/vkms/test_plane_default_values/planes/plane0/name
> (null)
> 
> We'd need to return in both places an empty string instead.

Good catch, I will fix for v3!

>>   	}
>>   
>>   	vkms_config_for_each_crtc(vkmsdev->config, crtc_cfg) {
>> @@ -392,6 +394,7 @@ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *config)
>>   
>>   	plane_cfg->config = config;
>>   	vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_OVERLAY);
>> +	vkms_config_plane_set_name(plane_cfg, NULL);
>>   	xa_init_flags(&plane_cfg->possible_crtcs, XA_FLAGS_ALLOC);
>>   
>>   	list_add_tail(&plane_cfg->link, &config->planes);
>> @@ -404,6 +407,7 @@ void vkms_config_destroy_plane(struct vkms_config_plane *plane_cfg)
>>   {
>>   	xa_destroy(&plane_cfg->possible_crtcs);
>>   	list_del(&plane_cfg->link);
>> +	kfree_const(plane_cfg->name);
>>   	kfree(plane_cfg);
>>   }
>>   EXPORT_SYMBOL_IF_KUNIT(vkms_config_destroy_plane);
>> diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
>> index 4c8d668e7ef8..57342db5795a 100644
>> --- a/drivers/gpu/drm/vkms/vkms_config.h
>> +++ b/drivers/gpu/drm/vkms/vkms_config.h
>> @@ -35,6 +35,7 @@ struct vkms_config {
>>    *
>>    * @link: Link to the others planes in vkms_config
>>    * @config: The vkms_config this plane belongs to
>> + * @name: Name of the plane
>>    * @type: Type of the plane. The creator of configuration needs to ensures that
>>    *        at least one primary plane is present.
>>    * @possible_crtcs: Array of CRTCs that can be used with this plane
>> @@ -47,6 +48,7 @@ struct vkms_config_plane {
>>   	struct list_head link;
>>   	struct vkms_config *config;
>>   
>> +	const char *name;
>>   	enum drm_plane_type type;
>>   	struct xarray possible_crtcs;
>>   
>> @@ -288,6 +290,30 @@ vkms_config_plane_set_type(struct vkms_config_plane *plane_cfg,
>>   	plane_cfg->type = type;
>>   }
>>   
>> +/**
>> + * vkms_config_plane_set_name() - Set the plane name
>> + * @plane_cfg: Plane to set the name to
>> + * @name: New plane name. The name is copied.
>> + */
>> +static inline void
>> +vkms_config_plane_set_name(struct vkms_config_plane *plane_cfg,
>> +			   const char *name)
>> +{
>> +	if (plane_cfg->name)
>> +		kfree_const(plane_cfg->name);
>> +	plane_cfg->name = kstrdup_const(name, GFP_KERNEL);
>> +}
>> +
>> +/**
>> + * vkms_config_plane_get_name - Get the plane name
>> + * @plane_cfg: Plane to get the name from
>> + */
>> +static inline const char *
>> +vkms_config_plane_get_name(const struct vkms_config_plane *plane_cfg)
>> +{
>> +	return plane_cfg->name;
>> +}
>> +
>>   /**
>>    * vkms_config_plane_attach_crtc - Attach a plane to a CRTC
>>    * @plane_cfg: Plane to attach
>> diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h
>> index db260df1d4f6..9ad286f043b5 100644
>> --- a/drivers/gpu/drm/vkms/vkms_drv.h
>> +++ b/drivers/gpu/drm/vkms/vkms_drv.h
>> @@ -225,6 +225,7 @@ struct vkms_output {
>>   };
>>   
>>   struct vkms_config;
>> +struct vkms_config_plane;
>>   
>>   /**
>>    * struct vkms_device - Description of a VKMS device
>> @@ -298,10 +299,10 @@ int vkms_output_init(struct vkms_device *vkmsdev);
>>    * vkms_plane_init() - Initialize a plane
>>    *
>>    * @vkmsdev: VKMS device containing the plane
>> - * @type: type of plane to initialize
>> + * @config: plane configuration
>>    */
>>   struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
>> -				   enum drm_plane_type type);
>> +				   struct vkms_config_plane *config);
>>   
>>   /* CRC Support */
>>   const char *const *vkms_get_crc_sources(struct drm_crtc *crtc,
>> diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c
>> index 2ee3749e2b28..22208d02afa4 100644
>> --- a/drivers/gpu/drm/vkms/vkms_output.c
>> +++ b/drivers/gpu/drm/vkms/vkms_output.c
>> @@ -19,11 +19,7 @@ int vkms_output_init(struct vkms_device *vkmsdev)
>>   		return -EINVAL;
>>   
>>   	vkms_config_for_each_plane(vkmsdev->config, plane_cfg) {
>> -		enum drm_plane_type type;
>> -
>> -		type = vkms_config_plane_get_type(plane_cfg);
>> -
>> -		plane_cfg->plane = vkms_plane_init(vkmsdev, type);
>> +		plane_cfg->plane = vkms_plane_init(vkmsdev, plane_cfg);
>>   		if (IS_ERR(plane_cfg->plane)) {
>>   			DRM_DEV_ERROR(dev->dev, "Failed to init vkms plane\n");
>>   			return PTR_ERR(plane_cfg->plane);
>> diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
>> index e592e47a5736..73180cbb78b1 100644
>> --- a/drivers/gpu/drm/vkms/vkms_plane.c
>> +++ b/drivers/gpu/drm/vkms/vkms_plane.c
>> @@ -9,6 +9,7 @@
>>   #include <drm/drm_gem_atomic_helper.h>
>>   #include <drm/drm_gem_framebuffer_helper.h>
>>   
>> +#include "vkms_config.h"
>>   #include "vkms_drv.h"
>>   #include "vkms_formats.h"
>>   
>> @@ -217,7 +218,7 @@ static const struct drm_plane_helper_funcs vkms_plane_helper_funcs = {
>>   };
>>   
>>   struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
>> -				   enum drm_plane_type type)
>> +				   struct vkms_config_plane *config)
>>   {
>>   	struct drm_device *dev = &vkmsdev->drm;
>>   	struct vkms_plane *plane;
>> @@ -225,7 +226,8 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
>>   	plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, 0,
>>   					   &vkms_plane_funcs,
>>   					   vkms_formats, ARRAY_SIZE(vkms_formats),
>> -					   NULL, type, NULL);
>> +					   NULL, vkms_config_plane_get_type(config),
>> +					   vkms_config_plane_get_name(config));
>>   	if (IS_ERR(plane))
>>   		return plane;
>>   
>>
>> -- 
>> 2.51.0
>>


  reply	other threads:[~2025-11-17 14:12 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-29 14:36 [PATCH RESEND v2 00/32] VKMS: Introduce multiple configFS attributes Louis Chauvet
2025-10-29 14:36 ` [PATCH RESEND v2 01/32] drm/drm_mode_config: Add helper to get plane type name Louis Chauvet
2025-11-13 14:06   ` José Expósito
2025-11-17 11:28     ` Louis Chauvet
2025-12-18 17:56   ` Luca Ceresoli
2025-10-29 14:36 ` [PATCH RESEND v2 02/32] drm/vkms: Explicitly display plane type Louis Chauvet
2025-11-13 14:07   ` José Expósito
2025-12-18 17:56   ` Luca Ceresoli
2025-10-29 14:36 ` [PATCH RESEND v2 03/32] drm/vkms: Use enabled/disabled instead of 1/0 for debug Louis Chauvet
2025-11-13 14:09   ` José Expósito
2025-12-18 17:57     ` Luca Ceresoli
2025-10-29 14:36 ` [PATCH RESEND v2 04/32] drm/vkms: Explicitly display connector status Louis Chauvet
2025-11-13 14:11   ` José Expósito
2025-12-18 17:56   ` Luca Ceresoli
2025-10-29 14:36 ` [PATCH RESEND v2 05/32] drm/vkms: Introduce config for plane name Louis Chauvet
2025-11-13 14:17   ` José Expósito
2025-11-17 14:12     ` Louis Chauvet [this message]
2025-10-29 14:36 ` [PATCH RESEND v2 06/32] drm/vkms: Introduce configfs " Louis Chauvet
2025-11-13 14:21   ` José Expósito
2025-11-17  9:56     ` Louis Chauvet
2025-12-18 17:58       ` Luca Ceresoli
2025-12-19 15:49         ` Louis Chauvet
2025-10-29 14:36 ` [PATCH RESEND v2 07/32] drm/blend: Get a rotation name from it's bitfield Louis Chauvet
2025-11-13 14:23   ` José Expósito
2025-12-18 17:58   ` Luca Ceresoli
2025-10-29 14:36 ` [PATCH RESEND v2 08/32] drm/vkms: Introduce config for plane rotation Louis Chauvet
2025-12-18 17:59   ` Luca Ceresoli
2025-10-29 14:36 ` [PATCH RESEND v2 09/32] drm/vkms: Introduce configfs " Louis Chauvet
2025-12-18 17:59   ` Luca Ceresoli
2025-10-29 14:36 ` [PATCH RESEND v2 10/32] drm/drm_color_mgmt: Expose drm_get_color_encoding_name Louis Chauvet
2025-12-18 17:59   ` Luca Ceresoli
2025-10-29 14:36 ` [PATCH RESEND v2 11/32] drm/vkms: Introduce config for plane color encoding Louis Chauvet
2025-12-18 17:59   ` Luca Ceresoli
2025-10-29 14:36 ` [PATCH RESEND v2 12/32] drm/vkms: Introduce configfs " Louis Chauvet
2025-12-18 17:59   ` Luca Ceresoli
2025-12-19 16:40     ` Louis Chauvet
2025-12-19 17:51       ` Louis Chauvet
2025-10-29 14:36 ` [PATCH RESEND v2 13/32] drm/drm_color_mgmt: Expose drm_get_color_range_name Louis Chauvet
2025-12-18 17:59   ` Luca Ceresoli
2025-10-29 14:36 ` [PATCH RESEND v2 14/32] drm/vkms: Introduce config for plane color range Louis Chauvet
2025-12-18 17:59   ` Luca Ceresoli
2025-10-29 14:36 ` [PATCH RESEND v2 15/32] drm/vkms: Introduce configfs " Louis Chauvet
2025-12-18 18:00   ` Luca Ceresoli
2025-12-19 16:55     ` Louis Chauvet
2025-10-29 14:36 ` [PATCH RESEND v2 16/32] drm/vkms: Introduce config for plane format Louis Chauvet
2025-12-19 14:55   ` Luca Ceresoli
2025-12-19 18:31     ` Louis Chauvet
2025-10-29 14:36 ` [PATCH RESEND v2 17/32] drm/vkms: Introduce configfs " Louis Chauvet
2025-12-19 17:07   ` Luca Ceresoli
2025-12-19 17:28     ` Louis Chauvet
2025-10-29 14:36 ` [PATCH RESEND v2 18/32] drm/vkms: Properly render plane using their zpos Louis Chauvet
2025-12-19 17:08   ` Luca Ceresoli
2025-10-29 14:36 ` [PATCH RESEND v2 19/32] drm/vkms: Introduce config for plane zpos property Louis Chauvet
2025-12-19 17:08   ` Luca Ceresoli
2025-10-29 14:36 ` [PATCH RESEND v2 20/32] drm/vkms: Introduce configfs " Louis Chauvet
2025-12-19 17:08   ` Luca Ceresoli
2025-10-29 14:36 ` [PATCH RESEND v2 21/32] drm/vkms: Introduce config for connector type Louis Chauvet
2025-12-19 17:08   ` Luca Ceresoli
2025-10-29 14:36 ` [PATCH RESEND v2 22/32] drm/vkms: Introduce configfs " Louis Chauvet
2025-12-19 17:08   ` Luca Ceresoli
2025-10-29 14:37 ` [PATCH RESEND v2 23/32] drm/connector: Export drm_get_colorspace_name Louis Chauvet
2025-12-19 17:08   ` Luca Ceresoli
2025-10-29 14:37 ` [PATCH RESEND v2 24/32] drm/vkms: Introduce config for connector supported colorspace Louis Chauvet
2025-12-19 17:08   ` Luca Ceresoli
2025-10-29 14:37 ` [PATCH RESEND v2 25/32] drm/vkms: Introduce configfs " Louis Chauvet
2025-12-19 18:56   ` Luca Ceresoli
2025-10-29 14:37 ` [PATCH RESEND v2 26/32] drm/vkms: Introduce config for connector EDID Louis Chauvet
2025-12-19 18:56   ` Luca Ceresoli
2025-10-29 14:37 ` [PATCH RESEND v2 27/32] drm/vkms: Introduce configfs " Louis Chauvet
2025-12-19 18:56   ` Luca Ceresoli
2025-10-29 14:37 ` [PATCH RESEND v2 28/32] drm/vkms: Store the enabled/disabled status for connector Louis Chauvet
2025-12-19 18:57   ` Luca Ceresoli
2025-10-29 14:37 ` [PATCH RESEND v2 29/32] drm/vkms: Rename vkms_connector_init to vkms_connector_init_static Louis Chauvet
2025-12-19 18:58   ` Luca Ceresoli
2025-12-19 19:11     ` Louis Chauvet
2025-12-19 20:47       ` Luca Ceresoli
2025-10-29 14:37 ` [PATCH RESEND v2 30/32] drm/vkms: Extract common code for connector initialization Louis Chauvet
2025-12-19 20:47   ` Luca Ceresoli
2025-10-29 14:37 ` [PATCH RESEND v2 31/32] drm/vkms: Allow to hot-add connectors Louis Chauvet
2025-12-19 20:47   ` Luca Ceresoli
2025-10-29 14:37 ` [PATCH RESEND v2 32/32] drm/vkms: Introduce configfs for dynamic connector creation Louis Chauvet
2025-12-19 20:47   ` Luca Ceresoli
2025-12-19 22:01     ` Louis Chauvet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5da5b38f-1f34-4a1e-88a3-f7a90753e094@bootlin.com \
    --to=louis.chauvet@bootlin.com \
    --cc=airlied@gmail.com \
    --cc=corbet@lwn.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hamohammed.sa@gmail.com \
    --cc=jose.exposito89@gmail.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=melissa.srw@gmail.com \
    --cc=mripard@kernel.org \
    --cc=sebastian.wick@redhat.com \
    --cc=simona@ffwll.ch \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=tzimmermann@suse.de \
    --cc=victoria@system76.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®