* [PATCH v7 01/43] drm/vkms: Lock the config dump against concurrent configfs changes
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
@ 2026-11-26 11:28 ` Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 02/43] drm/drm_mode_config: Add helper to get plane type name Louis Chauvet
` (41 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:28 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
The vkms_config debugfs dump iterates the configuration lists while
configfs can concurrently mutate or free them, which leads to a
use-after-free. Move the configuration lock into struct vkms_config and
run the dump under it.
Fixes: 64229b846a7e ("drm/vkms: Allow to attach connectors and encoders via configfs")
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/vkms_config.c | 74 +++++++++++++++++-------------
drivers/gpu/drm/vkms/vkms_config.h | 29 ++++++++++--
drivers/gpu/drm/vkms/vkms_configfs.c | 85 +++++++++++++++++++----------------
drivers/gpu/drm/vkms/vkms_connector.c | 6 ++-
4 files changed, 119 insertions(+), 75 deletions(-)
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index f9e30a4e5a3f..6699ddae7126 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -27,6 +27,7 @@ struct vkms_config *vkms_config_create(const char *dev_name)
INIT_LIST_HEAD(&config->crtcs);
INIT_LIST_HEAD(&config->encoders);
INIT_LIST_HEAD(&config->connectors);
+ mutex_init(&config->lock);
return config;
}
@@ -130,6 +131,7 @@ void vkms_config_destroy(struct vkms_config *config)
list_for_each_entry_safe(connector_cfg, connector_tmp, &config->connectors, link)
vkms_config_destroy_connector(connector_cfg);
+ mutex_destroy(&config->lock);
kfree_const(config->dev_name);
kfree(config);
}
@@ -348,28 +350,38 @@ static int vkms_config_show(struct seq_file *m, void *data)
struct vkms_config_encoder *encoder_cfg;
struct vkms_config_connector *connector_cfg;
- dev_name = vkms_config_get_device_name((struct vkms_config *)vkmsdev->config);
- seq_printf(m, "dev_name=%s\n", dev_name);
-
- vkms_config_for_each_plane(vkmsdev->config, plane_cfg) {
- seq_puts(m, "plane:\n");
- seq_printf(m, "\ttype=%d\n",
- vkms_config_plane_get_type(plane_cfg));
- }
+ /*
+ * The configuration lists are mutated by the configfs under the
+ * configuration lock. Walk them under RCU instead: mutations use
+ * list_{add,del}_rcu and free the objects after a grace period,
+ * so this reader holds no lock and cannot block the configfs
+ * paths (the disable path removes this file while holding the
+ * lock, and the debugfs removal waits for this reader to drain).
+ */
+ scoped_guard(rcu) {
+ dev_name = vkms_config_get_device_name((struct vkms_config *)vkmsdev->config);
+ seq_printf(m, "dev_name=%s\n", dev_name);
+
+ vkms_config_for_each_plane(vkmsdev->config, plane_cfg) {
+ seq_puts(m, "plane:\n");
+ seq_printf(m, "\ttype=%d\n",
+ vkms_config_plane_get_type(plane_cfg));
+ }
- vkms_config_for_each_crtc(vkmsdev->config, crtc_cfg) {
- seq_puts(m, "crtc:\n");
- seq_printf(m, "\twriteback=%d\n",
- vkms_config_crtc_get_writeback(crtc_cfg));
- }
+ vkms_config_for_each_crtc(vkmsdev->config, crtc_cfg) {
+ seq_puts(m, "crtc:\n");
+ seq_printf(m, "\twriteback=%d\n",
+ vkms_config_crtc_get_writeback(crtc_cfg));
+ }
- vkms_config_for_each_encoder(vkmsdev->config, encoder_cfg)
- seq_puts(m, "encoder\n");
+ vkms_config_for_each_encoder(vkmsdev->config, encoder_cfg)
+ seq_puts(m, "encoder\n");
- vkms_config_for_each_connector(vkmsdev->config, connector_cfg) {
- seq_puts(m, "connector:\n");
- seq_printf(m, "\tstatus=%s\n",
- drm_get_connector_status_name(vkms_config_connector_get_status(connector_cfg)));
+ vkms_config_for_each_connector(vkmsdev->config, connector_cfg) {
+ seq_puts(m, "connector:\n");
+ seq_printf(m, "\tstatus=%s\n",
+ drm_get_connector_status_name(vkms_config_connector_get_status(connector_cfg)));
+ }
}
return 0;
@@ -398,7 +410,7 @@ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *config)
vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_OVERLAY);
xa_init_flags(&plane_cfg->possible_crtcs, XA_FLAGS_ALLOC);
- list_add_tail(&plane_cfg->link, &config->planes);
+ list_add_tail_rcu(&plane_cfg->link, &config->planes);
return plane_cfg;
}
@@ -407,8 +419,8 @@ EXPORT_SYMBOL_IF_KUNIT(vkms_config_create_plane);
void vkms_config_destroy_plane(struct vkms_config_plane *plane_cfg)
{
xa_destroy(&plane_cfg->possible_crtcs);
- list_del(&plane_cfg->link);
- kfree(plane_cfg);
+ list_del_rcu(&plane_cfg->link);
+ kfree_rcu(plane_cfg, rcu);
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_destroy_plane);
@@ -456,7 +468,7 @@ struct vkms_config_crtc *vkms_config_create_crtc(struct vkms_config *config)
crtc_cfg->config = config;
vkms_config_crtc_set_writeback(crtc_cfg, false);
- list_add_tail(&crtc_cfg->link, &config->crtcs);
+ list_add_tail_rcu(&crtc_cfg->link, &config->crtcs);
return crtc_cfg;
}
@@ -474,8 +486,8 @@ void vkms_config_destroy_crtc(struct vkms_config *config,
vkms_config_for_each_encoder(config, encoder_cfg)
vkms_config_encoder_detach_crtc(encoder_cfg, crtc_cfg);
- list_del(&crtc_cfg->link);
- kfree(crtc_cfg);
+ list_del_rcu(&crtc_cfg->link);
+ kfree_rcu(crtc_cfg, rcu);
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_destroy_crtc);
@@ -535,7 +547,7 @@ struct vkms_config_encoder *vkms_config_create_encoder(struct vkms_config *confi
encoder_cfg->config = config;
xa_init_flags(&encoder_cfg->possible_crtcs, XA_FLAGS_ALLOC);
- list_add_tail(&encoder_cfg->link, &config->encoders);
+ list_add_tail_rcu(&encoder_cfg->link, &config->encoders);
return encoder_cfg;
}
@@ -550,8 +562,8 @@ void vkms_config_destroy_encoder(struct vkms_config *config,
vkms_config_connector_detach_encoder(connector_cfg, encoder_cfg);
xa_destroy(&encoder_cfg->possible_crtcs);
- list_del(&encoder_cfg->link);
- kfree(encoder_cfg);
+ list_del_rcu(&encoder_cfg->link);
+ kfree_rcu(encoder_cfg, rcu);
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_destroy_encoder);
@@ -600,7 +612,7 @@ struct vkms_config_connector *vkms_config_create_connector(struct vkms_config *c
connector_cfg->status = connector_status_connected;
xa_init_flags(&connector_cfg->possible_encoders, XA_FLAGS_ALLOC);
- list_add_tail(&connector_cfg->link, &config->connectors);
+ list_add_tail_rcu(&connector_cfg->link, &config->connectors);
return connector_cfg;
}
@@ -609,8 +621,8 @@ EXPORT_SYMBOL_IF_KUNIT(vkms_config_create_connector);
void vkms_config_destroy_connector(struct vkms_config_connector *connector_cfg)
{
xa_destroy(&connector_cfg->possible_encoders);
- list_del(&connector_cfg->link);
- kfree(connector_cfg);
+ list_del_rcu(&connector_cfg->link);
+ kfree_rcu(connector_cfg, rcu);
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_destroy_connector);
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index 56805b0c9b14..125273f67e7d 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -4,6 +4,8 @@
#define _VKMS_CONFIG_H_
#include <linux/list.h>
+#include <linux/rculist.h>
+#include <linux/mutex.h>
#include <linux/types.h>
#include <linux/xarray.h>
@@ -19,6 +21,8 @@
* @crtcs: List of CRTCs configured for the device
* @encoders: List of encoders configured for the device
* @connectors: List of connectors configured for the device
+ * @lock: Protects the whole configuration (lists and item fields) against
+ * concurrent access from the configfs, debugfs and DRM paths
* @dev: Used to store the current VKMS device. Only set when the device is instantiated.
*/
struct vkms_config {
@@ -27,6 +31,7 @@ struct vkms_config {
struct list_head crtcs;
struct list_head encoders;
struct list_head connectors;
+ struct mutex lock;
struct vkms_device *dev;
};
@@ -34,6 +39,7 @@ struct vkms_config {
* struct vkms_config_plane
*
* @link: Link to the others planes in vkms_config
+ * @rcu: RCU head for deferred freeing of this object
* @config: The vkms_config this plane belongs to
* @type: Type of the plane. The creator of configuration needs to ensures that
* at least one primary plane is present.
@@ -45,6 +51,7 @@ struct vkms_config {
*/
struct vkms_config_plane {
struct list_head link;
+ struct rcu_head rcu;
struct vkms_config *config;
enum drm_plane_type type;
@@ -59,6 +66,7 @@ struct vkms_config_plane {
* struct vkms_config_crtc
*
* @link: Link to the others CRTCs in vkms_config
+ * @rcu: RCU head for deferred freeing of this object
* @config: The vkms_config this CRTC belongs to
* @writeback: If true, a writeback buffer can be attached to the CRTC
* @crtc: Internal usage. This pointer should never be considered as valid.
@@ -68,6 +76,7 @@ struct vkms_config_plane {
*/
struct vkms_config_crtc {
struct list_head link;
+ struct rcu_head rcu;
struct vkms_config *config;
bool writeback;
@@ -80,6 +89,7 @@ struct vkms_config_crtc {
* struct vkms_config_encoder
*
* @link: Link to the others encoders in vkms_config
+ * @rcu: RCU head for deferred freeing of this object
* @config: The vkms_config this CRTC belongs to
* @possible_crtcs: Array of CRTCs that can be used with this encoder
* @encoder: Internal usage. This pointer should never be considered as valid.
@@ -89,6 +99,7 @@ struct vkms_config_crtc {
*/
struct vkms_config_encoder {
struct list_head link;
+ struct rcu_head rcu;
struct vkms_config *config;
struct xarray possible_crtcs;
@@ -101,6 +112,7 @@ struct vkms_config_encoder {
* struct vkms_config_connector
*
* @link: Link to the others connector in vkms_config
+ * @rcu: RCU head for deferred freeing of this object
* @config: The vkms_config this connector belongs to
* @status: Status (connected, disconnected...) of the connector
* @possible_encoders: Array of encoders that can be used with this connector
@@ -111,6 +123,7 @@ struct vkms_config_encoder {
*/
struct vkms_config_connector {
struct list_head link;
+ struct rcu_head rcu;
struct vkms_config *config;
enum drm_connector_status status;
@@ -126,7 +139,9 @@ struct vkms_config_connector {
* @plane_cfg: &struct vkms_config_plane pointer used as cursor
*/
#define vkms_config_for_each_plane(config, plane_cfg) \
- list_for_each_entry((plane_cfg), &(config)->planes, link)
+ list_for_each_entry_rcu((plane_cfg), &(config)->planes, link, \
+ lockdep_is_held(&(config)->lock) || \
+ !(config)->dev)
/**
* vkms_config_for_each_crtc - Iterate over the vkms_config CRTCs
@@ -134,7 +149,9 @@ struct vkms_config_connector {
* @crtc_cfg: &struct vkms_config_crtc pointer used as cursor
*/
#define vkms_config_for_each_crtc(config, crtc_cfg) \
- list_for_each_entry((crtc_cfg), &(config)->crtcs, link)
+ list_for_each_entry_rcu((crtc_cfg), &(config)->crtcs, link, \
+ lockdep_is_held(&(config)->lock) || \
+ !(config)->dev)
/**
* vkms_config_for_each_encoder - Iterate over the vkms_config encoders
@@ -142,7 +159,9 @@ struct vkms_config_connector {
* @encoder_cfg: &struct vkms_config_encoder pointer used as cursor
*/
#define vkms_config_for_each_encoder(config, encoder_cfg) \
- list_for_each_entry((encoder_cfg), &(config)->encoders, link)
+ list_for_each_entry_rcu((encoder_cfg), &(config)->encoders, link, \
+ lockdep_is_held(&(config)->lock) || \
+ !(config)->dev)
/**
* vkms_config_for_each_connector - Iterate over the vkms_config connectors
@@ -150,7 +169,9 @@ struct vkms_config_connector {
* @connector_cfg: &struct vkms_config_connector pointer used as cursor
*/
#define vkms_config_for_each_connector(config, connector_cfg) \
- list_for_each_entry((connector_cfg), &(config)->connectors, link)
+ list_for_each_entry_rcu((connector_cfg), &(config)->connectors, link, \
+ lockdep_is_held(&(config)->lock) || \
+ !(config)->dev)
/**
* vkms_config_plane_for_each_possible_crtc - Iterate over the vkms_config_plane
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index af097967ca6f..6bb24f5835db 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -21,10 +21,9 @@ static bool is_configfs_registered;
* @crtcs_group: Default subgroup of @group at "/config/vkms/crtcs"
* @encoders_group: Default subgroup of @group at "/config/vkms/encoders"
* @connectors_group: Default subgroup of @group at "/config/vkms/connectors"
- * @lock: Lock used to project concurrent access to the configuration attributes
- * @config: Protected by @lock. Configuration of the VKMS device
- * @enabled: Protected by @lock. The device is created or destroyed when this
- * option changes
+ * @config: Configuration of the VKMS device. Its @lock field protects it
+ * against concurrent access
+ * @enabled: The device is created or destroyed when this option changes
*/
struct vkms_configfs_device {
struct config_group group;
@@ -33,7 +32,6 @@ struct vkms_configfs_device {
struct config_group encoders_group;
struct config_group connectors_group;
- struct mutex lock;
struct vkms_config *config;
bool enabled;
};
@@ -141,7 +139,7 @@ static ssize_t crtc_writeback_show(struct config_item *item, char *page)
crtc = crtc_item_to_vkms_configfs_crtc(item);
- scoped_guard(mutex, &crtc->dev->lock)
+ scoped_guard(mutex, &crtc->dev->config->lock)
writeback = vkms_config_crtc_get_writeback(crtc->config);
return sprintf(page, "%d\n", writeback);
@@ -158,7 +156,7 @@ static ssize_t crtc_writeback_store(struct config_item *item, const char *page,
if (kstrtobool(page, &writeback))
return -EINVAL;
- scoped_guard(mutex, &crtc->dev->lock) {
+ scoped_guard(mutex, &crtc->dev->config->lock) {
if (crtc->dev->enabled)
return -EBUSY;
@@ -181,7 +179,7 @@ static void crtc_release(struct config_item *item)
struct mutex *lock;
crtc = crtc_item_to_vkms_configfs_crtc(item);
- lock = &crtc->dev->lock;
+ lock = &crtc->dev->config->lock;
scoped_guard(mutex, lock) {
vkms_config_destroy_crtc(crtc->dev->config, crtc->config);
@@ -208,7 +206,7 @@ static struct config_group *make_crtc_group(struct config_group *group,
dev = child_group_to_vkms_configfs_device(group);
- scoped_guard(mutex, &dev->lock) {
+ scoped_guard(mutex, &dev->config->lock) {
if (dev->enabled)
return ERR_PTR(-EBUSY);
@@ -253,7 +251,7 @@ static int plane_possible_crtcs_allow_link(struct config_item *src,
plane = plane_possible_crtcs_item_to_vkms_configfs_plane(src);
crtc = crtc_item_to_vkms_configfs_crtc(target);
- scoped_guard(mutex, &plane->dev->lock) {
+ scoped_guard(mutex, &plane->dev->config->lock) {
if (plane->dev->enabled)
return -EBUSY;
@@ -272,7 +270,7 @@ static void plane_possible_crtcs_drop_link(struct config_item *src,
plane = plane_possible_crtcs_item_to_vkms_configfs_plane(src);
crtc = crtc_item_to_vkms_configfs_crtc(target);
- scoped_guard(mutex, &plane->dev->lock)
+ scoped_guard(mutex, &plane->dev->config->lock)
vkms_config_plane_detach_crtc(plane->config, crtc->config);
}
@@ -293,7 +291,7 @@ static ssize_t plane_type_show(struct config_item *item, char *page)
plane = plane_item_to_vkms_configfs_plane(item);
- scoped_guard(mutex, &plane->dev->lock)
+ scoped_guard(mutex, &plane->dev->config->lock)
type = vkms_config_plane_get_type(plane->config);
return sprintf(page, "%u\n", type);
@@ -314,7 +312,7 @@ static ssize_t plane_type_store(struct config_item *item, const char *page,
type != DRM_PLANE_TYPE_CURSOR)
return -EINVAL;
- scoped_guard(mutex, &plane->dev->lock) {
+ scoped_guard(mutex, &plane->dev->config->lock) {
if (plane->dev->enabled)
return -EBUSY;
@@ -337,7 +335,7 @@ static void plane_release(struct config_item *item)
struct mutex *lock;
plane = plane_item_to_vkms_configfs_plane(item);
- lock = &plane->dev->lock;
+ lock = &plane->dev->config->lock;
scoped_guard(mutex, lock) {
vkms_config_destroy_plane(plane->config);
@@ -364,7 +362,7 @@ static struct config_group *make_plane_group(struct config_group *group,
dev = child_group_to_vkms_configfs_device(group);
- scoped_guard(mutex, &dev->lock) {
+ scoped_guard(mutex, &dev->config->lock) {
if (dev->enabled)
return ERR_PTR(-EBUSY);
@@ -415,7 +413,7 @@ static int encoder_possible_crtcs_allow_link(struct config_item *src,
encoder = encoder_possible_crtcs_item_to_vkms_configfs_encoder(src);
crtc = crtc_item_to_vkms_configfs_crtc(target);
- scoped_guard(mutex, &encoder->dev->lock) {
+ scoped_guard(mutex, &encoder->dev->config->lock) {
if (encoder->dev->enabled)
return -EBUSY;
@@ -434,7 +432,7 @@ static void encoder_possible_crtcs_drop_link(struct config_item *src,
encoder = encoder_possible_crtcs_item_to_vkms_configfs_encoder(src);
crtc = crtc_item_to_vkms_configfs_crtc(target);
- scoped_guard(mutex, &encoder->dev->lock)
+ scoped_guard(mutex, &encoder->dev->config->lock)
vkms_config_encoder_detach_crtc(encoder->config, crtc->config);
}
@@ -454,7 +452,7 @@ static void encoder_release(struct config_item *item)
struct mutex *lock;
encoder = encoder_item_to_vkms_configfs_encoder(item);
- lock = &encoder->dev->lock;
+ lock = &encoder->dev->config->lock;
scoped_guard(mutex, lock) {
vkms_config_destroy_encoder(encoder->dev->config, encoder->config);
@@ -480,7 +478,7 @@ static struct config_group *make_encoder_group(struct config_group *group,
dev = child_group_to_vkms_configfs_device(group);
- scoped_guard(mutex, &dev->lock) {
+ scoped_guard(mutex, &dev->config->lock) {
if (dev->enabled)
return ERR_PTR(-EBUSY);
@@ -526,7 +524,7 @@ static ssize_t connector_status_show(struct config_item *item, char *page)
connector = connector_item_to_vkms_configfs_connector(item);
- scoped_guard(mutex, &connector->dev->lock)
+ scoped_guard(mutex, &connector->dev->config->lock)
status = vkms_config_connector_get_status(connector->config);
return sprintf(page, "%u\n", status);
@@ -548,7 +546,7 @@ static ssize_t connector_status_store(struct config_item *item,
status != connector_status_unknown)
return -EINVAL;
- scoped_guard(mutex, &connector->dev->lock) {
+ scoped_guard(mutex, &connector->dev->config->lock) {
vkms_config_connector_set_status(connector->config, status);
if (connector->dev->enabled)
@@ -571,7 +569,7 @@ static void connector_release(struct config_item *item)
struct mutex *lock;
connector = connector_item_to_vkms_configfs_connector(item);
- lock = &connector->dev->lock;
+ lock = &connector->dev->config->lock;
scoped_guard(mutex, lock) {
vkms_config_destroy_connector(connector->config);
@@ -602,7 +600,7 @@ static int connector_possible_encoders_allow_link(struct config_item *src,
connector = connector_possible_encoders_item_to_vkms_configfs_connector(src);
encoder = encoder_item_to_vkms_configfs_encoder(target);
- scoped_guard(mutex, &connector->dev->lock) {
+ scoped_guard(mutex, &connector->dev->config->lock) {
if (connector->dev->enabled)
return -EBUSY;
@@ -622,7 +620,7 @@ static void connector_possible_encoders_drop_link(struct config_item *src,
connector = connector_possible_encoders_item_to_vkms_configfs_connector(src);
encoder = encoder_item_to_vkms_configfs_encoder(target);
- scoped_guard(mutex, &connector->dev->lock) {
+ scoped_guard(mutex, &connector->dev->config->lock) {
vkms_config_connector_detach_encoder(connector->config,
encoder->config);
}
@@ -647,7 +645,7 @@ static struct config_group *make_connector_group(struct config_group *group,
dev = child_group_to_vkms_configfs_device(group);
- scoped_guard(mutex, &dev->lock) {
+ scoped_guard(mutex, &dev->config->lock) {
if (dev->enabled)
return ERR_PTR(-EBUSY);
@@ -693,7 +691,7 @@ static ssize_t device_enabled_show(struct config_item *item, char *page)
dev = device_item_to_vkms_configfs_device(item);
- scoped_guard(mutex, &dev->lock)
+ scoped_guard(mutex, &dev->config->lock)
enabled = dev->enabled;
return sprintf(page, "%d\n", enabled);
@@ -711,21 +709,34 @@ static ssize_t device_enabled_store(struct config_item *item, const char *page,
if (kstrtobool(page, &enabled))
return -EINVAL;
- scoped_guard(mutex, &dev->lock) {
- if (!dev->enabled && enabled) {
- if (!vkms_config_is_valid(dev->config))
- return -EINVAL;
+ scoped_guard(mutex, &dev->config->lock) {
+ if (dev->enabled == enabled)
+ return (ssize_t)count;
- ret = vkms_create(dev->config);
- if (ret)
- return ret;
- } else if (dev->enabled && !enabled) {
- vkms_destroy(dev->config);
- }
+ if (!dev->enabled && !vkms_config_is_valid(dev->config))
+ return -EINVAL;
dev->enabled = enabled;
}
+ /*
+ * Do not hold config->lock while creating/destroying the device:
+ * vkms_destroy() unregisters the DRM device, which removes the
+ * vkms_config debugfs file and waits for its readers to drain, and
+ * vkms_connector_detect() takes config->lock to read the connector
+ * status.
+ */
+ if (enabled) {
+ ret = vkms_create(dev->config);
+ if (ret) {
+ scoped_guard(mutex, &dev->config->lock)
+ dev->enabled = false;
+ return ret;
+ }
+ } else {
+ vkms_destroy(dev->config);
+ }
+
return (ssize_t)count;
}
@@ -745,7 +756,6 @@ static void device_release(struct config_item *item)
if (dev->enabled)
vkms_destroy(dev->config);
- mutex_destroy(&dev->lock);
vkms_config_destroy(dev->config);
kfree(dev);
}
@@ -781,7 +791,6 @@ static struct config_group *make_device_group(struct config_group *group,
}
config_group_init_type_name(&dev->group, name, &device_item_type);
- mutex_init(&dev->lock);
config_group_init_type_name(&dev->planes_group, "planes",
&plane_group_type);
diff --git a/drivers/gpu/drm/vkms/vkms_connector.c b/drivers/gpu/drm/vkms/vkms_connector.c
index 57138027966f..080a0240d5e9 100644
--- a/drivers/gpu/drm/vkms/vkms_connector.c
+++ b/drivers/gpu/drm/vkms/vkms_connector.c
@@ -27,8 +27,10 @@ static enum drm_connector_status vkms_connector_detect(struct drm_connector *con
status = connector->status;
vkms_config_for_each_connector(vkmsdev->config, connector_cfg) {
- if (connector_cfg->connector == vkms_connector)
- status = vkms_config_connector_get_status(connector_cfg);
+ if (connector_cfg->connector == vkms_connector) {
+ scoped_guard(mutex, &vkmsdev->config->lock)
+ status = vkms_config_connector_get_status(connector_cfg);
+ }
}
return status;
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 02/43] drm/drm_mode_config: Add helper to get plane type name
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 01/43] drm/vkms: Lock the config dump against concurrent configfs changes Louis Chauvet
@ 2026-11-26 11:28 ` Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 03/43] drm/blend: Get a rotation name from its bitfield Louis Chauvet
` (40 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:28 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm,
José Expósito
Create and export a helper to display plane type using the property
string. This could be used to display debug information in VKMS.
Reviewed-by: José Expósito <jose.exposito@redhat.com>
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/drm_mode_config.c | 16 ++++++++++++++++
include/drm/drm_mode_config.h | 3 +++
2 files changed, 19 insertions(+)
diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index c1e993a78702..0d814424c698 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -419,6 +419,22 @@ static const struct drm_prop_enum_list drm_plane_type_enum_list[] = {
{ DRM_PLANE_TYPE_CURSOR, "Cursor" },
};
+/**
+ * drm_get_plane_type_name - return a string for plane type name
+ * @type: plane type to compute name of
+ *
+ * Returns: The name of the plane type. "(unknown)" if type is not a known
+ * plane type.
+ */
+const char *drm_get_plane_type_name(enum drm_plane_type type)
+{
+ if (type >= 0 && type < ARRAY_SIZE(drm_plane_type_enum_list))
+ return drm_plane_type_enum_list[type].name;
+ else
+ return "(unknown)";
+}
+EXPORT_SYMBOL(drm_get_plane_type_name);
+
static int drm_mode_create_standard_properties(struct drm_device *dev)
{
struct drm_property *prop;
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index 084517beb924..545a5b684acc 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -30,6 +30,7 @@
#include <linux/llist.h>
#include <drm/drm_modeset_lock.h>
+#include <drm/drm_plane.h>
struct drm_file;
struct drm_device;
@@ -1011,4 +1012,6 @@ int drm_mode_config_create_initial_state(struct drm_device *dev);
void drm_mode_config_reset(struct drm_device *dev);
void drm_mode_config_cleanup(struct drm_device *dev);
+const char *drm_get_plane_type_name(enum drm_plane_type type);
+
#endif
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 03/43] drm/blend: Get a rotation name from its bitfield
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 01/43] drm/vkms: Lock the config dump against concurrent configfs changes Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 02/43] drm/drm_mode_config: Add helper to get plane type name Louis Chauvet
@ 2026-11-26 11:28 ` Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 04/43] drm/tests: Add test cases for DRM rotation name Louis Chauvet
` (39 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:28 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
Extract the rotation/reflection name table and expose the
DRM_ROTATION_FMT()/DRM_ROTATION_FMT_ARGS() helpers to print a
human-readable rotation mask.
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/drm_blend.c | 19 ++++++++++---------
include/drm/drm_blend.h | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c
index d17ae964fb21..b62f1db9c311 100644
--- a/drivers/gpu/drm/drm_blend.c
+++ b/drivers/gpu/drm/drm_blend.c
@@ -256,6 +256,15 @@ int drm_plane_create_alpha_property(struct drm_plane *plane)
}
EXPORT_SYMBOL(drm_plane_create_alpha_property);
+static const struct drm_prop_enum_list rotation_props[] = {
+ { __builtin_ffs(DRM_MODE_ROTATE_0) - 1, "rotate-0" },
+ { __builtin_ffs(DRM_MODE_ROTATE_90) - 1, "rotate-90" },
+ { __builtin_ffs(DRM_MODE_ROTATE_180) - 1, "rotate-180" },
+ { __builtin_ffs(DRM_MODE_ROTATE_270) - 1, "rotate-270" },
+ { __builtin_ffs(DRM_MODE_REFLECT_X) - 1, "reflect-x" },
+ { __builtin_ffs(DRM_MODE_REFLECT_Y) - 1, "reflect-y" },
+};
+
/**
* drm_plane_create_rotation_property - create a new rotation property
* @plane: drm plane
@@ -294,14 +303,6 @@ int drm_plane_create_rotation_property(struct drm_plane *plane,
unsigned int rotation,
unsigned int supported_rotations)
{
- static const struct drm_prop_enum_list props[] = {
- { __builtin_ffs(DRM_MODE_ROTATE_0) - 1, "rotate-0" },
- { __builtin_ffs(DRM_MODE_ROTATE_90) - 1, "rotate-90" },
- { __builtin_ffs(DRM_MODE_ROTATE_180) - 1, "rotate-180" },
- { __builtin_ffs(DRM_MODE_ROTATE_270) - 1, "rotate-270" },
- { __builtin_ffs(DRM_MODE_REFLECT_X) - 1, "reflect-x" },
- { __builtin_ffs(DRM_MODE_REFLECT_Y) - 1, "reflect-y" },
- };
struct drm_property *prop;
WARN_ON((supported_rotations & DRM_MODE_ROTATE_MASK) == 0);
@@ -309,7 +310,7 @@ int drm_plane_create_rotation_property(struct drm_plane *plane,
WARN_ON(rotation & ~supported_rotations);
prop = drm_property_create_bitmask(plane->dev, 0, "rotation",
- props, ARRAY_SIZE(props),
+ rotation_props, ARRAY_SIZE(rotation_props),
supported_rotations);
if (!prop)
return -ENOMEM;
diff --git a/include/drm/drm_blend.h b/include/drm/drm_blend.h
index bebbb77a8f21..f000b10a16e7 100644
--- a/include/drm/drm_blend.h
+++ b/include/drm/drm_blend.h
@@ -43,6 +43,40 @@ static inline bool drm_rotation_90_or_270(unsigned int rotation)
#define DRM_BLEND_ALPHA_OPAQUE 0xffff
+/**
+ * DRM_ROTATION_FMT - printf format string describing a rotation bitmask
+ *
+ * To be used together with DRM_ROTATION_FMT_ARGS(), e.g.:
+ *
+ * seq_printf(m, "rotation=" DRM_ROTATION_FMT "\n",
+ * DRM_ROTATION_FMT_ARGS(state->rotation));
+ *
+ * The result names every set bit, separated by single spaces, and ends
+ * with the raw value in parentheses, e.g.:
+ *
+ * rotate-90 reflect-x (0x00000012)
+ *
+ * The trailing raw value ensures the output is never empty and never
+ * ends with a space, even when no bit is set.
+ */
+#define DRM_ROTATION_FMT "%s%s%s%s%s%s(0x%08x)"
+
+/**
+ * DRM_ROTATION_FMT_ARGS - printf arguments for DRM_ROTATION_FMT
+ * @rot: rotation bitmask (DRM_MODE_ROTATE_* | DRM_MODE_REFLECT_*)
+ *
+ * Evaluates @rot several times: only pass a variable or an expression
+ * without side effects.
+ */
+#define DRM_ROTATION_FMT_ARGS(rot) \
+ ((rot) & DRM_MODE_ROTATE_0) ? "rotate-0 " : "", \
+ ((rot) & DRM_MODE_ROTATE_90) ? "rotate-90 " : "", \
+ ((rot) & DRM_MODE_ROTATE_180) ? "rotate-180 " : "", \
+ ((rot) & DRM_MODE_ROTATE_270) ? "rotate-270 " : "", \
+ ((rot) & DRM_MODE_REFLECT_X) ? "reflect-x " : "", \
+ ((rot) & DRM_MODE_REFLECT_Y) ? "reflect-y " : "", \
+ (rot)
+
int drm_plane_create_alpha_property(struct drm_plane *plane);
int drm_plane_create_rotation_property(struct drm_plane *plane,
unsigned int rotation,
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 04/43] drm/tests: Add test cases for DRM rotation name
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (2 preceding siblings ...)
2026-11-26 11:28 ` [PATCH v7 03/43] drm/blend: Get a rotation name from its bitfield Louis Chauvet
@ 2026-11-26 11:28 ` Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 05/43] drm/drm_color_mgmt: Expose drm_get_color_encoding_name Louis Chauvet
` (38 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:28 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
Verify the DRM_ROTATION_FMT()/DRM_ROTATION_FMT_ARGS() helpers.
Tested-by: Oarora Etimis <oaroraetimis@gmail.com>
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/tests/Makefile | 1 +
drivers/gpu/drm/tests/drm_rotation_test.c | 76 +++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+)
diff --git a/drivers/gpu/drm/tests/Makefile b/drivers/gpu/drm/tests/Makefile
index 42207df1d1c8..c10bd6a97f5b 100644
--- a/drivers/gpu/drm/tests/Makefile
+++ b/drivers/gpu/drm/tests/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_DRM_KUNIT_TEST) += \
drm_plane_helper_test.o \
drm_probe_helper_test.o \
drm_rect_test.o \
+ drm_rotation_test.o \
drm_sysfb_modeset_test.o \
drm_fixp_test.o \
drm_kunit_edid.o
diff --git a/drivers/gpu/drm/tests/drm_rotation_test.c b/drivers/gpu/drm/tests/drm_rotation_test.c
new file mode 100644
index 000000000000..c537e7ca35b9
--- /dev/null
+++ b/drivers/gpu/drm/tests/drm_rotation_test.c
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Test cases for DRM rotation functions and macros
+ *
+ * Tests DRM_ROTATION_FMT_ARGS()
+ */
+
+#include <kunit/test.h>
+#include <drm/drm_blend.h>
+
+static void drm_test_rotation_fmt_args(struct kunit *test)
+{
+ char buf[128];
+
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf), DRM_ROTATION_FMT, DRM_ROTATION_FMT_ARGS(0));
+ KUNIT_EXPECT_STREQ(test, buf, "(0x00000000)");
+
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf), DRM_ROTATION_FMT, DRM_ROTATION_FMT_ARGS(DRM_MODE_ROTATE_0));
+ KUNIT_EXPECT_STREQ(test, buf, "rotate-0 (0x00000001)");
+
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf), DRM_ROTATION_FMT, DRM_ROTATION_FMT_ARGS(DRM_MODE_ROTATE_90));
+ KUNIT_EXPECT_STREQ(test, buf, "rotate-90 (0x00000002)");
+
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf), DRM_ROTATION_FMT, DRM_ROTATION_FMT_ARGS(DRM_MODE_ROTATE_180));
+ KUNIT_EXPECT_STREQ(test, buf, "rotate-180 (0x00000004)");
+
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf), DRM_ROTATION_FMT, DRM_ROTATION_FMT_ARGS(DRM_MODE_ROTATE_270));
+ KUNIT_EXPECT_STREQ(test, buf, "rotate-270 (0x00000008)");
+
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf), DRM_ROTATION_FMT, DRM_ROTATION_FMT_ARGS(DRM_MODE_REFLECT_X));
+ KUNIT_EXPECT_STREQ(test, buf, "reflect-x (0x00000010)");
+
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf), DRM_ROTATION_FMT, DRM_ROTATION_FMT_ARGS(DRM_MODE_REFLECT_Y));
+ KUNIT_EXPECT_STREQ(test, buf, "reflect-y (0x00000020)");
+
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf), DRM_ROTATION_FMT,
+ DRM_ROTATION_FMT_ARGS(DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_90 |
+ DRM_MODE_REFLECT_X));
+ KUNIT_EXPECT_STREQ(test, buf, "rotate-0 rotate-90 reflect-x (0x00000013)");
+
+ unsigned int all = DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_90 | DRM_MODE_ROTATE_180 |
+ DRM_MODE_ROTATE_270 | DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y;
+
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf), DRM_ROTATION_FMT, DRM_ROTATION_FMT_ARGS(all));
+ KUNIT_EXPECT_STREQ(test, buf,
+ "rotate-0 rotate-90 rotate-180 rotate-270 reflect-x reflect-y (0x0000003f)");
+
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf), DRM_ROTATION_FMT,
+ DRM_ROTATION_FMT_ARGS(DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y));
+ KUNIT_EXPECT_STREQ(test, buf, "reflect-x reflect-y (0x00000030)");
+}
+
+static struct kunit_case drm_rotation_tests[] = {
+ KUNIT_CASE(drm_test_rotation_fmt_args),
+ {}
+};
+
+static struct kunit_suite drm_rotation_test_suite = {
+ .name = "drm_rotation",
+ .test_cases = drm_rotation_tests,
+};
+
+kunit_test_suite(drm_rotation_test_suite);
+
+MODULE_DESCRIPTION("Test cases for DRM rotation functions and macros");
+MODULE_LICENSE("GPL");
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 05/43] drm/drm_color_mgmt: Expose drm_get_color_encoding_name
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (3 preceding siblings ...)
2026-11-26 11:28 ` [PATCH v7 04/43] drm/tests: Add test cases for DRM rotation name Louis Chauvet
@ 2026-11-26 11:28 ` Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 06/43] drm/drm_color_mgmt: Expose drm_get_color_range_name Louis Chauvet
` (37 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:28 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
drm_get_color_encoding_name can be useful to display debug information
outside drm core. Export it so it could be used for VKMS
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/drm_color_mgmt.c | 2 +-
drivers/gpu/drm/drm_crtc_internal.h | 2 --
include/drm/drm_color_mgmt.h | 2 ++
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index e4e31bc0153e..de219c23322f 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -496,7 +496,7 @@ const char *drm_get_color_encoding_name(enum drm_color_encoding encoding)
return color_encoding_name[encoding];
}
-EXPORT_SYMBOL_IF_KUNIT(drm_get_color_encoding_name);
+EXPORT_SYMBOL(drm_get_color_encoding_name);
/**
* drm_get_color_range_name - return a string for color range
diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
index f60216adcd31..c7aeb69b54c9 100644
--- a/drivers/gpu/drm/drm_crtc_internal.h
+++ b/drivers/gpu/drm/drm_crtc_internal.h
@@ -38,7 +38,6 @@
#include <linux/err.h>
#include <linux/types.h>
-enum drm_color_encoding;
enum drm_color_range;
enum drm_connector_force;
enum drm_mode_status;
@@ -121,7 +120,6 @@ int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv);
/* drm_color_mgmt.c */
-const char *drm_get_color_encoding_name(enum drm_color_encoding encoding);
const char *drm_get_color_range_name(enum drm_color_range range);
/* IOCTLs */
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
index 5140691f476a..133ca77d91c7 100644
--- a/include/drm/drm_color_mgmt.h
+++ b/include/drm/drm_color_mgmt.h
@@ -113,6 +113,8 @@ enum drm_color_range {
DRM_COLOR_RANGE_MAX,
};
+const char *drm_get_color_encoding_name(enum drm_color_encoding encoding);
+
int drm_plane_create_color_properties(struct drm_plane *plane,
u32 supported_encodings,
u32 supported_ranges,
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 06/43] drm/drm_color_mgmt: Expose drm_get_color_range_name
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (4 preceding siblings ...)
2026-11-26 11:28 ` [PATCH v7 05/43] drm/drm_color_mgmt: Expose drm_get_color_encoding_name Louis Chauvet
@ 2026-11-26 11:28 ` Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 07/43] drm/connector: Export drm_get_colorspace_name Louis Chauvet
` (36 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:28 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
drm_get_color_range_name can be useful to print debugging information.
Export it so it could be used from VKMS.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/drm_color_mgmt.c | 2 +-
drivers/gpu/drm/drm_crtc_internal.h | 4 ----
include/drm/drm_color_mgmt.h | 1 +
3 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
index de219c23322f..a65fef5702ab 100644
--- a/drivers/gpu/drm/drm_color_mgmt.c
+++ b/drivers/gpu/drm/drm_color_mgmt.c
@@ -512,7 +512,7 @@ const char *drm_get_color_range_name(enum drm_color_range range)
return color_range_name[range];
}
-EXPORT_SYMBOL_IF_KUNIT(drm_get_color_range_name);
+EXPORT_SYMBOL(drm_get_color_range_name);
/**
* drm_plane_create_color_properties - color encoding related plane properties
diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
index c7aeb69b54c9..bea1fbf80e89 100644
--- a/drivers/gpu/drm/drm_crtc_internal.h
+++ b/drivers/gpu/drm/drm_crtc_internal.h
@@ -38,7 +38,6 @@
#include <linux/err.h>
#include <linux/types.h>
-enum drm_color_range;
enum drm_connector_force;
enum drm_mode_status;
@@ -119,9 +118,6 @@ int drm_mode_mmap_dumb_ioctl(struct drm_device *dev,
int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv);
-/* drm_color_mgmt.c */
-const char *drm_get_color_range_name(enum drm_color_range range);
-
/* IOCTLs */
int drm_mode_gamma_get_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv);
diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
index 133ca77d91c7..e91f494e5a63 100644
--- a/include/drm/drm_color_mgmt.h
+++ b/include/drm/drm_color_mgmt.h
@@ -114,6 +114,7 @@ enum drm_color_range {
};
const char *drm_get_color_encoding_name(enum drm_color_encoding encoding);
+const char *drm_get_color_range_name(enum drm_color_range range);
int drm_plane_create_color_properties(struct drm_plane *plane,
u32 supported_encodings,
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 07/43] drm/connector: Export drm_get_colorspace_name
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (5 preceding siblings ...)
2026-11-26 11:28 ` [PATCH v7 06/43] drm/drm_color_mgmt: Expose drm_get_color_range_name Louis Chauvet
@ 2026-11-26 11:28 ` Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 08/43] drm/drm_atomic_state_helper: Properly load default value for rotation Louis Chauvet
` (35 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:28 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
Export drm_get_colorspace_name so it could be used by VKMS
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/drm_connector.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index da0b16f25ac4..e604d9ea3058 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -1531,6 +1531,7 @@ const char *drm_get_colorspace_name(enum drm_colorspace colorspace)
else
return "(null)";
}
+EXPORT_SYMBOL(drm_get_colorspace_name);
static const u32 hdmi_colorspaces =
BIT(DRM_MODE_COLORIMETRY_SMPTE_170M_YCC) |
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 08/43] drm/drm_atomic_state_helper: Properly load default value for rotation
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (6 preceding siblings ...)
2026-11-26 11:28 ` [PATCH v7 07/43] drm/connector: Export drm_get_colorspace_name Louis Chauvet
@ 2026-11-26 11:28 ` Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 09/43] Documentation: ABI: vkms: Add current VKMS ABI documentation Louis Chauvet
` (34 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:28 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
Currently, the default rotation is always DRM_MODE_ROTATE_0 for all planes.
Some planes may have a rotation property, and the property may specify a
different default value and supported values.
This is not an issue for "fixed" configurations, but with the introduction
of VKMS configuration, some plane may only support 90° and 180°
rotations, so the reset state of the plane was wrong (forced to 0°).
Fixes: ab2dd990f4ab ("drm: Add __drm_atomic_helper_crtc_state_reset() & co.")
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/drm_atomic_state_helper.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
index 267f44330629..13e848abb33c 100644
--- a/drivers/gpu/drm/drm_atomic_state_helper.c
+++ b/drivers/gpu/drm/drm_atomic_state_helper.c
@@ -32,6 +32,7 @@
#include <drm/drm_crtc.h>
#include <drm/drm_device.h>
#include <drm/drm_framebuffer.h>
+#include <drm/drm_mode_object.h>
#include <drm/drm_plane.h>
#include <drm/drm_print.h>
#include <drm/drm_vblank.h>
@@ -231,6 +232,11 @@ void __drm_atomic_helper_plane_state_init(struct drm_plane_state *plane_state,
plane_state->plane = plane;
plane_state->rotation = DRM_MODE_ROTATE_0;
+ if (plane->rotation_property &&
+ !drm_object_property_get_default_value(&plane->base,
+ plane->rotation_property,
+ &val))
+ plane_state->rotation = val;
plane_state->alpha = DRM_BLEND_ALPHA_OPAQUE;
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 09/43] Documentation: ABI: vkms: Add current VKMS ABI documentation
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (7 preceding siblings ...)
2026-11-26 11:28 ` [PATCH v7 08/43] drm/drm_atomic_state_helper: Properly load default value for rotation Louis Chauvet
@ 2026-11-26 11:28 ` Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 10/43] drm/vkms: Reset config->dev when the device creation fails Louis Chauvet
` (33 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:28 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
VKMS recently introduced a ConfigFS API to configure new devices.
Add proper ABI documentation.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
Documentation/ABI/testing/configfs-vkms | 123 ++++++++++++++++++++++++++++++++
1 file changed, 123 insertions(+)
diff --git a/Documentation/ABI/testing/configfs-vkms b/Documentation/ABI/testing/configfs-vkms
new file mode 100644
index 000000000000..26e7f81b5b7d
--- /dev/null
+++ b/Documentation/ABI/testing/configfs-vkms
@@ -0,0 +1,123 @@
+What: /sys/kernel/config/vkms/
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ This group contains sub-groups corresponding to created
+ VKMS devices. Creating a device named "vkms" fails with
+ -EINVAL: that name is reserved for the default device
+ created by the create_default_dev module parameter.
+
+What: /sys/kernel/config/vkms/<device>
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ This group contains sub-groups corresponding to the VKMS
+ device <device>.
+
+What: /sys/kernel/config/vkms/<device>/connectors
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ This group contains sub-groups corresponding to the
+ connectors of the VKMS device <device>.
+
+What: /sys/kernel/config/vkms/<device>/connectors/<connector>
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ This group contains attributes corresponding to the
+ connector <connector> of the VKMS device <device>.
+
+What: /sys/kernel/config/vkms/<device>/connectors/<connector>/status
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Connection status of the connector. Possible values:
+ 1 - connected, 2 - disconnected, 3 - unknown. Changing
+ the status triggers a connector hotplug if the device is
+ enabled.
+
+What: /sys/kernel/config/vkms/<device>/connectors/<connector>/possible_encoders
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ This group contains symbolic links to possible encoders
+ for this connector.
+
+What: /sys/kernel/config/vkms/<device>/crtcs
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ This group contains sub-groups corresponding to the
+ CRTCs of the VKMS device <device>.
+
+What: /sys/kernel/config/vkms/<device>/crtcs/<crtc>
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ This group contains attributes corresponding to the
+ CRTC <crtc> of the VKMS device <device>.
+
+What: /sys/kernel/config/vkms/<device>/crtcs/<crtc>/writeback
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Enable or disable writeback connector support for this
+ CRTC. Value: 1 - enabled, 0 - disabled.
+
+What: /sys/kernel/config/vkms/<device>/encoders
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ This group contains sub-groups corresponding to the
+ encoders of the VKMS device <device>.
+
+What: /sys/kernel/config/vkms/<device>/encoders/<encoder>
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ This group contains attributes corresponding to the
+ encoder <encoder> of the VKMS device <device>.
+
+What: /sys/kernel/config/vkms/<device>/encoders/<encoder>/possible_crtcs
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ This group contains symbolic links to possible CRTCs
+ for this encoder.
+
+What: /sys/kernel/config/vkms/<device>/planes
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ This group contains sub-groups corresponding to the
+ planes of the VKMS device <device>.
+
+What: /sys/kernel/config/vkms/<device>/planes/<plane>
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ This group contains attributes corresponding to the
+ plane <plane> of the VKMS device <device>.
+
+What: /sys/kernel/config/vkms/<device>/planes/<plane>/type
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Plane type. Possible values: 0 - overlay, 1 - primary,
+ 2 - cursor.
+
+What: /sys/kernel/config/vkms/<device>/planes/<plane>/possible_crtcs
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ This group contains symbolic links to possible CRTCs
+ for this plane.
+
+What: /sys/kernel/config/vkms/<device>/enabled
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Enable or disable the VKMS device. Value: 1 - enabled,
+ 0 - disabled. Enabling validates the device configuration
+ and fails with -EINVAL if it is invalid.
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 10/43] drm/vkms: Reset config->dev when the device creation fails
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (8 preceding siblings ...)
2026-11-26 11:28 ` [PATCH v7 09/43] Documentation: ABI: vkms: Add current VKMS ABI documentation Louis Chauvet
@ 2026-11-26 11:28 ` Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 11/43] drm/vkms: Reference-count vkms_config and vkms_config_connector Louis Chauvet
` (32 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:28 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
vkms_create() stores the vkms_device in config->dev, but the error paths
after that point free the device (through devres_release_group()) without
clearing the pointer. The configuration then keeps a dangling pointer,
which can be dereferenced later (for example by vkms_destroy() or by the
configfs disable path) once the device is already gone.
Clear config->dev in the out_devres error path so the configuration stays
consistent when the device creation fails.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/vkms_drv.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
index 28b99511f186..4cbb1173fcc6 100644
--- a/drivers/gpu/drm/vkms/vkms_drv.c
+++ b/drivers/gpu/drm/vkms/vkms_drv.c
@@ -215,6 +215,7 @@ int vkms_create(struct vkms_config *config)
out_devres:
devres_release_group(&fdev->dev, NULL);
+ config->dev = NULL;
out_unregister:
faux_device_destroy(fdev);
return ret;
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 11/43] drm/vkms: Reference-count vkms_config and vkms_config_connector
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (9 preceding siblings ...)
2026-11-26 11:28 ` [PATCH v7 10/43] drm/vkms: Reset config->dev when the device creation fails Louis Chauvet
@ 2026-11-26 11:28 ` Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 12/43] drm/vkms: Add KUnit test for device lifecycle Louis Chauvet
` (31 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:28 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
The configuration objects are referenced from places with independent
lifetimes: connectors keep a pointer to their vkms_config_connector, the
DRM device outlives the configfs view, and userspace can delete a
configfs directory while the device is still running. Freeing a
configuration when its configfs representation disappears can therefore
lead to use-after-free.
Add explicit get/put references to vkms_config and vkms_config_connector:
a configuration destroyed while still referenced is detached and kept
alive until its last reference is dropped.
The connectors list owns the initial reference of each connector (taken by
kref_init() in vkms_config_create_connector()). A connector does not take
a reference on its configuration at creation time: the configuration
already owns the connector through config->connectors, so the opposite
reference would create a cycle that plain krefs cannot reclaim. Instead,
vkms_config_destroy_connector() pins the configuration when the connector
is detached, so a connector which outlives its configuration keeps it
alive until its own last put.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/vkms_config.c | 74 ++++++++++++++++++++++++++++++++++----
drivers/gpu/drm/vkms/vkms_config.h | 48 +++++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_drv.c | 6 +++-
3 files changed, 121 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index 6699ddae7126..8cd4fe6551fb 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -9,6 +9,8 @@
#include "vkms_config.h"
+static void vkms_config_connector_release(struct kref *ref);
+
struct vkms_config *vkms_config_create(const char *dev_name)
{
struct vkms_config *config;
@@ -27,6 +29,8 @@ struct vkms_config *vkms_config_create(const char *dev_name)
INIT_LIST_HEAD(&config->crtcs);
INIT_LIST_HEAD(&config->encoders);
INIT_LIST_HEAD(&config->connectors);
+ /* refcnt starts at 1: the caller owns this initial reference */
+ kref_init(&config->refcnt);
mutex_init(&config->lock);
return config;
@@ -112,8 +116,9 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor,
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_default_create);
-void vkms_config_destroy(struct vkms_config *config)
+static void vkms_config_release(struct kref *ref)
{
+ struct vkms_config *config = container_of(ref, struct vkms_config, refcnt);
struct vkms_config_plane *plane_cfg, *plane_tmp;
struct vkms_config_crtc *crtc_cfg, *crtc_tmp;
struct vkms_config_encoder *encoder_cfg, *encoder_tmp;
@@ -128,12 +133,31 @@ void vkms_config_destroy(struct vkms_config *config)
list_for_each_entry_safe(encoder_cfg, encoder_tmp, &config->encoders, link)
vkms_config_destroy_encoder(config, encoder_cfg);
- list_for_each_entry_safe(connector_cfg, connector_tmp, &config->connectors, link)
- vkms_config_destroy_connector(connector_cfg);
+ list_for_each_entry_safe(connector_cfg, connector_tmp, &config->connectors, link) {
+ /* The config is dying: drop the list's reference on each connector */
+ vkms_config_connector_put(connector_cfg);
+ }
mutex_destroy(&config->lock);
kfree_const(config->dev_name);
- kfree(config);
+ kfree_rcu(config, rcu);
+}
+
+void vkms_config_get(struct vkms_config *config)
+{
+ kref_get(&config->refcnt);
+}
+EXPORT_SYMBOL_IF_KUNIT(vkms_config_get);
+
+void vkms_config_put(struct vkms_config *config)
+{
+ kref_put(&config->refcnt, vkms_config_release);
+}
+EXPORT_SYMBOL_IF_KUNIT(vkms_config_put);
+
+void vkms_config_destroy(struct vkms_config *config)
+{
+ vkms_config_put(config);
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_destroy);
@@ -611,6 +635,8 @@ struct vkms_config_connector *vkms_config_create_connector(struct vkms_config *c
connector_cfg->config = config;
connector_cfg->status = connector_status_connected;
xa_init_flags(&connector_cfg->possible_encoders, XA_FLAGS_ALLOC);
+ /* refcnt starts at 1: this reference is owned by config->connectors */
+ kref_init(&connector_cfg->refcnt);
list_add_tail_rcu(&connector_cfg->link, &config->connectors);
@@ -618,12 +644,48 @@ struct vkms_config_connector *vkms_config_create_connector(struct vkms_config *c
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_create_connector);
-void vkms_config_destroy_connector(struct vkms_config_connector *connector_cfg)
+static void vkms_config_connector_release(struct kref *ref)
{
+ struct vkms_config_connector *connector_cfg =
+ container_of(ref, struct vkms_config_connector, refcnt);
xa_destroy(&connector_cfg->possible_encoders);
- list_del_rcu(&connector_cfg->link);
+ if (connector_cfg->unlinked) {
+ /* Detached by vkms_config_destroy_connector(): drop its config pin */
+ vkms_config_put(connector_cfg->config);
+ } else {
+ /* The config is dying and is draining us: just unlink */
+ list_del_init(&connector_cfg->link);
+ }
kfree_rcu(connector_cfg, rcu);
}
+
+struct vkms_config_connector *vkms_config_connector_get(struct vkms_config_connector *connector_cfg)
+{
+ kref_get(&connector_cfg->refcnt);
+ return connector_cfg;
+}
+EXPORT_SYMBOL_IF_KUNIT(vkms_config_connector_get);
+
+void vkms_config_connector_put(struct vkms_config_connector *connector_cfg)
+{
+ kref_put(&connector_cfg->refcnt, vkms_config_connector_release);
+}
+EXPORT_SYMBOL_IF_KUNIT(vkms_config_connector_put);
+
+void vkms_config_destroy_connector(struct vkms_config_connector *connector_cfg)
+{
+ /*
+ * Pin the config, then unlink and drop the list's reference. If this
+ * was the last connector reference the release callback runs right
+ * here, so it must not walk config->connectors (already unlinked)
+ * nor free the config (pinned). list_del_rcu() because a concurrent
+ * dump may still be walking this connector.
+ */
+ vkms_config_get(connector_cfg->config);
+ list_del_rcu(&connector_cfg->link);
+ connector_cfg->unlinked = true;
+ vkms_config_connector_put(connector_cfg);
+}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_destroy_connector);
int __must_check vkms_config_connector_attach_encoder(struct vkms_config_connector *connector_cfg,
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index 125273f67e7d..95e5c3694742 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -3,9 +3,14 @@
#ifndef _VKMS_CONFIG_H_
#define _VKMS_CONFIG_H_
+#include <linux/cleanup.h>
+#include <linux/kref.h>
#include <linux/list.h>
#include <linux/rculist.h>
#include <linux/mutex.h>
+#include <linux/rcupdate.h>
+#include <linux/string.h>
+#include <linux/list.h>
#include <linux/types.h>
#include <linux/xarray.h>
@@ -24,6 +29,8 @@
* @lock: Protects the whole configuration (lists and item fields) against
* concurrent access from the configfs, debugfs and DRM paths
* @dev: Used to store the current VKMS device. Only set when the device is instantiated.
+ * @refcnt: Reference counter, starts at 1 (owned by the creator)
+ * @rcu: RCU head for deferred freeing of this object
*/
struct vkms_config {
const char *dev_name;
@@ -33,6 +40,8 @@ struct vkms_config {
struct list_head connectors;
struct mutex lock;
struct vkms_device *dev;
+ struct kref refcnt;
+ struct rcu_head rcu;
};
/**
@@ -116,10 +125,14 @@ struct vkms_config_encoder {
* @config: The vkms_config this connector belongs to
* @status: Status (connected, disconnected...) of the connector
* @possible_encoders: Array of encoders that can be used with this connector
+ * @unlinked: Set when the connector was unlinked from config->connectors
+ * by vkms_config_destroy_connector()
* @connector: Internal usage. This pointer should never be considered as valid.
* It can be used to store a temporary reference to a VKMS connector
* during device creation. This pointer is not managed by the
* configuration and must be managed by other means.
+ * @refcnt: Reference counter, starts at 1 (owned by config->connectors). The
+ * object is freed only after an RCU grace period
*/
struct vkms_config_connector {
struct list_head link;
@@ -128,9 +141,12 @@ struct vkms_config_connector {
enum drm_connector_status status;
struct xarray possible_encoders;
+ bool unlinked;
/* Internal usage */
struct vkms_connector *connector;
+
+ struct kref refcnt;
};
/**
@@ -228,6 +244,23 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor,
bool enable_overlay,
bool enable_plane_pipeline);
+/**
+ * vkms_config_get() - Acquire a reference to a VKMS configuration
+ * @config: vkms_config to acquire a reference to
+ */
+void vkms_config_get(struct vkms_config *config);
+
+/**
+ * vkms_config_put() - Release a reference to a VKMS configuration
+ * @config: vkms_config to release the reference from
+ *
+ * When the last reference is released, the configuration and all its
+ * sub-components are freed.
+ */
+void vkms_config_put(struct vkms_config *config);
+
+DEFINE_FREE(vkms_config_put, struct vkms_config *, if (_T) vkms_config_put(_T));
+
/**
* vkms_config_destroy() - Free a VKMS configuration
* @config: vkms_config to free
@@ -463,6 +496,21 @@ void vkms_config_encoder_detach_crtc(struct vkms_config_encoder *encoder_cfg,
*/
struct vkms_config_connector *vkms_config_create_connector(struct vkms_config *config);
+/**
+ * vkms_config_connector_get() - Acquire a reference to a connector configuration
+ * @connector_cfg: Connector configuration to acquire a reference to
+ */
+struct vkms_config_connector *
+vkms_config_connector_get(struct vkms_config_connector *connector_cfg);
+
+/**
+ * vkms_config_connector_put() - Release a reference to a connector configuration
+ * @connector_cfg: Connector configuration to release the reference from
+ *
+ * When the last reference is released, the connector configuration is freed.
+ */
+void vkms_config_connector_put(struct vkms_config_connector *connector_cfg);
+
/**
* vkms_config_destroy_connector() - Remove and free a connector configuration
* @connector_cfg: Connector configuration to destroy
diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
index 4cbb1173fcc6..24572bc779b4 100644
--- a/drivers/gpu/drm/vkms/vkms_drv.c
+++ b/drivers/gpu/drm/vkms/vkms_drv.c
@@ -163,6 +163,10 @@ int vkms_create(struct vkms_config *config)
struct faux_device *fdev;
struct vkms_device *vkms_device;
const char *dev_name;
+ /* The device keeps the config alive for its whole lifetime */
+ struct vkms_config *cfg __free(vkms_config_put) = config;
+
+ vkms_config_get(cfg);
dev_name = vkms_config_get_device_name(config);
fdev = faux_device_create(dev_name, NULL, NULL);
@@ -276,7 +280,7 @@ static void __exit vkms_exit(void)
return;
vkms_destroy(default_config);
- vkms_config_destroy(default_config);
+ vkms_config_put(default_config);
}
module_init(vkms_init);
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 12/43] drm/vkms: Add KUnit test for device lifecycle
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (10 preceding siblings ...)
2026-11-26 11:28 ` [PATCH v7 11/43] drm/vkms: Reference-count vkms_config and vkms_config_connector Louis Chauvet
@ 2026-11-26 11:28 ` Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 13/43] drm/vkms: Add error handling in plane config creation Louis Chauvet
` (30 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:28 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
The configuration objects are now reference-counted and their lifetime is
driven by explicit get/put calls. Add tests aiming to spot UAF and leaks
using KASAN.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/tests/.kunitconfig | 10 +
drivers/gpu/drm/vkms/tests/Makefile | 3 +-
drivers/gpu/drm/vkms/tests/vkms_lifecycle_test.c | 280 +++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_drv.c | 3 +
4 files changed, 295 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/vkms/tests/.kunitconfig b/drivers/gpu/drm/vkms/tests/.kunitconfig
index 6a2d87068edc..c9752bde8487 100644
--- a/drivers/gpu/drm/vkms/tests/.kunitconfig
+++ b/drivers/gpu/drm/vkms/tests/.kunitconfig
@@ -2,3 +2,13 @@ CONFIG_KUNIT=y
CONFIG_DRM=y
CONFIG_DRM_VKMS=y
CONFIG_DRM_VKMS_KUNIT_TEST=y
+CONFIG_KASAN=y
+CONFIG_KASAN_INLINE=y
+CONFIG_KASAN_VMALLOC=y
+CONFIG_KUNIT_ALL_TESTS=n
+CONFIG_DEBUG_KERNEL=y
+CONFIG_DEBUG_KMEMLEAK=y
+CONFIG_DEBUG_OBJECTS=y
+CONFIG_DEBUG_OBJECTS_FREE=y
+CONFIG_DEBUG_OBJECTS_TIMERS=y
+CONFIG_PAGE_POISONING=y
diff --git a/drivers/gpu/drm/vkms/tests/Makefile b/drivers/gpu/drm/vkms/tests/Makefile
index d4d9ba8d4c54..a7810a12c9c8 100644
--- a/drivers/gpu/drm/vkms/tests/Makefile
+++ b/drivers/gpu/drm/vkms/tests/Makefile
@@ -3,6 +3,7 @@
vkms-kunit-tests-y := \
vkms_config_test.o \
vkms_format_test.o \
- vkms_color_test.o
+ vkms_color_test.o \
+ vkms_lifecycle_test.o \
obj-$(CONFIG_DRM_VKMS_KUNIT_TEST) += vkms-kunit-tests.o
diff --git a/drivers/gpu/drm/vkms/tests/vkms_lifecycle_test.c b/drivers/gpu/drm/vkms/tests/vkms_lifecycle_test.c
new file mode 100644
index 000000000000..7f7b31368710
--- /dev/null
+++ b/drivers/gpu/drm/vkms/tests/vkms_lifecycle_test.c
@@ -0,0 +1,280 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <kunit/test.h>
+#include <linux/string.h>
+
+#include "../vkms_config.h"
+#include "../vkms_drv.h"
+
+MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
+
+#define LIFECYCLE_ITERATIONS 50
+#define STRESS_ITERATIONS 500
+
+/*
+ * vkms_init() may already have registered a device named DEFAULT_DEVICE_NAME,
+ * so give each test configuration its own name: vkms_create() fails with
+ * -EEXIST otherwise.
+ */
+static void vkms_lifecycle_test_set_unique_name(struct kunit *test,
+ struct vkms_config *config,
+ const char *name)
+{
+ const char *new_name = kstrdup_const(name, GFP_KERNEL);
+
+ KUNIT_ASSERT_NOT_NULL(test, new_name);
+ kfree_const(config->dev_name);
+ config->dev_name = new_name;
+}
+
+static void vkms_lifecycle_test_create_destroy_default(struct kunit *test)
+{
+ struct vkms_config *config;
+ int ret, i;
+
+ for (i = 0; i < LIFECYCLE_ITERATIONS; i++) {
+ config = vkms_config_default_create(true, true, false, false);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+ vkms_lifecycle_test_set_unique_name(test, config, test->name);
+
+ ret = vkms_create(config);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+
+ vkms_destroy(config);
+ vkms_config_destroy(config);
+ }
+}
+
+static void vkms_lifecycle_test_create_destroy_with_overlay(struct kunit *test)
+{
+ struct vkms_config *config;
+ int ret, i;
+
+ for (i = 0; i < LIFECYCLE_ITERATIONS; i++) {
+ config = vkms_config_default_create(true, true, true, false);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+ vkms_lifecycle_test_set_unique_name(test, config, test->name);
+
+ ret = vkms_create(config);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+
+ vkms_destroy(config);
+ vkms_config_destroy(config);
+ }
+}
+
+static void vkms_lifecycle_test_create_destroy_with_pipeline(struct kunit *test)
+{
+ struct vkms_config *config;
+ int ret, i;
+
+ for (i = 0; i < LIFECYCLE_ITERATIONS; i++) {
+ config = vkms_config_default_create(true, true, true, true);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+ vkms_lifecycle_test_set_unique_name(test, config, test->name);
+
+ ret = vkms_create(config);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+
+ vkms_destroy(config);
+ vkms_config_destroy(config);
+ }
+}
+
+static void vkms_lifecycle_test_create_destroy_minimal(struct kunit *test)
+{
+ struct vkms_config *config;
+ int ret, i;
+
+ for (i = 0; i < LIFECYCLE_ITERATIONS; i++) {
+ config = vkms_config_default_create(false, false, false, false);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+ vkms_lifecycle_test_set_unique_name(test, config, test->name);
+
+ ret = vkms_create(config);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+
+ vkms_destroy(config);
+ vkms_config_destroy(config);
+ }
+}
+
+static void vkms_lifecycle_test_create_destroy_writeback(struct kunit *test)
+{
+ struct vkms_config *config;
+ int ret, i;
+
+ for (i = 0; i < LIFECYCLE_ITERATIONS; i++) {
+ config = vkms_config_default_create(false, true, false, false);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+ vkms_lifecycle_test_set_unique_name(test, config, test->name);
+
+ ret = vkms_create(config);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+
+ vkms_destroy(config);
+ vkms_config_destroy(config);
+ }
+}
+
+static void vkms_lifecycle_test_stress_many_cycles(struct kunit *test)
+{
+ struct vkms_config *config;
+ int ret, i;
+
+ for (i = 0; i < STRESS_ITERATIONS; i++) {
+ config = vkms_config_default_create(true, true, true, false);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+ vkms_lifecycle_test_set_unique_name(test, config, test->name);
+
+ ret = vkms_create(config);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+
+ vkms_destroy(config);
+ vkms_config_destroy(config);
+ }
+}
+
+static void vkms_lifecycle_test_interleaved_create_destroy(struct kunit *test)
+{
+ struct vkms_config *configs[5];
+ char name[64];
+ int ret, i, j;
+
+ for (j = 0; j < 20; j++) {
+ for (i = 0; i < 5; i++) {
+ configs[i] = vkms_config_default_create(i & 1, i & 2, i & 4, false);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, configs[i]);
+
+ snprintf(name, sizeof(name), "%s-%d", test->name, i);
+ vkms_lifecycle_test_set_unique_name(test, configs[i], name);
+
+ ret = vkms_create(configs[i]);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+ }
+
+ for (i = 4; i >= 0; i--) {
+ vkms_destroy(configs[i]);
+ vkms_config_destroy(configs[i]);
+ }
+ }
+}
+
+static void vkms_lifecycle_test_destroy_uncreated_device(struct kunit *test)
+{
+ struct vkms_config *config;
+
+ config = vkms_config_default_create(true, true, false, false);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+
+ KUNIT_ASSERT_NULL(test, config->dev);
+
+ vkms_config_destroy(config);
+}
+
+static void vkms_lifecycle_test_double_destroy(struct kunit *test)
+{
+ struct vkms_config *config;
+ int ret;
+
+ config = vkms_config_default_create(true, true, false, false);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+ vkms_lifecycle_test_set_unique_name(test, config, test->name);
+
+ ret = vkms_create(config);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+
+ vkms_destroy(config);
+ KUNIT_ASSERT_NULL(test, config->dev);
+
+ vkms_config_destroy(config);
+}
+
+static void vkms_lifecycle_test_create_after_destroy(struct kunit *test)
+{
+ struct vkms_config *config;
+ int ret, i;
+
+ for (i = 0; i < 20; i++) {
+ config = vkms_config_default_create(true, true, false, false);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+ vkms_lifecycle_test_set_unique_name(test, config, test->name);
+
+ ret = vkms_create(config);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+
+ vkms_destroy(config);
+
+ ret = vkms_create(config);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+
+ vkms_destroy(config);
+ vkms_config_destroy(config);
+ }
+}
+
+static void vkms_lifecycle_test_connector_ref_outlives_config(struct kunit *test)
+{
+ struct vkms_config_connector *connector_cfg;
+ struct vkms_config *config;
+
+ config = vkms_config_default_create(false, false, false, false);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+ KUNIT_ASSERT_FALSE(test, list_empty(&config->connectors));
+
+ connector_cfg = list_first_entry(&config->connectors,
+ struct vkms_config_connector, link);
+
+ /* Simulate the rmdir while DRM hold the device */
+ vkms_config_connector_get(connector_cfg);
+ vkms_config_destroy_connector(connector_cfg);
+ vkms_config_destroy(config);
+
+ /* The connector must survive, detached from the configuration. */
+ KUNIT_EXPECT_EQ(test, kref_read(&connector_cfg->refcnt), 1);
+ KUNIT_EXPECT_TRUE(test, connector_cfg->unlinked);
+
+ /* Last reference: connector and configuration are freed here. */
+ vkms_config_connector_put(connector_cfg);
+}
+
+static void vkms_lifecycle_test_connector_static_drmm_release(struct kunit *test)
+{
+ struct vkms_config *config;
+
+ config = vkms_config_default_create(true, true, false, false);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+ vkms_lifecycle_test_set_unique_name(test, config, test->name);
+
+ KUNIT_ASSERT_EQ(test, vkms_create(config), 0);
+
+ /* vkms_destroy() runs the drmm action, which frees and detaches the connector. */
+ vkms_destroy(config);
+ vkms_config_destroy(config);
+}
+
+static struct kunit_case vkms_lifecycle_test_cases[] = {
+ KUNIT_CASE(vkms_lifecycle_test_create_destroy_default),
+ KUNIT_CASE(vkms_lifecycle_test_create_destroy_with_overlay),
+ KUNIT_CASE(vkms_lifecycle_test_create_destroy_with_pipeline),
+ KUNIT_CASE(vkms_lifecycle_test_create_destroy_minimal),
+ KUNIT_CASE(vkms_lifecycle_test_create_destroy_writeback),
+ KUNIT_CASE(vkms_lifecycle_test_stress_many_cycles),
+ KUNIT_CASE(vkms_lifecycle_test_interleaved_create_destroy),
+ KUNIT_CASE(vkms_lifecycle_test_destroy_uncreated_device),
+ KUNIT_CASE(vkms_lifecycle_test_double_destroy),
+ KUNIT_CASE(vkms_lifecycle_test_create_after_destroy),
+ KUNIT_CASE(vkms_lifecycle_test_connector_ref_outlives_config),
+ KUNIT_CASE(vkms_lifecycle_test_connector_static_drmm_release),
+ {}
+};
+
+static struct kunit_suite vkms_lifecycle_test_suite = {
+ .name = "vkms-lifecycle",
+ .test_cases = vkms_lifecycle_test_cases,
+};
+
+kunit_test_suite(vkms_lifecycle_test_suite);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("KUnit test for VKMS device lifecycle, aiming to catch UAF and memory issues");
diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
index 24572bc779b4..f73f136e5588 100644
--- a/drivers/gpu/drm/vkms/vkms_drv.c
+++ b/drivers/gpu/drm/vkms/vkms_drv.c
@@ -18,6 +18,7 @@
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_colorop.h>
+#include <kunit/visibility.h>
#include <drm/drm_drv.h>
#include <drm/drm_fbdev_shmem.h>
#include <drm/drm_file.h>
@@ -252,6 +253,7 @@ static int __init vkms_init(void)
return 0;
}
+EXPORT_SYMBOL_IF_KUNIT(vkms_create);
void vkms_destroy(struct vkms_config *config)
{
@@ -271,6 +273,7 @@ void vkms_destroy(struct vkms_config *config)
config->dev = NULL;
}
+EXPORT_SYMBOL_IF_KUNIT(vkms_destroy);
static void __exit vkms_exit(void)
{
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 13/43] drm/vkms: Add error handling in plane config creation
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (11 preceding siblings ...)
2026-11-26 11:28 ` [PATCH v7 12/43] drm/vkms: Add KUnit test for device lifecycle Louis Chauvet
@ 2026-11-26 11:28 ` Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 14/43] drm/vkms: Simplify plane_release code Louis Chauvet
` (29 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:28 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
Properly route the error path of vkms_config_create_plane() through a
fail label to simplify future work.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/vkms_config.c | 12 +++++++++---
drivers/gpu/drm/vkms/vkms_config.h | 2 +-
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index 8cd4fe6551fb..c5d90f7e934a 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -421,13 +421,16 @@ void vkms_config_register_debugfs(struct vkms_device *vkms_device)
ARRAY_SIZE(vkms_config_debugfs_list));
}
-struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *config)
+struct vkms_config_plane __must_check *vkms_config_create_plane(struct vkms_config *config)
{
struct vkms_config_plane *plane_cfg;
+ int ret;
plane_cfg = kzalloc_obj(*plane_cfg);
- if (!plane_cfg)
- return ERR_PTR(-ENOMEM);
+ if (!plane_cfg) {
+ ret = -ENOMEM;
+ goto fail;
+ }
plane_cfg->config = config;
plane_cfg->default_pipeline = false;
@@ -437,6 +440,9 @@ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *config)
list_add_tail_rcu(&plane_cfg->link, &config->planes);
return plane_cfg;
+
+fail:
+ return ERR_PTR(ret);
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_create_plane);
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index 95e5c3694742..8f038562afd4 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -314,7 +314,7 @@ void vkms_config_register_debugfs(struct vkms_device *vkms_device);
* The new plane configuration or an error. Call vkms_config_destroy_plane() to
* free the returned plane configuration.
*/
-struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *config);
+struct vkms_config_plane __must_check *vkms_config_create_plane(struct vkms_config *config);
/**
* vkms_config_destroy_plane() - Remove and free a plane configuration
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 14/43] drm/vkms: Simplify plane_release code
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (12 preceding siblings ...)
2026-11-26 11:28 ` [PATCH v7 13/43] drm/vkms: Add error handling in plane config creation Louis Chauvet
@ 2026-11-26 11:28 ` Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 15/43] drm/vkms: Explicitly display plane type Louis Chauvet
` (28 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:28 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
plane_release code used multiple intermediate variable, remove those in
favor of direct access.
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/vkms_configfs.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index 6bb24f5835db..c57791df72cb 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -331,13 +331,9 @@ static struct configfs_attribute *plane_item_attrs[] = {
static void plane_release(struct config_item *item)
{
- struct vkms_configfs_plane *plane;
- struct mutex *lock;
-
- plane = plane_item_to_vkms_configfs_plane(item);
- lock = &plane->dev->config->lock;
+ struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item);
- scoped_guard(mutex, lock) {
+ scoped_guard(mutex, &plane->dev->config->lock) {
vkms_config_destroy_plane(plane->config);
kfree(plane);
}
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 15/43] drm/vkms: Explicitly display plane type
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (13 preceding siblings ...)
2026-11-26 11:28 ` [PATCH v7 14/43] drm/vkms: Simplify plane_release code Louis Chauvet
@ 2026-11-26 11:28 ` Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 16/43] drm/vkms: Use enabled/disabled instead of 1/0 for debug Louis Chauvet
` (27 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:28 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm,
José Expósito
Debug information are mainly read by human, so use full name instead
of values.
Reviewed-by: José Expósito <jose.exposito@redhat.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/vkms_config.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index c5d90f7e934a..e933d61cb526 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -388,8 +388,8 @@ static int vkms_config_show(struct seq_file *m, void *data)
vkms_config_for_each_plane(vkmsdev->config, plane_cfg) {
seq_puts(m, "plane:\n");
- seq_printf(m, "\ttype=%d\n",
- vkms_config_plane_get_type(plane_cfg));
+ seq_printf(m, "\ttype=%s\n",
+ drm_get_plane_type_name(vkms_config_plane_get_type(plane_cfg)));
}
vkms_config_for_each_crtc(vkmsdev->config, crtc_cfg) {
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 16/43] drm/vkms: Use enabled/disabled instead of 1/0 for debug
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (14 preceding siblings ...)
2026-11-26 11:28 ` [PATCH v7 15/43] drm/vkms: Explicitly display plane type Louis Chauvet
@ 2026-11-26 11:28 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 17/43] drm/vkms: Introduce config for plane name Louis Chauvet
` (26 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:28 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm,
José Expósito
Debug information are mainly read by human, so display human
readable values.
Reviewed-by: José Expósito <jose.exposito@redhat.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/vkms_config.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index e933d61cb526..e2b656723898 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include <drm/drm_connector.h>
#include <drm/drm_print.h>
@@ -394,8 +395,8 @@ static int vkms_config_show(struct seq_file *m, void *data)
vkms_config_for_each_crtc(vkmsdev->config, crtc_cfg) {
seq_puts(m, "crtc:\n");
- seq_printf(m, "\twriteback=%d\n",
- vkms_config_crtc_get_writeback(crtc_cfg));
+ seq_printf(m, "\twriteback=%s\n",
+ str_enabled_disabled(vkms_config_crtc_get_writeback(crtc_cfg)));
}
vkms_config_for_each_encoder(vkmsdev->config, encoder_cfg)
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 17/43] drm/vkms: Introduce config for plane name
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (15 preceding siblings ...)
2026-11-26 11:28 ` [PATCH v7 16/43] drm/vkms: Use enabled/disabled instead of 1/0 for debug Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 18/43] drm/vkms: Use plane folder name as " Louis Chauvet
` (25 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
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 | 37 ++++++++++++++++++++++++++++++++++++-
drivers/gpu/drm/vkms/vkms_config.h | 22 ++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_plane.c | 8 +++++++-
3 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index e2b656723898..56ab9ea6e141 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -391,6 +391,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) {
@@ -436,25 +439,57 @@ 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, 0);
+ if (ret)
+ goto cleanup_plane_cfg;
+
xa_init_flags(&plane_cfg->possible_crtcs, XA_FLAGS_ALLOC);
list_add_tail_rcu(&plane_cfg->link, &config->planes);
return plane_cfg;
+cleanup_plane_cfg:
+ kfree(plane_cfg);
fail:
return ERR_PTR(ret);
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_create_plane);
+static void vkms_config_plane_rcu_free(struct rcu_head *head)
+{
+ struct vkms_config_plane *plane_cfg =
+ container_of(head, struct vkms_config_plane, rcu);
+
+ kfree(plane_cfg->name);
+ kfree(plane_cfg);
+}
+
void vkms_config_destroy_plane(struct vkms_config_plane *plane_cfg)
{
xa_destroy(&plane_cfg->possible_crtcs);
list_del_rcu(&plane_cfg->link);
- kfree_rcu(plane_cfg, rcu);
+ call_rcu(&plane_cfg->rcu, vkms_config_plane_rcu_free);
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_destroy_plane);
+int __must_check vkms_config_plane_set_name(struct vkms_config_plane *plane_cfg,
+ const char *name, size_t name_len)
+{
+ char *new_name;
+
+ new_name = kmemdup_nul(name, name_len, GFP_KERNEL);
+ if (name && !new_name)
+ return -ENOMEM;
+
+ kfree(plane_cfg->name);
+ plane_cfg->name = new_name;
+
+ return 0;
+}
+EXPORT_SYMBOL_IF_KUNIT(vkms_config_plane_set_name);
+
int __must_check vkms_config_plane_attach_crtc(struct vkms_config_plane *plane_cfg,
struct vkms_config_crtc *crtc_cfg)
{
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index 8f038562afd4..e428946cb70e 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -50,6 +50,7 @@ struct vkms_config {
* @link: Link to the others planes in vkms_config
* @rcu: RCU head for deferred freeing of this object
* @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
@@ -63,6 +64,7 @@ struct vkms_config_plane {
struct rcu_head rcu;
struct vkms_config *config;
+ const char *name;
enum drm_plane_type type;
struct xarray possible_crtcs;
bool default_pipeline;
@@ -368,6 +370,26 @@ 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
+ */
+int __must_check vkms_config_plane_set_name(struct vkms_config_plane *plane_cfg,
+ const char *name, size_t name_len);
+
+/**
+ * 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 fd3d34dcf0fe..35aabec85b33 100644
--- a/drivers/gpu/drm/vkms/vkms_plane.c
+++ b/drivers/gpu/drm/vkms/vkms_plane.c
@@ -12,6 +12,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"
@@ -261,11 +262,16 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
struct drm_device *dev = &vkmsdev->drm;
struct vkms_plane *plane;
+ /*
+ * Keep the default "plane-%d" name from the DRM core when no name is
+ * configured, instead of passing a NULL string to "%s".
+ */
plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, 0,
&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) ? "%s" : NULL,
+ vkms_config_plane_get_name(plane_cfg));
if (IS_ERR(plane))
return plane;
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 18/43] drm/vkms: Use plane folder name as plane name
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (16 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 17/43] drm/vkms: Introduce config for plane name Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 19/43] drm/vkms: Introduce config for plane rotation Louis Chauvet
` (24 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
The plane name is now directly derived from the configfs folder
name. When a plane directory is created under
/config/vkms/<device>/planes/, the folder name is used as the
plane name via vkms_config_plane_set_name.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
Documentation/ABI/testing/configfs-vkms | 3 ++-
drivers/gpu/drm/vkms/vkms_configfs.c | 7 +++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/Documentation/ABI/testing/configfs-vkms b/Documentation/ABI/testing/configfs-vkms
index 26e7f81b5b7d..55e4183046ec 100644
--- a/Documentation/ABI/testing/configfs-vkms
+++ b/Documentation/ABI/testing/configfs-vkms
@@ -98,7 +98,8 @@ Date: Nov 2025
Contact: dri-devel@lists.freedesktop.org
Description:
This group contains attributes corresponding to the
- plane <plane> of the VKMS device <device>.
+ plane <plane> of the VKMS device <device>. The name of
+ the directory becomes the name of the DRM plane.
What: /sys/kernel/config/vkms/<device>/planes/<plane>/type
Date: Nov 2025
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index c57791df72cb..bbfc0c8a922c 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -375,6 +375,13 @@ static struct config_group *make_plane_group(struct config_group *group,
return ERR_PTR(ret);
}
+ ret = vkms_config_plane_set_name(plane->config, name, strlen(name));
+ if (ret) {
+ vkms_config_destroy_plane(plane->config);
+ kfree(plane);
+ return ERR_PTR(ret);
+ }
+
config_group_init_type_name(&plane->group, name, &plane_item_type);
config_group_init_type_name(&plane->possible_crtcs_group,
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 19/43] drm/vkms: Introduce config for plane rotation
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (17 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 18/43] drm/vkms: Use plane folder name as " Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 20/43] drm/vkms: Introduce configfs " Louis Chauvet
` (23 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
VKMS driver supports all the rotation on planes, but for testing it can be
useful to only advertise few of them. This new configuration interface
will allow configuring the rotation per planes.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/tests/vkms_config_test.c | 53 ++++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_config.c | 46 +++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_config.h | 59 +++++++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_plane.c | 5 ++-
4 files changed, 161 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/vkms/tests/vkms_config_test.c b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
index 1e4ea1863420..dcb29ed8ac4a 100644
--- a/drivers/gpu/drm/vkms/tests/vkms_config_test.c
+++ b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
+#include <drm/drm_mode.h>
#include <kunit/test.h>
#include "../vkms_config.h"
@@ -185,6 +186,12 @@ static void vkms_config_test_default_config(struct kunit *test)
n_possible_crtcs++;
}
KUNIT_EXPECT_EQ(test, n_possible_crtcs, 1);
+ KUNIT_EXPECT_EQ(test,
+ vkms_config_plane_get_supported_rotations(plane_cfg),
+ DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK);
+ KUNIT_EXPECT_EQ(test,
+ vkms_config_plane_get_default_rotation(plane_cfg),
+ DRM_MODE_ROTATE_0);
}
/* Encoders */
@@ -481,6 +488,51 @@ static void vkms_config_test_valid_plane_type(struct kunit *test)
vkms_config_destroy(config);
}
+static void vkms_config_test_valid_plane_rotations(struct kunit *test)
+{
+ struct vkms_config *config;
+ struct vkms_config_plane *plane_cfg;
+
+ config = vkms_config_default_create(false, false, false, false);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+
+ plane_cfg = get_first_plane(config);
+
+ /* Valid, no rotation, no reflection */
+ vkms_config_plane_set_supported_rotations(plane_cfg, DRM_MODE_ROTATE_0);
+ vkms_config_plane_set_default_rotation(plane_cfg, DRM_MODE_ROTATE_0);
+ KUNIT_EXPECT_TRUE(test, vkms_config_valid_plane_rotation(config, plane_cfg));
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Invalid, default rotation is not supported */
+ vkms_config_plane_set_supported_rotations(plane_cfg, DRM_MODE_ROTATE_0);
+ vkms_config_plane_set_default_rotation(plane_cfg, DRM_MODE_ROTATE_90);
+ KUNIT_EXPECT_FALSE(test, vkms_config_valid_plane_rotation(config, plane_cfg));
+ KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
+
+ /* Invalid, supported rotations must contain at least one base rotation angle */
+ vkms_config_plane_set_supported_rotations(plane_cfg, DRM_MODE_REFLECT_MASK);
+ vkms_config_plane_set_default_rotation(plane_cfg, DRM_MODE_REFLECT_X | DRM_MODE_ROTATE_0);
+ KUNIT_EXPECT_FALSE(test, vkms_config_valid_plane_rotation(config, plane_cfg));
+ KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
+
+ /* Invalid, default rotation must contain exactly one base rotation angle */
+ vkms_config_plane_set_supported_rotations(plane_cfg,
+ DRM_MODE_REFLECT_MASK | DRM_MODE_ROTATE_0);
+ vkms_config_plane_set_default_rotation(plane_cfg, DRM_MODE_REFLECT_X);
+ KUNIT_EXPECT_FALSE(test, vkms_config_valid_plane_rotation(config, plane_cfg));
+ KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
+
+ /* Invalid, multiple rotation bits in default_rotation */
+ vkms_config_plane_set_supported_rotations(plane_cfg,
+ DRM_MODE_REFLECT_MASK | DRM_MODE_ROTATE_MASK);
+ vkms_config_plane_set_default_rotation(plane_cfg, DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_90);
+ KUNIT_EXPECT_FALSE(test, vkms_config_valid_plane_rotation(config, plane_cfg));
+ KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
+
+ vkms_config_destroy(config);
+}
+
static void vkms_config_test_valid_plane_possible_crtcs(struct kunit *test)
{
struct vkms_config *config;
@@ -1003,6 +1055,7 @@ static struct kunit_case vkms_config_test_cases[] = {
KUNIT_CASE(vkms_config_test_get_connectors),
KUNIT_CASE(vkms_config_test_invalid_plane_number),
KUNIT_CASE(vkms_config_test_valid_plane_type),
+ KUNIT_CASE(vkms_config_test_valid_plane_rotations),
KUNIT_CASE(vkms_config_test_valid_plane_possible_crtcs),
KUNIT_CASE(vkms_config_test_invalid_crtc_number),
KUNIT_CASE(vkms_config_test_invalid_encoder_number),
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index 56ab9ea6e141..d4f15f1c53b0 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -2,8 +2,11 @@
#include <linux/slab.h>
#include <linux/string_choices.h>
+#include <linux/log2.h>
+#include <drm/drm_blend.h>
#include <drm/drm_connector.h>
+#include <drm/drm_mode.h>
#include <drm/drm_print.h>
#include <drm/drm_debugfs.h>
#include <kunit/visibility.h>
@@ -176,6 +179,35 @@ static bool valid_plane_number(const struct vkms_config *config)
return true;
}
+VISIBLE_IF_KUNIT
+bool vkms_config_valid_plane_rotation(const struct vkms_config *config,
+ const struct vkms_config_plane *plane_cfg)
+{
+ struct drm_device *dev = config->dev ? &config->dev->drm : NULL;
+
+ if ((vkms_config_plane_get_supported_rotations(plane_cfg) &
+ DRM_MODE_ROTATE_MASK) == 0) {
+ drm_info(dev, "Configured supported rotations must contain at least one base rotation angle\n");
+ return false;
+ }
+
+ if (!is_power_of_2(vkms_config_plane_get_default_rotation(plane_cfg) &
+ DRM_MODE_ROTATE_MASK)) {
+ drm_info(dev, "Configured default rotation must contain exactly one base rotation angle\n");
+ return false;
+ }
+
+ if ((vkms_config_plane_get_default_rotation(plane_cfg) &
+ vkms_config_plane_get_supported_rotations(plane_cfg)) !=
+ vkms_config_plane_get_default_rotation(plane_cfg)) {
+ drm_info(dev, "Configured default rotation is not supported by the plane\n");
+ return false;
+ }
+
+ return true;
+}
+EXPORT_SYMBOL_IF_KUNIT(vkms_config_valid_plane_rotation);
+
static bool valid_planes_for_crtc(const struct vkms_config *config,
struct vkms_config_crtc *crtc_cfg)
{
@@ -333,6 +365,12 @@ static bool valid_connector_possible_encoders(const struct vkms_config *config)
bool vkms_config_is_valid(const struct vkms_config *config)
{
struct vkms_config_crtc *crtc_cfg;
+ struct vkms_config_plane *plane_cfg;
+
+ vkms_config_for_each_plane(config, plane_cfg) {
+ if (!vkms_config_valid_plane_rotation(config, plane_cfg))
+ return false;
+ }
if (!valid_plane_number(config))
return false;
@@ -394,6 +432,10 @@ static int vkms_config_show(struct seq_file *m, void *data)
seq_printf(m, "\tname=%s\n",
vkms_config_plane_get_name(plane_cfg) ?
vkms_config_plane_get_name(plane_cfg) : "(null)");
+ seq_printf(m, "\tsupported rotations=" DRM_ROTATION_FMT "\n",
+ DRM_ROTATION_FMT_ARGS(vkms_config_plane_get_supported_rotations(plane_cfg)));
+ seq_printf(m, "\tdefault rotation=" DRM_ROTATION_FMT "\n",
+ DRM_ROTATION_FMT_ARGS(vkms_config_plane_get_default_rotation(plane_cfg)));
}
vkms_config_for_each_crtc(vkmsdev->config, crtc_cfg) {
@@ -444,6 +486,10 @@ struct vkms_config_plane __must_check *vkms_config_create_plane(struct vkms_conf
if (ret)
goto cleanup_plane_cfg;
+ vkms_config_plane_set_supported_rotations(plane_cfg,
+ DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK);
+ vkms_config_plane_set_default_rotation(plane_cfg, DRM_MODE_ROTATE_0);
+
xa_init_flags(&plane_cfg->possible_crtcs, XA_FLAGS_ALLOC);
list_add_tail_rcu(&plane_cfg->link, &config->planes);
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index e428946cb70e..8587a4a28b19 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -54,6 +54,8 @@ struct vkms_config {
* @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
+ * @default_rotation: Default rotation that should be used by this plane
+ * @supported_rotation: Rotation that this plane will support
* @plane: Internal usage. This pointer should never be considered as valid.
* It can be used to store a temporary reference to a VKMS plane during
* device creation. This pointer is not managed by the configuration and
@@ -66,6 +68,8 @@ struct vkms_config_plane {
const char *name;
enum drm_plane_type type;
+ unsigned int default_rotation;
+ unsigned int supported_rotations;
struct xarray possible_crtcs;
bool default_pipeline;
@@ -370,6 +374,61 @@ vkms_config_plane_set_default_pipeline(struct vkms_config_plane *plane_cfg,
plane_cfg->default_pipeline = default_pipeline;
}
+/**
+ * vkms_config_plane_get_default_rotation() - Get the default rotation for a plane
+ * @plane_cfg: Plane to get the default rotation from
+ *
+ * Returns:
+ * The default rotation for the plane.
+ */
+static inline unsigned int
+vkms_config_plane_get_default_rotation(const struct vkms_config_plane *plane_cfg)
+{
+ return plane_cfg->default_rotation;
+}
+
+/**
+ * vkms_config_plane_set_default_rotation() - Set the default rotation for a plane
+ * @plane_cfg: Plane to set the default rotation to
+ * @default_rotation: New default rotation for the plane
+ */
+static inline void
+vkms_config_plane_set_default_rotation(struct vkms_config_plane *plane_cfg,
+ unsigned int default_rotation)
+{
+ plane_cfg->default_rotation = default_rotation;
+}
+
+/**
+ * vkms_config_plane_get_supported_rotations() - Get the supported rotations for a plane
+ * @plane_cfg: Plane to get the supported rotations from
+ *
+ * Returns:
+ * The supported rotations for the plane.
+ */
+static inline unsigned int
+vkms_config_plane_get_supported_rotations(const struct vkms_config_plane *plane_cfg)
+{
+ return plane_cfg->supported_rotations;
+}
+
+/**
+ * vkms_config_plane_set_supported_rotations() - Set the supported rotations for a plane
+ * @plane_cfg: Plane to set the supported rotations to
+ * @supported_rotations: New supported rotations for the plane
+ */
+static inline void
+vkms_config_plane_set_supported_rotations(struct vkms_config_plane *plane_cfg,
+ unsigned int supported_rotations)
+{
+ plane_cfg->supported_rotations = supported_rotations;
+}
+
+#if IS_ENABLED(CONFIG_KUNIT)
+bool vkms_config_valid_plane_rotation(const struct vkms_config *config,
+ const struct vkms_config_plane *plane_cfg);
+#endif
+
/**
* vkms_config_plane_set_name() - Set the plane name
* @plane_cfg: Plane to set the name to
diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
index 35aabec85b33..9545bbd1744f 100644
--- a/drivers/gpu/drm/vkms/vkms_plane.c
+++ b/drivers/gpu/drm/vkms/vkms_plane.c
@@ -277,8 +277,9 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
drm_plane_helper_add(&plane->base, &vkms_plane_helper_funcs);
- drm_plane_create_rotation_property(&plane->base, DRM_MODE_ROTATE_0,
- DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK);
+ drm_plane_create_rotation_property(&plane->base,
+ vkms_config_plane_get_default_rotation(plane_cfg),
+ vkms_config_plane_get_supported_rotations(plane_cfg));
drm_plane_create_color_properties(&plane->base,
BIT(DRM_COLOR_YCBCR_BT601) |
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 20/43] drm/vkms: Introduce configfs for plane rotation
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (18 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 19/43] drm/vkms: Introduce config for plane rotation Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 21/43] drm/vkms: Introduce config for plane color encoding Louis Chauvet
` (22 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
To allows the userspace to test many hardware configurations, introduce a
new interface to configure the available rotation per planes. VKMS
supports any rotation and reflection, so the userspace can choose any
combination.
The supported rotations are configured by writing a rotation bitmask to
the file `supported_rotations` and the default rotation is chosen by
writing a rotation bitmask to `default_rotation`.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
Documentation/ABI/testing/configfs-vkms | 19 ++++++++
Documentation/gpu/vkms.rst | 7 ++-
drivers/gpu/drm/vkms/vkms_configfs.c | 84 +++++++++++++++++++++++++++++++++
3 files changed, 109 insertions(+), 1 deletion(-)
diff --git a/Documentation/ABI/testing/configfs-vkms b/Documentation/ABI/testing/configfs-vkms
index 55e4183046ec..07ebb797617d 100644
--- a/Documentation/ABI/testing/configfs-vkms
+++ b/Documentation/ABI/testing/configfs-vkms
@@ -108,6 +108,25 @@ Description:
Plane type. Possible values: 0 - overlay, 1 - primary,
2 - cursor.
+What: /sys/kernel/config/vkms/<device>/planes/<plane>/supported_rotations
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Available rotations for the plane, as a bitmask:
+ 0x01 - no rotation, 0x02 - rotate 90°, 0x04 - rotate 180°,
+ 0x08 - rotate 270°, 0x10 - reflect x, 0x20 - reflect y.
+ The value may be written in decimal or hexadecimal (with
+ a 0x prefix) and is read back as a decimal number.
+
+What: /sys/kernel/config/vkms/<device>/planes/<plane>/default_rotation
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Default rotation presented to userspace, using the same
+ bit values as supported_rotations. The value must contain
+ exactly one rotation bit; reflection bits may be set in
+ addition.
+
What: /sys/kernel/config/vkms/<device>/planes/<plane>/possible_crtcs
Date: Nov 2025
Contact: dri-devel@lists.freedesktop.org
diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst
index 1e79e62a6bc4..610305483716 100644
--- a/Documentation/gpu/vkms.rst
+++ b/Documentation/gpu/vkms.rst
@@ -87,10 +87,15 @@ Start by creating one or more planes::
sudo mkdir /config/vkms/my-vkms/planes/plane0
-Planes have 1 configurable attribute:
+Planes have 3 configurable attributes:
- type: Plane type: 0 overlay, 1 primary, 2 cursor (same values as those
exposed by the "type" property of a plane)
+- supported_rotations: Available rotation for a plane, as a bitmask: 0x01 no rotation,
+ 0x02 rotate 90°, 0x04 rotate 180°, 0x08 rotate 270°, 0x10 reflect x, 0x20 reflect y
+ (same values as those exposed by the "rotation" property of a plane)
+- default_rotation: Default rotation presented to the userspace, same values as
+ supported_rotations.
Continue by creating one or more CRTCs::
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index bbfc0c8a922c..5c62797627c1 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -322,10 +322,94 @@ static ssize_t plane_type_store(struct config_item *item, const char *page,
return (ssize_t)count;
}
+static ssize_t plane_supported_rotations_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item);
+ unsigned int plane_supported_rotations;
+
+ scoped_guard(mutex, &plane->dev->config->lock)
+ plane_supported_rotations = vkms_config_plane_get_supported_rotations(plane->config);
+
+ return sprintf(page, "%u\n", plane_supported_rotations);
+}
+
+static ssize_t plane_supported_rotations_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item);
+ int ret;
+ unsigned int val = 0;
+
+ ret = kstrtouint(page, 0, &val);
+ if (ret)
+ return ret;
+
+ /* Should be a supported value */
+ if (val & ~(DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK))
+ return -EINVAL;
+ /* Should at least provide one rotation */
+ if (!(val & DRM_MODE_ROTATE_MASK))
+ return -EINVAL;
+
+ scoped_guard(mutex, &plane->dev->config->lock) {
+ if (plane->dev->enabled)
+ return -EBUSY;
+
+ vkms_config_plane_set_supported_rotations(plane->config, val);
+ }
+
+ return count;
+}
+
+static ssize_t plane_default_rotation_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item);
+ unsigned int plane_default_rotation;
+
+ scoped_guard(mutex, &plane->dev->config->lock) {
+ plane_default_rotation = vkms_config_plane_get_default_rotation(plane->config);
+ }
+
+ return sprintf(page, "%u\n", plane_default_rotation);
+}
+
+static ssize_t plane_default_rotation_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item);
+ int ret;
+ unsigned int val = 0;
+
+ ret = kstrtouint(page, 0, &val);
+ if (ret)
+ return ret;
+
+ /* Should be a supported value */
+ if (val & ~(DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK))
+ return -EINVAL;
+
+ /* Should contain exactly one rotation */
+ if (!is_power_of_2(val & DRM_MODE_ROTATE_MASK))
+ return -EINVAL;
+
+ scoped_guard(mutex, &plane->dev->config->lock) {
+ if (plane->dev->enabled)
+ return -EBUSY;
+
+ vkms_config_plane_set_default_rotation(plane->config, val);
+ }
+
+ return count;
+}
+
CONFIGFS_ATTR(plane_, type);
+CONFIGFS_ATTR(plane_, supported_rotations);
+CONFIGFS_ATTR(plane_, default_rotation);
static struct configfs_attribute *plane_item_attrs[] = {
&plane_attr_type,
+ &plane_attr_supported_rotations,
+ &plane_attr_default_rotation,
NULL,
};
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 21/43] drm/vkms: Introduce config for plane color encoding
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (19 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 20/43] drm/vkms: Introduce configfs " Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 22/43] drm/vkms: Introduce configfs " Louis Chauvet
` (21 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
VKMS driver supports all the color encoding on planes, but for testing it
can be useful to only advertise few of them. This new configuration
interface will allow configuring the color encoding per planes.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/tests/vkms_config_test.c | 51 +++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_config.c | 48 ++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_config.h | 64 +++++++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_plane.c | 15 +++----
4 files changed, 170 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/vkms/tests/vkms_config_test.c b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
index dcb29ed8ac4a..0254268da6a2 100644
--- a/drivers/gpu/drm/vkms/tests/vkms_config_test.c
+++ b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
@@ -192,6 +192,14 @@ static void vkms_config_test_default_config(struct kunit *test)
KUNIT_EXPECT_EQ(test,
vkms_config_plane_get_default_rotation(plane_cfg),
DRM_MODE_ROTATE_0);
+ KUNIT_EXPECT_EQ(test,
+ vkms_config_plane_get_supported_color_encodings(plane_cfg),
+ BIT(DRM_COLOR_YCBCR_BT601) |
+ BIT(DRM_COLOR_YCBCR_BT709) |
+ BIT(DRM_COLOR_YCBCR_BT2020));
+ KUNIT_EXPECT_EQ(test,
+ vkms_config_plane_get_default_color_encoding(plane_cfg),
+ DRM_COLOR_YCBCR_BT601);
}
/* Encoders */
@@ -533,6 +541,48 @@ static void vkms_config_test_valid_plane_rotations(struct kunit *test)
vkms_config_destroy(config);
}
+static void vkms_config_test_valid_plane_color_encoding(struct kunit *test)
+{
+ struct vkms_config *config;
+ struct vkms_config_plane *plane_cfg;
+
+ config = vkms_config_default_create(false, false, false, false);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+
+ plane_cfg = get_first_plane(config);
+
+ /* Valid, all color encoding supported */
+ vkms_config_plane_set_supported_color_encodings(plane_cfg,
+ BIT(DRM_COLOR_YCBCR_BT601) |
+ BIT(DRM_COLOR_YCBCR_BT709) |
+ BIT(DRM_COLOR_YCBCR_BT2020));
+ vkms_config_plane_set_default_color_encoding(plane_cfg, DRM_COLOR_YCBCR_BT601);
+ KUNIT_EXPECT_TRUE(test, vkms_config_valid_plane_color_encoding(config, plane_cfg));
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Invalid, default color encoding is not supported */
+ vkms_config_plane_set_supported_color_encodings(plane_cfg,
+ BIT(DRM_COLOR_YCBCR_BT601) |
+ BIT(DRM_COLOR_YCBCR_BT2020));
+ vkms_config_plane_set_default_color_encoding(plane_cfg, DRM_COLOR_YCBCR_BT709);
+ KUNIT_EXPECT_FALSE(test, vkms_config_valid_plane_color_encoding(config, plane_cfg));
+ KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
+
+ /* Valid, no supported or color encoding */
+ vkms_config_plane_set_supported_color_encodings(plane_cfg, 0);
+ vkms_config_plane_set_default_color_encoding(plane_cfg, 0);
+ KUNIT_EXPECT_TRUE(test, vkms_config_valid_plane_color_encoding(config, plane_cfg));
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Valid, if no supported color encoding, default is ignored */
+ vkms_config_plane_set_supported_color_encodings(plane_cfg, 0);
+ vkms_config_plane_set_default_color_encoding(plane_cfg, DRM_COLOR_YCBCR_BT601);
+ KUNIT_EXPECT_TRUE(test, vkms_config_valid_plane_color_encoding(config, plane_cfg));
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ vkms_config_destroy(config);
+}
+
static void vkms_config_test_valid_plane_possible_crtcs(struct kunit *test)
{
struct vkms_config *config;
@@ -1056,6 +1106,7 @@ static struct kunit_case vkms_config_test_cases[] = {
KUNIT_CASE(vkms_config_test_invalid_plane_number),
KUNIT_CASE(vkms_config_test_valid_plane_type),
KUNIT_CASE(vkms_config_test_valid_plane_rotations),
+ KUNIT_CASE(vkms_config_test_valid_plane_color_encoding),
KUNIT_CASE(vkms_config_test_valid_plane_possible_crtcs),
KUNIT_CASE(vkms_config_test_invalid_crtc_number),
KUNIT_CASE(vkms_config_test_invalid_encoder_number),
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index d4f15f1c53b0..90cc28f3d386 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -208,6 +208,25 @@ bool vkms_config_valid_plane_rotation(const struct vkms_config *config,
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_valid_plane_rotation);
+VISIBLE_IF_KUNIT
+bool vkms_config_valid_plane_color_encoding(const struct vkms_config *config,
+ const struct vkms_config_plane *plane_cfg)
+{
+ struct drm_device *dev = config->dev ? &config->dev->drm : NULL;
+
+ if (vkms_config_plane_get_supported_color_encodings(plane_cfg)) {
+ if ((BIT(vkms_config_plane_get_default_color_encoding(plane_cfg)) &
+ vkms_config_plane_get_supported_color_encodings(plane_cfg)) !=
+ BIT(vkms_config_plane_get_default_color_encoding(plane_cfg))) {
+ drm_info(dev, "Configured default color encoding is not supported by the plane\n");
+ return false;
+ }
+ }
+
+ return true;
+}
+EXPORT_SYMBOL_IF_KUNIT(vkms_config_valid_plane_color_encoding);
+
static bool valid_planes_for_crtc(const struct vkms_config *config,
struct vkms_config_crtc *crtc_cfg)
{
@@ -370,6 +389,9 @@ bool vkms_config_is_valid(const struct vkms_config *config)
vkms_config_for_each_plane(config, plane_cfg) {
if (!vkms_config_valid_plane_rotation(config, plane_cfg))
return false;
+
+ if (!vkms_config_valid_plane_color_encoding(config, plane_cfg))
+ return false;
}
if (!valid_plane_number(config))
@@ -402,6 +424,22 @@ bool vkms_config_is_valid(const struct vkms_config *config)
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_is_valid);
+static __nocfi void show_bitfield(struct seq_file *m, uint32_t value, const char *callback(unsigned int))
+{
+ u32 offset = 0;
+ bool first = true;
+
+ while (value >= BIT(offset) && offset < 32) {
+ if (value & BIT(offset)) {
+ if (!first)
+ seq_puts(m, ",");
+ seq_printf(m, "%s", callback(offset));
+ first = false;
+ }
+ offset += 1;
+ }
+}
+
static int vkms_config_show(struct seq_file *m, void *data)
{
struct drm_debugfs_entry *entry = m->private;
@@ -436,6 +474,12 @@ static int vkms_config_show(struct seq_file *m, void *data)
DRM_ROTATION_FMT_ARGS(vkms_config_plane_get_supported_rotations(plane_cfg)));
seq_printf(m, "\tdefault rotation=" DRM_ROTATION_FMT "\n",
DRM_ROTATION_FMT_ARGS(vkms_config_plane_get_default_rotation(plane_cfg)));
+ seq_puts(m, "\tsupported color encoding=");
+ show_bitfield(m, vkms_config_plane_get_supported_color_encodings(plane_cfg),
+ drm_get_color_encoding_name);
+ seq_puts(m, "\n");
+ seq_printf(m, "\tdefault color encoding=%s\n",
+ drm_get_color_encoding_name(vkms_config_plane_get_default_color_encoding(plane_cfg)));
}
vkms_config_for_each_crtc(vkmsdev->config, crtc_cfg) {
@@ -489,6 +533,10 @@ struct vkms_config_plane __must_check *vkms_config_create_plane(struct vkms_conf
vkms_config_plane_set_supported_rotations(plane_cfg,
DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK);
vkms_config_plane_set_default_rotation(plane_cfg, DRM_MODE_ROTATE_0);
+ vkms_config_plane_set_supported_color_encodings(plane_cfg, BIT(DRM_COLOR_YCBCR_BT601) |
+ BIT(DRM_COLOR_YCBCR_BT709) |
+ BIT(DRM_COLOR_YCBCR_BT2020));
+ vkms_config_plane_set_default_color_encoding(plane_cfg, DRM_COLOR_YCBCR_BT601);
xa_init_flags(&plane_cfg->possible_crtcs, XA_FLAGS_ALLOC);
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index 8587a4a28b19..11457213a551 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -60,6 +60,8 @@ struct vkms_config {
* It can be used to store a temporary reference to a VKMS plane during
* device creation. This pointer is not managed by the configuration and
* must be managed by other means.
+ * @default_color_encoding: Default color encoding that should be used by this plane
+ * @supported_color_encodings: Color encodings that this plane will support
*/
struct vkms_config_plane {
struct list_head link;
@@ -70,6 +72,8 @@ struct vkms_config_plane {
enum drm_plane_type type;
unsigned int default_rotation;
unsigned int supported_rotations;
+ enum drm_color_encoding default_color_encoding;
+ unsigned int supported_color_encodings;
struct xarray possible_crtcs;
bool default_pipeline;
@@ -429,6 +433,66 @@ bool vkms_config_valid_plane_rotation(const struct vkms_config *config,
const struct vkms_config_plane *plane_cfg);
#endif
+/**
+ * vkms_config_plane_get_default_color_encoding() - Get the default color encoding for a plane
+ * @plane_cfg: Plane to get the default color encoding from
+ *
+ * Returns:
+ * The default color encoding for the plane
+ */
+static inline enum drm_color_encoding
+vkms_config_plane_get_default_color_encoding(const struct vkms_config_plane *plane_cfg)
+{
+ return plane_cfg->default_color_encoding;
+}
+
+/**
+ * vkms_config_plane_set_default_color_encoding() - Set the default color encoding for a plane
+ * @plane_cfg: Plane to set the default color encoding to
+ * @default_color_encoding: New default color encoding for the plane
+ */
+static inline void
+vkms_config_plane_set_default_color_encoding(struct vkms_config_plane *plane_cfg,
+ enum drm_color_encoding default_color_encoding)
+{
+ plane_cfg->default_color_encoding = default_color_encoding;
+}
+
+/**
+ * vkms_config_plane_get_supported_color_encodings() - Get the supported color encodings for a plane
+ * @plane_cfg: Plane to get the supported color encodings from
+ *
+ * Returns:
+ * The supported color encodings for the plane. Each set bit correspond to a value of enum
+ * drm_color_encoding: BIT(DRM_COLOR_YCBCR_BT601) | BIT(DRM_COLOR_YCBCR_BT709) means that
+ * DRM_COLOR_YCBCR_BT601 and DRM_COLOR_YCBCR_BT709 are supported.
+ */
+static inline unsigned int
+vkms_config_plane_get_supported_color_encodings(const struct vkms_config_plane *plane_cfg)
+{
+ return plane_cfg->supported_color_encodings;
+}
+
+/**
+ * vkms_config_plane_set_supported_color_encodings() - Set the supported color encodings for a plane
+ * @plane_cfg: Plane to set the supported color encodings to
+ * @supported_color_encodings: New supported color encodings for the plane. Each set bit corresponds
+ * to a value of enum drm_color_encoding:
+ * BIT(DRM_COLOR_YCBCR_BT601) | BIT(DRM_COLOR_YCBCR_BT709) means that
+ * DRM_COLOR_YCBCR_BT601 and DRM_COLOR_YCBCR_BT709 are supported.
+ */
+static inline void
+vkms_config_plane_set_supported_color_encodings(struct vkms_config_plane *plane_cfg,
+ unsigned int supported_color_encodings)
+{
+ plane_cfg->supported_color_encodings = supported_color_encodings;
+}
+
+#if IS_ENABLED(CONFIG_KUNIT)
+bool vkms_config_valid_plane_color_encoding(const struct vkms_config *config,
+ const struct vkms_config_plane *plane_cfg);
+#endif
+
/**
* vkms_config_plane_set_name() - Set the plane name
* @plane_cfg: Plane to set the name to
diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
index 9545bbd1744f..92018e5b7a56 100644
--- a/drivers/gpu/drm/vkms/vkms_plane.c
+++ b/drivers/gpu/drm/vkms/vkms_plane.c
@@ -281,14 +281,13 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
vkms_config_plane_get_default_rotation(plane_cfg),
vkms_config_plane_get_supported_rotations(plane_cfg));
- drm_plane_create_color_properties(&plane->base,
- BIT(DRM_COLOR_YCBCR_BT601) |
- BIT(DRM_COLOR_YCBCR_BT709) |
- BIT(DRM_COLOR_YCBCR_BT2020),
- BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
- BIT(DRM_COLOR_YCBCR_FULL_RANGE),
- DRM_COLOR_YCBCR_BT601,
- DRM_COLOR_YCBCR_FULL_RANGE);
+ if (vkms_config_plane_get_supported_color_encodings(plane_cfg) != 0)
+ drm_plane_create_color_properties(&plane->base,
+ vkms_config_plane_get_supported_color_encodings(plane_cfg),
+ BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
+ BIT(DRM_COLOR_YCBCR_FULL_RANGE),
+ vkms_config_plane_get_default_color_encoding(plane_cfg),
+ DRM_COLOR_YCBCR_FULL_RANGE);
if (vkms_config_plane_get_default_pipeline(plane_cfg))
vkms_initialize_colorops(&plane->base);
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 22/43] drm/vkms: Introduce configfs for plane color encoding
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (20 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 21/43] drm/vkms: Introduce config for plane color encoding Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 23/43] drm/vkms: Introduce config for plane color range Louis Chauvet
` (20 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
To allows the userspace to test many hardware configuration, introduce a
new interface to configure the available color encoding per planes. VKMS
supports multiple color encoding, so the userspace can choose any
combination.
The supported color encoding are configured by writing a color encoding
bitmask to the file `supported_color_encoding` and the default color
encoding is chosen by writing a color encoding bitmask to
`default_color_encoding`.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
Documentation/ABI/testing/configfs-vkms | 18 +++++++
Documentation/gpu/vkms.rst | 8 ++-
drivers/gpu/drm/vkms/vkms_configfs.c | 91 +++++++++++++++++++++++++++++++++
3 files changed, 116 insertions(+), 1 deletion(-)
diff --git a/Documentation/ABI/testing/configfs-vkms b/Documentation/ABI/testing/configfs-vkms
index 07ebb797617d..592df5602065 100644
--- a/Documentation/ABI/testing/configfs-vkms
+++ b/Documentation/ABI/testing/configfs-vkms
@@ -127,6 +127,24 @@ Description:
exactly one rotation bit; reflection bits may be set in
addition.
+What: /sys/kernel/config/vkms/<device>/planes/<plane>/supported_color_encodings
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Available color encodings for the plane, as a bitmask:
+ 0x01 - YCBCR_BT601, 0x02 - YCBCR_BT709, 0x04 - YCBCR_BT2020.
+ The value may be written in decimal or hexadecimal (with
+ a 0x prefix) and is read back as a decimal number.
+
+What: /sys/kernel/config/vkms/<device>/planes/<plane>/default_color_encoding
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Default color encoding presented to userspace, using the
+ same bit values as supported_color_encodings. The value
+ must be a single bit: 1 - YCBCR_BT601, 2 - YCBCR_BT709,
+ 4 - YCBCR_BT2020.
+
What: /sys/kernel/config/vkms/<device>/planes/<plane>/possible_crtcs
Date: Nov 2025
Contact: dri-devel@lists.freedesktop.org
diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst
index 610305483716..7206cd2b231a 100644
--- a/Documentation/gpu/vkms.rst
+++ b/Documentation/gpu/vkms.rst
@@ -87,7 +87,7 @@ Start by creating one or more planes::
sudo mkdir /config/vkms/my-vkms/planes/plane0
-Planes have 3 configurable attributes:
+Planes have 5 configurable attributes:
- type: Plane type: 0 overlay, 1 primary, 2 cursor (same values as those
exposed by the "type" property of a plane)
@@ -96,6 +96,12 @@ Planes have 3 configurable attributes:
(same values as those exposed by the "rotation" property of a plane)
- default_rotation: Default rotation presented to the userspace, same values as
supported_rotations.
+- supported_color_encodings: Available encodings for a plane, as a bitmask:
+ 0x01 YCBCR_BT601, 0x02 YCBCR_BT709, 0x04 YCBCR_BT2020 (same values as those exposed
+ by the COLOR_ENCODING property of a plane). If set, supported_color_range
+ must be set too.
+- default_color_encoding: Default color encoding presented to the userspace, same
+ values as supported_color_encodings
Continue by creating one or more CRTCs::
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index 5c62797627c1..c6efc6db64c4 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -9,6 +9,14 @@
#include "vkms_configfs.h"
#include "vkms_connector.h"
+/**
+ * VKMS_SUPPORTED_COLOR_ENCODINGS - Bitmask of all supported color encodings in VKMS
+ */
+#define VKMS_SUPPORTED_COLOR_ENCODINGS ( \
+ BIT(DRM_COLOR_YCBCR_BT601) | \
+ BIT(DRM_COLOR_YCBCR_BT709) | \
+ BIT(DRM_COLOR_YCBCR_BT2020))
+
/* To avoid registering configfs more than once or unregistering on error */
static bool is_configfs_registered;
@@ -402,14 +410,97 @@ static ssize_t plane_default_rotation_store(struct config_item *item,
return count;
}
+static ssize_t plane_supported_color_encodings_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item);
+ unsigned int supported_color_encodings;
+
+ scoped_guard(mutex, &plane->dev->config->lock)
+ supported_color_encodings = vkms_config_plane_get_supported_color_encodings(plane->config);
+
+ return sprintf(page, "%u\n", supported_color_encodings);
+}
+
+static ssize_t plane_supported_color_encodings_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item);
+ int ret;
+ unsigned int val = 0;
+
+ ret = kstrtouint(page, 0, &val);
+ if (ret)
+ return ret;
+
+ /* Should be a supported value */
+ if (val & ~(VKMS_SUPPORTED_COLOR_ENCODINGS))
+ return -EINVAL;
+
+ scoped_guard(mutex, &plane->dev->config->lock) {
+ if (plane->dev->enabled)
+ return -EBUSY;
+
+ vkms_config_plane_set_supported_color_encodings(plane->config, val);
+ }
+
+ return count;
+}
+
+static ssize_t plane_default_color_encoding_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item);
+ unsigned int default_color_encoding;
+
+ scoped_guard(mutex, &plane->dev->config->lock)
+ default_color_encoding = BIT(vkms_config_plane_get_default_color_encoding(plane->config));
+
+ return sprintf(page, "%u\n", default_color_encoding);
+}
+
+static ssize_t plane_default_color_encoding_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item);
+ int ret;
+ unsigned int val = 0;
+
+ ret = kstrtouint(page, 0, &val);
+ if (ret)
+ return ret;
+
+ /* Should be a supported value */
+ if (val & ~VKMS_SUPPORTED_COLOR_ENCODINGS)
+ return -EINVAL;
+
+ /* Ensure val is a single bit set */
+ if (!is_power_of_2(val))
+ return -EINVAL;
+
+ /* Convert bit position to the proper enum value */
+ val = __ffs(val) + DRM_COLOR_YCBCR_BT601;
+
+ scoped_guard(mutex, &plane->dev->config->lock) {
+ if (plane->dev->enabled)
+ return -EBUSY;
+
+ vkms_config_plane_set_default_color_encoding(plane->config, val);
+ }
+
+ return count;
+}
+
CONFIGFS_ATTR(plane_, type);
CONFIGFS_ATTR(plane_, supported_rotations);
CONFIGFS_ATTR(plane_, default_rotation);
+CONFIGFS_ATTR(plane_, supported_color_encodings);
+CONFIGFS_ATTR(plane_, default_color_encoding);
static struct configfs_attribute *plane_item_attrs[] = {
&plane_attr_type,
&plane_attr_supported_rotations,
&plane_attr_default_rotation,
+ &plane_attr_supported_color_encodings,
+ &plane_attr_default_color_encoding,
NULL,
};
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 23/43] drm/vkms: Introduce config for plane color range
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (21 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 22/43] drm/vkms: Introduce configfs " Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 24/43] drm/vkms: Introduce configfs " Louis Chauvet
` (19 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
VKMS driver supports all the color range on planes, but for testing it can
be useful to only advertise few of them. This new configuration interface
will allow configuring the color range per planes.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/tests/vkms_config_test.c | 44 +++++++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_config.c | 39 ++++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_config.h | 35 +++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_plane.c | 8 ++---
4 files changed, 122 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/vkms/tests/vkms_config_test.c b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
index 0254268da6a2..0f902e770e4b 100644
--- a/drivers/gpu/drm/vkms/tests/vkms_config_test.c
+++ b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
+#include <drm/drm_color_mgmt.h>
#include <drm/drm_mode.h>
#include <kunit/test.h>
@@ -569,6 +570,7 @@ static void vkms_config_test_valid_plane_color_encoding(struct kunit *test)
KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
/* Valid, no supported or color encoding */
+ vkms_config_plane_set_supported_color_ranges(plane_cfg, 0);
vkms_config_plane_set_supported_color_encodings(plane_cfg, 0);
vkms_config_plane_set_default_color_encoding(plane_cfg, 0);
KUNIT_EXPECT_TRUE(test, vkms_config_valid_plane_color_encoding(config, plane_cfg));
@@ -583,6 +585,47 @@ static void vkms_config_test_valid_plane_color_encoding(struct kunit *test)
vkms_config_destroy(config);
}
+static void vkms_config_test_valid_plane_color_range(struct kunit *test)
+{
+ struct vkms_config *config;
+ struct vkms_config_plane *plane_cfg;
+
+ config = vkms_config_default_create(false, false, false, false);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+
+ plane_cfg = get_first_plane(config);
+
+ /* Valid, all color range supported */
+ vkms_config_plane_set_supported_color_ranges(plane_cfg,
+ BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
+ BIT(DRM_COLOR_YCBCR_FULL_RANGE));
+ vkms_config_plane_set_default_color_range(plane_cfg, DRM_COLOR_YCBCR_FULL_RANGE);
+ KUNIT_EXPECT_TRUE(test, vkms_config_valid_plane_color_range(config, plane_cfg));
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Invalid, default color range is not supported */
+ vkms_config_plane_set_supported_color_ranges(plane_cfg,
+ BIT(DRM_COLOR_YCBCR_FULL_RANGE));
+ vkms_config_plane_set_default_color_range(plane_cfg, DRM_COLOR_YCBCR_LIMITED_RANGE);
+ KUNIT_EXPECT_FALSE(test, vkms_config_valid_plane_color_range(config, plane_cfg));
+ KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
+
+ /* Valid, no supported or color range */
+ vkms_config_plane_set_supported_color_encodings(plane_cfg, 0);
+ vkms_config_plane_set_supported_color_ranges(plane_cfg, 0);
+ vkms_config_plane_set_default_color_range(plane_cfg, 0);
+ KUNIT_EXPECT_TRUE(test, vkms_config_valid_plane_color_range(config, plane_cfg));
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Valid, if no supported color range, default is ignored */
+ vkms_config_plane_set_supported_color_ranges(plane_cfg, 0);
+ vkms_config_plane_set_default_color_range(plane_cfg, DRM_COLOR_YCBCR_LIMITED_RANGE);
+ KUNIT_EXPECT_TRUE(test, vkms_config_valid_plane_color_range(config, plane_cfg));
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ vkms_config_destroy(config);
+}
+
static void vkms_config_test_valid_plane_possible_crtcs(struct kunit *test)
{
struct vkms_config *config;
@@ -1107,6 +1150,7 @@ static struct kunit_case vkms_config_test_cases[] = {
KUNIT_CASE(vkms_config_test_valid_plane_type),
KUNIT_CASE(vkms_config_test_valid_plane_rotations),
KUNIT_CASE(vkms_config_test_valid_plane_color_encoding),
+ KUNIT_CASE(vkms_config_test_valid_plane_color_range),
KUNIT_CASE(vkms_config_test_valid_plane_possible_crtcs),
KUNIT_CASE(vkms_config_test_invalid_crtc_number),
KUNIT_CASE(vkms_config_test_invalid_encoder_number),
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index 90cc28f3d386..6e4e2143c652 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -227,6 +227,25 @@ bool vkms_config_valid_plane_color_encoding(const struct vkms_config *config,
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_valid_plane_color_encoding);
+VISIBLE_IF_KUNIT
+bool vkms_config_valid_plane_color_range(const struct vkms_config *config,
+ const struct vkms_config_plane *plane_cfg)
+{
+ struct drm_device *dev = config->dev ? &config->dev->drm : NULL;
+
+ if (vkms_config_plane_get_supported_color_ranges(plane_cfg)) {
+ if ((BIT(vkms_config_plane_get_default_color_range(plane_cfg)) &
+ vkms_config_plane_get_supported_color_ranges(plane_cfg)) !=
+ BIT(vkms_config_plane_get_default_color_range(plane_cfg))) {
+ drm_info(dev, "Configured default color range is not supported by the plane\n");
+ return false;
+ }
+ }
+
+ return true;
+}
+EXPORT_SYMBOL_IF_KUNIT(vkms_config_valid_plane_color_range);
+
static bool valid_planes_for_crtc(const struct vkms_config *config,
struct vkms_config_crtc *crtc_cfg)
{
@@ -383,6 +402,7 @@ static bool valid_connector_possible_encoders(const struct vkms_config *config)
bool vkms_config_is_valid(const struct vkms_config *config)
{
+ struct drm_device *dev = config->dev ? &config->dev->drm : NULL;
struct vkms_config_crtc *crtc_cfg;
struct vkms_config_plane *plane_cfg;
@@ -392,6 +412,16 @@ bool vkms_config_is_valid(const struct vkms_config *config)
if (!vkms_config_valid_plane_color_encoding(config, plane_cfg))
return false;
+
+ if (!vkms_config_valid_plane_color_range(config, plane_cfg))
+ return false;
+
+ if ((vkms_config_plane_get_supported_color_encodings(plane_cfg) == 0) !=
+ (vkms_config_plane_get_supported_color_ranges(plane_cfg) == 0)) {
+ drm_info(dev,
+ "Both supported color encodings and color ranges must be set, or none\n");
+ return false;
+ }
}
if (!valid_plane_number(config))
@@ -480,6 +510,12 @@ static int vkms_config_show(struct seq_file *m, void *data)
seq_puts(m, "\n");
seq_printf(m, "\tdefault color encoding=%s\n",
drm_get_color_encoding_name(vkms_config_plane_get_default_color_encoding(plane_cfg)));
+ seq_puts(m, "\tsupported color ranges=");
+ show_bitfield(m, vkms_config_plane_get_supported_color_ranges(plane_cfg),
+ drm_get_color_range_name);
+ seq_puts(m, "\n");
+ seq_printf(m, "\tdefault color range=%s\n",
+ drm_get_color_range_name(vkms_config_plane_get_default_color_range(plane_cfg)));
}
vkms_config_for_each_crtc(vkmsdev->config, crtc_cfg) {
@@ -537,6 +573,9 @@ struct vkms_config_plane __must_check *vkms_config_create_plane(struct vkms_conf
BIT(DRM_COLOR_YCBCR_BT709) |
BIT(DRM_COLOR_YCBCR_BT2020));
vkms_config_plane_set_default_color_encoding(plane_cfg, DRM_COLOR_YCBCR_BT601);
+ vkms_config_plane_set_supported_color_ranges(plane_cfg, BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
+ BIT(DRM_COLOR_YCBCR_FULL_RANGE));
+ vkms_config_plane_set_default_color_range(plane_cfg, DRM_COLOR_YCBCR_FULL_RANGE);
xa_init_flags(&plane_cfg->possible_crtcs, XA_FLAGS_ALLOC);
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index 11457213a551..20369e8d7c6e 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -62,6 +62,8 @@ struct vkms_config {
* must be managed by other means.
* @default_color_encoding: Default color encoding that should be used by this plane
* @supported_color_encodings: Color encodings that this plane will support
+ * @default_color_range: Default color range that should be used by this plane
+ * @supported_color_ranges: Color ranges that this plane will support
*/
struct vkms_config_plane {
struct list_head link;
@@ -74,6 +76,8 @@ struct vkms_config_plane {
unsigned int supported_rotations;
enum drm_color_encoding default_color_encoding;
unsigned int supported_color_encodings;
+ enum drm_color_range default_color_range;
+ unsigned int supported_color_ranges;
struct xarray possible_crtcs;
bool default_pipeline;
@@ -493,6 +497,37 @@ bool vkms_config_valid_plane_color_encoding(const struct vkms_config *config,
const struct vkms_config_plane *plane_cfg);
#endif
+static inline enum drm_color_range
+vkms_config_plane_get_default_color_range(const struct vkms_config_plane *plane_cfg)
+{
+ return plane_cfg->default_color_range;
+}
+
+static inline void
+vkms_config_plane_set_default_color_range(struct vkms_config_plane *plane_cfg,
+ enum drm_color_range default_color_range)
+{
+ plane_cfg->default_color_range = default_color_range;
+}
+
+static inline unsigned int
+vkms_config_plane_get_supported_color_ranges(const struct vkms_config_plane *plane_cfg)
+{
+ return plane_cfg->supported_color_ranges;
+}
+
+static inline void
+vkms_config_plane_set_supported_color_ranges(struct vkms_config_plane *plane_cfg,
+ unsigned int supported_color_ranges)
+{
+ plane_cfg->supported_color_ranges = supported_color_ranges;
+}
+
+#if IS_ENABLED(CONFIG_KUNIT)
+bool vkms_config_valid_plane_color_range(const struct vkms_config *config,
+ const struct vkms_config_plane *plane_cfg);
+#endif
+
/**
* vkms_config_plane_set_name() - Set the plane name
* @plane_cfg: Plane to set the name to
diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
index 92018e5b7a56..71be819fe159 100644
--- a/drivers/gpu/drm/vkms/vkms_plane.c
+++ b/drivers/gpu/drm/vkms/vkms_plane.c
@@ -281,13 +281,13 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
vkms_config_plane_get_default_rotation(plane_cfg),
vkms_config_plane_get_supported_rotations(plane_cfg));
- if (vkms_config_plane_get_supported_color_encodings(plane_cfg) != 0)
+ if (vkms_config_plane_get_supported_color_encodings(plane_cfg) != 0 &&
+ vkms_config_plane_get_supported_color_ranges(plane_cfg) != 0)
drm_plane_create_color_properties(&plane->base,
vkms_config_plane_get_supported_color_encodings(plane_cfg),
- BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
- BIT(DRM_COLOR_YCBCR_FULL_RANGE),
+ vkms_config_plane_get_supported_color_ranges(plane_cfg),
vkms_config_plane_get_default_color_encoding(plane_cfg),
- DRM_COLOR_YCBCR_FULL_RANGE);
+ vkms_config_plane_get_default_color_range(plane_cfg));
if (vkms_config_plane_get_default_pipeline(plane_cfg))
vkms_initialize_colorops(&plane->base);
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 24/43] drm/vkms: Introduce configfs for plane color range
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (22 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 23/43] drm/vkms: Introduce config for plane color range Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 25/43] drm/vkms: Introduce config for plane format Louis Chauvet
` (18 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
To allows the userspace to test many hardware configuration, introduce a
new interface to configure the available color ranges per planes. VKMS
supports multiple color ranges, so the userspace can choose any
combination.
The supported color ranges are configured by writing a color range bitmask
to the file `supported_color_ranges` and the default color range is
chosen by writing a color range bitmask to `default_color_range`.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
Documentation/ABI/testing/configfs-vkms | 19 +++++++
Documentation/gpu/vkms.rst | 10 +++-
drivers/gpu/drm/vkms/vkms_configfs.c | 91 +++++++++++++++++++++++++++++++++
3 files changed, 118 insertions(+), 2 deletions(-)
diff --git a/Documentation/ABI/testing/configfs-vkms b/Documentation/ABI/testing/configfs-vkms
index 592df5602065..16a44cc60e4a 100644
--- a/Documentation/ABI/testing/configfs-vkms
+++ b/Documentation/ABI/testing/configfs-vkms
@@ -145,6 +145,25 @@ Description:
must be a single bit: 1 - YCBCR_BT601, 2 - YCBCR_BT709,
4 - YCBCR_BT2020.
+What: /sys/kernel/config/vkms/<device>/planes/<plane>/supported_color_ranges
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Available color ranges for the plane, as a bitmask:
+ 0x1 - DRM_COLOR_YCBCR_LIMITED_RANGE,
+ 0x2 - DRM_COLOR_YCBCR_FULL_RANGE. The value may be
+ written in decimal or hexadecimal (with a 0x prefix) and
+ is read back as a decimal number.
+
+What: /sys/kernel/config/vkms/<device>/planes/<plane>/default_color_range
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Default color range presented to userspace. Value is a
+ decimal number with exactly one bit set: 1 -
+ DRM_COLOR_YCBCR_LIMITED_RANGE, 2 -
+ DRM_COLOR_YCBCR_FULL_RANGE.
+
What: /sys/kernel/config/vkms/<device>/planes/<plane>/possible_crtcs
Date: Nov 2025
Contact: dri-devel@lists.freedesktop.org
diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst
index 7206cd2b231a..7e8f4fe3b392 100644
--- a/Documentation/gpu/vkms.rst
+++ b/Documentation/gpu/vkms.rst
@@ -87,7 +87,7 @@ Start by creating one or more planes::
sudo mkdir /config/vkms/my-vkms/planes/plane0
-Planes have 5 configurable attributes:
+Planes have 7 configurable attributes:
- type: Plane type: 0 overlay, 1 primary, 2 cursor (same values as those
exposed by the "type" property of a plane)
@@ -98,10 +98,16 @@ Planes have 5 configurable attributes:
supported_rotations.
- supported_color_encodings: Available encodings for a plane, as a bitmask:
0x01 YCBCR_BT601, 0x02 YCBCR_BT709, 0x04 YCBCR_BT2020 (same values as those exposed
- by the COLOR_ENCODING property of a plane). If set, supported_color_range
+ by the COLOR_ENCODING property of a plane). If set, supported_color_ranges
must be set too.
- default_color_encoding: Default color encoding presented to the userspace, same
values as supported_color_encodings
+- supported_color_ranges: Available color range for a plane, as a bitmask:
+ 0x1 DRM_COLOR_YCBCR_LIMITED_RANGE, 0x2 DRM_COLOR_YCBCR_FULL_RANGE (same values as
+ those exposed by the COLOR_RANGE property of a plane). If set, supported_color_encoding
+ must be set too.
+- default_color_range: Default color range presented to the userspace, same
+ values as supported_color_ranges
Continue by creating one or more CRTCs::
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index c6efc6db64c4..a746fb5e22a3 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -17,6 +17,13 @@
BIT(DRM_COLOR_YCBCR_BT709) | \
BIT(DRM_COLOR_YCBCR_BT2020))
+/**
+ * VKMS_SUPPORTED_COLOR_RANGES - Bitmask of all supported color ranges in VKMS
+ */
+#define VKMS_SUPPORTED_COLOR_RANGES ( \
+ BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) | \
+ BIT(DRM_COLOR_YCBCR_FULL_RANGE))
+
/* To avoid registering configfs more than once or unregistering on error */
static bool is_configfs_registered;
@@ -410,6 +417,86 @@ static ssize_t plane_default_rotation_store(struct config_item *item,
return count;
}
+static ssize_t plane_supported_color_ranges_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item);
+ unsigned int supported_color_ranges;
+
+ scoped_guard(mutex, &plane->dev->config->lock)
+ supported_color_ranges = vkms_config_plane_get_supported_color_ranges(plane->config);
+
+ return sprintf(page, "%u\n", supported_color_ranges);
+}
+
+static ssize_t plane_supported_color_ranges_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item);
+ int ret;
+ unsigned int val = 0;
+
+ ret = kstrtouint(page, 0, &val);
+ if (ret)
+ return ret;
+
+ /* Should be a supported value */
+ if (val & ~VKMS_SUPPORTED_COLOR_RANGES)
+ return -EINVAL;
+ /* Should at least provide one color range */
+ if ((val & VKMS_SUPPORTED_COLOR_RANGES) == 0)
+ return -EINVAL;
+
+ scoped_guard(mutex, &plane->dev->config->lock) {
+ if (plane->dev->enabled)
+ return -EBUSY;
+
+ vkms_config_plane_set_supported_color_ranges(plane->config, val);
+ }
+
+ return count;
+}
+
+static ssize_t plane_default_color_range_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item);
+ unsigned int default_color_range;
+
+ scoped_guard(mutex, &plane->dev->config->lock)
+ default_color_range = vkms_config_plane_get_default_color_range(plane->config);
+
+ return sprintf(page, "%lu\n", BIT(default_color_range));
+}
+
+static ssize_t plane_default_color_range_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item);
+ int ret, val = 0;
+
+ ret = kstrtouint(page, 10, &val);
+ if (ret)
+ return ret;
+
+ /* Should be a supported value */
+ if (val & ~VKMS_SUPPORTED_COLOR_RANGES)
+ return -EINVAL;
+
+ if (!is_power_of_2(val))
+ return -EINVAL;
+
+ /* Convert bit position to the proper enum value */
+ val = ffs(val) + DRM_COLOR_YCBCR_LIMITED_RANGE - 1;
+
+ scoped_guard(mutex, &plane->dev->config->lock) {
+ if (plane->dev->enabled)
+ return -EBUSY;
+
+ vkms_config_plane_set_default_color_range(plane->config, val);
+ }
+
+ return count;
+}
+
static ssize_t plane_supported_color_encodings_show(struct config_item *item, char *page)
{
struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item);
@@ -492,6 +579,8 @@ static ssize_t plane_default_color_encoding_store(struct config_item *item,
CONFIGFS_ATTR(plane_, type);
CONFIGFS_ATTR(plane_, supported_rotations);
CONFIGFS_ATTR(plane_, default_rotation);
+CONFIGFS_ATTR(plane_, supported_color_ranges);
+CONFIGFS_ATTR(plane_, default_color_range);
CONFIGFS_ATTR(plane_, supported_color_encodings);
CONFIGFS_ATTR(plane_, default_color_encoding);
@@ -499,6 +588,8 @@ static struct configfs_attribute *plane_item_attrs[] = {
&plane_attr_type,
&plane_attr_supported_rotations,
&plane_attr_default_rotation,
+ &plane_attr_supported_color_ranges,
+ &plane_attr_default_color_range,
&plane_attr_supported_color_encodings,
&plane_attr_default_color_encoding,
NULL,
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 25/43] drm/vkms: Introduce config for plane format
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (23 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 24/43] drm/vkms: Introduce configfs " Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 26/43] drm/vkms: Introduce configfs " Louis Chauvet
` (17 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
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@bootlin.com>
---
drivers/gpu/drm/vkms/vkms_config.c | 140 +++++++++++++++++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_config.h | 51 ++++++++++++++
drivers/gpu/drm/vkms/vkms_plane.c | 39 +----------
3 files changed, 193 insertions(+), 37 deletions(-)
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index 6e4e2143c652..230346e56877 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -15,6 +15,42 @@
static void vkms_config_connector_release(struct kref *ref);
+static const u32 vkms_supported_plane_formats[] = {
+ DRM_FORMAT_ARGB8888,
+ DRM_FORMAT_ABGR8888,
+ DRM_FORMAT_BGRA8888,
+ DRM_FORMAT_RGBA8888,
+ DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_XBGR8888,
+ DRM_FORMAT_RGB888,
+ DRM_FORMAT_BGR888,
+ DRM_FORMAT_XRGB16161616,
+ DRM_FORMAT_XBGR16161616,
+ DRM_FORMAT_ARGB16161616,
+ DRM_FORMAT_ABGR16161616,
+ DRM_FORMAT_RGB565,
+ DRM_FORMAT_BGR565,
+ DRM_FORMAT_NV12,
+ DRM_FORMAT_NV16,
+ DRM_FORMAT_NV24,
+ DRM_FORMAT_NV21,
+ DRM_FORMAT_NV61,
+ DRM_FORMAT_NV42,
+ DRM_FORMAT_YUV420,
+ DRM_FORMAT_YUV422,
+ DRM_FORMAT_YUV444,
+ DRM_FORMAT_YVU420,
+ DRM_FORMAT_YVU422,
+ DRM_FORMAT_YVU444,
+ DRM_FORMAT_P010,
+ DRM_FORMAT_P012,
+ DRM_FORMAT_P016,
+ DRM_FORMAT_R1,
+ DRM_FORMAT_R2,
+ DRM_FORMAT_R4,
+ DRM_FORMAT_R8,
+};
+
struct vkms_config *vkms_config_create(const char *dev_name)
{
struct vkms_config *config;
@@ -407,6 +443,17 @@ bool vkms_config_is_valid(const struct vkms_config *config)
struct vkms_config_plane *plane_cfg;
vkms_config_for_each_plane(config, plane_cfg) {
+ if (vkms_config_plane_get_supported_formats_count(plane_cfg) == 0) {
+ drm_info(dev, "Plane must have at least one supported format.\n");
+ return false;
+ }
+
+ if (vkms_config_plane_get_supported_formats_count(plane_cfg) >
+ ARRAY_SIZE(vkms_supported_plane_formats)) {
+ drm_info(dev, "Plane has too much formats.\n");
+ return false;
+ }
+
if (!vkms_config_valid_plane_rotation(config, plane_cfg))
return false;
@@ -470,6 +517,15 @@ static __nocfi void show_bitfield(struct seq_file *m, uint32_t value, const char
}
}
+static void show_formats(struct seq_file *m, u32 *formats, size_t formats_count)
+{
+ for (int i = 0; i < formats_count; i++) {
+ seq_printf(m, "%p4cc", &formats[i]);
+ if (i != formats_count - 1)
+ seq_puts(m, ", ");
+ }
+}
+
static int vkms_config_show(struct seq_file *m, void *data)
{
struct drm_debugfs_entry *entry = m->private;
@@ -516,6 +572,10 @@ static int vkms_config_show(struct seq_file *m, void *data)
seq_puts(m, "\n");
seq_printf(m, "\tdefault color range=%s\n",
drm_get_color_range_name(vkms_config_plane_get_default_color_range(plane_cfg)));
+ seq_puts(m, "\tsupported formats=");
+ show_formats(m, vkms_config_plane_get_supported_formats(plane_cfg),
+ vkms_config_plane_get_supported_formats_count(plane_cfg));
+ seq_puts(m, "\n");
}
vkms_config_for_each_crtc(vkmsdev->config, crtc_cfg) {
@@ -566,6 +626,10 @@ struct vkms_config_plane __must_check *vkms_config_create_plane(struct vkms_conf
if (ret)
goto cleanup_plane_cfg;
+ ret = vkms_config_plane_add_all_formats(plane_cfg);
+ if (ret)
+ goto cleanup_plane_cfg;
+
vkms_config_plane_set_supported_rotations(plane_cfg,
DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK);
vkms_config_plane_set_default_rotation(plane_cfg, DRM_MODE_ROTATE_0);
@@ -584,6 +648,7 @@ struct vkms_config_plane __must_check *vkms_config_create_plane(struct vkms_conf
return plane_cfg;
cleanup_plane_cfg:
+ kfree(plane_cfg->supported_formats);
kfree(plane_cfg);
fail:
return ERR_PTR(ret);
@@ -595,6 +660,7 @@ static void vkms_config_plane_rcu_free(struct rcu_head *head)
struct vkms_config_plane *plane_cfg =
container_of(head, struct vkms_config_plane, rcu);
+ kfree(plane_cfg->supported_formats);
kfree(plane_cfg->name);
kfree(plane_cfg);
}
@@ -721,6 +787,80 @@ static struct vkms_config_plane *vkms_config_crtc_get_plane(const struct vkms_co
return NULL;
}
+int __must_check vkms_config_plane_add_all_formats(struct vkms_config_plane *plane_cfg)
+{
+ u32 *ret = krealloc_array(plane_cfg->supported_formats,
+ ARRAY_SIZE(vkms_supported_plane_formats),
+ sizeof(uint32_t), GFP_KERNEL);
+ if (!ret)
+ return -ENOMEM;
+ plane_cfg->supported_formats = ret;
+
+ memcpy(plane_cfg->supported_formats, vkms_supported_plane_formats,
+ sizeof(vkms_supported_plane_formats));
+ plane_cfg->supported_formats_count = ARRAY_SIZE(vkms_supported_plane_formats);
+ return 0;
+}
+
+static bool is_supported_format(u32 drm_format)
+{
+ for (int i = 0; i < ARRAY_SIZE(vkms_supported_plane_formats); i++) {
+ if (vkms_supported_plane_formats[i] == drm_format)
+ return true;
+ }
+
+ return false;
+}
+
+static bool vkms_config_plane_has_format(struct vkms_config_plane *plane_cfg, u32 drm_format)
+{
+ for (unsigned int i = 0; i < plane_cfg->supported_formats_count; i++) {
+ if (plane_cfg->supported_formats[i] == drm_format)
+ return true;
+ }
+ return false;
+}
+
+int __must_check vkms_config_plane_add_format(struct vkms_config_plane *plane_cfg, u32 drm_format)
+{
+ if (!is_supported_format(drm_format))
+ return -EINVAL;
+
+ if (vkms_config_plane_has_format(plane_cfg, 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;
+}
+
+void vkms_config_plane_remove_all_formats(struct vkms_config_plane *plane_cfg)
+{
+ plane_cfg->supported_formats_count = 0;
+ kfree(plane_cfg->supported_formats);
+ plane_cfg->supported_formats = NULL;
+}
+
+void vkms_config_plane_remove_format(struct vkms_config_plane *plane_cfg, u32 drm_format)
+{
+ for (unsigned int i = 0; i < plane_cfg->supported_formats_count; i++) {
+ if (plane_cfg->supported_formats[i] == drm_format) {
+ plane_cfg->supported_formats[i] =
+ plane_cfg->supported_formats[plane_cfg->supported_formats_count -
+ 1];
+ plane_cfg->supported_formats_count--;
+ }
+ }
+}
+
struct vkms_config_plane *vkms_config_crtc_primary_plane(const struct vkms_config *config,
struct vkms_config_crtc *crtc_cfg)
{
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index 20369e8d7c6e..1b353556166c 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -64,6 +64,8 @@ struct vkms_config {
* @supported_color_encodings: Color encodings that this plane will support
* @default_color_range: Default color range that should be used by this plane
* @supported_color_ranges: Color ranges that this plane will support
+ * @supported_formats: List of supported formats
+ * @supported_formats_count: Length of @supported_formats
*/
struct vkms_config_plane {
struct list_head link;
@@ -78,6 +80,8 @@ struct vkms_config_plane {
unsigned int supported_color_encodings;
enum drm_color_range default_color_range;
unsigned int supported_color_ranges;
+ u32 *supported_formats;
+ unsigned int supported_formats_count;
struct xarray possible_crtcs;
bool default_pipeline;
@@ -528,6 +532,53 @@ bool vkms_config_valid_plane_color_range(const struct vkms_config *config,
const struct vkms_config_plane *plane_cfg);
#endif
+static inline u32 *
+vkms_config_plane_get_supported_formats(const struct vkms_config_plane *plane_cfg)
+{
+ return plane_cfg->supported_formats;
+}
+
+static inline unsigned int
+vkms_config_plane_get_supported_formats_count(struct vkms_config_plane *plane_cfg)
+{
+ return plane_cfg->supported_formats_count;
+}
+
+/** vkms_config_plane_add_format - Add a format to the list of supported format of a plane
+ *
+ * The passed drm_format can already be present in the list. This may fail if the allocation of a
+ * bigger array fails.
+ *
+ * @plane_cfg: Plane to add the format to
+ * @drm_format: Format to add to this plane
+ *
+ * Returns: 0 on success, -ENOMEM if array allocation fails, -EINVAL if the format is not supported
+ * by VKMS
+ */
+int __must_check vkms_config_plane_add_format(struct vkms_config_plane *plane_cfg, u32 drm_format);
+
+/**
+ * vkms_config_plane_add_all_formats - Helper to quickly add all the supported formats
+ * @plane_cfg: Plane to add the formats to
+ *
+ * Returns: 0 on success, -ENOMEM if array allocation fails
+ * by VKMS
+ */
+int __must_check vkms_config_plane_add_all_formats(struct vkms_config_plane *plane_cfg);
+
+/**
+ * vkms_config_plane_remove_format - Remove a specific format from a plane
+ * @plane_cfg: Plane to remove the format from
+ * @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 formats from a plane
+ * @plane_cfg: Plane to remove the formats from
+ */
+void vkms_config_plane_remove_all_formats(struct vkms_config_plane *plane_cfg);
+
/**
* vkms_config_plane_set_name() - Set the plane name
* @plane_cfg: Plane to set the name to
diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
index 71be819fe159..70ed0e68a1c9 100644
--- a/drivers/gpu/drm/vkms/vkms_plane.c
+++ b/drivers/gpu/drm/vkms/vkms_plane.c
@@ -16,42 +16,6 @@
#include "vkms_drv.h"
#include "vkms_formats.h"
-static const u32 vkms_formats[] = {
- DRM_FORMAT_ARGB8888,
- DRM_FORMAT_ABGR8888,
- DRM_FORMAT_BGRA8888,
- DRM_FORMAT_RGBA8888,
- DRM_FORMAT_XRGB8888,
- DRM_FORMAT_XBGR8888,
- DRM_FORMAT_RGB888,
- DRM_FORMAT_BGR888,
- DRM_FORMAT_XRGB16161616,
- DRM_FORMAT_XBGR16161616,
- DRM_FORMAT_ARGB16161616,
- DRM_FORMAT_ABGR16161616,
- DRM_FORMAT_RGB565,
- DRM_FORMAT_BGR565,
- DRM_FORMAT_NV12,
- DRM_FORMAT_NV16,
- DRM_FORMAT_NV24,
- DRM_FORMAT_NV21,
- DRM_FORMAT_NV61,
- DRM_FORMAT_NV42,
- DRM_FORMAT_YUV420,
- DRM_FORMAT_YUV422,
- DRM_FORMAT_YUV444,
- DRM_FORMAT_YVU420,
- DRM_FORMAT_YVU422,
- DRM_FORMAT_YVU444,
- DRM_FORMAT_P010,
- DRM_FORMAT_P012,
- DRM_FORMAT_P016,
- DRM_FORMAT_R1,
- DRM_FORMAT_R2,
- DRM_FORMAT_R4,
- DRM_FORMAT_R8,
-};
-
static struct drm_plane_state *
vkms_plane_duplicate_state(struct drm_plane *plane)
{
@@ -268,7 +232,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),
+ vkms_config_plane_get_supported_formats(plane_cfg),
+ vkms_config_plane_get_supported_formats_count(plane_cfg),
NULL, vkms_config_plane_get_type(plane_cfg),
vkms_config_plane_get_name(plane_cfg) ? "%s" : NULL,
vkms_config_plane_get_name(plane_cfg));
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 26/43] drm/vkms: Introduce configfs for plane format
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (24 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 25/43] drm/vkms: Introduce config for plane format Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 27/43] drm/vkms: Properly render plane using their zpos Louis Chauvet
` (16 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
To allow the userspace to test many hardware configuration, introduce a
new interface to configure the available formats per planes. VKMS supports
multiple formats, so the userspace can choose any combination.
The supported formats are configured by writing the fourcc code in
supported_formats:
# enable AR24 format
echo '+AR24' > /config/vkms/DEVICE_1/planes/PLANE_1/supported_formats
# disable AR24 format
echo '-AR24' > /config/vkms/DEVICE_1/planes/PLANE_1/supported_formats
# enable all format supported by VKMS
echo '+*' > /config/vkms/DEVICE_1/planes/PLANE_1/supported_formats
# disable all formats
echo '-*' > /config/vkms/DEVICE_1/planes/PLANE_1/supported_formats
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
Documentation/ABI/testing/configfs-vkms | 10 ++++
Documentation/gpu/vkms.rst | 7 ++-
drivers/gpu/drm/vkms/vkms_configfs.c | 85 +++++++++++++++++++++++++++++++++
3 files changed, 101 insertions(+), 1 deletion(-)
diff --git a/Documentation/ABI/testing/configfs-vkms b/Documentation/ABI/testing/configfs-vkms
index 16a44cc60e4a..312631d12985 100644
--- a/Documentation/ABI/testing/configfs-vkms
+++ b/Documentation/ABI/testing/configfs-vkms
@@ -164,6 +164,16 @@ Description:
DRM_COLOR_YCBCR_LIMITED_RANGE, 2 -
DRM_COLOR_YCBCR_FULL_RANGE.
+What: /sys/kernel/config/vkms/<device>/planes/<plane>/supported_formats
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ List of supported formats for this plane. To add a new
+ item, write its fourcc code prefixed with '+'. To remove,
+ use '-' prefix. Use '+*' to add all formats supported by
+ the driver, '-*' to remove all. Reading returns the
+ supported formats, one fourcc code per line.
+
What: /sys/kernel/config/vkms/<device>/planes/<plane>/possible_crtcs
Date: Nov 2025
Contact: dri-devel@lists.freedesktop.org
diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst
index 7e8f4fe3b392..e5280a99eee8 100644
--- a/Documentation/gpu/vkms.rst
+++ b/Documentation/gpu/vkms.rst
@@ -87,7 +87,7 @@ Start by creating one or more planes::
sudo mkdir /config/vkms/my-vkms/planes/plane0
-Planes have 7 configurable attributes:
+Planes have 8 configurable attributes:
- type: Plane type: 0 overlay, 1 primary, 2 cursor (same values as those
exposed by the "type" property of a plane)
@@ -108,6 +108,11 @@ Planes have 7 configurable attributes:
must be set too.
- default_color_range: Default color range presented to the userspace, same
values as supported_color_ranges
+- supported_formats: List of supported formats for this plane. To add a new item in the
+ list, write it using a plus and fourcc code: +XR24
+ To remove a format, use a minus and its fourcc: -XR24
+ To add all formats use +*
+ To remove all formats, use -*
Continue by creating one or more CRTCs::
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index a746fb5e22a3..9f24e9e6ed6d 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -3,6 +3,7 @@
#include <linux/configfs.h>
#include <linux/mutex.h>
#include <linux/slab.h>
+#include <linux/string.h>
#include "vkms_drv.h"
#include "vkms_config.h"
@@ -576,6 +577,88 @@ static ssize_t plane_default_color_encoding_store(struct config_item *item,
return count;
}
+static ssize_t plane_supported_formats_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_plane *plane;
+
+ plane = plane_item_to_vkms_configfs_plane(item);
+
+ page[0] = '\0';
+
+ scoped_guard(mutex, &plane->dev->config->lock) {
+ u32 *formats = vkms_config_plane_get_supported_formats(plane->config);
+
+ for (int i = 0;
+ i < vkms_config_plane_get_supported_formats_count(plane->config);
+ i++) {
+ char tmp[6] = { 0 };
+ const ssize_t ret = snprintf(tmp, ARRAY_SIZE(tmp), "%.*s\n",
+ (int)sizeof(*formats),
+ (char *)&formats[i]);
+ if (ret < 0)
+ return ret;
+ /*
+ * Limitation of ConfigFS attributes: an attribute can't be
+ * bigger than PAGE_SIZE, so bail out with -ENOMEM if this
+ * plane supports too many formats (more than ≈1000).
+ */
+ if (ret + strlen(page) > PAGE_SIZE - 1)
+ return -ENOMEM;
+ strncat(page, tmp, ARRAY_SIZE(tmp));
+ }
+ }
+
+ return strlen(page);
+}
+
+static ssize_t plane_supported_formats_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_configfs_plane *plane;
+ ssize_t ret_count = count;
+ int ret = 0;
+
+ plane = plane_item_to_vkms_configfs_plane(item);
+
+ count = strlen(strim((char *)page));
+
+ if (count < 2 || count > 5)
+ return -EINVAL;
+
+ if (page[0] != '+' && page[0] != '-')
+ return -EINVAL;
+
+ if (page[1] == '*' && count != 2)
+ return -EINVAL;
+
+ scoped_guard(mutex, &plane->dev->config->lock) {
+ if (plane->dev->enabled)
+ return -EBUSY;
+
+ char fmt[4] = {' ', ' ', ' ', ' '};
+ u32 fourcc;
+
+ memcpy(fmt, &page[1], min(count - 1, 4));
+
+ if (page[0] == '+' && page[1] == '*')
+ ret = vkms_config_plane_add_all_formats(plane->config);
+ else if (page[0] == '-' && page[1] == '*')
+ vkms_config_plane_remove_all_formats(plane->config);
+ else if (page[0] == '+') {
+ memcpy(&fourcc, fmt, sizeof(fourcc));
+ ret = vkms_config_plane_add_format(plane->config, fourcc);
+ } else if (page[0] == '-') {
+ memcpy(&fourcc, fmt, sizeof(fourcc));
+ vkms_config_plane_remove_format(plane->config, fourcc);
+ }
+
+ if (ret)
+ return ret;
+ }
+
+ return (ssize_t)ret_count;
+}
+
CONFIGFS_ATTR(plane_, type);
CONFIGFS_ATTR(plane_, supported_rotations);
CONFIGFS_ATTR(plane_, default_rotation);
@@ -583,6 +666,7 @@ CONFIGFS_ATTR(plane_, supported_color_ranges);
CONFIGFS_ATTR(plane_, default_color_range);
CONFIGFS_ATTR(plane_, supported_color_encodings);
CONFIGFS_ATTR(plane_, default_color_encoding);
+CONFIGFS_ATTR(plane_, supported_formats);
static struct configfs_attribute *plane_item_attrs[] = {
&plane_attr_type,
@@ -592,6 +676,7 @@ static struct configfs_attribute *plane_item_attrs[] = {
&plane_attr_default_color_range,
&plane_attr_supported_color_encodings,
&plane_attr_default_color_encoding,
+ &plane_attr_supported_formats,
NULL,
};
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 27/43] drm/vkms: Properly render plane using their zpos
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (25 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 26/43] drm/vkms: Introduce configfs " Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 28/43] drm/vkms: Introduce config for plane zpos property Louis Chauvet
` (15 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
Currently planes are rendered in creation order. This is not an issue, but
with the introduction of new zpos configuration, it is required to
properly render planes.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/vkms_composer.c | 15 ++++++++++++---
drivers/gpu/drm/vkms/vkms_crtc.c | 16 ++++++++--------
drivers/gpu/drm/vkms/vkms_drv.c | 2 ++
3 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
index 7a6a7875520c..4ccca8bd0c5c 100644
--- a/drivers/gpu/drm/vkms/vkms_composer.c
+++ b/drivers/gpu/drm/vkms/vkms_composer.c
@@ -592,7 +592,8 @@ static void blend(struct vkms_writeback_job *wb,
/* The active planes are composed associatively in z-order. */
for (size_t i = 0; i < n_active_planes; i++) {
- blend_line(plane[i], y, crtc_x_limit, stage_buffer, output_buffer);
+ if (plane[i])
+ blend_line(plane[i], y, crtc_x_limit, stage_buffer, output_buffer);
}
apply_lut(crtc_state, output_buffer);
@@ -610,9 +611,13 @@ static int check_format_funcs(struct vkms_crtc_state *crtc_state,
struct vkms_plane_state **planes = crtc_state->active_planes;
u32 n_active_planes = crtc_state->num_active_planes;
- for (size_t i = 0; i < n_active_planes; i++)
+ for (size_t i = 0; i < n_active_planes; i++) {
+ /* Invisible planes are stored as NULL entries */
+ if (!planes[i])
+ continue;
if (!planes[i]->pixel_read_line)
return -1;
+ }
if (active_wb && !active_wb->pixel_write)
return -1;
@@ -625,9 +630,13 @@ static int check_iosys_map(struct vkms_crtc_state *crtc_state)
struct vkms_plane_state **plane_state = crtc_state->active_planes;
u32 n_active_planes = crtc_state->num_active_planes;
- for (size_t i = 0; i < n_active_planes; i++)
+ for (size_t i = 0; i < n_active_planes; i++) {
+ /* Invisible planes are stored as NULL entries */
+ if (!plane_state[i])
+ continue;
if (iosys_map_is_null(&plane_state[i]->frame_info.map[0]))
return -1;
+ }
return 0;
}
diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
index 019d7bc90cdc..eaddd8b70494 100644
--- a/drivers/gpu/drm/vkms/vkms_crtc.c
+++ b/drivers/gpu/drm/vkms/vkms_crtc.c
@@ -133,9 +133,6 @@ static int vkms_crtc_atomic_check(struct drm_crtc *crtc,
plane_state = drm_atomic_get_new_plane_state(crtc_state->state, plane);
WARN_ON(!plane_state);
- if (!plane_state->visible)
- continue;
-
i++;
}
@@ -144,15 +141,18 @@ static int vkms_crtc_atomic_check(struct drm_crtc *crtc,
return -ENOMEM;
vkms_state->num_active_planes = i;
- i = 0;
drm_for_each_plane_mask(plane, crtc->dev, crtc_state->plane_mask) {
plane_state = drm_atomic_get_new_plane_state(crtc_state->state, plane);
+ /*
+ * normalized_zpos is computed by the DRM core and is unique
+ * in the range 0..n_planes-1: use it to index the array.
+ */
if (!plane_state->visible)
- continue;
-
- vkms_state->active_planes[i++] =
- to_vkms_plane_state(plane_state);
+ vkms_state->active_planes[plane_state->normalized_zpos] = NULL;
+ else
+ vkms_state->active_planes[plane_state->normalized_zpos] =
+ to_vkms_plane_state(plane_state);
}
return 0;
diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
index f73f136e5588..6c88e2a6a890 100644
--- a/drivers/gpu/drm/vkms/vkms_drv.c
+++ b/drivers/gpu/drm/vkms/vkms_drv.c
@@ -155,6 +155,8 @@ static int vkms_modeset_init(struct vkms_device *vkmsdev)
dev->mode_config.preferred_depth = 0;
dev->mode_config.helper_private = &vkms_mode_config_helpers;
+ dev->mode_config.normalize_zpos = true;
+
return vkms_output_init(vkmsdev);
}
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 28/43] drm/vkms: Introduce config for plane zpos property
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (26 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 27/43] drm/vkms: Properly render plane using their zpos Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 29/43] drm/vkms: Introduce configfs " Louis Chauvet
` (14 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
VKMS can render plane in any order. Introduce the appropriate
configuration.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/tests/vkms_config_test.c | 89 ++++++++++++++++
drivers/gpu/drm/vkms/vkms_config.c | 56 ++++++++++
drivers/gpu/drm/vkms/vkms_config.h | 143 ++++++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_plane.c | 11 ++
4 files changed, 299 insertions(+)
diff --git a/drivers/gpu/drm/vkms/tests/vkms_config_test.c b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
index 0f902e770e4b..a43dff511fc3 100644
--- a/drivers/gpu/drm/vkms/tests/vkms_config_test.c
+++ b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
@@ -201,6 +201,9 @@ static void vkms_config_test_default_config(struct kunit *test)
KUNIT_EXPECT_EQ(test,
vkms_config_plane_get_default_color_encoding(plane_cfg),
DRM_COLOR_YCBCR_BT601);
+ KUNIT_EXPECT_EQ(test, vkms_config_plane_get_zpos_enabled(plane_cfg), false);
+ // No need to test the other zpos configurations as they are discarded if
+ // the zpos property is not created.
}
/* Encoders */
@@ -626,6 +629,91 @@ static void vkms_config_test_valid_plane_color_range(struct kunit *test)
vkms_config_destroy(config);
}
+static void vkms_config_test_valid_plane_zpos(struct kunit *test)
+{
+ struct vkms_config *config;
+ struct vkms_config_plane *plane_cfg;
+
+ config = vkms_config_default_create(false, false, false, false);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+
+ plane_cfg = get_first_plane(config);
+
+ /* Valid, zpos disabled */
+ vkms_config_plane_set_zpos_enabled(plane_cfg, false);
+ vkms_config_plane_set_zpos_mutable(plane_cfg, false);
+ vkms_config_plane_set_zpos_initial(plane_cfg, 0);
+ vkms_config_plane_set_zpos_min(plane_cfg, 0);
+ vkms_config_plane_set_zpos_max(plane_cfg, 0);
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Valid, zpos disabled, min/max are ignored */
+ vkms_config_plane_set_zpos_enabled(plane_cfg, false);
+ vkms_config_plane_set_zpos_mutable(plane_cfg, false);
+ vkms_config_plane_set_zpos_initial(plane_cfg, 8);
+ vkms_config_plane_set_zpos_min(plane_cfg, 3);
+ vkms_config_plane_set_zpos_max(plane_cfg, 2);
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Valid, zpos enabled but mutable disabled */
+ vkms_config_plane_set_zpos_enabled(plane_cfg, true);
+ vkms_config_plane_set_zpos_mutable(plane_cfg, false);
+ vkms_config_plane_set_zpos_initial(plane_cfg, 1);
+ vkms_config_plane_set_zpos_min(plane_cfg, 0);
+ vkms_config_plane_set_zpos_max(plane_cfg, 0);
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Valid, zpos enabled but mutable disabled */
+ vkms_config_plane_set_zpos_enabled(plane_cfg, true);
+ vkms_config_plane_set_zpos_mutable(plane_cfg, false);
+ vkms_config_plane_set_zpos_initial(plane_cfg, 0);
+ vkms_config_plane_set_zpos_min(plane_cfg, 0);
+ vkms_config_plane_set_zpos_max(plane_cfg, 0);
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Invalid, zpos enabled with min > max */
+ vkms_config_plane_set_zpos_enabled(plane_cfg, true);
+ vkms_config_plane_set_zpos_mutable(plane_cfg, true);
+ vkms_config_plane_set_zpos_initial(plane_cfg, 0);
+ vkms_config_plane_set_zpos_min(plane_cfg, 1);
+ vkms_config_plane_set_zpos_max(plane_cfg, 0);
+ KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
+
+ /* Valid, zpos enabled with min <= max */
+ vkms_config_plane_set_zpos_enabled(plane_cfg, true);
+ vkms_config_plane_set_zpos_mutable(plane_cfg, true);
+ vkms_config_plane_set_zpos_initial(plane_cfg, 0);
+ vkms_config_plane_set_zpos_min(plane_cfg, 0);
+ vkms_config_plane_set_zpos_max(plane_cfg, 1);
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Invalid, zpos enabled with initial < min */
+ vkms_config_plane_set_zpos_enabled(plane_cfg, true);
+ vkms_config_plane_set_zpos_mutable(plane_cfg, true);
+ vkms_config_plane_set_zpos_initial(plane_cfg, 0);
+ vkms_config_plane_set_zpos_min(plane_cfg, 1);
+ vkms_config_plane_set_zpos_max(plane_cfg, 2);
+ KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
+
+ /* Invalid, zpos enabled with initial > max */
+ vkms_config_plane_set_zpos_enabled(plane_cfg, true);
+ vkms_config_plane_set_zpos_mutable(plane_cfg, true);
+ vkms_config_plane_set_zpos_initial(plane_cfg, 3);
+ vkms_config_plane_set_zpos_min(plane_cfg, 1);
+ vkms_config_plane_set_zpos_max(plane_cfg, 2);
+ KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
+
+ /* Valid, zpos enabled with initial between min and max */
+ vkms_config_plane_set_zpos_enabled(plane_cfg, true);
+ vkms_config_plane_set_zpos_mutable(plane_cfg, true);
+ vkms_config_plane_set_zpos_initial(plane_cfg, 1);
+ vkms_config_plane_set_zpos_min(plane_cfg, 0);
+ vkms_config_plane_set_zpos_max(plane_cfg, 2);
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ vkms_config_destroy(config);
+}
+
static void vkms_config_test_valid_plane_possible_crtcs(struct kunit *test)
{
struct vkms_config *config;
@@ -1151,6 +1239,7 @@ static struct kunit_case vkms_config_test_cases[] = {
KUNIT_CASE(vkms_config_test_valid_plane_rotations),
KUNIT_CASE(vkms_config_test_valid_plane_color_encoding),
KUNIT_CASE(vkms_config_test_valid_plane_color_range),
+ KUNIT_CASE(vkms_config_test_valid_plane_zpos),
KUNIT_CASE(vkms_config_test_valid_plane_possible_crtcs),
KUNIT_CASE(vkms_config_test_invalid_crtc_number),
KUNIT_CASE(vkms_config_test_invalid_encoder_number),
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index 230346e56877..342b844bfc6d 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -97,6 +97,7 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor,
if (IS_ERR(plane_cfg))
goto err_alloc;
vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_PRIMARY);
+ vkms_config_plane_set_zpos_enabled(plane_cfg, false);
crtc_cfg = vkms_config_create_crtc(config);
if (IS_ERR(crtc_cfg))
@@ -116,6 +117,7 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor,
vkms_config_plane_set_type(plane_cfg,
DRM_PLANE_TYPE_OVERLAY);
vkms_config_plane_set_default_pipeline(plane_cfg, enable_plane_pipeline);
+ vkms_config_plane_set_zpos_enabled(plane_cfg, false);
if (vkms_config_plane_attach_crtc(plane_cfg, crtc_cfg))
goto err_alloc;
@@ -129,6 +131,7 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor,
vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_CURSOR);
vkms_config_plane_set_default_pipeline(plane_cfg, enable_plane_pipeline);
+ vkms_config_plane_set_zpos_enabled(plane_cfg, false);
if (vkms_config_plane_attach_crtc(plane_cfg, crtc_cfg))
goto err_alloc;
@@ -282,6 +285,33 @@ bool vkms_config_valid_plane_color_range(const struct vkms_config *config,
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_valid_plane_color_range);
+VISIBLE_IF_KUNIT
+bool vkms_config_valid_plane_zpos(const struct vkms_config *config,
+ const struct vkms_config_plane *plane_cfg)
+{
+ struct drm_device *dev = config->dev ? &config->dev->drm : NULL;
+
+ if (!vkms_config_plane_get_zpos_enabled(plane_cfg) ||
+ !vkms_config_plane_get_zpos_mutable(plane_cfg))
+ return true;
+
+ if (vkms_config_plane_get_zpos_initial(plane_cfg) >
+ vkms_config_plane_get_zpos_max(plane_cfg)) {
+ drm_info(dev, "Configured initial zpos value bigger than zpos max\n");
+ return false;
+ }
+
+ if (vkms_config_plane_get_zpos_max(plane_cfg) <
+ vkms_config_plane_get_zpos_min(plane_cfg) ||
+ vkms_config_plane_get_zpos_initial(plane_cfg) <
+ vkms_config_plane_get_zpos_min(plane_cfg)) {
+ drm_info(dev, "Configured zpos value outside (zpos min; zpos max)\n");
+ return false;
+ }
+
+ return true;
+}
+
static bool valid_planes_for_crtc(const struct vkms_config *config,
struct vkms_config_crtc *crtc_cfg)
{
@@ -442,6 +472,9 @@ bool vkms_config_is_valid(const struct vkms_config *config)
struct vkms_config_crtc *crtc_cfg;
struct vkms_config_plane *plane_cfg;
+ bool has_zpos_enabled = false;
+ bool has_zpos_disabled = false;
+
vkms_config_for_each_plane(config, plane_cfg) {
if (vkms_config_plane_get_supported_formats_count(plane_cfg) == 0) {
drm_info(dev, "Plane must have at least one supported format.\n");
@@ -469,6 +502,19 @@ bool vkms_config_is_valid(const struct vkms_config *config)
"Both supported color encodings and color ranges must be set, or none\n");
return false;
}
+
+ if (!vkms_config_valid_plane_zpos(config, plane_cfg))
+ return false;
+
+ if (vkms_config_plane_get_zpos_enabled(plane_cfg))
+ has_zpos_enabled = true;
+ else
+ has_zpos_disabled = true;
+ }
+
+ if (has_zpos_enabled && has_zpos_disabled) {
+ drm_info(dev, "In the same device, all planes must have zpos enabled or none of them");
+ return false;
}
if (!valid_plane_number(config))
@@ -576,6 +622,16 @@ static int vkms_config_show(struct seq_file *m, void *data)
show_formats(m, vkms_config_plane_get_supported_formats(plane_cfg),
vkms_config_plane_get_supported_formats_count(plane_cfg));
seq_puts(m, "\n");
+ seq_printf(m, "\tzpos_enabled=%s\n",
+ str_true_false(vkms_config_plane_get_zpos_enabled(plane_cfg)));
+ seq_printf(m, "\tzpos_mutable=%s\n",
+ str_true_false(vkms_config_plane_get_zpos_mutable(plane_cfg)));
+ seq_printf(m, "\tzpos_min=%d\n",
+ vkms_config_plane_get_zpos_min(plane_cfg));
+ seq_printf(m, "\tzpos_initial=%d\n",
+ vkms_config_plane_get_zpos_initial(plane_cfg));
+ seq_printf(m, "\tzpos_max=%d\n",
+ vkms_config_plane_get_zpos_max(plane_cfg));
}
vkms_config_for_each_crtc(vkmsdev->config, crtc_cfg) {
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index 1b353556166c..eb29008e54f0 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -66,6 +66,11 @@ struct vkms_config {
* @supported_color_ranges: Color ranges that this plane will support
* @supported_formats: List of supported formats
* @supported_formats_count: Length of @supported_formats
+ * @zpos_enabled: Enable or disable the zpos property
+ * @zpos_mutable: Make the zpos property mutable or not (ignored if @zpos_enabled is false)
+ * @zpos_initial: Initial value for zpos property (ignored if @zpos_enabled is false)
+ * @zpos_min: Minimal value for zpos property (ignored if @zpos_enabled is false)
+ * @zpos_max: Maximal value for zpos property (ignored if @zpos_enabled is false)
*/
struct vkms_config_plane {
struct list_head link;
@@ -84,6 +89,11 @@ struct vkms_config_plane {
unsigned int supported_formats_count;
struct xarray possible_crtcs;
bool default_pipeline;
+ bool zpos_enabled;
+ bool zpos_mutable;
+ unsigned int zpos_initial;
+ unsigned int zpos_min;
+ unsigned int zpos_max;
/* Internal usage */
struct vkms_plane *plane;
@@ -599,6 +609,139 @@ vkms_config_plane_get_name(const struct vkms_config_plane *plane_cfg)
return plane_cfg->name;
}
+/**
+ * vkms_config_plane_set_zpos_enabled() - Enable or disable zpos property for a plane
+ * @plane_cfg: Plane configuration to modify
+ * @zpos_enabled: Whether to enable the zpos property
+ */
+static inline
+void vkms_config_plane_set_zpos_enabled(struct vkms_config_plane *plane_cfg,
+ bool zpos_enabled)
+{
+ plane_cfg->zpos_enabled = zpos_enabled;
+}
+
+/**
+ * vkms_config_plane_set_zpos_mutable() - Set whether zpos property is mutable
+ * @plane_cfg: Plane configuration to modify
+ * @zpos_mutable: Whether the zpos property should be mutable
+ */
+static inline
+void vkms_config_plane_set_zpos_mutable(struct vkms_config_plane *plane_cfg,
+ bool zpos_mutable)
+{
+ plane_cfg->zpos_mutable = zpos_mutable;
+}
+
+/**
+ * vkms_config_plane_set_zpos_initial() - Set the initial zpos value
+ * @plane_cfg: Plane configuration to modify
+ * @zpos_initial: Initial zpos value
+ */
+static inline
+void vkms_config_plane_set_zpos_initial(struct vkms_config_plane *plane_cfg,
+ unsigned int zpos_initial)
+{
+ plane_cfg->zpos_initial = zpos_initial;
+}
+
+/**
+ * vkms_config_plane_set_zpos_min() - Set the minimum zpos value
+ * @plane_cfg: Plane configuration to modify
+ * @zpos_min: Minimum zpos value
+ */
+static inline
+void vkms_config_plane_set_zpos_min(struct vkms_config_plane *plane_cfg,
+ unsigned int zpos_min)
+{
+ plane_cfg->zpos_min = zpos_min;
+}
+
+/**
+ * vkms_config_plane_set_zpos_max() - Set the maximum zpos value
+ * @plane_cfg: Plane configuration to modify
+ * @zpos_max: Maximum zpos value
+ */
+static inline
+void vkms_config_plane_set_zpos_max(struct vkms_config_plane *plane_cfg,
+ unsigned int zpos_max)
+{
+ plane_cfg->zpos_max = zpos_max;
+}
+
+/**
+ * vkms_config_plane_get_zpos_enabled() - Check if zpos property is enabled
+ * @plane_cfg: Plane configuration to check
+ *
+ * Returns:
+ * True if the zpos property is enabled for this plane, false otherwise.
+ */
+static inline
+bool vkms_config_plane_get_zpos_enabled(const struct vkms_config_plane *plane_cfg)
+{
+ return plane_cfg->zpos_enabled;
+}
+
+/**
+ * vkms_config_plane_get_zpos_mutable() - Check if zpos property is mutable
+ * @plane_cfg: Plane configuration to check
+ *
+ * Returns:
+ * True if the zpos property is mutable for this plane, false otherwise.
+ */
+static inline
+bool vkms_config_plane_get_zpos_mutable(const struct vkms_config_plane *plane_cfg)
+{
+ return plane_cfg->zpos_mutable;
+}
+
+/**
+ * vkms_config_plane_get_zpos_initial() - Get the initial zpos value
+ * @plane_cfg: Plane configuration to check
+ *
+ * Returns:
+ * The initial zpos value for this plane. The return value is undefined if
+ * zpos is disabled.
+ */
+static inline
+unsigned int vkms_config_plane_get_zpos_initial(const struct vkms_config_plane *plane_cfg)
+{
+ return plane_cfg->zpos_initial;
+}
+
+/**
+ * vkms_config_plane_get_zpos_min() - Get the minimum zpos value
+ * @plane_cfg: Plane configuration to check
+ *
+ * Returns:
+ * The minimum allowed zpos value for this plane. The return value is undefined
+ * if zpos is disabled.
+ */
+static inline
+unsigned int vkms_config_plane_get_zpos_min(const struct vkms_config_plane *plane_cfg)
+{
+ return plane_cfg->zpos_min;
+}
+
+/**
+ * vkms_config_plane_get_zpos_max() - Get the maximum zpos value
+ * @plane_cfg: Plane configuration to check
+ *
+ * Returns:
+ * The maximum allowed zpos value for this plane. The return value is undefined
+ * if zpos is disabled.
+ */
+static inline
+unsigned int vkms_config_plane_get_zpos_max(const struct vkms_config_plane *plane_cfg)
+{
+ return plane_cfg->zpos_max;
+}
+
+#if IS_ENABLED(CONFIG_KUNIT)
+bool vkms_config_valid_plane_zpos(const struct vkms_config *config,
+ const struct vkms_config_plane *plane_cfg);
+#endif
+
/**
* 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 70ed0e68a1c9..60fae99fed53 100644
--- a/drivers/gpu/drm/vkms/vkms_plane.c
+++ b/drivers/gpu/drm/vkms/vkms_plane.c
@@ -256,6 +256,17 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
if (vkms_config_plane_get_default_pipeline(plane_cfg))
vkms_initialize_colorops(&plane->base);
+ if (vkms_config_plane_get_zpos_enabled(plane_cfg)) {
+ if (vkms_config_plane_get_zpos_mutable(plane_cfg)) {
+ drm_plane_create_zpos_property(&plane->base,
+ vkms_config_plane_get_zpos_initial(plane_cfg),
+ vkms_config_plane_get_zpos_min(plane_cfg),
+ vkms_config_plane_get_zpos_max(plane_cfg));
+ } else {
+ drm_plane_create_zpos_immutable_property(&plane->base,
+ vkms_config_plane_get_zpos_initial(plane_cfg));
+ }
+ }
return plane;
}
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 29/43] drm/vkms: Introduce configfs for plane zpos property
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (27 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 28/43] drm/vkms: Introduce config for plane zpos property Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 30/43] drm/vkms: Introduce back pointer to connector Louis Chauvet
` (13 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
Modern compositor rely on zpos management to offload some processing to
deticated hardware. In order to test multiple configurations, add zpos
configuration to configFS.
Introduce multiple attributes to configure zpos:
- zpos_enabled - Create or not the zpos property. If not created, the zpos
is undefined.
- zpos_mutable - If the zpos property is created, allow or not the
userspace to modify it
- zpos_initial - Initial value for zpos property. Must be between zpos_min
and zpos_max
- zpos_min - Minimum zpos value for this plane. Must be <= zpos_max
- zpos_max - Maximum zpos value for this plane. Must be >= zpos_min
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
Documentation/ABI/testing/configfs-vkms | 36 +++++++
Documentation/gpu/vkms.rst | 9 +-
drivers/gpu/drm/vkms/vkms_configfs.c | 180 ++++++++++++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_plane.c | 19 ++--
4 files changed, 237 insertions(+), 7 deletions(-)
diff --git a/Documentation/ABI/testing/configfs-vkms b/Documentation/ABI/testing/configfs-vkms
index 312631d12985..2db0c950adc4 100644
--- a/Documentation/ABI/testing/configfs-vkms
+++ b/Documentation/ABI/testing/configfs-vkms
@@ -174,6 +174,42 @@ Description:
the driver, '-*' to remove all. Reading returns the
supported formats, one fourcc code per line.
+What: /sys/kernel/config/vkms/<device>/planes/<plane>/zpos_enabled
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Enable or disable the zpos property. Value: 1 - enabled,
+ 0 - disabled.
+
+What: /sys/kernel/config/vkms/<device>/planes/<plane>/zpos_mutable
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Create the zpos property as mutable or immutable.
+ Value: 1 - mutable, 0 - immutable. No effect if
+ zpos_enabled is not set.
+
+What: /sys/kernel/config/vkms/<device>/planes/<plane>/zpos_initial
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Set the initial zpos value. Must be between zpos_min
+ and zpos_max. No effect if zpos_enabled is not set.
+
+What: /sys/kernel/config/vkms/<device>/planes/<plane>/zpos_min
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Set the minimal zpos value. No effect if zpos_enabled
+ is not set.
+
+What: /sys/kernel/config/vkms/<device>/planes/<plane>/zpos_max
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Set the maximal zpos value. No effect if zpos_enabled
+ is not set.
+
What: /sys/kernel/config/vkms/<device>/planes/<plane>/possible_crtcs
Date: Nov 2025
Contact: dri-devel@lists.freedesktop.org
diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst
index e5280a99eee8..b58e96a3c273 100644
--- a/Documentation/gpu/vkms.rst
+++ b/Documentation/gpu/vkms.rst
@@ -87,7 +87,7 @@ Start by creating one or more planes::
sudo mkdir /config/vkms/my-vkms/planes/plane0
-Planes have 8 configurable attributes:
+Planes have 13 configurable attributes:
- type: Plane type: 0 overlay, 1 primary, 2 cursor (same values as those
exposed by the "type" property of a plane)
@@ -113,6 +113,13 @@ Planes have 8 configurable attributes:
To remove a format, use a minus and its fourcc: -XR24
To add all formats use +*
To remove all formats, use -*
+- zpos_enabled: Enable or not the zpos property: 1 enable, 0 disable
+- zpos_mutable: Create the zpos property as a mutable or imutable property: 1 mutable,
+ 0 immutable. No effect if zpos_enabled is not set.
+- zpos_initial: Set the initial zpos value. Must be between zpos_min and zpos_max. No
+ effect if zpos_enabled is not set.
+- zpos_min: Set the minimum zpos value. No effect if zpos_enabled is not set.
+- zpos_max: Set the maximum zpos value. No effect if zpos_enabled is not set.
Continue by creating one or more CRTCs::
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index 9f24e9e6ed6d..1390f6084c19 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -659,6 +659,176 @@ static ssize_t plane_supported_formats_store(struct config_item *item,
return (ssize_t)ret_count;
}
+static ssize_t plane_zpos_enabled_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_plane *plane;
+ bool enabled;
+
+ plane = plane_item_to_vkms_configfs_plane(item);
+
+ scoped_guard(mutex, &plane->dev->config->lock)
+ enabled = vkms_config_plane_get_zpos_enabled(plane->config);
+
+ return sprintf(page, "%d\n", enabled);
+}
+
+static ssize_t plane_zpos_enabled_store(struct config_item *item, const char *page,
+ size_t count)
+{
+ struct vkms_configfs_plane *plane;
+ bool enabled;
+
+ plane = plane_item_to_vkms_configfs_plane(item);
+
+ if (kstrtobool(page, &enabled))
+ return -EINVAL;
+
+ scoped_guard(mutex, &plane->dev->config->lock) {
+ if (plane->dev->enabled)
+ return -EBUSY;
+
+ vkms_config_plane_set_zpos_enabled(plane->config, enabled);
+ }
+
+ return (ssize_t)count;
+}
+
+static ssize_t plane_zpos_mutable_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_plane *plane;
+ bool mutable;
+
+ plane = plane_item_to_vkms_configfs_plane(item);
+
+ scoped_guard(mutex, &plane->dev->config->lock)
+ mutable = vkms_config_plane_get_zpos_mutable(plane->config);
+
+ return sprintf(page, "%d\n", mutable);
+}
+
+static ssize_t plane_zpos_mutable_store(struct config_item *item, const char *page,
+ size_t count)
+{
+ struct vkms_configfs_plane *plane;
+ bool mutable;
+
+ plane = plane_item_to_vkms_configfs_plane(item);
+
+ if (kstrtobool(page, &mutable))
+ return -EINVAL;
+
+ scoped_guard(mutex, &plane->dev->config->lock) {
+ if (plane->dev->enabled)
+ return -EBUSY;
+
+ vkms_config_plane_set_zpos_mutable(plane->config, mutable);
+ }
+
+ return (ssize_t)count;
+}
+
+static ssize_t plane_zpos_initial_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_plane *plane;
+ unsigned int initial;
+
+ plane = plane_item_to_vkms_configfs_plane(item);
+
+ scoped_guard(mutex, &plane->dev->config->lock)
+ initial = vkms_config_plane_get_zpos_initial(plane->config);
+
+ return sprintf(page, "%u\n", initial);
+}
+
+static ssize_t plane_zpos_initial_store(struct config_item *item, const char *page,
+ size_t count)
+{
+ struct vkms_configfs_plane *plane;
+ unsigned int initial;
+
+ plane = plane_item_to_vkms_configfs_plane(item);
+
+ if (kstrtouint(page, 10, &initial))
+ return -EINVAL;
+
+ scoped_guard(mutex, &plane->dev->config->lock) {
+ if (plane->dev->enabled)
+ return -EBUSY;
+
+ vkms_config_plane_set_zpos_initial(plane->config, initial);
+ }
+
+ return (ssize_t)count;
+}
+
+static ssize_t plane_zpos_min_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_plane *plane;
+ unsigned int min;
+
+ plane = plane_item_to_vkms_configfs_plane(item);
+
+ scoped_guard(mutex, &plane->dev->config->lock)
+ min = vkms_config_plane_get_zpos_min(plane->config);
+
+ return sprintf(page, "%u\n", min);
+}
+
+static ssize_t plane_zpos_min_store(struct config_item *item, const char *page,
+ size_t count)
+{
+ struct vkms_configfs_plane *plane;
+ unsigned int min;
+
+ plane = plane_item_to_vkms_configfs_plane(item);
+
+ if (kstrtouint(page, 10, &min))
+ return -EINVAL;
+
+ scoped_guard(mutex, &plane->dev->config->lock) {
+ if (plane->dev->enabled)
+ return -EBUSY;
+
+ vkms_config_plane_set_zpos_min(plane->config, min);
+ }
+
+ return (ssize_t)count;
+}
+
+static ssize_t plane_zpos_max_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_plane *plane;
+ unsigned int max;
+
+ plane = plane_item_to_vkms_configfs_plane(item);
+
+ scoped_guard(mutex, &plane->dev->config->lock)
+ max = vkms_config_plane_get_zpos_max(plane->config);
+
+ return sprintf(page, "%u\n", max);
+}
+
+static ssize_t plane_zpos_max_store(struct config_item *item, const char *page,
+ size_t count)
+{
+ struct vkms_configfs_plane *plane;
+ unsigned int max;
+
+ plane = plane_item_to_vkms_configfs_plane(item);
+
+ if (kstrtouint(page, 10, &max))
+ return -EINVAL;
+
+ scoped_guard(mutex, &plane->dev->config->lock) {
+ if (plane->dev->enabled)
+ return -EBUSY;
+
+ vkms_config_plane_set_zpos_max(plane->config, max);
+ }
+
+ return (ssize_t)count;
+}
+
CONFIGFS_ATTR(plane_, type);
CONFIGFS_ATTR(plane_, supported_rotations);
CONFIGFS_ATTR(plane_, default_rotation);
@@ -667,6 +837,11 @@ CONFIGFS_ATTR(plane_, default_color_range);
CONFIGFS_ATTR(plane_, supported_color_encodings);
CONFIGFS_ATTR(plane_, default_color_encoding);
CONFIGFS_ATTR(plane_, supported_formats);
+CONFIGFS_ATTR(plane_, zpos_enabled);
+CONFIGFS_ATTR(plane_, zpos_mutable);
+CONFIGFS_ATTR(plane_, zpos_initial);
+CONFIGFS_ATTR(plane_, zpos_min);
+CONFIGFS_ATTR(plane_, zpos_max);
static struct configfs_attribute *plane_item_attrs[] = {
&plane_attr_type,
@@ -677,6 +852,11 @@ static struct configfs_attribute *plane_item_attrs[] = {
&plane_attr_supported_color_encodings,
&plane_attr_default_color_encoding,
&plane_attr_supported_formats,
+ &plane_attr_zpos_enabled,
+ &plane_attr_zpos_mutable,
+ &plane_attr_zpos_initial,
+ &plane_attr_zpos_min,
+ &plane_attr_zpos_max,
NULL,
};
diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
index 60fae99fed53..71abfe4b25d0 100644
--- a/drivers/gpu/drm/vkms/vkms_plane.c
+++ b/drivers/gpu/drm/vkms/vkms_plane.c
@@ -225,6 +225,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
{
struct drm_device *dev = &vkmsdev->drm;
struct vkms_plane *plane;
+ int ret;
/*
* Keep the default "plane-%d" name from the DRM core when no name is
@@ -258,13 +259,19 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
vkms_initialize_colorops(&plane->base);
if (vkms_config_plane_get_zpos_enabled(plane_cfg)) {
if (vkms_config_plane_get_zpos_mutable(plane_cfg)) {
- drm_plane_create_zpos_property(&plane->base,
- vkms_config_plane_get_zpos_initial(plane_cfg),
- vkms_config_plane_get_zpos_min(plane_cfg),
- vkms_config_plane_get_zpos_max(plane_cfg));
+ ret = drm_plane_create_zpos_property(
+ &plane->base,
+ vkms_config_plane_get_zpos_initial(plane_cfg),
+ vkms_config_plane_get_zpos_min(plane_cfg),
+ vkms_config_plane_get_zpos_max(plane_cfg));
+ if (ret)
+ return ERR_PTR(ret);
} else {
- drm_plane_create_zpos_immutable_property(&plane->base,
- vkms_config_plane_get_zpos_initial(plane_cfg));
+ ret = drm_plane_create_zpos_immutable_property(
+ &plane->base,
+ vkms_config_plane_get_zpos_initial(plane_cfg));
+ if (ret)
+ return ERR_PTR(ret);
}
}
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 30/43] drm/vkms: Introduce back pointer to connector
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (28 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 29/43] drm/vkms: Introduce configfs " Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 31/43] drm/vkms: Introduce connector type Louis Chauvet
` (12 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
Each connector now stores a pointer to its vkms_config_connector and
takes a reference on it when created, released through a drmm action on
device cleanup; detect() uses the back-pointer instead of walking the
configuration list.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/vkms_connector.c | 33 ++++++++++++++++++++++++---------
drivers/gpu/drm/vkms/vkms_connector.h | 9 ++++++++-
drivers/gpu/drm/vkms/vkms_output.c | 2 +-
3 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/vkms/vkms_connector.c b/drivers/gpu/drm/vkms/vkms_connector.c
index 080a0240d5e9..bb023b5af4e4 100644
--- a/drivers/gpu/drm/vkms/vkms_connector.c
+++ b/drivers/gpu/drm/vkms/vkms_connector.c
@@ -11,11 +11,9 @@
static enum drm_connector_status vkms_connector_detect(struct drm_connector *connector,
bool force)
{
- struct drm_device *dev = connector->dev;
- struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev);
struct vkms_connector *vkms_connector;
+ struct vkms_config_connector *cfg;
enum drm_connector_status status;
- struct vkms_config_connector *connector_cfg;
vkms_connector = drm_connector_to_vkms_connector(connector);
@@ -26,11 +24,12 @@ static enum drm_connector_status vkms_connector_detect(struct drm_connector *con
*/
status = connector->status;
- vkms_config_for_each_connector(vkmsdev->config, connector_cfg) {
- if (connector_cfg->connector == vkms_connector) {
- scoped_guard(mutex, &vkmsdev->config->lock)
- status = vkms_config_connector_get_status(connector_cfg);
- }
+ cfg = vkms_connector->cfg;
+ if (cfg) {
+ cfg = vkms_config_connector_get(cfg);
+ scoped_guard(mutex, &cfg->config->lock)
+ status = vkms_config_connector_get_status(cfg);
+ vkms_config_connector_put(cfg);
}
return status;
@@ -70,7 +69,16 @@ static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = {
.best_encoder = vkms_conn_best_encoder,
};
-struct vkms_connector *vkms_connector_init(struct vkms_device *vkmsdev)
+static void vkms_connector_static_cfg_release(struct drm_device *dev, void *res)
+{
+ struct vkms_connector *connector = res;
+
+ vkms_config_connector_put(connector->cfg);
+}
+
+
+struct vkms_connector *vkms_connector_init(struct vkms_device *vkmsdev,
+ struct vkms_config_connector *connector_cfg)
{
struct drm_device *dev = &vkmsdev->drm;
struct vkms_connector *connector;
@@ -87,6 +95,13 @@ struct vkms_connector *vkms_connector_init(struct vkms_device *vkmsdev)
drm_connector_helper_add(&connector->base, &vkms_conn_helper_funcs);
+ connector->cfg = connector_cfg;
+ vkms_config_connector_get(connector_cfg);
+ ret = drmm_add_action_or_reset(dev, vkms_connector_static_cfg_release,
+ connector);
+ if (ret)
+ return ERR_PTR(ret);
+
return connector;
}
diff --git a/drivers/gpu/drm/vkms/vkms_connector.h b/drivers/gpu/drm/vkms/vkms_connector.h
index 52ae97af2bc1..89d7f3a15d6e 100644
--- a/drivers/gpu/drm/vkms/vkms_connector.h
+++ b/drivers/gpu/drm/vkms/vkms_connector.h
@@ -4,6 +4,7 @@
#define _VKMS_CONNECTOR_H_
#include "vkms_drv.h"
+#include "vkms_config.h"
#define drm_connector_to_vkms_connector(target) \
container_of(target, struct vkms_connector, base)
@@ -12,19 +13,25 @@
* struct vkms_connector - VKMS custom type wrapping around the DRM connector
*
* @base: Base DRM connector
+ * @cfg: Configuration of the connector. A reference on it is taken at
+ * creation and released by a drmm action on device cleanup
*/
struct vkms_connector {
struct drm_connector base;
+
+ struct vkms_config_connector *cfg;
};
/**
* vkms_connector_init() - Initialize a connector
* @vkmsdev: VKMS device containing the connector
+ * @connector_cfg: Connector's configuration
*
* Returns:
* The connector or an error on failure.
*/
-struct vkms_connector *vkms_connector_init(struct vkms_device *vkmsdev);
+struct vkms_connector *vkms_connector_init(struct vkms_device *vkmsdev,
+ struct vkms_config_connector *connector_cfg);
/**
* vkms_trigger_connector_hotplug() - Update the device's connectors status
diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c
index 982c6cd5fcc7..7783a2f6d343 100644
--- a/drivers/gpu/drm/vkms/vkms_output.c
+++ b/drivers/gpu/drm/vkms/vkms_output.c
@@ -97,7 +97,7 @@ int vkms_output_init(struct vkms_device *vkmsdev)
struct vkms_config_encoder *possible_encoder;
unsigned long idx = 0;
- connector_cfg->connector = vkms_connector_init(vkmsdev);
+ connector_cfg->connector = vkms_connector_init(vkmsdev, connector_cfg);
if (IS_ERR(connector_cfg->connector)) {
DRM_ERROR("Failed to init connector\n");
return PTR_ERR(connector_cfg->connector);
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 31/43] drm/vkms: Introduce connector type
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (29 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 30/43] drm/vkms: Introduce back pointer to connector Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 32/43] drm/vkms: Introduce configfs for " Louis Chauvet
` (11 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
In order to emulate connector-specific behavior, add the connector type
to the connector configuration.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/tests/vkms_config_test.c | 5 +++++
drivers/gpu/drm/vkms/vkms_config.c | 3 +++
drivers/gpu/drm/vkms/vkms_config.h | 24 ++++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_connector.c | 2 +-
4 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/vkms/tests/vkms_config_test.c b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
index a43dff511fc3..257ba0342034 100644
--- a/drivers/gpu/drm/vkms/tests/vkms_config_test.c
+++ b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
@@ -137,6 +137,7 @@ static void vkms_config_test_default_config(struct kunit *test)
struct vkms_config *config;
struct vkms_config_plane *plane_cfg;
struct vkms_config_crtc *crtc_cfg;
+ struct vkms_config_connector *connector_cfg;
int n_primaries = 0;
int n_cursors = 0;
int n_overlays = 0;
@@ -211,6 +212,10 @@ static void vkms_config_test_default_config(struct kunit *test)
/* Connectors */
KUNIT_EXPECT_EQ(test, vkms_config_get_num_connectors(config), 1);
+ vkms_config_for_each_connector(config, connector_cfg) {
+ KUNIT_EXPECT_EQ(test, vkms_config_connector_get_type(connector_cfg),
+ DRM_MODE_CONNECTOR_VIRTUAL);
+ }
KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index 342b844bfc6d..b415d4bf6edb 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -647,6 +647,8 @@ static int vkms_config_show(struct seq_file *m, void *data)
seq_puts(m, "connector:\n");
seq_printf(m, "\tstatus=%s\n",
drm_get_connector_status_name(vkms_config_connector_get_status(connector_cfg)));
+ seq_printf(m, "\ttype=%s\n",
+ drm_get_connector_type_name(vkms_config_connector_get_type(connector_cfg)));
}
}
@@ -1005,6 +1007,7 @@ struct vkms_config_connector *vkms_config_create_connector(struct vkms_config *c
connector_cfg->config = config;
connector_cfg->status = connector_status_connected;
+ vkms_config_connector_set_type(connector_cfg, DRM_MODE_CONNECTOR_VIRTUAL);
xa_init_flags(&connector_cfg->possible_encoders, XA_FLAGS_ALLOC);
/* refcnt starts at 1: this reference is owned by config->connectors */
kref_init(&connector_cfg->refcnt);
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index eb29008e54f0..efebb190ce40 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -150,6 +150,7 @@ struct vkms_config_encoder {
*
* @link: Link to the others connector in vkms_config
* @rcu: RCU head for deferred freeing of this object
+ * @type: Store the type of connector using DRM_MODE_CONNECTOR_* values
* @config: The vkms_config this connector belongs to
* @status: Status (connected, disconnected...) of the connector
* @possible_encoders: Array of encoders that can be used with this connector
@@ -167,6 +168,7 @@ struct vkms_config_connector {
struct rcu_head rcu;
struct vkms_config *config;
+ int type;
enum drm_connector_status status;
struct xarray possible_encoders;
bool unlinked;
@@ -397,6 +399,28 @@ vkms_config_plane_set_default_pipeline(struct vkms_config_plane *plane_cfg,
}
/**
+ * vkms_config_connector_get_type() - Return the connector type
+ * @connector_cfg: Connector to get the type from
+ */
+static inline int
+vkms_config_connector_get_type(const struct vkms_config_connector *connector_cfg)
+{
+ return connector_cfg->type;
+}
+
+/**
+ * vkms_config_connector_set_type() - Set the connector type
+ * @connector_cfg: Connector to set the type to
+ * @type: New connector type
+ */
+static inline void
+vkms_config_connector_set_type(struct vkms_config_connector *connector_cfg,
+ int type)
+{
+ connector_cfg->type = type;
+}
+
+/*
* vkms_config_plane_get_default_rotation() - Get the default rotation for a plane
* @plane_cfg: Plane to get the default rotation from
*
diff --git a/drivers/gpu/drm/vkms/vkms_connector.c b/drivers/gpu/drm/vkms/vkms_connector.c
index bb023b5af4e4..84c49915ed44 100644
--- a/drivers/gpu/drm/vkms/vkms_connector.c
+++ b/drivers/gpu/drm/vkms/vkms_connector.c
@@ -89,7 +89,7 @@ struct vkms_connector *vkms_connector_init(struct vkms_device *vkmsdev,
return ERR_PTR(-ENOMEM);
ret = drmm_connector_init(dev, &connector->base, &vkms_connector_funcs,
- DRM_MODE_CONNECTOR_VIRTUAL, NULL);
+ vkms_config_connector_get_type(connector_cfg), NULL);
if (ret)
return ERR_PTR(ret);
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 32/43] drm/vkms: Introduce configfs for connector type
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (30 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 31/43] drm/vkms: Introduce connector type Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 33/43] drm/vkms: Rename vkms_connector_init to vkms_connector_init_static Louis Chauvet
` (10 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
Add a new attribute to connector to change its type. This is mostly
cosmetic and don't have direct effect in VKMS behavior.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
Documentation/ABI/testing/configfs-vkms | 11 ++++++
Documentation/gpu/vkms.rst | 3 +-
drivers/gpu/drm/vkms/vkms_configfs.c | 65 +++++++++++++++++++++++++++++++++
3 files changed, 78 insertions(+), 1 deletion(-)
diff --git a/Documentation/ABI/testing/configfs-vkms b/Documentation/ABI/testing/configfs-vkms
index 2db0c950adc4..4974f3851090 100644
--- a/Documentation/ABI/testing/configfs-vkms
+++ b/Documentation/ABI/testing/configfs-vkms
@@ -37,6 +37,17 @@ Description:
the status triggers a connector hotplug if the device is
enabled.
+What: /sys/kernel/config/vkms/<device>/connectors/<connector>/type
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Type of the connector. Possible values are the DRM_MODE_CONNECTOR_*
+ numbers from drm_mode.h, restricted to one of Unknown, VGA, DVI-I,
+ DVI-D, DVI-A, Composite, SVIDEO, LVDS, Component, 9PinDIN,
+ DisplayPort, HDMI-A, HDMI-B, TV, eDP, Virtual, DSI, DPI, SPI and
+ USB. Writing fails with -EBUSY if the device is enabled and the
+ connector is enabled.
+
What: /sys/kernel/config/vkms/<device>/connectors/<connector>/possible_encoders
Date: Nov 2025
Contact: dri-devel@lists.freedesktop.org
diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst
index b58e96a3c273..f2622b3fd8af 100644
--- a/Documentation/gpu/vkms.rst
+++ b/Documentation/gpu/vkms.rst
@@ -137,10 +137,11 @@ Last but not least, create one or more connectors::
sudo mkdir /config/vkms/my-vkms/connectors/connector0
-Connectors have 1 configurable attribute:
+Connectors have 2 configurable attribute:
- status: Connection status: 1 connected, 2 disconnected, 3 unknown (same values
as those exposed by the "status" property of a connector)
+- type: Type of connector. Same values as exposed by the "type" field in drm_connector.
To finish the configuration, link the different pipeline items::
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index 1390f6084c19..fef731bdb059 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -1090,10 +1090,75 @@ static ssize_t connector_status_store(struct config_item *item,
return (ssize_t)count;
}
+static ssize_t connector_type_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_connector *connector;
+ int type;
+
+ connector = connector_item_to_vkms_configfs_connector(item);
+
+ scoped_guard(mutex, &connector->dev->config->lock) {
+ type = vkms_config_connector_get_type(connector->config);
+ }
+
+ return sprintf(page, "%u\n", type);
+}
+
+static ssize_t connector_type_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_configfs_connector *connector;
+ int val, ret;
+
+ connector = connector_item_to_vkms_configfs_connector(item);
+
+ ret = kstrtouint(page, 10, &val);
+
+ if (ret)
+ return ret;
+
+ switch (val) {
+ case DRM_MODE_CONNECTOR_Unknown:
+ case DRM_MODE_CONNECTOR_VGA:
+ case DRM_MODE_CONNECTOR_DVII:
+ case DRM_MODE_CONNECTOR_DVID:
+ case DRM_MODE_CONNECTOR_DVIA:
+ case DRM_MODE_CONNECTOR_Composite:
+ case DRM_MODE_CONNECTOR_SVIDEO:
+ case DRM_MODE_CONNECTOR_LVDS:
+ case DRM_MODE_CONNECTOR_Component:
+ case DRM_MODE_CONNECTOR_9PinDIN:
+ case DRM_MODE_CONNECTOR_DisplayPort:
+ case DRM_MODE_CONNECTOR_HDMIA:
+ case DRM_MODE_CONNECTOR_HDMIB:
+ case DRM_MODE_CONNECTOR_TV:
+ case DRM_MODE_CONNECTOR_eDP:
+ case DRM_MODE_CONNECTOR_VIRTUAL:
+ case DRM_MODE_CONNECTOR_DSI:
+ case DRM_MODE_CONNECTOR_DPI:
+ case DRM_MODE_CONNECTOR_SPI:
+ case DRM_MODE_CONNECTOR_USB:
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ scoped_guard(mutex, &connector->dev->config->lock) {
+ if (connector->dev->enabled)
+ return -EBUSY;
+
+ vkms_config_connector_set_type(connector->config, val);
+ }
+
+ return count;
+}
+
CONFIGFS_ATTR(connector_, status);
+CONFIGFS_ATTR(connector_, type);
static struct configfs_attribute *connector_item_attrs[] = {
&connector_attr_status,
+ &connector_attr_type,
NULL,
};
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 33/43] drm/vkms: Rename vkms_connector_init to vkms_connector_init_static
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (31 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 32/43] drm/vkms: Introduce configfs for " Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 34/43] drm/vkms: Introduce config for connector supported colorspace Louis Chauvet
` (9 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
With the introduction of dynamic connectors we will have two way of
initializing a VKMS connector. Rename the current function to clarify
the case.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/vkms_connector.c | 5 ++---
drivers/gpu/drm/vkms/vkms_connector.h | 6 +++---
drivers/gpu/drm/vkms/vkms_output.c | 2 +-
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/vkms/vkms_connector.c b/drivers/gpu/drm/vkms/vkms_connector.c
index 84c49915ed44..7264ca84f910 100644
--- a/drivers/gpu/drm/vkms/vkms_connector.c
+++ b/drivers/gpu/drm/vkms/vkms_connector.c
@@ -76,9 +76,8 @@ static void vkms_connector_static_cfg_release(struct drm_device *dev, void *res)
vkms_config_connector_put(connector->cfg);
}
-
-struct vkms_connector *vkms_connector_init(struct vkms_device *vkmsdev,
- struct vkms_config_connector *connector_cfg)
+struct vkms_connector *vkms_connector_init_static(struct vkms_device *vkmsdev,
+ struct vkms_config_connector *connector_cfg)
{
struct drm_device *dev = &vkmsdev->drm;
struct vkms_connector *connector;
diff --git a/drivers/gpu/drm/vkms/vkms_connector.h b/drivers/gpu/drm/vkms/vkms_connector.h
index 89d7f3a15d6e..61a8dd55d7f7 100644
--- a/drivers/gpu/drm/vkms/vkms_connector.h
+++ b/drivers/gpu/drm/vkms/vkms_connector.h
@@ -23,15 +23,15 @@ struct vkms_connector {
};
/**
- * vkms_connector_init() - Initialize a connector
+ * vkms_connector_init_static() - Initialize a connector
* @vkmsdev: VKMS device containing the connector
* @connector_cfg: Connector's configuration
*
* Returns:
* The connector or an error on failure.
*/
-struct vkms_connector *vkms_connector_init(struct vkms_device *vkmsdev,
- struct vkms_config_connector *connector_cfg);
+struct vkms_connector *vkms_connector_init_static(struct vkms_device *vkmsdev,
+ struct vkms_config_connector *connector_cfg);
/**
* vkms_trigger_connector_hotplug() - Update the device's connectors status
diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c
index 7783a2f6d343..2b0f7a8a80b5 100644
--- a/drivers/gpu/drm/vkms/vkms_output.c
+++ b/drivers/gpu/drm/vkms/vkms_output.c
@@ -97,7 +97,7 @@ int vkms_output_init(struct vkms_device *vkmsdev)
struct vkms_config_encoder *possible_encoder;
unsigned long idx = 0;
- connector_cfg->connector = vkms_connector_init(vkmsdev, connector_cfg);
+ connector_cfg->connector = vkms_connector_init_static(vkmsdev, connector_cfg);
if (IS_ERR(connector_cfg->connector)) {
DRM_ERROR("Failed to init connector\n");
return PTR_ERR(connector_cfg->connector);
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 34/43] drm/vkms: Introduce config for connector supported colorspace
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (32 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 33/43] drm/vkms: Rename vkms_connector_init to vkms_connector_init_static Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 16:44 ` kernel test robot
2026-11-26 11:29 ` [PATCH v7 35/43] drm/vkms: Introduce configfs " Louis Chauvet
` (8 subsequent siblings)
42 siblings, 1 reply; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
To emulate some HDR features of displays, it is required to expose some
properties on HDMI, eDP and DP connectors.
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/tests/vkms_config_test.c | 3 ++
drivers/gpu/drm/vkms/vkms_config.c | 40 +++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_config.h | 30 ++++++++++++++++
drivers/gpu/drm/vkms/vkms_connector.c | 51 +++++++++++++++++++++++++++
4 files changed, 124 insertions(+)
diff --git a/drivers/gpu/drm/vkms/tests/vkms_config_test.c b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
index 257ba0342034..1c54d6f9828d 100644
--- a/drivers/gpu/drm/vkms/tests/vkms_config_test.c
+++ b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
@@ -215,6 +215,9 @@ static void vkms_config_test_default_config(struct kunit *test)
vkms_config_for_each_connector(config, connector_cfg) {
KUNIT_EXPECT_EQ(test, vkms_config_connector_get_type(connector_cfg),
DRM_MODE_CONNECTOR_VIRTUAL);
+ KUNIT_EXPECT_EQ(test,
+ vkms_config_connector_get_supported_colorspaces(connector_cfg),
+ 0);
}
KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index b415d4bf6edb..fa4ca256b4b9 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -466,6 +466,38 @@ static bool valid_connector_possible_encoders(const struct vkms_config *config)
return true;
}
+static bool valid_connector_colorspaces(const struct vkms_config *config)
+{
+ struct drm_device *dev = config->dev ? &config->dev->drm : NULL;
+ struct vkms_config_connector *connector_cfg;
+
+ vkms_config_for_each_connector(config, connector_cfg) {
+ u32 colorspaces = vkms_config_connector_get_supported_colorspaces(connector_cfg);
+
+ if (!colorspaces)
+ continue;
+
+ switch (connector_cfg->type) {
+ case DRM_MODE_CONNECTOR_HDMIA:
+ case DRM_MODE_CONNECTOR_HDMIB:
+ case DRM_MODE_CONNECTOR_DisplayPort:
+ case DRM_MODE_CONNECTOR_eDP:
+ break;
+ default:
+ drm_info(dev,
+ "Colorspaces are only supported on HDMI, DisplayPort and eDP connectors\n");
+ return false;
+ }
+
+ if (colorspaces & ~(BIT(DRM_MODE_COLORIMETRY_COUNT) - 1)) {
+ drm_info(dev, "Colorspace value contains invalid bits\n");
+ return false;
+ }
+ }
+
+ return true;
+}
+
bool vkms_config_is_valid(const struct vkms_config *config)
{
struct drm_device *dev = config->dev ? &config->dev->drm : NULL;
@@ -543,6 +575,9 @@ bool vkms_config_is_valid(const struct vkms_config *config)
if (!valid_connector_possible_encoders(config))
return false;
+ if (!valid_connector_colorspaces(config))
+ return false;
+
return true;
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_is_valid);
@@ -649,6 +684,10 @@ static int vkms_config_show(struct seq_file *m, void *data)
drm_get_connector_status_name(vkms_config_connector_get_status(connector_cfg)));
seq_printf(m, "\ttype=%s\n",
drm_get_connector_type_name(vkms_config_connector_get_type(connector_cfg)));
+ seq_puts(m, "\tsupported colorspaces=");
+ show_bitfield(m, vkms_config_connector_get_supported_colorspaces(connector_cfg),
+ drm_get_colorspace_name);
+ seq_puts(m, "\n");
}
}
@@ -1008,6 +1047,7 @@ struct vkms_config_connector *vkms_config_create_connector(struct vkms_config *c
connector_cfg->config = config;
connector_cfg->status = connector_status_connected;
vkms_config_connector_set_type(connector_cfg, DRM_MODE_CONNECTOR_VIRTUAL);
+ vkms_config_connector_set_supported_colorspaces(connector_cfg, 0);
xa_init_flags(&connector_cfg->possible_encoders, XA_FLAGS_ALLOC);
/* refcnt starts at 1: this reference is owned by config->connectors */
kref_init(&connector_cfg->refcnt);
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index efebb190ce40..341e0638b508 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -153,6 +153,10 @@ struct vkms_config_encoder {
* @type: Store the type of connector using DRM_MODE_CONNECTOR_* values
* @config: The vkms_config this connector belongs to
* @status: Status (connected, disconnected...) of the connector
+ * @supported_colorspaces: Bitmask of all the supported colorspaces. Values
+ * are the sames as ones accepted by
+ * drm_mode_create_hdmi_colorspace_property() and
+ * drm_mode_create_dp_colorspace_property()
* @possible_encoders: Array of encoders that can be used with this connector
* @unlinked: Set when the connector was unlinked from config->connectors
* by vkms_config_destroy_connector()
@@ -170,6 +174,7 @@ struct vkms_config_connector {
int type;
enum drm_connector_status status;
+ u32 supported_colorspaces;
struct xarray possible_encoders;
bool unlinked;
@@ -297,6 +302,31 @@ DEFINE_FREE(vkms_config_put, struct vkms_config *, if (_T) vkms_config_put(_T));
*/
void vkms_config_destroy(struct vkms_config *config);
+/**
+ * vkms_config_connector_set_supported_colorspaces() - Set the supported colorspaces for a connector
+ * @connector_cfg: Connector configuration to modify
+ * @supported_colorspaces: Bitmask of supported colorspaces (DRM_MODE_COLORIMETRY_*)
+ */
+static inline void
+vkms_config_connector_set_supported_colorspaces(struct vkms_config_connector *connector_cfg,
+ u32 supported_colorspaces)
+{
+ connector_cfg->supported_colorspaces = supported_colorspaces;
+}
+
+/**
+ * vkms_config_connector_get_supported_colorspaces() - Get the supported colorspaces for a connector
+ * @connector_cfg: Connector configuration to query
+ *
+ * Returns:
+ * Bitmask of supported colorspaces (DRM_MODE_COLORIMETRY_*)
+ */
+static inline u32
+vkms_config_connector_get_supported_colorspaces(const struct vkms_config_connector *connector_cfg)
+{
+ return connector_cfg->supported_colorspaces;
+}
+
/**
* vkms_config_get_device_name() - Return the name of the device
* @config: Configuration to get the device name from
diff --git a/drivers/gpu/drm/vkms/vkms_connector.c b/drivers/gpu/drm/vkms/vkms_connector.c
index 7264ca84f910..552d767c3976 100644
--- a/drivers/gpu/drm/vkms/vkms_connector.c
+++ b/drivers/gpu/drm/vkms/vkms_connector.c
@@ -76,6 +76,53 @@ static void vkms_connector_static_cfg_release(struct drm_device *dev, void *res)
vkms_config_connector_put(connector->cfg);
}
+/**
+ * vkms_connector_init - Common initialization for all vkms connectors
+ *
+ * @connector - Already allocated connector
+ * @connector_cfg - Configuration to apply
+ *
+ * Returns: 0 on success, errno on error;
+ */
+static int __must_check vkms_connector_init(struct vkms_connector *connector,
+ struct vkms_config_connector *connector_cfg)
+{
+ int ret = 0;
+
+ if (vkms_config_connector_get_supported_colorspaces(connector_cfg)) {
+ if (connector_cfg->type == DRM_MODE_CONNECTOR_HDMIA ||
+ connector_cfg->type == DRM_MODE_CONNECTOR_HDMIB) {
+ ret = drm_mode_create_hdmi_colorspace_property(
+ &connector->base,
+ vkms_config_connector_get_supported_colorspaces(connector_cfg));
+ if (ret)
+ return ret;
+ } else if (connector_cfg->type == DRM_MODE_CONNECTOR_DisplayPort ||
+ connector_cfg->type == DRM_MODE_CONNECTOR_eDP) {
+ ret = drm_mode_create_dp_colorspace_property(
+ &connector->base,
+ vkms_config_connector_get_supported_colorspaces(connector_cfg));
+ if (ret)
+ return ret;
+ }
+
+ if (connector_cfg->type == DRM_MODE_CONNECTOR_HDMIA ||
+ connector_cfg->type == DRM_MODE_CONNECTOR_HDMIB ||
+ connector_cfg->type == DRM_MODE_CONNECTOR_DisplayPort ||
+ connector_cfg->type == DRM_MODE_CONNECTOR_eDP) {
+ ret = drm_connector_attach_colorspace_property(&connector->base);
+ if (ret) {
+ drm_property_destroy(connector->base.dev,
+ connector->base.colorspace_property);
+ return ret;
+ }
+ drm_connector_attach_hdr_output_metadata_property(&connector->base);
+ }
+ }
+
+ return 0;
+}
+
struct vkms_connector *vkms_connector_init_static(struct vkms_device *vkmsdev,
struct vkms_config_connector *connector_cfg)
{
@@ -92,6 +139,10 @@ struct vkms_connector *vkms_connector_init_static(struct vkms_device *vkmsdev,
if (ret)
return ERR_PTR(ret);
+ ret = vkms_connector_init(connector, connector_cfg);
+ if (ret)
+ return ERR_PTR(ret);
+
drm_connector_helper_add(&connector->base, &vkms_conn_helper_funcs);
connector->cfg = connector_cfg;
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* Re: [PATCH v7 34/43] drm/vkms: Introduce config for connector supported colorspace
2026-11-26 11:29 ` [PATCH v7 34/43] drm/vkms: Introduce config for connector supported colorspace Louis Chauvet
@ 2026-11-26 16:44 ` kernel test robot
0 siblings, 0 replies; 46+ messages in thread
From: kernel test robot @ 2026-11-26 16:44 UTC (permalink / raw)
To: Louis Chauvet, Haneen Mohammed, Simona Vetter, Melissa Wen,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, jose.exposito89, Jonathan Corbet, Oarora Etimis,
Harry Wentland, Lucas De Marchi, Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Shuah Khan, Miguel Ojeda,
Nathan Chancellor, Bill Wendling, Justin Stitt
Cc: oe-kbuild-all, Luca Ceresoli, Kory Maincent, sebastian.wick,
victoria, thomas.petazzoni, dri-devel, linux-kernel, linux-doc,
llvm
Hi Louis,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 3c7c3c12dfc7704ca614abbfa266ca00a2b5a994]
url: https://github.com/intel-lab-lkp/linux/commits/Louis-Chauvet/drm-vkms-Lock-the-config-dump-against-concurrent-configfs-changes/20261126-122844
base: 3c7c3c12dfc7704ca614abbfa266ca00a2b5a994
patch link: https://lore.kernel.org/r/20261126-vkms-all-config-v7-34-21194cda2468%40bootlin.com
patch subject: [PATCH v7 34/43] drm/vkms: Introduce config for connector supported colorspace
config: i386-randconfig-1004-20261126 (https://download.01.org/0day-ci/archive/20261127/20261127003812.SJ4m3pfw-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261127/20261127003812.SJ4m3pfw-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261127003812.SJ4m3pfw-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> Warning: drivers/gpu/drm/vkms/vkms_connector.c:88 function parameter 'connector' not described in 'vkms_connector_init'
>> Warning: drivers/gpu/drm/vkms/vkms_connector.c:88 function parameter 'connector_cfg' not described in 'vkms_connector_init'
>> Warning: drivers/gpu/drm/vkms/vkms_connector.c:88 function parameter 'connector' not described in 'vkms_connector_init'
>> Warning: drivers/gpu/drm/vkms/vkms_connector.c:88 function parameter 'connector_cfg' not described in 'vkms_connector_init'
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 46+ messages in thread
* [PATCH v7 35/43] drm/vkms: Introduce configfs for connector supported colorspace
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (33 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 34/43] drm/vkms: Introduce config for connector supported colorspace Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 36/43] drm/vkms: Introduce config for connector EDID Louis Chauvet
` (7 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
Add the attribute supported_colorspaces to configure the supported
colorspace of a connector. It will allows emulating some HDR features of
displays. This feature is only supported for HDMI, DP and eDP connectors.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
Documentation/ABI/testing/configfs-vkms | 12 ++++++++++
Documentation/gpu/vkms.rst | 7 +++++-
drivers/gpu/drm/vkms/vkms_configfs.c | 40 +++++++++++++++++++++++++++++++++
3 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/Documentation/ABI/testing/configfs-vkms b/Documentation/ABI/testing/configfs-vkms
index 4974f3851090..79a9486e359e 100644
--- a/Documentation/ABI/testing/configfs-vkms
+++ b/Documentation/ABI/testing/configfs-vkms
@@ -48,6 +48,18 @@ Description:
USB. Writing fails with -EBUSY if the device is enabled and the
connector is enabled.
+
+What: /sys/kernel/config/vkms/<device>/connectors/<connector>/supported_colorspaces
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Supported colorspaces for HDMI, DP, and eDP connectors.
+ Value is a decimal number, where bit 0 = NO_DATA,
+ bit 1 = SMPTE_170M_YCC, etc. Bits beyond
+ DRM_MODE_COLORIMETRY_COUNT are rejected. Writing fails
+ with -EBUSY if the device is enabled. See enum
+ drm_colorspace for the full list.
+
What: /sys/kernel/config/vkms/<device>/connectors/<connector>/possible_encoders
Date: Nov 2025
Contact: dri-devel@lists.freedesktop.org
diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst
index f2622b3fd8af..11058b6e6250 100644
--- a/Documentation/gpu/vkms.rst
+++ b/Documentation/gpu/vkms.rst
@@ -137,11 +137,16 @@ Last but not least, create one or more connectors::
sudo mkdir /config/vkms/my-vkms/connectors/connector0
-Connectors have 2 configurable attribute:
+Connectors have 3 configurable attribute:
- status: Connection status: 1 connected, 2 disconnected, 3 unknown (same values
as those exposed by the "status" property of a connector)
- type: Type of connector. Same values as exposed by the "type" field in drm_connector.
+- supported_colorspaces: Supported colorspaces values for HDMI, DP and eDP connectors.
+ If supported_colorspaces is not 0, the HDR_OUTPUT_METADATA will also be created.
+ Value is a bitfield, 0x1 = NO_DATA, 0x2 = SMPTE_170M_YCC... see enum drm_colorspace
+ for full list.
+
To finish the configuration, link the different pipeline items::
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index fef731bdb059..7377d967be75 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -1153,12 +1153,52 @@ static ssize_t connector_type_store(struct config_item *item,
return count;
}
+static ssize_t connector_supported_colorspaces_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_connector *connector;
+ int colorspaces;
+
+ connector = connector_item_to_vkms_configfs_connector(item);
+
+ scoped_guard(mutex, &connector->dev->config->lock)
+ colorspaces = vkms_config_connector_get_supported_colorspaces(connector->config);
+
+ return sprintf(page, "%u\n", colorspaces);
+}
+
+static ssize_t connector_supported_colorspaces_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_configfs_connector *connector;
+ int val, ret;
+
+ connector = connector_item_to_vkms_configfs_connector(item);
+
+ ret = kstrtouint(page, 10, &val);
+ if (ret)
+ return ret;
+
+ if ((val & -BIT(DRM_MODE_COLORIMETRY_COUNT)) != 0)
+ return -EINVAL;
+
+ scoped_guard(mutex, &connector->dev->config->lock) {
+ if (connector->dev->enabled)
+ return -EBUSY;
+
+ vkms_config_connector_set_supported_colorspaces(connector->config, val);
+ }
+
+ return count;
+}
+
CONFIGFS_ATTR(connector_, status);
CONFIGFS_ATTR(connector_, type);
+CONFIGFS_ATTR(connector_, supported_colorspaces);
static struct configfs_attribute *connector_item_attrs[] = {
&connector_attr_status,
&connector_attr_type,
+ &connector_attr_supported_colorspaces,
NULL,
};
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 36/43] drm/vkms: Introduce config for connector EDID
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (34 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 35/43] drm/vkms: Introduce configfs " Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 37/43] drm/vkms: Introduce configfs " Louis Chauvet
` (6 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
Allows configuration of EDID for each connector.
get_modes() uses the connector back-pointer (with an explicit
reference) instead of walking the whole configuration list.
Store the EDID in a dedicated vkms_config_edid structure holding the
data, its length and an rcu_head, so that the data and its length are
always read coherently. Writers publish the new structure with
rcu_assign_pointer() and free the previous one after a grace period
with call_rcu(); vkms_config_connector_get_edid() returns the data with
rcu_dereference(), so readers must hold rcu_read_lock() while using the
returned pointer. Take it around the mode probe in vkms_conn_get_modes()
and around the debugfs configuration output.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/tests/vkms_config_test.c | 2 +
drivers/gpu/drm/vkms/vkms_config.c | 62 ++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_config.h | 75 +++++++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_connector.c | 50 ++++++++++++++++--
4 files changed, 185 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/vkms/tests/vkms_config_test.c b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
index 1c54d6f9828d..8a13c45e1683 100644
--- a/drivers/gpu/drm/vkms/tests/vkms_config_test.c
+++ b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
@@ -218,6 +218,8 @@ static void vkms_config_test_default_config(struct kunit *test)
KUNIT_EXPECT_EQ(test,
vkms_config_connector_get_supported_colorspaces(connector_cfg),
0);
+ KUNIT_EXPECT_EQ(test, vkms_config_connector_get_edid_enabled(connector_cfg),
+ false);
}
KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index fa4ca256b4b9..173e88122bcb 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -613,6 +613,7 @@ static int vkms_config_show(struct seq_file *m, void *data)
struct drm_device *dev = entry->dev;
struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev);
const char *dev_name;
+ int edid_len;
struct vkms_config_plane *plane_cfg;
struct vkms_config_crtc *crtc_cfg;
struct vkms_config_encoder *encoder_cfg;
@@ -688,6 +689,11 @@ static int vkms_config_show(struct seq_file *m, void *data)
show_bitfield(m, vkms_config_connector_get_supported_colorspaces(connector_cfg),
drm_get_colorspace_name);
seq_puts(m, "\n");
+ vkms_config_connector_get_edid(connector_cfg, &edid_len);
+ seq_printf(m, "\tEDID=%s (len=%d)\n",
+ str_enabled_disabled(vkms_config_connector_get_edid_enabled(connector_cfg)),
+ edid_len
+ );
}
}
@@ -1058,6 +1064,14 @@ struct vkms_config_connector *vkms_config_create_connector(struct vkms_config *c
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_create_connector);
+static void vkms_config_edid_free(struct rcu_head *head)
+{
+ struct vkms_config_edid *edid = container_of(head, struct vkms_config_edid, rcu);
+
+ kfree(edid->edid);
+ kfree(edid);
+}
+
static void vkms_config_connector_release(struct kref *ref)
{
struct vkms_config_connector *connector_cfg =
@@ -1070,6 +1084,8 @@ static void vkms_config_connector_release(struct kref *ref)
/* The config is dying and is draining us: just unlink */
list_del_init(&connector_cfg->link);
}
+ if (connector_cfg->edid)
+ call_rcu(&connector_cfg->edid->rcu, vkms_config_edid_free);
kfree_rcu(connector_cfg, rcu);
}
@@ -1086,6 +1102,52 @@ void vkms_config_connector_put(struct vkms_config_connector *connector_cfg)
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_connector_put);
+/**
+ * vkms_config_connector_set_edid() - Set the EDID data for a connector
+ * @connector_cfg: Connector configuration to modify
+ * @edid: Pointer to the EDID data buffer
+ * @len: Length of the EDID data
+ *
+ * If @len is 0, the EDID data will be cleared and @edid ignored.
+ *
+ * The old EDID data is freed after an RCU grace period, so readers
+ * currently accessing it are not affected.
+ *
+ * Returns: 0 in case of success, -ENOMEM if the memory allocation
+ * failed. On failure the existing EDID data is preserved.
+ */
+int vkms_config_connector_set_edid(struct vkms_config_connector *connector_cfg,
+ const u8 *edid, unsigned int len)
+{
+ struct vkms_config_edid *old, *new;
+
+ if (!len) {
+ old = rcu_dereference_protected(connector_cfg->edid, true);
+ rcu_assign_pointer(connector_cfg->edid, NULL);
+ if (old)
+ call_rcu(&old->rcu, vkms_config_edid_free);
+ return 0;
+ }
+
+ new = kmalloc(sizeof(*new), GFP_KERNEL);
+ if (!new)
+ return -ENOMEM;
+
+ new->edid = kmemdup(edid, len, GFP_KERNEL);
+ if (!new->edid) {
+ kfree(new);
+ return -ENOMEM;
+ }
+ new->edid_len = len;
+
+ old = rcu_dereference_protected(connector_cfg->edid, true);
+ rcu_assign_pointer(connector_cfg->edid, new);
+ if (old)
+ call_rcu(&old->rcu, vkms_config_edid_free);
+ return 0;
+}
+EXPORT_SYMBOL_IF_KUNIT(vkms_config_connector_set_edid);
+
void vkms_config_destroy_connector(struct vkms_config_connector *connector_cfg)
{
/*
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index 341e0638b508..ef8de0316b94 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -145,6 +145,22 @@ struct vkms_config_encoder {
struct drm_encoder *encoder;
};
+/**
+ * struct vkms_config_edid - RCU-protected EDID data
+ *
+ * @edid: Pointer to the EDID data buffer
+ * @edid_len: Length of the EDID data
+ * @rcu: RCU head for safe freeing
+ *
+ * This struct ensures EDID data and its length are always accessed
+ * coherently by readers without requiring locks.
+ */
+struct vkms_config_edid {
+ const u8 *edid;
+ unsigned int edid_len;
+ struct rcu_head rcu;
+};
+
/**
* struct vkms_config_connector
*
@@ -157,6 +173,8 @@ struct vkms_config_encoder {
* are the sames as ones accepted by
* drm_mode_create_hdmi_colorspace_property() and
* drm_mode_create_dp_colorspace_property()
+ * @edid_enabled: If true, create the EDID property
+ * @edid: RCU-protected EDID data. Readers must use rcu_read_lock() to access.
* @possible_encoders: Array of encoders that can be used with this connector
* @unlinked: Set when the connector was unlinked from config->connectors
* by vkms_config_destroy_connector()
@@ -175,6 +193,8 @@ struct vkms_config_connector {
int type;
enum drm_connector_status status;
u32 supported_colorspaces;
+ bool edid_enabled;
+ struct vkms_config_edid __rcu *edid;
struct xarray possible_encoders;
bool unlinked;
@@ -327,6 +347,61 @@ vkms_config_connector_get_supported_colorspaces(const struct vkms_config_connect
return connector_cfg->supported_colorspaces;
}
+/**
+ * vkms_config_connector_get_edid_enabled() - Check if EDID is enabled for a connector
+ * @connector_cfg: Connector configuration to check
+ *
+ * Returns:
+ * True if EDID is enabled for this connector, false otherwise.
+ */
+static inline bool
+vkms_config_connector_get_edid_enabled(const struct vkms_config_connector *connector_cfg)
+{
+ return connector_cfg->edid_enabled;
+}
+
+/**
+ * vkms_config_connector_set_edid_enabled() - Enable or disable EDID for a connector
+ * @connector_cfg: Connector configuration to modify
+ * @enabled: Whether to enable EDID for this connector
+ */
+static inline void
+vkms_config_connector_set_edid_enabled(struct vkms_config_connector *connector_cfg,
+ bool enabled)
+{
+ connector_cfg->edid_enabled = enabled;
+}
+
+/**
+ * vkms_config_connector_get_edid() - Get the EDID data for a connector
+ * @connector_cfg: Connector configuration to get the EDID from
+ * @len: Pointer to store the length of the EDID data
+ *
+ * The caller must hold rcu_read_lock() when calling this function and
+ * while using the returned pointer.
+ *
+ * Returns:
+ * Pointer to the EDID data buffer, or NULL if no EDID is set.
+ * The length of the EDID data is stored in @len.
+ */
+static inline const u8 *
+vkms_config_connector_get_edid(const struct vkms_config_connector *connector_cfg, int *len)
+{
+ const struct vkms_config_edid *edid = rcu_dereference(connector_cfg->edid);
+
+ if (edid) {
+ *len = edid->edid_len;
+ return edid->edid;
+ }
+
+ *len = 0;
+ return NULL;
+}
+
+int vkms_config_connector_set_edid(struct vkms_config_connector *connector_cfg,
+ const u8 *edid, unsigned int len);
+
+
/**
* vkms_config_get_device_name() - Return the name of the device
* @config: Configuration to get the device name from
diff --git a/drivers/gpu/drm/vkms/vkms_connector.c b/drivers/gpu/drm/vkms/vkms_connector.c
index 552d767c3976..71a0ae15be65 100644
--- a/drivers/gpu/drm/vkms/vkms_connector.c
+++ b/drivers/gpu/drm/vkms/vkms_connector.c
@@ -43,13 +43,48 @@ static const struct drm_connector_funcs vkms_connector_funcs = {
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
};
+static int vkms_connector_read_block(void *context, u8 *buf, unsigned int block, size_t len)
+{
+ struct vkms_config_connector *config = context;
+ unsigned int edid_len;
+ const u8 *edid = vkms_config_connector_get_edid(config, &edid_len);
+
+ if (block * len + len > edid_len)
+ return 1;
+ memcpy(buf, &edid[block * len], len);
+ return 0;
+}
+
static int vkms_conn_get_modes(struct drm_connector *connector)
{
- int count;
+ struct vkms_connector *vkms_connector = drm_connector_to_vkms_connector(connector);
+ const struct drm_edid *drm_edid = NULL;
+ int count = 0;
+ struct vkms_config_connector *cfg = vkms_config_connector_get(vkms_connector->cfg);
+
+ if (vkms_config_connector_get_edid_enabled(cfg)) {
+ /*
+ * Hold rcu_read_lock() for the entire duration so that
+ * the EDID data accessed via the callback remains valid.
+ */
+ rcu_read_lock();
+ drm_edid = drm_edid_read_custom(connector,
+ vkms_connector_read_block, cfg);
+
+ drm_edid_connector_update(connector, drm_edid);
+
+ count = drm_edid_connector_add_modes(connector);
+
+ drm_edid_free(drm_edid);
+ rcu_read_unlock();
+ } else {
+ drm_edid_connector_update(connector, NULL);
+
+ count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX);
+ drm_set_preferred_mode(connector, XRES_DEF, YRES_DEF);
+ }
- /* Use the default modes list from DRM */
- count = drm_add_modes_noedid(connector, XRES_MAX, YRES_MAX);
- drm_set_preferred_mode(connector, XRES_DEF, YRES_DEF);
+ vkms_config_connector_put(cfg);
return count;
}
@@ -120,6 +155,13 @@ static int __must_check vkms_connector_init(struct vkms_connector *connector,
}
}
+ /*
+ * The DRM core skips Virtual connectors when attaching the EDID
+ * property; attach it here so an EDID set later can be stored.
+ */
+ if (connector_cfg->type == DRM_MODE_CONNECTOR_VIRTUAL)
+ drm_connector_attach_edid_property(&connector->base);
+
return 0;
}
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 37/43] drm/vkms: Introduce configfs for connector EDID
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (35 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 36/43] drm/vkms: Introduce config for connector EDID Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 38/43] drm/vkms: Store the enabled/disabled status for connector Louis Chauvet
` (5 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
Introduce new attributes to configure EDID of a connector:
- edid_enable - chose if the connector will have an EDID or not
- edid - raw edid content
Due to limitation of ConfigFS, the max len of EDID is PAGE_SIZE (4kB on
x86), it should be sufficient for many tests. One possible evolution is
using a ConfigFS blob to allow bigger EDID.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
Documentation/ABI/testing/configfs-vkms | 21 +++++++
Documentation/gpu/vkms.rst | 5 +-
drivers/gpu/drm/vkms/vkms_configfs.c | 98 +++++++++++++++++++++++++++++++++
3 files changed, 123 insertions(+), 1 deletion(-)
diff --git a/Documentation/ABI/testing/configfs-vkms b/Documentation/ABI/testing/configfs-vkms
index 79a9486e359e..11b4435a3562 100644
--- a/Documentation/ABI/testing/configfs-vkms
+++ b/Documentation/ABI/testing/configfs-vkms
@@ -60,6 +60,27 @@ Description:
with -EBUSY if the device is enabled. See enum
drm_colorspace for the full list.
+What: /sys/kernel/config/vkms/<device>/connectors/<connector>/edid_enabled
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Enable or disable EDID for this connector. Value:
+ 1 - enabled, 0 - disabled. Changing it triggers a
+ connector hotplug if the device is enabled and the
+ connector status is not disconnected.
+
+What: /sys/kernel/config/vkms/<device>/connectors/<connector>/edid
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Raw content of the EDID for this connector. Writing stores
+ the given bytes and triggers a connector hotplug if the
+ device is enabled and the connector status is not
+ disconnected; writing zero bytes clears the EDID. Reading
+ returns up to PAGE_SIZE bytes of the stored EDID. The EDID
+ is only used to generate connector modes when edid_enabled
+ is set.
+
What: /sys/kernel/config/vkms/<device>/connectors/<connector>/possible_encoders
Date: Nov 2025
Contact: dri-devel@lists.freedesktop.org
diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst
index 11058b6e6250..2a3e175bf67b 100644
--- a/Documentation/gpu/vkms.rst
+++ b/Documentation/gpu/vkms.rst
@@ -137,7 +137,7 @@ Last but not least, create one or more connectors::
sudo mkdir /config/vkms/my-vkms/connectors/connector0
-Connectors have 3 configurable attribute:
+Connectors have 5 configurable attribute:
- status: Connection status: 1 connected, 2 disconnected, 3 unknown (same values
as those exposed by the "status" property of a connector)
@@ -146,6 +146,9 @@ Connectors have 3 configurable attribute:
If supported_colorspaces is not 0, the HDR_OUTPUT_METADATA will also be created.
Value is a bitfield, 0x1 = NO_DATA, 0x2 = SMPTE_170M_YCC... see enum drm_colorspace
for full list.
+- edid_enabled: Enable or not EDID for this connector. Some connectors may not have an
+ EDID but just a list of modes, this attribute allows to disable EDID property.
+- edid: Content of the EDID. Ignored if edid_enabled is not set
To finish the configuration, link the different pipeline items::
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index 7377d967be75..32ac4d7c4194 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -2,6 +2,7 @@
#include <linux/cleanup.h>
#include <linux/configfs.h>
#include <linux/mutex.h>
+#include <linux/rcupdate.h>
#include <linux/slab.h>
#include <linux/string.h>
@@ -1191,14 +1192,111 @@ static ssize_t connector_supported_colorspaces_store(struct config_item *item,
return count;
}
+static ssize_t connector_edid_enabled_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_connector *connector;
+ bool enabled;
+
+ connector = connector_item_to_vkms_configfs_connector(item);
+
+ scoped_guard(mutex, &connector->dev->config->lock)
+ enabled = vkms_config_connector_get_edid_enabled(connector->config);
+
+ return sprintf(page, "%d\n", enabled);
+}
+
+static ssize_t connector_edid_enabled_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_configfs_connector *connector;
+ struct vkms_config_connector *connector_cfg;
+ bool enabled;
+
+ connector = connector_item_to_vkms_configfs_connector(item);
+ connector_cfg = connector->config;
+
+ if (kstrtobool(page, &enabled))
+ return -EINVAL;
+
+ scoped_guard(mutex, &connector->dev->config->lock)
+ {
+ vkms_config_connector_set_edid_enabled(connector_cfg, enabled);
+
+ if (connector->dev->enabled &&
+ vkms_config_connector_get_status(connector_cfg) !=
+ connector_status_disconnected)
+ vkms_trigger_connector_hotplug(connector->dev->config->dev);
+ }
+ return count;
+}
+
+static ssize_t connector_edid_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_connector *connector;
+ ssize_t ret = 0;
+
+ connector = connector_item_to_vkms_configfs_connector(item);
+
+ scoped_guard(mutex, &connector->dev->config->lock)
+ {
+ int len = 0;
+ const u8 *edid;
+ size_t copy_len;
+
+ /*
+ * vkms_config_connector_get_edid() is an RCU reader; hold
+ * the read-side critical section while copying the data to
+ * the userspace page, like the debugfs reader does.
+ */
+ rcu_read_lock();
+ edid = vkms_config_connector_get_edid(connector->config, &len);
+ if (edid && len > 0) {
+ copy_len = min_t(size_t, (size_t)len, PAGE_SIZE);
+ memcpy(page, edid, copy_len);
+ ret = copy_len;
+ }
+ rcu_read_unlock();
+ }
+
+ return ret;
+}
+
+static ssize_t connector_edid_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_configfs_connector *connector;
+
+ connector = connector_item_to_vkms_configfs_connector(item);
+
+ scoped_guard(mutex, &connector->dev->config->lock)
+ {
+ int ret;
+
+ ret = vkms_config_connector_set_edid(connector->config, page, count);
+ if (ret)
+ return ret;
+
+ if (connector->dev->enabled &&
+ vkms_config_connector_get_status(connector->config) !=
+ connector_status_disconnected)
+ vkms_trigger_connector_hotplug(connector->dev->config->dev);
+ }
+
+ return count;
+}
+
CONFIGFS_ATTR(connector_, status);
CONFIGFS_ATTR(connector_, type);
CONFIGFS_ATTR(connector_, supported_colorspaces);
+CONFIGFS_ATTR(connector_, edid_enabled);
+CONFIGFS_ATTR(connector_, edid);
static struct configfs_attribute *connector_item_attrs[] = {
&connector_attr_status,
&connector_attr_type,
&connector_attr_supported_colorspaces,
+ &connector_attr_edid_enabled,
+ &connector_attr_edid,
NULL,
};
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 38/43] drm/vkms: Store the enabled/disabled status for connector
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (36 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 37/43] drm/vkms: Introduce configfs " Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 39/43] drm/connector: Add a way to detach encoders Louis Chauvet
` (4 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
In order to prepare for dynamic connector configuration, we need to store
if a connector is dynamic and if it is enabled.
The two new vkms_config_connector fields will help for that.
Co-developed-by: José Expósito <jose.exposito89@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
.clang-format | 2 +
drivers/gpu/drm/vkms/tests/vkms_config_test.c | 4 ++
drivers/gpu/drm/vkms/vkms_config.c | 6 +++
drivers/gpu/drm/vkms/vkms_config.h | 70 +++++++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_output.c | 2 +-
5 files changed, 83 insertions(+), 1 deletion(-)
diff --git a/.clang-format b/.clang-format
index 395292ab2ac6..ca8e16e39c15 100644
--- a/.clang-format
+++ b/.clang-format
@@ -726,6 +726,8 @@ ForEachMacros:
- 'v4l2_m2m_for_each_src_buf_safe'
- 'virtio_device_for_each_vq'
- 'vkms_config_for_each_connector'
+ - 'vkms_config_for_each_connector_static'
+ - 'vkms_config_for_each_connector_dynamic'
- 'vkms_config_for_each_crtc'
- 'vkms_config_for_each_encoder'
- 'vkms_config_for_each_plane'
diff --git a/drivers/gpu/drm/vkms/tests/vkms_config_test.c b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
index 8a13c45e1683..9d21ac527170 100644
--- a/drivers/gpu/drm/vkms/tests/vkms_config_test.c
+++ b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
@@ -220,6 +220,10 @@ static void vkms_config_test_default_config(struct kunit *test)
0);
KUNIT_EXPECT_EQ(test, vkms_config_connector_get_edid_enabled(connector_cfg),
false);
+ KUNIT_EXPECT_EQ(test, vkms_config_connector_is_enabled(connector_cfg),
+ true);
+ KUNIT_EXPECT_EQ(test, vkms_config_connector_is_dynamic(connector_cfg),
+ false);
}
KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index 173e88122bcb..2c6a53d6f778 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -681,6 +681,8 @@ static int vkms_config_show(struct seq_file *m, void *data)
vkms_config_for_each_connector(vkmsdev->config, connector_cfg) {
seq_puts(m, "connector:\n");
+ seq_printf(m, "\tenabled=%s\n",
+ str_enabled_disabled(vkms_config_connector_is_enabled(connector_cfg)));
seq_printf(m, "\tstatus=%s\n",
drm_get_connector_status_name(vkms_config_connector_get_status(connector_cfg)));
seq_printf(m, "\ttype=%s\n",
@@ -694,6 +696,8 @@ static int vkms_config_show(struct seq_file *m, void *data)
str_enabled_disabled(vkms_config_connector_get_edid_enabled(connector_cfg)),
edid_len
);
+ seq_printf(m, "\tdynamic=%s\n",
+ str_true_false(vkms_config_connector_is_dynamic(connector_cfg)));
}
}
@@ -1054,6 +1058,8 @@ struct vkms_config_connector *vkms_config_create_connector(struct vkms_config *c
connector_cfg->status = connector_status_connected;
vkms_config_connector_set_type(connector_cfg, DRM_MODE_CONNECTOR_VIRTUAL);
vkms_config_connector_set_supported_colorspaces(connector_cfg, 0);
+ vkms_config_connector_set_dynamic(connector_cfg, false);
+ vkms_config_connector_set_enabled(connector_cfg, true);
xa_init_flags(&connector_cfg->possible_encoders, XA_FLAGS_ALLOC);
/* refcnt starts at 1: this reference is owned by config->connectors */
kref_init(&connector_cfg->refcnt);
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index ef8de0316b94..e5352aaea85e 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -168,6 +168,8 @@ struct vkms_config_edid {
* @rcu: RCU head for deferred freeing of this object
* @type: Store the type of connector using DRM_MODE_CONNECTOR_* values
* @config: The vkms_config this connector belongs to
+ * @dynamic: Store if a connector should be created with drm_connector_dynamic_init
+ * @enabled: If @dynamic, this means that the connector is currently registered in drm
* @status: Status (connected, disconnected...) of the connector
* @supported_colorspaces: Bitmask of all the supported colorspaces. Values
* are the sames as ones accepted by
@@ -191,6 +193,8 @@ struct vkms_config_connector {
struct vkms_config *config;
int type;
+ bool enabled;
+ bool dynamic;
enum drm_connector_status status;
u32 supported_colorspaces;
bool edid_enabled;
@@ -244,6 +248,28 @@ struct vkms_config_connector {
lockdep_is_held(&(config)->lock) || \
!(config)->dev)
+/**
+ * vkms_config_for_each_connector_static - Iterate over the static vkms_config connectors
+ * @config: &struct vkms_config pointer
+ * @connector_cfg: &struct vkms_config_connector pointer used as cursor
+ */
+#define vkms_config_for_each_connector_static(config, connector_cfg) \
+ vkms_config_for_each_connector((config), (connector_cfg)) \
+ if ((connector_cfg)->dynamic) \
+ ; \
+ else
+
+/**
+ * vkms_config_for_each_connector_dynamic - Iterate over the dynamic vkms_config connectors
+ * @config: &struct vkms_config pointer
+ * @connector_cfg: &struct vkms_config_connector pointer used as cursor
+ */
+#define vkms_config_for_each_connector_dynamic(config, connector_cfg) \
+ vkms_config_for_each_connector((config), (connector_cfg)) \
+ if (!(connector_cfg)->dynamic) \
+ ; \
+ else
+
/**
* vkms_config_plane_for_each_possible_crtc - Iterate over the vkms_config_plane
* possible CRTCs
@@ -525,6 +551,50 @@ vkms_config_connector_set_type(struct vkms_config_connector *connector_cfg,
connector_cfg->type = type;
}
+/**
+ * vkms_config_connector_set_enabled() - If the connector is part of the device
+ * @connector_cfg: Target connector
+ * @enabled: Add or remove the connector
+ */
+static inline void
+vkms_config_connector_set_enabled(struct vkms_config_connector *connector_cfg,
+ bool enabled)
+{
+ connector_cfg->enabled = enabled;
+}
+
+/**
+ * vkms_config_connector_is_enabled() - If the connector is part of the device
+ * @connector_cfg: The connector
+ */
+static inline bool
+vkms_config_connector_is_enabled(const struct vkms_config_connector *connector_cfg)
+{
+ return connector_cfg->enabled;
+}
+
+/**
+ * vkms_config_connector_set_dynamic() - If the connector is dynamic
+ * @connector_cfg: Target connector
+ * @dynamic: Enable or disable the dynamic status
+ */
+static inline void
+vkms_config_connector_set_dynamic(struct vkms_config_connector *connector_cfg,
+ bool dynamic)
+{
+ connector_cfg->dynamic = dynamic;
+}
+
+/**
+ * vkms_config_connector_is_dynamic() - If the connector is dynamic
+ * @connector_cfg: The connector
+ */
+static inline bool
+vkms_config_connector_is_dynamic(const struct vkms_config_connector *connector_cfg)
+{
+ return connector_cfg->dynamic;
+}
+
/*
* vkms_config_plane_get_default_rotation() - Get the default rotation for a plane
* @plane_cfg: Plane to get the default rotation from
diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c
index 2b0f7a8a80b5..fb30cffc10ef 100644
--- a/drivers/gpu/drm/vkms/vkms_output.c
+++ b/drivers/gpu/drm/vkms/vkms_output.c
@@ -93,7 +93,7 @@ int vkms_output_init(struct vkms_device *vkmsdev)
}
}
- vkms_config_for_each_connector(vkmsdev->config, connector_cfg) {
+ vkms_config_for_each_connector_static(vkmsdev->config, connector_cfg) {
struct vkms_config_encoder *possible_encoder;
unsigned long idx = 0;
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 39/43] drm/connector: Add a way to detach encoders
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (37 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 38/43] drm/vkms: Store the enabled/disabled status for connector Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 40/43] drm/vkms: Allow to hot-add connectors Louis Chauvet
` (3 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
As vkms can fully configure dynamic connectors at runtime, add a clean way
to detach encoder from a connector.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/drm_connector.c | 17 +++++++++++++++++
include/drm/drm_connector.h | 2 ++
2 files changed, 19 insertions(+)
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index e604d9ea3058..8704df140f2f 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -837,6 +837,23 @@ int drm_connector_attach_encoder(struct drm_connector *connector,
}
EXPORT_SYMBOL(drm_connector_attach_encoder);
+/**
+ * drm_connector_detach_encoder - detach an encoder from a connector
+ * @connector: connector to detach
+ * @encoder: encoder to detach @connector from
+ *
+ * Returns:
+ * Zero on success, negative errno on failure.
+ */
+int drm_connector_detach_encoder(struct drm_connector *connector,
+ struct drm_encoder *encoder)
+{
+ connector->possible_encoders &= ~drm_encoder_mask(encoder);
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_connector_detach_encoder);
+
/**
* drm_connector_has_possible_encoder - check if the connector and encoder are
* associated with each other
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 07218ab26c9e..532ec08d0017 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -2758,6 +2758,8 @@ int drm_connector_dynamic_register(struct drm_connector *connector);
void drm_connector_unregister(struct drm_connector *connector);
int drm_connector_attach_encoder(struct drm_connector *connector,
struct drm_encoder *encoder);
+int drm_connector_detach_encoder(struct drm_connector *connector,
+ struct drm_encoder *encoder);
void drm_connector_cleanup(struct drm_connector *connector);
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 40/43] drm/vkms: Allow to hot-add connectors
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (38 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 39/43] drm/connector: Add a way to detach encoders Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 41/43] drm/vkms: Introduce configfs for dynamic connector creation Louis Chauvet
` (2 subsequent siblings)
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
In order to allow creating dynamic connectors, add the required
infrastructure in vkms_connector.
A dynamic connector creates its own initial atomic state before being
registered. The hot-add and hot-remove paths are serialized with
mode_config.mutex, which drm_mode_getconnector() holds for the whole
duration of a probe, so probes never observe intermediate states.
Hot-remove only detaches the cfg->connector back-pointer, keeping the
configuration reference until the connector is destroyed, and
vkms_connector_dynamic_destroy() releases it. Attaching an encoder at
runtime (vkms_connector_hot_attach_encoder()) only updates the
connector's possible_encoders mask.
Co-developed-by: José Expósito <jose.exposito89@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/vkms_configfs.c | 5 ++
drivers/gpu/drm/vkms/vkms_connector.c | 138 ++++++++++++++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_connector.h | 40 ++++++++++
drivers/gpu/drm/vkms/vkms_output.c | 15 +++-
4 files changed, 197 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index 32ac4d7c4194..1822978879ff 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -1358,6 +1358,11 @@ static void connector_possible_encoders_drop_link(struct config_item *src,
encoder = encoder_item_to_vkms_configfs_encoder(target);
scoped_guard(mutex, &connector->dev->config->lock) {
+ if (connector->dev->enabled && connector->config->dynamic &&
+ connector->config->enabled && connector->config->connector)
+ vkms_connector_hot_detach_encoder(connector->config->connector,
+ encoder->config->encoder);
+
vkms_config_connector_detach_encoder(connector->config,
encoder->config);
}
diff --git a/drivers/gpu/drm/vkms/vkms_connector.c b/drivers/gpu/drm/vkms/vkms_connector.c
index 71a0ae15be65..93bceba0a1ae 100644
--- a/drivers/gpu/drm/vkms/vkms_connector.c
+++ b/drivers/gpu/drm/vkms/vkms_connector.c
@@ -149,6 +149,7 @@ static int __must_check vkms_connector_init(struct vkms_connector *connector,
if (ret) {
drm_property_destroy(connector->base.dev,
connector->base.colorspace_property);
+ connector->base.colorspace_property = NULL;
return ret;
}
drm_connector_attach_hdr_output_metadata_property(&connector->base);
@@ -197,9 +198,146 @@ struct vkms_connector *vkms_connector_init_static(struct vkms_device *vkmsdev,
return connector;
}
+static void vkms_connector_dynamic_destroy(struct drm_connector *connector)
+{
+ struct vkms_connector *vkms_connector = drm_connector_to_vkms_connector(connector);
+
+ if (connector->colorspace_property) {
+ drm_property_destroy(connector->dev,
+ connector->colorspace_property);
+ connector->colorspace_property = NULL;
+ }
+
+ drm_connector_cleanup(connector);
+
+ if (vkms_connector->cfg)
+ vkms_config_connector_put(vkms_connector->cfg);
+ kfree(vkms_connector);
+}
+
+static const struct drm_connector_funcs vkms_dynamic_connector_funcs = {
+ .fill_modes = drm_helper_probe_single_connector_modes,
+ .atomic_create_state = drm_atomic_helper_connector_create_state,
+ .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+ .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
+ .destroy = vkms_connector_dynamic_destroy,
+ .detect = vkms_connector_detect,
+};
+
void vkms_trigger_connector_hotplug(struct vkms_device *vkmsdev)
{
struct drm_device *dev = &vkmsdev->drm;
drm_kms_helper_hotplug_event(dev);
}
+
+struct vkms_connector *vkms_connector_hot_add(struct vkms_device *vkmsdev,
+ struct vkms_config_connector *connector_cfg)
+{
+ struct vkms_config_encoder *encoder_cfg;
+ struct vkms_connector *connector = NULL;
+ struct drm_connector_state *conn_state;
+ int ret;
+ unsigned long idx = 0;
+
+ connector = kzalloc_obj(*connector, GFP_KERNEL);
+ if (!connector)
+ return ERR_PTR(-ENOMEM);
+
+ ret = drm_connector_dynamic_init(&vkmsdev->drm,
+ &connector->base,
+ &vkms_dynamic_connector_funcs,
+ connector_cfg->type,
+ NULL);
+ if (ret) {
+ kfree(connector);
+ return ERR_PTR(ret);
+ }
+
+ drm_connector_helper_add(&connector->base, &vkms_conn_helper_funcs);
+
+ vkms_config_connector_for_each_possible_encoder(connector_cfg, idx, encoder_cfg) {
+ ret = drm_connector_attach_encoder(&connector->base,
+ encoder_cfg->encoder);
+ if (ret) {
+ drm_connector_put(&connector->base);
+ return ERR_PTR(ret);
+ }
+ }
+
+ conn_state = drm_atomic_helper_connector_create_state(&connector->base);
+ if (IS_ERR(conn_state)) {
+ drm_connector_put(&connector->base);
+ return ERR_CAST(conn_state);
+ }
+ connector->base.state = conn_state;
+
+ ret = vkms_connector_init(connector, connector_cfg);
+ if (ret) {
+ drm_connector_put(&connector->base);
+ return ERR_PTR(ret);
+ }
+
+ /*
+ * Attach the configuration before registration and serialize the
+ * registration with in-flight probes: drm_mode_getconnector() holds
+ * dev->mode_config.mutex for the whole duration of the probe and the
+ * detect()/get_modes() callbacks read connector->cfg. Registering
+ * under the same mutex prevents a probe from observing the new
+ * connector before it is fully set up.
+ */
+ vkms_config_connector_get(connector_cfg);
+ connector->cfg = connector_cfg;
+
+ mutex_lock(&connector->base.dev->mode_config.mutex);
+ ret = drm_connector_dynamic_register(&connector->base);
+ mutex_unlock(&connector->base.dev->mode_config.mutex);
+
+ if (ret) {
+ drm_connector_put(&connector->base);
+ return ERR_PTR(ret);
+ }
+
+ return connector;
+}
+
+void vkms_connector_hot_remove(struct vkms_connector *connector)
+{
+ /*
+ * Userspace probes are serialized by mode_config.mutex:
+ * drm_mode_getconnector() holds it for the whole duration of the
+ * probe and the detect()/get_modes() callbacks read the connector
+ * state, including connector->cfg. Take the same mutex here so the
+ * unregistration and the config detachment are not visible in the
+ * middle of an in-flight probe.
+ */
+ mutex_lock(&connector->base.dev->mode_config.mutex);
+
+ drm_connector_unregister(&connector->base);
+
+ /*
+ * Only detach the config from the connector: in-flight userspace
+ * probes may still be reading connector->cfg (see vkms_connector_detect()
+ * and vkms_conn_get_modes()), so the reference taken in
+ * vkms_connector_hot_add() must be kept until the connector is
+ * finally destroyed. vkms_connector_dynamic_destroy() releases it.
+ */
+ if (connector->cfg)
+ connector->cfg->connector = NULL;
+
+ mutex_unlock(&connector->base.dev->mode_config.mutex);
+
+ drm_connector_put(&connector->base);
+}
+
+int vkms_connector_hot_attach_encoder(struct vkms_connector *connector,
+ struct drm_encoder *encoder)
+{
+ return drm_connector_attach_encoder(&connector->base, encoder);
+}
+
+int vkms_connector_hot_detach_encoder(struct vkms_connector *connector,
+ struct drm_encoder *encoder)
+{
+ return drm_connector_detach_encoder(&connector->base, encoder);
+}
diff --git a/drivers/gpu/drm/vkms/vkms_connector.h b/drivers/gpu/drm/vkms/vkms_connector.h
index 61a8dd55d7f7..83b5b32b42de 100644
--- a/drivers/gpu/drm/vkms/vkms_connector.h
+++ b/drivers/gpu/drm/vkms/vkms_connector.h
@@ -39,4 +39,44 @@ struct vkms_connector *vkms_connector_init_static(struct vkms_device *vkmsdev,
*/
void vkms_trigger_connector_hotplug(struct vkms_device *vkmsdev);
+/**
+ * vkms_connector_hot_add() - Create a connector after the device is created
+ * @vkmsdev: Device to hot-add the connector to
+ * @connector_cfg: Connector's configuration
+ *
+ * Returns:
+ * A pointer to the newly created connector or a PTR_ERR on failure.
+ */
+struct vkms_connector *vkms_connector_hot_add(struct vkms_device *vkmsdev,
+ struct vkms_config_connector *connector_cfg);
+
+/**
+ * vkms_connector_hot_remove() - Remove a connector after a device is created
+ * @connector: The connector to hot-remove
+ */
+void vkms_connector_hot_remove(struct vkms_connector *connector);
+
+/**
+ * vkms_connector_hot_attach_encoder() - Attach a connector to a encoder after
+ * the device is created.
+ * @connector: Connector to attach to @encoder
+ * @encoder: Target encoder
+ *
+ * Returns:
+ * 0 on success or an error on failure.
+ */
+int vkms_connector_hot_attach_encoder(struct vkms_connector *connector,
+ struct drm_encoder *encoder);
+
+/**
+ * vkms_connector_hot_detach_encoder() - Detach an encoder from a connector
+ * after the device is created.
+ * @connector: Connector to detach from @encoder
+ * @encoder: Target encoder
+ *
+ * Returns: 0 on success, negative errno on failure.
+ */
+int vkms_connector_hot_detach_encoder(struct vkms_connector *connector,
+ struct drm_encoder *encoder);
+
#endif /* _VKMS_CONNECTOR_H_ */
diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c
index fb30cffc10ef..b100ed0c91e6 100644
--- a/drivers/gpu/drm/vkms/vkms_output.c
+++ b/drivers/gpu/drm/vkms/vkms_output.c
@@ -115,5 +115,18 @@ int vkms_output_init(struct vkms_device *vkmsdev)
}
}
- return drm_mode_config_create_initial_state(dev);
+ ret = drm_mode_config_create_initial_state(dev);
+ if (ret)
+ return ret;
+
+ vkms_config_for_each_connector_dynamic(vkmsdev->config, connector_cfg) {
+ if (connector_cfg->enabled) {
+ connector_cfg->connector = vkms_connector_hot_add(vkmsdev, connector_cfg);
+
+ if (IS_ERR(connector_cfg->connector))
+ return PTR_ERR(connector_cfg->connector);
+ }
+ }
+
+ return 0;
}
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 41/43] drm/vkms: Introduce configfs for dynamic connector creation
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (39 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 40/43] drm/vkms: Allow to hot-add connectors Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 42/43] drm/vkms: Add connector parent configuration in vkms_config Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 43/43] drm/vkms: Add ConfigFS interface for connector parent and port_id Louis Chauvet
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
DRM allows the connector to be created after the device. To allow
emulating this, add two configfs attributes to the connector.
Using the dynamic attribute you can set if a connector will be dynamic or
not.
Using the enabled attribute, you can set at runtime if a dynamic connector
is present or not.
Co-developed-by: José Expósito <jose.exposito89@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
Documentation/ABI/testing/configfs-vkms | 40 +++++++--
Documentation/gpu/vkms.rst | 6 +-
drivers/gpu/drm/vkms/vkms_configfs.c | 143 ++++++++++++++++++++++++++++++--
3 files changed, 173 insertions(+), 16 deletions(-)
diff --git a/Documentation/ABI/testing/configfs-vkms b/Documentation/ABI/testing/configfs-vkms
index 11b4435a3562..f59533e6f80e 100644
--- a/Documentation/ABI/testing/configfs-vkms
+++ b/Documentation/ABI/testing/configfs-vkms
@@ -26,7 +26,10 @@ Date: Nov 2025
Contact: dri-devel@lists.freedesktop.org
Description:
This group contains attributes corresponding to the
- connector <connector> of the VKMS device <device>.
+ connector <connector> of the VKMS device <device>. If the
+ directory is created while the device is enabled, the new
+ connector is automatically marked dynamic and disabled,
+ ready to be hot-added through the enabled attribute.
What: /sys/kernel/config/vkms/<device>/connectors/<connector>/status
Date: Nov 2025
@@ -35,7 +38,7 @@ Description:
Connection status of the connector. Possible values:
1 - connected, 2 - disconnected, 3 - unknown. Changing
the status triggers a connector hotplug if the device is
- enabled.
+ enabled and the connector is enabled.
What: /sys/kernel/config/vkms/<device>/connectors/<connector>/type
Date: Nov 2025
@@ -48,7 +51,6 @@ Description:
USB. Writing fails with -EBUSY if the device is enabled and the
connector is enabled.
-
What: /sys/kernel/config/vkms/<device>/connectors/<connector>/supported_colorspaces
Date: Nov 2025
Contact: dri-devel@lists.freedesktop.org
@@ -57,8 +59,10 @@ Description:
Value is a decimal number, where bit 0 = NO_DATA,
bit 1 = SMPTE_170M_YCC, etc. Bits beyond
DRM_MODE_COLORIMETRY_COUNT are rejected. Writing fails
- with -EBUSY if the device is enabled. See enum
- drm_colorspace for the full list.
+ with -EBUSY if the device is enabled and the connector is
+ enabled; a dynamic connector disabled with enabled=0
+ remains writable. See enum drm_colorspace for the full
+ list.
What: /sys/kernel/config/vkms/<device>/connectors/<connector>/edid_enabled
Date: Nov 2025
@@ -81,12 +85,36 @@ Description:
is only used to generate connector modes when edid_enabled
is set.
+What: /sys/kernel/config/vkms/<device>/connectors/<connector>/dynamic
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Set to 1 to create a dynamic connector (emulates DP MST).
+ Value: 1 - dynamic, 0 - static. Cannot be changed while
+ the device is enabled (-EBUSY).
+
+What: /sys/kernel/config/vkms/<device>/connectors/<connector>/enabled
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ For dynamic connectors, set to 1 to create the connector,
+ 0 to remove it. Value: 1 - enabled, 0 - disabled. While
+ the device is enabled, only dynamic connectors can be
+ changed (-EBUSY for static connectors), enabling validates
+ the whole device configuration (-EINVAL if invalid), and
+ toggling actually creates or removes the connector. While
+ the device is disabled, the value is only stored and takes
+ effect when the device is enabled.
+
What: /sys/kernel/config/vkms/<device>/connectors/<connector>/possible_encoders
Date: Nov 2025
Contact: dri-devel@lists.freedesktop.org
Description:
This group contains symbolic links to possible encoders
- for this connector.
+ for this connector. While the device is enabled and the
+ connector is enabled, linking an encoder into a dynamic
+ connector attaches it immediately, and linking into a
+ static connector fails with -EBUSY.
What: /sys/kernel/config/vkms/<device>/crtcs
Date: Nov 2025
diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst
index 2a3e175bf67b..31569421d8f5 100644
--- a/Documentation/gpu/vkms.rst
+++ b/Documentation/gpu/vkms.rst
@@ -137,7 +137,7 @@ Last but not least, create one or more connectors::
sudo mkdir /config/vkms/my-vkms/connectors/connector0
-Connectors have 5 configurable attribute:
+Connectors have 7 configurable attribute:
- status: Connection status: 1 connected, 2 disconnected, 3 unknown (same values
as those exposed by the "status" property of a connector)
@@ -149,7 +149,9 @@ Connectors have 5 configurable attribute:
- edid_enabled: Enable or not EDID for this connector. Some connectors may not have an
EDID but just a list of modes, this attribute allows to disable EDID property.
- edid: Content of the EDID. Ignored if edid_enabled is not set
-
+- dynamic: Set to 1 while configuring the device to create a dynamic connector. A dynamic
+ connector can be used to emulate DP MST connectors.
+- enabled: For dynamic connector, set it to 1 to create the connector, 0 to remove it.
To finish the configuration, link the different pipeline items::
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index 1822978879ff..0681722e98e8 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -1065,6 +1065,12 @@ static ssize_t connector_status_show(struct config_item *item, char *page)
return sprintf(page, "%u\n", status);
}
+static bool connector_is_enabled(struct vkms_config_connector *connector_cfg)
+{
+ return !connector_cfg->dynamic ||
+ (connector_cfg->dynamic && connector_cfg->enabled);
+}
+
static ssize_t connector_status_store(struct config_item *item,
const char *page, size_t count)
{
@@ -1084,7 +1090,7 @@ static ssize_t connector_status_store(struct config_item *item,
scoped_guard(mutex, &connector->dev->config->lock) {
vkms_config_connector_set_status(connector->config, status);
- if (connector->dev->enabled)
+ if (connector->dev->enabled && connector_is_enabled(connector->config))
vkms_trigger_connector_hotplug(connector->dev->config->dev);
}
@@ -1145,7 +1151,7 @@ static ssize_t connector_type_store(struct config_item *item,
}
scoped_guard(mutex, &connector->dev->config->lock) {
- if (connector->dev->enabled)
+ if (connector->dev->enabled && connector_is_enabled(connector->config))
return -EBUSY;
vkms_config_connector_set_type(connector->config, val);
@@ -1183,7 +1189,7 @@ static ssize_t connector_supported_colorspaces_store(struct config_item *item,
return -EINVAL;
scoped_guard(mutex, &connector->dev->config->lock) {
- if (connector->dev->enabled)
+ if (connector->dev->enabled && connector_is_enabled(connector->config))
return -EBUSY;
vkms_config_connector_set_supported_colorspaces(connector->config, val);
@@ -1281,6 +1287,106 @@ static ssize_t connector_edid_store(struct config_item *item,
connector_status_disconnected)
vkms_trigger_connector_hotplug(connector->dev->config->dev);
}
+ return count;
+}
+
+static ssize_t connector_enabled_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_connector *connector;
+ bool enabled;
+
+ connector = connector_item_to_vkms_configfs_connector(item);
+
+ scoped_guard(mutex, &connector->dev->config->lock)
+ enabled = vkms_config_connector_is_enabled(connector->config);
+
+ return sprintf(page, "%d\n", enabled);
+}
+
+static ssize_t connector_enabled_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_configfs_connector *connector;
+ struct vkms_config_connector *connector_cfg;
+ bool enabled, was_enabled;
+
+ connector = connector_item_to_vkms_configfs_connector(item);
+ connector_cfg = connector->config;
+
+ if (kstrtobool(page, &enabled))
+ return -EINVAL;
+ scoped_guard(mutex, &connector->dev->config->lock) {
+ if (!connector->dev->enabled) {
+ vkms_config_connector_set_enabled(connector_cfg, enabled);
+ } else {
+ // Only dynamic connector can be enabled/disabled at runtime
+ if (!connector_cfg->dynamic)
+ return -EBUSY;
+
+ was_enabled = vkms_config_connector_is_enabled(connector_cfg);
+ vkms_config_connector_set_enabled(connector_cfg, enabled);
+
+ // Resulting configuration is invalid (missing encoder for example)
+ // Early return to avoid drm core issue
+ if (!vkms_config_is_valid(connector->dev->config)) {
+ vkms_config_connector_set_enabled(connector_cfg,
+ was_enabled);
+ return -EINVAL;
+ }
+
+ if (!was_enabled && enabled) {
+ struct vkms_connector *conn;
+
+ // Adding the connector
+ conn = vkms_connector_hot_add(connector->dev->config->dev,
+ connector_cfg);
+ if (IS_ERR(conn)) {
+ vkms_config_connector_set_enabled(connector_cfg, was_enabled);
+ return PTR_ERR(conn);
+ }
+ connector_cfg->connector = conn;
+ } else if (was_enabled && !enabled) {
+ vkms_connector_hot_remove(connector_cfg->connector);
+ }
+ }
+ }
+ return count;
+}
+
+static ssize_t connector_dynamic_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_connector *connector;
+ bool enabled;
+
+ connector = connector_item_to_vkms_configfs_connector(item);
+
+ scoped_guard(mutex, &connector->dev->config->lock) {
+ enabled = vkms_config_connector_is_dynamic(connector->config);
+ }
+
+ return sprintf(page, "%d\n", enabled);
+}
+
+static ssize_t connector_dynamic_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_configfs_connector *connector;
+ struct vkms_config_connector *connector_cfg;
+ bool dynamic;
+
+ connector = connector_item_to_vkms_configfs_connector(item);
+ connector_cfg = connector->config;
+
+ if (kstrtobool(page, &dynamic))
+ return -EINVAL;
+
+ scoped_guard(mutex, &connector->dev->config->lock) {
+ // Can't change the dynamic status when the device is activated
+ if (connector->dev->enabled)
+ return -EBUSY;
+
+ vkms_config_connector_set_dynamic(connector_cfg, dynamic);
+ }
return count;
}
@@ -1290,6 +1396,8 @@ CONFIGFS_ATTR(connector_, type);
CONFIGFS_ATTR(connector_, supported_colorspaces);
CONFIGFS_ATTR(connector_, edid_enabled);
CONFIGFS_ATTR(connector_, edid);
+CONFIGFS_ATTR(connector_, dynamic);
+CONFIGFS_ATTR(connector_, enabled);
static struct configfs_attribute *connector_item_attrs[] = {
&connector_attr_status,
@@ -1297,19 +1405,27 @@ static struct configfs_attribute *connector_item_attrs[] = {
&connector_attr_supported_colorspaces,
&connector_attr_edid_enabled,
&connector_attr_edid,
+ &connector_attr_dynamic,
+ &connector_attr_enabled,
NULL,
};
static void connector_release(struct config_item *item)
{
struct vkms_configfs_connector *connector;
+ struct vkms_config_connector *connector_cfg;
struct mutex *lock;
connector = connector_item_to_vkms_configfs_connector(item);
+ connector_cfg = connector->config;
lock = &connector->dev->config->lock;
scoped_guard(mutex, lock) {
+ if (connector->dev->enabled && connector_cfg->dynamic && connector_cfg->enabled)
+ vkms_connector_hot_remove(connector_cfg->connector);
+
vkms_config_destroy_connector(connector->config);
+
kfree(connector);
}
}
@@ -1328,6 +1444,7 @@ static int connector_possible_encoders_allow_link(struct config_item *src,
struct config_item *target)
{
struct vkms_configfs_connector *connector;
+ struct vkms_config_connector *connector_cfg;
struct vkms_configfs_encoder *encoder;
int ret;
@@ -1335,14 +1452,24 @@ static int connector_possible_encoders_allow_link(struct config_item *src,
return -EINVAL;
connector = connector_possible_encoders_item_to_vkms_configfs_connector(src);
+ connector_cfg = connector->config;
encoder = encoder_item_to_vkms_configfs_encoder(target);
scoped_guard(mutex, &connector->dev->config->lock) {
- if (connector->dev->enabled)
- return -EBUSY;
+ if (connector->dev->enabled && connector_cfg->enabled) {
+ if (!connector_cfg->dynamic)
+ return -EBUSY;
+
+ ret = vkms_connector_hot_attach_encoder(connector->config->connector,
+ encoder->config->encoder);
+ if (ret)
+ return ret;
+ }
ret = vkms_config_connector_attach_encoder(connector->config,
encoder->config);
+ if (ret)
+ return ret;
}
return ret;
@@ -1388,9 +1515,6 @@ static struct config_group *make_connector_group(struct config_group *group,
dev = child_group_to_vkms_configfs_device(group);
scoped_guard(mutex, &dev->config->lock) {
- if (dev->enabled)
- return ERR_PTR(-EBUSY);
-
connector = kzalloc_obj(*connector);
if (!connector)
return ERR_PTR(-ENOMEM);
@@ -1404,6 +1528,9 @@ static struct config_group *make_connector_group(struct config_group *group,
return ERR_PTR(ret);
}
+ vkms_config_connector_set_dynamic(connector->config, connector->dev->enabled);
+ vkms_config_connector_set_enabled(connector->config, !connector->dev->enabled);
+
config_group_init_type_name(&connector->group, name,
&connector_item_type);
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 42/43] drm/vkms: Add connector parent configuration in vkms_config
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (40 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 41/43] drm/vkms: Introduce configfs for dynamic connector creation Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 43/43] drm/vkms: Add ConfigFS interface for connector parent and port_id Louis Chauvet
42 siblings, 0 replies; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
In order to fully emulate MST connector from the userspace point of view,
add a way to configure the PATH property.
Add two things:
- port_id, to configure the MST port id (used to generate the last
-<port-id> in the PATH property)
- parent, to configure the parent connector (used to
generate <connector-id>- or -<port-id>- in the PATH property)
In order to properly populate the PATH property, it should be done after
all the connector initialization to ensure that the <connector-id> is
known.
Attaching a parent takes a reference on it; a destroyed parent stays
allocated while its children hold that reference, and
vkms_config_connector_get_parent() then reports NULL for it.
vkms_config_destroy_connector() detaches the connector from its own
parent and drops the initial reference; each release drops the
reference its children took on it, and the parent release chains
from there.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/tests/vkms_config_test.c | 269 ++++++++++++++++++++++-
drivers/gpu/drm/vkms/tests/vkms_lifecycle_test.c | 2 +-
drivers/gpu/drm/vkms/vkms_config.c | 94 +++++++-
drivers/gpu/drm/vkms/vkms_config.h | 72 +++++-
drivers/gpu/drm/vkms/vkms_configfs.c | 2 +-
drivers/gpu/drm/vkms/vkms_connector.c | 90 +++++++-
drivers/gpu/drm/vkms/vkms_connector.h | 9 +
drivers/gpu/drm/vkms/vkms_output.c | 2 +
8 files changed, 525 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/vkms/tests/vkms_config_test.c b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
index 9d21ac527170..0080dd5b5d35 100644
--- a/drivers/gpu/drm/vkms/tests/vkms_config_test.c
+++ b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
@@ -396,7 +396,7 @@ static void vkms_config_test_get_connectors(struct kunit *test)
KUNIT_ASSERT_EQ(test, n_connectors, 2);
n_connectors = 0;
- vkms_config_destroy_connector(connector_cfg2);
+ vkms_config_destroy_connector(config, connector_cfg2);
vkms_config_for_each_connector(config, connector_cfg) {
n_connectors++;
if (connector_cfg != connector_cfg1)
@@ -852,7 +852,7 @@ static void vkms_config_test_invalid_connector_number(struct kunit *test)
/* Invalid: No connectors */
connector_cfg = get_first_connector(config);
- vkms_config_destroy_connector(connector_cfg);
+ vkms_config_destroy_connector(config, connector_cfg);
KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
/* Invalid: Too many connectors */
@@ -1240,6 +1240,267 @@ static void vkms_config_test_connector_status(struct kunit *test)
vkms_config_destroy(config);
}
+static void vkms_config_test_connector_dynamic_status(struct kunit *test)
+{
+ struct vkms_config *config;
+ struct vkms_config_connector *connector_cfg;
+ struct vkms_config_encoder *encoder_cfg;
+ struct vkms_config_crtc *crtc_cfg;
+ struct vkms_config_plane *plane_cfg;
+ enum drm_connector_status status;
+ int err;
+
+ config = vkms_config_create("test");
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+
+ /* Create a complete pipeline */
+ crtc_cfg = vkms_config_create_crtc(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc_cfg);
+
+ encoder_cfg = vkms_config_create_encoder(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, encoder_cfg);
+
+ connector_cfg = vkms_config_create_connector(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, connector_cfg);
+
+ plane_cfg = vkms_config_create_plane(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, plane_cfg);
+
+ vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_PRIMARY);
+ err = vkms_config_plane_attach_crtc(plane_cfg, crtc_cfg);
+ KUNIT_EXPECT_EQ(test, err, 0);
+
+ err = vkms_config_encoder_attach_crtc(encoder_cfg, crtc_cfg);
+ KUNIT_EXPECT_EQ(test, err, 0);
+
+ err = vkms_config_connector_attach_encoder(connector_cfg, encoder_cfg);
+ KUNIT_EXPECT_EQ(test, err, 0);
+
+ /* Test dynamic status changes */
+ status = vkms_config_connector_get_status(connector_cfg);
+ KUNIT_EXPECT_EQ(test, status, connector_status_connected);
+
+ vkms_config_connector_set_status(connector_cfg, connector_status_disconnected);
+ status = vkms_config_connector_get_status(connector_cfg);
+ KUNIT_EXPECT_EQ(test, status, connector_status_disconnected);
+
+ /* Configuration should still be valid regardless of connector status */
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ vkms_config_connector_set_status(connector_cfg, connector_status_connected);
+ status = vkms_config_connector_get_status(connector_cfg);
+ KUNIT_EXPECT_EQ(test, status, connector_status_connected);
+
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Test with unknown status */
+ vkms_config_connector_set_status(connector_cfg, connector_status_unknown);
+ status = vkms_config_connector_get_status(connector_cfg);
+ KUNIT_EXPECT_EQ(test, status, connector_status_unknown);
+
+ /* Configuration should still be valid */
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ vkms_config_destroy(config);
+}
+
+static void vkms_config_test_dynamic_connector_validity(struct kunit *test)
+{
+ struct vkms_config *config;
+ struct vkms_config_connector *connector_cfg1, *connector_cfg2;
+ struct vkms_config_encoder *encoder_cfg;
+ struct vkms_config_crtc *crtc_cfg;
+ struct vkms_config_plane *plane_cfg;
+ int err;
+
+ config = vkms_config_create("test");
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+
+ /* Create a complete pipeline */
+ crtc_cfg = vkms_config_create_crtc(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc_cfg);
+
+ encoder_cfg = vkms_config_create_encoder(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, encoder_cfg);
+
+ connector_cfg1 = vkms_config_create_connector(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, connector_cfg1);
+
+ plane_cfg = vkms_config_create_plane(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, plane_cfg);
+
+ vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_PRIMARY);
+ err = vkms_config_plane_attach_crtc(plane_cfg, crtc_cfg);
+ KUNIT_EXPECT_EQ(test, err, 0);
+
+ err = vkms_config_encoder_attach_crtc(encoder_cfg, crtc_cfg);
+ KUNIT_EXPECT_EQ(test, err, 0);
+
+ err = vkms_config_connector_attach_encoder(connector_cfg1, encoder_cfg);
+ KUNIT_EXPECT_EQ(test, err, 0);
+
+ /* Valid: Non-dynamic connector */
+ vkms_config_connector_set_dynamic(connector_cfg1, false);
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Valid: Dynamic connector */
+ vkms_config_connector_set_dynamic(connector_cfg1, true);
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Valid: Multiple dynamic connectors */
+ connector_cfg2 = vkms_config_create_connector(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, connector_cfg2);
+ vkms_config_connector_set_dynamic(connector_cfg2, true);
+ err = vkms_config_connector_attach_encoder(connector_cfg2, encoder_cfg);
+ KUNIT_EXPECT_EQ(test, err, 0);
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ vkms_config_destroy(config);
+}
+
+static void vkms_config_test_dynamic_connector_parent_validity(struct kunit *test)
+{
+ struct vkms_config *config;
+ struct vkms_config_connector *connector_cfg1, *connector_cfg2, *connector_cfg3;
+ struct vkms_config_encoder *encoder_cfg;
+ struct vkms_config_crtc *crtc_cfg;
+ struct vkms_config_plane *plane_cfg;
+ int err;
+
+ config = vkms_config_create("test");
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+
+ /* Create a complete pipeline */
+ crtc_cfg = vkms_config_create_crtc(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc_cfg);
+
+ encoder_cfg = vkms_config_create_encoder(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, encoder_cfg);
+
+ connector_cfg1 = vkms_config_create_connector(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, connector_cfg1);
+
+ plane_cfg = vkms_config_create_plane(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, plane_cfg);
+
+ vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_PRIMARY);
+ err = vkms_config_plane_attach_crtc(plane_cfg, crtc_cfg);
+ KUNIT_EXPECT_EQ(test, err, 0);
+
+ err = vkms_config_encoder_attach_crtc(encoder_cfg, crtc_cfg);
+ KUNIT_EXPECT_EQ(test, err, 0);
+
+ err = vkms_config_connector_attach_encoder(connector_cfg1, encoder_cfg);
+ KUNIT_EXPECT_EQ(test, err, 0);
+
+ /* Valid: Non-dynamic connector with no parent */
+ vkms_config_connector_set_dynamic(connector_cfg1, false);
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Valid: Dynamic connector with no parent */
+ vkms_config_connector_set_dynamic(connector_cfg1, true);
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Valid: Dynamic connector with dynamic parent */
+ connector_cfg2 = vkms_config_create_connector(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, connector_cfg2);
+ vkms_config_connector_set_dynamic(connector_cfg2, true);
+ err = vkms_config_connector_attach_encoder(connector_cfg2, encoder_cfg);
+ KUNIT_EXPECT_EQ(test, err, 0);
+ vkms_config_connector_attach_parent(connector_cfg2, connector_cfg1);
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Valid: Dynamic connector with non-dynamic parent */
+ vkms_config_connector_set_dynamic(connector_cfg1, false);
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Valid: Non-dynamic connector with no parent */
+ vkms_config_connector_attach_parent(connector_cfg2, NULL);
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Valid: Multiple levels of dynamic parent-child relationships */
+ vkms_config_connector_set_dynamic(connector_cfg1, true);
+ vkms_config_connector_attach_parent(connector_cfg2, connector_cfg1);
+ connector_cfg3 = vkms_config_create_connector(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, connector_cfg3);
+ vkms_config_connector_set_dynamic(connector_cfg3, true);
+ err = vkms_config_connector_attach_encoder(connector_cfg3, encoder_cfg);
+ KUNIT_EXPECT_EQ(test, err, 0);
+ vkms_config_connector_attach_parent(connector_cfg3, connector_cfg2);
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ vkms_config_destroy(config);
+}
+
+static void vkms_config_test_dynamic_connector_parent_loop(struct kunit *test)
+{
+ struct vkms_config *config;
+ struct vkms_config_connector *connector_cfg1, *connector_cfg2, *connector_cfg3;
+ struct vkms_config_encoder *encoder_cfg;
+ struct vkms_config_crtc *crtc_cfg;
+ struct vkms_config_plane *plane_cfg;
+ int err;
+
+ config = vkms_config_create("test");
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
+
+ /* Create a complete pipeline */
+ crtc_cfg = vkms_config_create_crtc(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc_cfg);
+
+ encoder_cfg = vkms_config_create_encoder(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, encoder_cfg);
+
+ connector_cfg1 = vkms_config_create_connector(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, connector_cfg1);
+
+ plane_cfg = vkms_config_create_plane(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, plane_cfg);
+
+ vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_PRIMARY);
+ err = vkms_config_plane_attach_crtc(plane_cfg, crtc_cfg);
+ KUNIT_EXPECT_EQ(test, err, 0);
+
+ err = vkms_config_encoder_attach_crtc(encoder_cfg, crtc_cfg);
+ KUNIT_EXPECT_EQ(test, err, 0);
+
+ err = vkms_config_connector_attach_encoder(connector_cfg1, encoder_cfg);
+ KUNIT_EXPECT_EQ(test, err, 0);
+
+ /* Valid: Single dynamic connector with no parent */
+ vkms_config_connector_set_dynamic(connector_cfg1, true);
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Valid: Two dynamic connectors in a chain */
+ connector_cfg2 = vkms_config_create_connector(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, connector_cfg2);
+ vkms_config_connector_set_dynamic(connector_cfg2, true);
+ err = vkms_config_connector_attach_encoder(connector_cfg2, encoder_cfg);
+ KUNIT_EXPECT_EQ(test, err, 0);
+ vkms_config_connector_attach_parent(connector_cfg2, connector_cfg1);
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Invalid: Create a loop - connector2 -> connector1 -> connector2 */
+ vkms_config_connector_attach_parent(connector_cfg1, connector_cfg2);
+ KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
+
+ /* Fix the loop */
+ vkms_config_connector_attach_parent(connector_cfg1, NULL);
+ KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
+
+ /* Invalid: Create a longer loop - connector1 -> connector2 -> connector3 -> connector1 */
+ connector_cfg3 = vkms_config_create_connector(config);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, connector_cfg3);
+ vkms_config_connector_set_dynamic(connector_cfg3, true);
+ err = vkms_config_connector_attach_encoder(connector_cfg3, encoder_cfg);
+ KUNIT_EXPECT_EQ(test, err, 0);
+ vkms_config_connector_attach_parent(connector_cfg3, connector_cfg2);
+ vkms_config_connector_attach_parent(connector_cfg1, connector_cfg3);
+ KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
+
+ vkms_config_destroy(config);
+}
+
static struct kunit_case vkms_config_test_cases[] = {
KUNIT_CASE(vkms_config_test_empty_config),
KUNIT_CASE_PARAM(vkms_config_test_default_config,
@@ -1266,6 +1527,10 @@ static struct kunit_case vkms_config_test_cases[] = {
KUNIT_CASE(vkms_config_test_encoder_get_possible_crtcs),
KUNIT_CASE(vkms_config_test_connector_get_possible_encoders),
KUNIT_CASE(vkms_config_test_connector_status),
+ KUNIT_CASE(vkms_config_test_connector_dynamic_status),
+ KUNIT_CASE(vkms_config_test_dynamic_connector_validity),
+ KUNIT_CASE(vkms_config_test_dynamic_connector_parent_validity),
+ KUNIT_CASE(vkms_config_test_dynamic_connector_parent_loop),
{}
};
diff --git a/drivers/gpu/drm/vkms/tests/vkms_lifecycle_test.c b/drivers/gpu/drm/vkms/tests/vkms_lifecycle_test.c
index 7f7b31368710..34310ba382a9 100644
--- a/drivers/gpu/drm/vkms/tests/vkms_lifecycle_test.c
+++ b/drivers/gpu/drm/vkms/tests/vkms_lifecycle_test.c
@@ -227,7 +227,7 @@ static void vkms_lifecycle_test_connector_ref_outlives_config(struct kunit *test
/* Simulate the rmdir while DRM hold the device */
vkms_config_connector_get(connector_cfg);
- vkms_config_destroy_connector(connector_cfg);
+ vkms_config_destroy_connector(config, connector_cfg);
vkms_config_destroy(config);
/* The connector must survive, detached from the configuration. */
diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index 2c6a53d6f778..fb6368e53c07 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -177,7 +177,17 @@ static void vkms_config_release(struct kref *ref)
vkms_config_destroy_encoder(config, encoder_cfg);
list_for_each_entry_safe(connector_cfg, connector_tmp, &config->connectors, link) {
- /* The config is dying: drop the list's reference on each connector */
+ /*
+ * The config is dying: break the parent chain first so parent
+ * cycles are reclaimable, then drop the list's reference on
+ * each connector.
+ */
+ if (connector_cfg->parent) {
+ struct vkms_config_connector *parent = connector_cfg->parent;
+
+ connector_cfg->parent = NULL;
+ vkms_config_connector_put(parent);
+ }
vkms_config_connector_put(connector_cfg);
}
@@ -498,6 +508,43 @@ static bool valid_connector_colorspaces(const struct vkms_config *config)
return true;
}
+static bool valid_connector_parents(const struct vkms_config *config)
+{
+ struct drm_device *dev = config->dev ? &config->dev->drm : NULL;
+
+ struct vkms_config_connector *connector_cfg;
+ const struct vkms_config_connector *parent;
+ size_t num_connectors = 0;
+ size_t depth;
+
+ vkms_config_for_each_connector(config, connector_cfg)
+ num_connectors++;
+
+ vkms_config_for_each_connector(config, connector_cfg) {
+ bool expected_status = connector_cfg->enabled;
+
+ parent = connector_cfg;
+ for (depth = 0; parent; depth++) {
+ /* A loop in the parent chain is walked more than
+ * num_connectors times.
+ */
+ if (depth > num_connectors) {
+ drm_info(dev, "Parents of connector should not form a loop\n");
+ return false;
+ }
+
+ if (expected_status && parent->enabled != expected_status) {
+ drm_info(dev, "All parents of an enabled connector must be enabled\n");
+ return false;
+ }
+
+ parent = vkms_config_connector_get_parent(parent);
+ }
+ }
+
+ return true;
+}
+
bool vkms_config_is_valid(const struct vkms_config *config)
{
struct drm_device *dev = config->dev ? &config->dev->drm : NULL;
@@ -578,6 +625,9 @@ bool vkms_config_is_valid(const struct vkms_config *config)
if (!valid_connector_colorspaces(config))
return false;
+ if (!valid_connector_parents(config))
+ return false;
+
return true;
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_is_valid);
@@ -1090,6 +1140,15 @@ static void vkms_config_connector_release(struct kref *ref)
/* The config is dying and is draining us: just unlink */
list_del_init(&connector_cfg->link);
}
+ /*
+ * Drop the reference the children took on their parent. This can
+ * run in any context (deferred probe put, drmm action, configfs
+ * release), so it must not touch config->connectors: the parent
+ * is kept alive by this reference, and its own release chains
+ * from here.
+ */
+ if (connector_cfg->parent)
+ vkms_config_connector_put(connector_cfg->parent);
if (connector_cfg->edid)
call_rcu(&connector_cfg->edid->rcu, vkms_config_edid_free);
kfree_rcu(connector_cfg, rcu);
@@ -1154,7 +1213,8 @@ int vkms_config_connector_set_edid(struct vkms_config_connector *connector_cfg,
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_connector_set_edid);
-void vkms_config_destroy_connector(struct vkms_config_connector *connector_cfg)
+void vkms_config_destroy_connector(struct vkms_config *config,
+ struct vkms_config_connector *connector_cfg)
{
/*
* Pin the config, then unlink and drop the list's reference. If this
@@ -1163,13 +1223,41 @@ void vkms_config_destroy_connector(struct vkms_config_connector *connector_cfg)
* nor free the config (pinned). list_del_rcu() because a concurrent
* dump may still be walking this connector.
*/
- vkms_config_get(connector_cfg->config);
+ vkms_config_get(config);
list_del_rcu(&connector_cfg->link);
connector_cfg->unlinked = true;
+ /*
+ * The connector is logically destroyed but stays allocated
+ * while its children still hold a reference on it; detach it
+ * from its own parent now. Without this, a parent cycle
+ * (accepted at link time, rejected when enabling the device)
+ * would keep every member of the cycle alive forever, as
+ * plain krefs cannot be reclaimed in a loop.
+ */
+ if (connector_cfg->parent) {
+ struct vkms_config_connector *parent = connector_cfg->parent;
+
+ connector_cfg->parent = NULL;
+ vkms_config_connector_put(parent);
+ }
+
vkms_config_connector_put(connector_cfg);
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_destroy_connector);
+void vkms_config_connector_attach_parent(struct vkms_config_connector *connector_cfg,
+ struct vkms_config_connector *parent)
+{
+ if (parent)
+ vkms_config_connector_get(parent);
+
+ if (connector_cfg->parent)
+ vkms_config_connector_put(connector_cfg->parent);
+
+ connector_cfg->parent = parent;
+}
+EXPORT_SYMBOL_IF_KUNIT(vkms_config_connector_attach_parent);
+
int __must_check vkms_config_connector_attach_encoder(struct vkms_config_connector *connector_cfg,
struct vkms_config_encoder *encoder_cfg)
{
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index e5352aaea85e..83869e677f15 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -180,6 +180,13 @@ struct vkms_config_edid {
* @possible_encoders: Array of encoders that can be used with this connector
* @unlinked: Set when the connector was unlinked from config->connectors
* by vkms_config_destroy_connector()
+ * @parent: To emulate MST connector, pointer to the parent connector. Attaching
+ * a parent takes a reference on it; the parent then stays allocated
+ * until the child detaches or is released, even if the parent itself
+ * is destroyed (it then stays logically detached: vkms_config_connector_get_parent()
+ * reports NULL for it)
+ * @port_id: To emulate MST connector, this contains the physical port id. Used to
+ * generate the PATH property.
* @connector: Internal usage. This pointer should never be considered as valid.
* It can be used to store a temporary reference to a VKMS connector
* during device creation. This pointer is not managed by the
@@ -201,6 +208,8 @@ struct vkms_config_connector {
struct vkms_config_edid __rcu *edid;
struct xarray possible_encoders;
bool unlinked;
+ struct vkms_config_connector *parent;
+ u8 port_id;
/* Internal usage */
struct vkms_connector *connector;
@@ -423,6 +432,65 @@ vkms_config_connector_get_edid(const struct vkms_config_connector *connector_cfg
*len = 0;
return NULL;
}
+/**
+ * vkms_config_connector_attach_parent - Attach a connector to a parent connector
+ * @connector_cfg: Connector to attach
+ * @parent: Parent connector to attach @connector_cfg to. Can be NULL to detach
+ * the current parent.
+ *
+ * Attaching takes a reference on @parent, detached or replaced parents are
+ * released. Must be called with the configuration lock held, as the release
+ * of a replaced parent can free it.
+ */
+void vkms_config_connector_attach_parent(struct vkms_config_connector *connector_cfg,
+ struct vkms_config_connector *parent);
+
+/**
+ * vkms_config_connector_get_parent - Get the parent connector of a connector
+ * @connector_cfg: Connector to get the parent from
+ *
+ * Returns:
+ * The parent connector of @connector_cfg, or NULL if none is assigned or if
+ * the parent was destroyed: a destroyed parent stays allocated while its
+ * children hold a reference on it, but is logically detached, and its
+ * children then behave as if they had no parent.
+ */
+static inline struct vkms_config_connector*
+vkms_config_connector_get_parent(const struct vkms_config_connector *connector_cfg)
+{
+ struct vkms_config_connector *parent = connector_cfg->parent;
+
+ if (parent && list_empty(&parent->link))
+ return NULL;
+
+ return parent;
+}
+
+/**
+ * vkms_config_connector_get_port_id() - Get the port ID for a connector
+ * @connector_cfg: Connector configuration to query
+ *
+ * Returns:
+ * The port ID for this connector.
+ */
+static inline u8
+vkms_config_connector_get_port_id(const struct vkms_config_connector *connector_cfg)
+{
+ return connector_cfg->port_id;
+}
+
+/**
+ * vkms_config_connector_set_port_id() - Set the port ID for a connector
+ * @connector_cfg: Connector configuration to modify
+ * @port_id: New port ID for this connector
+ */
+static inline void
+vkms_config_connector_set_port_id(struct vkms_config_connector *connector_cfg,
+ u8 port_id)
+{
+ connector_cfg->port_id = port_id;
+}
+
int vkms_config_connector_set_edid(struct vkms_config_connector *connector_cfg,
const u8 *edid, unsigned int len);
@@ -1086,9 +1154,11 @@ void vkms_config_connector_put(struct vkms_config_connector *connector_cfg);
/**
* vkms_config_destroy_connector() - Remove and free a connector configuration
+ * @config: Configuration to remove the connector from
* @connector_cfg: Connector configuration to destroy
*/
-void vkms_config_destroy_connector(struct vkms_config_connector *connector_cfg);
+void vkms_config_destroy_connector(struct vkms_config *config,
+ struct vkms_config_connector *connector_cfg);
/**
* vkms_config_connector_attach_encoder - Attach a connector to an encoder
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index 0681722e98e8..e6222db02a2e 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -1424,7 +1424,7 @@ static void connector_release(struct config_item *item)
if (connector->dev->enabled && connector_cfg->dynamic && connector_cfg->enabled)
vkms_connector_hot_remove(connector_cfg->connector);
- vkms_config_destroy_connector(connector->config);
+ vkms_config_destroy_connector(connector->dev->config, connector->config);
kfree(connector);
}
diff --git a/drivers/gpu/drm/vkms/vkms_connector.c b/drivers/gpu/drm/vkms/vkms_connector.c
index 93bceba0a1ae..5655f8b649c6 100644
--- a/drivers/gpu/drm/vkms/vkms_connector.c
+++ b/drivers/gpu/drm/vkms/vkms_connector.c
@@ -8,6 +8,76 @@
#include "vkms_config.h"
#include "vkms_connector.h"
+/**
+ * vkms_connector_build_path_property() - Build the PATH property string for MST connectors
+ * @connector: The connector to build the PATH property for
+ * @connector_cfg: The connector configuration
+ *
+ * The PATH property format is:
+ * mst:<drm object ID of root connector>-<dash-separated list of port_id>
+ * For nested MST connectors, this builds the full path like mst:45-2-3-4-2
+ */
+static void vkms_connector_build_path_property(struct vkms_connector *connector,
+ const struct vkms_config_connector *connector_cfg)
+{
+ const struct vkms_config_connector *current_cfg = connector_cfg;
+ const struct vkms_config_connector *root_cfg = NULL;
+ struct vkms_connector *root_connector = NULL;
+ char path[128]; /* Increased size for nested MST paths */
+ int len = 0;
+ u8 port_ids[16]; /* Max 16 levels of nesting */
+ int port_count = 0;
+ int i;
+
+ if (!vkms_config_connector_get_parent(connector_cfg))
+ return;
+
+ while (current_cfg) {
+ if (port_count < ARRAY_SIZE(port_ids))
+ port_ids[port_count++] = current_cfg->port_id;
+
+ if (!vkms_config_connector_get_parent(current_cfg)) {
+ root_cfg = current_cfg;
+ break;
+ }
+
+ current_cfg = vkms_config_connector_get_parent(current_cfg);
+ }
+
+ if (!root_cfg || !root_cfg->connector)
+ return;
+
+ root_connector = root_cfg->connector;
+
+ len = snprintf(path, sizeof(path), "mst:%d", root_connector->base.base.id);
+
+ for (i = port_count - 2; i >= 0; i--) {
+ int added = snprintf(path + len, sizeof(path) - len,
+ "-%u", port_ids[i]);
+ if (added < 0 || len + added >= sizeof(path))
+ return;
+ len += added;
+ }
+
+ drm_connector_set_path_property(&connector->base, path);
+}
+
+/**
+ * vkms_connector_update_path_properties() - Update PATH properties for all connectors
+ * @vkmsdev: VKMS device
+ *
+ * This should be called after all connectors are created to ensure parent connectors
+ * have valid DRM object IDs.
+ */
+void vkms_connector_update_path_properties(struct vkms_device *vkmsdev)
+{
+ struct vkms_config_connector *connector_cfg;
+
+ vkms_config_for_each_connector(vkmsdev->config, connector_cfg)
+ if (connector_cfg->connector)
+ vkms_connector_build_path_property(connector_cfg->connector, connector_cfg);
+}
+
static enum drm_connector_status vkms_connector_detect(struct drm_connector *connector,
bool force)
{
@@ -104,13 +174,6 @@ static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = {
.best_encoder = vkms_conn_best_encoder,
};
-static void vkms_connector_static_cfg_release(struct drm_device *dev, void *res)
-{
- struct vkms_connector *connector = res;
-
- vkms_config_connector_put(connector->cfg);
-}
-
/**
* vkms_connector_init - Common initialization for all vkms connectors
*
@@ -163,9 +226,20 @@ static int __must_check vkms_connector_init(struct vkms_connector *connector,
if (connector_cfg->type == DRM_MODE_CONNECTOR_VIRTUAL)
drm_connector_attach_edid_property(&connector->base);
+ if (vkms_config_connector_get_parent(connector_cfg))
+ drm_object_attach_property(&connector->base.base,
+ connector->base.dev->mode_config.path_property, 0);
+
return 0;
}
+static void vkms_connector_static_cfg_release(struct drm_device *dev, void *res)
+{
+ struct vkms_connector *connector = res;
+
+ vkms_config_connector_put(connector->cfg);
+}
+
struct vkms_connector *vkms_connector_init_static(struct vkms_device *vkmsdev,
struct vkms_config_connector *connector_cfg)
{
@@ -278,6 +352,8 @@ struct vkms_connector *vkms_connector_hot_add(struct vkms_device *vkmsdev,
return ERR_PTR(ret);
}
+ vkms_connector_build_path_property(connector, connector_cfg);
+
/*
* Attach the configuration before registration and serialize the
* registration with in-flight probes: drm_mode_getconnector() holds
diff --git a/drivers/gpu/drm/vkms/vkms_connector.h b/drivers/gpu/drm/vkms/vkms_connector.h
index 83b5b32b42de..5a80735204d4 100644
--- a/drivers/gpu/drm/vkms/vkms_connector.h
+++ b/drivers/gpu/drm/vkms/vkms_connector.h
@@ -79,4 +79,13 @@ int vkms_connector_hot_attach_encoder(struct vkms_connector *connector,
int vkms_connector_hot_detach_encoder(struct vkms_connector *connector,
struct drm_encoder *encoder);
+/**
+ * vkms_connector_update_path_properties() - Update PATH properties for all connectors
+ * @vkmsdev: VKMS device
+ *
+ * This should be called after all connectors are created to ensure parent connectors
+ * have valid DRM object IDs.
+ */
+void vkms_connector_update_path_properties(struct vkms_device *vkmsdev);
+
#endif /* _VKMS_CONNECTOR_H_ */
diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c
index b100ed0c91e6..0b938e057e82 100644
--- a/drivers/gpu/drm/vkms/vkms_output.c
+++ b/drivers/gpu/drm/vkms/vkms_output.c
@@ -128,5 +128,7 @@ int vkms_output_init(struct vkms_device *vkmsdev)
}
}
+ vkms_connector_update_path_properties(vkmsdev);
+
return 0;
}
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* [PATCH v7 43/43] drm/vkms: Add ConfigFS interface for connector parent and port_id
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
` (41 preceding siblings ...)
2026-11-26 11:29 ` [PATCH v7 42/43] drm/vkms: Add connector parent configuration in vkms_config Louis Chauvet
@ 2026-11-26 11:29 ` Louis Chauvet
2026-11-26 19:49 ` kernel test robot
42 siblings, 1 reply; 46+ messages in thread
From: Louis Chauvet @ 2026-11-26 11:29 UTC (permalink / raw)
To: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Oarora Etimis, Harry Wentland, Lucas De Marchi,
Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Louis Chauvet, Shuah Khan,
Miguel Ojeda, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt
Cc: Luca Ceresoli, Kory Maincent, sebastian.wick, victoria,
thomas.petazzoni, dri-devel, linux-kernel, linux-doc, llvm
Add the parent and port_id configuration for a connector.
- port_id can contain any u8 value
- parent can contain at most one symlink to an other connector.
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
Documentation/ABI/testing/configfs-vkms | 28 +++++++++
drivers/gpu/drm/vkms/vkms_config.h | 8 +--
drivers/gpu/drm/vkms/vkms_configfs.c | 103 ++++++++++++++++++++++++++++++++
3 files changed, 135 insertions(+), 4 deletions(-)
diff --git a/Documentation/ABI/testing/configfs-vkms b/Documentation/ABI/testing/configfs-vkms
index f59533e6f80e..27d307935771 100644
--- a/Documentation/ABI/testing/configfs-vkms
+++ b/Documentation/ABI/testing/configfs-vkms
@@ -106,6 +106,15 @@ Description:
the device is disabled, the value is only stored and takes
effect when the device is enabled.
+What: /sys/kernel/config/vkms/<device>/connectors/<connector>/port_id
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ Port number of the connector, used together with parent to
+ build the MST PATH property. Value is a decimal number
+ between 0 and 255. Writing fails with -EBUSY if the device
+ is enabled and the connector is enabled.
+
What: /sys/kernel/config/vkms/<device>/connectors/<connector>/possible_encoders
Date: Nov 2025
Contact: dri-devel@lists.freedesktop.org
@@ -116,6 +125,25 @@ Description:
connector attaches it immediately, and linking into a
static connector fails with -EBUSY.
+What: /sys/kernel/config/vkms/<device>/connectors/<connector>/parent
+Date: Nov 2025
+Contact: dri-devel@lists.freedesktop.org
+Description:
+ This group contains a symbolic link to the parent
+ connector, to emulate a DP MST topology. The target must
+ be a connector of the same VKMS device. Creating the link
+ fails with -EMLINK if the connector already has a parent,
+ and with -EBUSY if the device is enabled and the connector
+ is enabled. Removing the link detaches the parent. A
+ connector with a parent exposes a PATH property of the
+ form "mst:<root connector DRM ID>-<port_id>...", listing
+ the port IDs along the path from the first connector below
+ the root down to this one (up to 16 levels of nesting).
+ Creating a link that forms a parent cycle (A becoming the
+ parent of B while B is already the parent of A) is accepted,
+ but such a cycle is rejected when the device is enabled,
+ during configuration validation (-EINVAL).
+
What: /sys/kernel/config/vkms/<device>/crtcs
Date: Nov 2025
Contact: dri-devel@lists.freedesktop.org
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index 83869e677f15..457239cfc2a4 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -432,6 +432,10 @@ vkms_config_connector_get_edid(const struct vkms_config_connector *connector_cfg
*len = 0;
return NULL;
}
+
+int vkms_config_connector_set_edid(struct vkms_config_connector *connector_cfg,
+ const u8 *edid, unsigned int len);
+
/**
* vkms_config_connector_attach_parent - Attach a connector to a parent connector
* @connector_cfg: Connector to attach
@@ -492,10 +496,6 @@ vkms_config_connector_set_port_id(struct vkms_config_connector *connector_cfg,
}
-int vkms_config_connector_set_edid(struct vkms_config_connector *connector_cfg,
- const u8 *edid, unsigned int len);
-
-
/**
* vkms_config_get_device_name() - Return the name of the device
* @config: Configuration to get the device name from
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index e6222db02a2e..55de6a06ab2d 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -112,6 +112,7 @@ struct vkms_configfs_encoder {
struct vkms_configfs_connector {
struct config_group group;
struct config_group possible_encoders_group;
+ struct config_group parent_group;
struct vkms_configfs_device *dev;
struct vkms_config_connector *config;
};
@@ -149,6 +150,10 @@ struct vkms_configfs_connector {
container_of(to_config_group((item)), struct vkms_configfs_connector, \
possible_encoders_group)
+#define connector_parent_item_to_vkms_configfs_connector(item) \
+ container_of(to_config_group((item)), struct vkms_configfs_connector, \
+ parent_group)
+
static ssize_t crtc_writeback_show(struct config_item *item, char *page)
{
struct vkms_configfs_crtc *crtc;
@@ -1391,6 +1396,42 @@ static ssize_t connector_dynamic_store(struct config_item *item,
return count;
}
+static ssize_t connector_port_id_show(struct config_item *item, char *page)
+{
+ struct vkms_configfs_connector *connector;
+ u8 port_id;
+
+ connector = connector_item_to_vkms_configfs_connector(item);
+
+ scoped_guard(mutex, &connector->dev->config->lock)
+ port_id = vkms_config_connector_get_port_id(connector->config);
+
+ return sprintf(page, "%u\n", port_id);
+}
+
+static ssize_t connector_port_id_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_configfs_connector *connector;
+ u8 port_id;
+ int ret;
+
+ connector = connector_item_to_vkms_configfs_connector(item);
+
+ ret = kstrtou8(page, 10, &port_id);
+ if (ret)
+ return ret;
+
+ scoped_guard(mutex, &connector->dev->config->lock) {
+ if (connector->dev->enabled && connector_is_enabled(connector->config))
+ return -EBUSY;
+
+ vkms_config_connector_set_port_id(connector->config, port_id);
+ }
+
+ return count;
+}
+
CONFIGFS_ATTR(connector_, status);
CONFIGFS_ATTR(connector_, type);
CONFIGFS_ATTR(connector_, supported_colorspaces);
@@ -1398,6 +1439,7 @@ CONFIGFS_ATTR(connector_, edid_enabled);
CONFIGFS_ATTR(connector_, edid);
CONFIGFS_ATTR(connector_, dynamic);
CONFIGFS_ATTR(connector_, enabled);
+CONFIGFS_ATTR(connector_, port_id);
static struct configfs_attribute *connector_item_attrs[] = {
&connector_attr_status,
@@ -1407,6 +1449,7 @@ static struct configfs_attribute *connector_item_attrs[] = {
&connector_attr_edid,
&connector_attr_dynamic,
&connector_attr_enabled,
+ &connector_attr_port_id,
NULL,
};
@@ -1505,6 +1548,62 @@ static const struct config_item_type connector_possible_encoders_group_type = {
.ct_owner = THIS_MODULE,
};
+static int connector_parent_connector_allow_link(struct config_item *src,
+ struct config_item *target)
+{
+ struct vkms_configfs_connector *connector;
+ struct vkms_config_connector *connector_cfg;
+ struct vkms_configfs_connector *parent;
+ struct vkms_config_connector *parent_cfg;
+
+ if (target->ci_type != &connector_item_type)
+ return -EINVAL;
+
+ connector = connector_parent_item_to_vkms_configfs_connector(src);
+ connector_cfg = connector->config;
+ parent = connector_item_to_vkms_configfs_connector(target);
+ parent_cfg = parent->config;
+
+ if (connector->dev != parent->dev)
+ return -EINVAL;
+
+ scoped_guard(mutex, &connector->dev->config->lock) {
+ if (vkms_config_connector_get_parent(connector_cfg))
+ return -EMLINK;
+
+ if (connector->dev->enabled && connector_cfg->enabled)
+ return -EBUSY;
+
+ vkms_config_connector_attach_parent(connector_cfg,
+ parent_cfg);
+ }
+
+ return 0;
+}
+
+static void connector_parent_connector_drop_link(struct config_item *src,
+ struct config_item *target)
+{
+ struct vkms_configfs_connector *connector;
+ struct vkms_config_connector *connector_cfg;
+
+ connector = connector_parent_item_to_vkms_configfs_connector(src);
+ connector_cfg = connector->config;
+
+ scoped_guard(mutex, &connector->dev->config->lock)
+ vkms_config_connector_attach_parent(connector_cfg, NULL);
+}
+
+static struct configfs_item_operations connector_parent_item_operations = {
+ .allow_link = connector_parent_connector_allow_link,
+ .drop_link = connector_parent_connector_drop_link,
+};
+
+static const struct config_item_type connector_parent_group_type = {
+ .ct_item_ops = &connector_parent_item_operations,
+ .ct_owner = THIS_MODULE,
+};
+
static struct config_group *make_connector_group(struct config_group *group,
const char *name)
{
@@ -1537,6 +1636,10 @@ static struct config_group *make_connector_group(struct config_group *group,
config_group_init_type_name(&connector->possible_encoders_group,
"possible_encoders",
&connector_possible_encoders_group_type);
+ config_group_init_type_name(&connector->parent_group,
+ "parent",
+ &connector_parent_group_type);
+ configfs_add_default_group(&connector->parent_group, &connector->group);
configfs_add_default_group(&connector->possible_encoders_group,
&connector->group);
}
--
2.56.0
^ permalink raw reply [flat|nested] 46+ messages in thread* Re: [PATCH v7 43/43] drm/vkms: Add ConfigFS interface for connector parent and port_id
2026-11-26 11:29 ` [PATCH v7 43/43] drm/vkms: Add ConfigFS interface for connector parent and port_id Louis Chauvet
@ 2026-11-26 19:49 ` kernel test robot
0 siblings, 0 replies; 46+ messages in thread
From: kernel test robot @ 2026-11-26 19:49 UTC (permalink / raw)
To: Louis Chauvet, Haneen Mohammed, Simona Vetter, Melissa Wen,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, jose.exposito89, Jonathan Corbet, Oarora Etimis,
Harry Wentland, Lucas De Marchi, Ville Syrjälä,
Randy Dunlap, Nick Desaulniers, Shuah Khan, Miguel Ojeda,
Nathan Chancellor, Bill Wendling, Justin Stitt
Cc: oe-kbuild-all, Luca Ceresoli, Kory Maincent, sebastian.wick,
victoria, thomas.petazzoni, dri-devel, linux-kernel, linux-doc,
llvm
Hi Louis,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 3c7c3c12dfc7704ca614abbfa266ca00a2b5a994]
url: https://github.com/intel-lab-lkp/linux/commits/Louis-Chauvet/drm-vkms-Lock-the-config-dump-against-concurrent-configfs-changes/20261126-122844
base: 3c7c3c12dfc7704ca614abbfa266ca00a2b5a994
patch link: https://lore.kernel.org/r/20261126-vkms-all-config-v7-43-21194cda2468%40bootlin.com
patch subject: [PATCH v7 43/43] drm/vkms: Add ConfigFS interface for connector parent and port_id
config: i386-randconfig-1004-20261126 (https://download.01.org/0day-ci/archive/20261127/20261127033740.miob9yII-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261127/20261127033740.miob9yII-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261127033740.miob9yII-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> Warning: drivers/gpu/drm/vkms/vkms_configfs.c:117 struct member 'parent_group' not described in 'vkms_configfs_connector'
>> Warning: drivers/gpu/drm/vkms/vkms_configfs.c:117 struct member 'parent_group' not described in 'vkms_configfs_connector'
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 46+ messages in thread