[PATCH v4 13/37] drm/vkms: Introduce config for plane name

Louis Chauvet
2026-04-22T16:49:29Z

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 | 11 +++++++++++
drivers/gpu/drm/vkms/vkms_config.h | 33 +++++++++++++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_plane.c | 3 ++-
3 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index 9071d6864d52..9dcac8af8d03 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -356,6 +356,9 @@ 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) ?
+ vkms_config_plane_get_name(plane_cfg) : "(null)");
}

vkms_config_for_each_crtc(vkmsdev->config, crtc_cfg) {
@@ -400,12 +403,19 @@ struct vkms_config_plane __must_check *vkms_config_create_plane(struct vkms_conf
plane_cfg->config = config;
plane_cfg->default_pipeline = false;
vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_OVERLAY);
+
+ ret = vkms_config_plane_set_name(plane_cfg, NULL);
+ if (ret)
+ goto cleanup_plane_cfg;
+
xa_init_flags(&plane_cfg->possible_crtcs, XA_FLAGS_ALLOC);

list_add_tail(&plane_cfg->link, &config->planes);

return plane_cfg;

+cleanup_plane_cfg:
+ kfree(plane_cfg);
fail:
return ERR_PTR(ret);
}
@@ -415,6 +425,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 8f7f286a4bdd..6fd921074203 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;
bool default_pipeline;
@@ -314,6 +316,37 @@ vkms_config_plane_set_default_pipeline(struct vkms_config_plane *plane_cfg,
plane_cfg->default_pipeline = default_pipeline;
}

+/**
+ * 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.
+ *
+ * Returns: -ENOMEM if the memory allocation failed, 0 in case of success
+ */
+static inline int __must_check
+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);
+
+ if (name && !plane_cfg->name)
+ return -ENOMEM;
+
+ return 0;
+}
+
+/**
+ * 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_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
index ca7aee101a95..71650c5c7b38 100644
--- a/drivers/gpu/drm/vkms/vkms_plane.c
+++ b/drivers/gpu/drm/vkms/vkms_plane.c
@@ -11,6 +11,7 @@
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_print.h>

+#include "vkms_config.h"
#include "vkms_drv.h"
#include "vkms_formats.h"

@@ -228,7 +229,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
&vkms_plane_funcs,
vkms_formats, ARRAY_SIZE(vkms_formats),
NULL, vkms_config_plane_get_type(plane_cfg),
- NULL);
+ vkms_config_plane_get_name(plane_cfg));
if (IS_ERR(plane))
return plane;

--
2.54.0