* [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:50 ` sashiko-bot
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, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 01/43] drm/vkms: Lock the config dump against concurrent configfs changes
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:50 ` sashiko-bot
0 siblings, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:50 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [High] drm/vkms: const discarded locking config->lock in
vkms_connector_detect()
- [High] drm/vkms: self-deadlock on config->lock in
connector_status_store()
- [Medium] drm/vkms: unlocked RCU list walk and UAF in
vkms_connector_detect()
- [Medium] drm/vkms: races from dropping config->lock in
device_enabled_store()
- [Medium] drm/vkms: RCU lockdep warning in vkms_config_for_each_*
during vkms_create()
- [Low] drm/vkms: commit message and vkms_config_show() comment mismatch
with code
--
commit e3fcd80e0d55e7be8d3c20f129777ead0dbe15ab
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Lock the config dump against concurrent configfs changes
This commit moves the configuration lock into struct vkms_config, converts
the configuration lists to RCU-protected lists, and updates configfs,
debugfs, and connector detection to synchronize configuration access.
> diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
> index f9e30a4e5a3f8..6699ddae71260 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.c
> +++ b/drivers/gpu/drm/vkms/vkms_config.c
[ ... ]
> @@ -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) {
[Severity: Low]
This isn't a bug, but both the commit message and this comment appear out of
sync with the code. The commit message says "Move the configuration lock
into struct vkms_config and run the dump under it", whereas
vkms_config_show() uses scoped_guard(rcu). In addition, this comment says
the disable path removes the debugfs file while holding the lock, but
device_enabled_store() drops dev->config->lock before calling vkms_destroy().
> diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
> index 56805b0c9b145..125273f67e7d7 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.h
> +++ b/drivers/gpu/drm/vkms/vkms_config.h
[ ... ]
> @@ -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)
[Severity: Medium]
Does this lockdep condition trigger an RCU_LOCKDEP_WARN splat during
vkms_create() when CONFIG_PROVE_RCU_LIST=y is enabled?
In vkms_create(), config->dev is assigned before calling vkms_modeset_init():
drivers/gpu/drm/vkms/vkms_drv.c:vkms_create() {
...
vkms_device->faux_dev = fdev;
vkms_device->config = config;
config->dev = vkms_device;
...
ret = vkms_modeset_init(vkms_device);
}
Neither vkms_init() nor device_enabled_store() holds config->lock or
rcu_read_lock() across vkms_create(), so config->dev is non-NULL when
vkms_modeset_init() -> vkms_output_init() and vkms_config_is_valid() iterate
the configuration lists with vkms_config_for_each_{plane,crtc,encoder,connector}().
> diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
> index af097967ca6fc..6bb24f5835db1 100644
> --- a/drivers/gpu/drm/vkms/vkms_configfs.c
> +++ b/drivers/gpu/drm/vkms/vkms_configfs.c
[ ... ]
> @@ -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)
> vkms_trigger_connector_hotplug(connector->dev->config->dev);
> }
[Severity: High]
Does calling vkms_trigger_connector_hotplug() while holding
connector->dev->config->lock self-deadlock on config->lock when a connector's
configfs status is written on an enabled device?
connector_status_store()
mutex_lock(&connector->dev->config->lock)
vkms_trigger_connector_hotplug()
drm_kms_helper_hotplug_event()
...
drm_helper_probe_single_connector_modes()
vkms_connector_detect()
mutex_lock(&vkmsdev->config->lock) <-- deadlocks
This also inverts the lock order against normal DRM connector probing (such
as drm_mode_getconnector()), which acquires dev->mode_config.mutex before
calling vkms_connector_detect() -> mutex_lock(&vkmsdev->config->lock).
[ ... ]
> @@ -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);
> + }
[Severity: Medium]
Can dropping dev->config->lock after setting dev->enabled leave vkms_create()
and vkms_destroy() open to concurrent configfs operations?
CPU0 CPU1
device_enabled_store(1)
mutex_lock(&config->lock)
dev->enabled = true
mutex_unlock(&config->lock)
connector_status_store()
mutex_lock(&config->lock)
if (connector->dev->enabled)
vkms_trigger_connector_hotplug(
config->dev)
<-- NULL pointer dereference
vkms_create(dev->config)
config->dev = vkms_device
Because config->lock is released before vkms_create() or vkms_destroy() runs:
- a second write to enabled on another file descriptor can run vkms_destroy()
concurrently with vkms_create() (or mutate the configuration after
dev->enabled is cleared to false while vkms_destroy() is still running);
- configfs unlink (*_drop_link) and rmdir (*_release) callbacks do not check
dev->enabled, so they can acquire config->lock after vkms_config_is_valid()
returns and detach or free planes, CRTCs, encoders, or connectors while
vkms_create() -> vkms_output_init() is initializing the device.
> diff --git a/drivers/gpu/drm/vkms/vkms_connector.c b/drivers/gpu/drm/vkms/vkms_connector.c
> index 57138027966f5..080a0240d5e92 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);
> + }
> }
[Severity: High]
Does passing &vkmsdev->config->lock to scoped_guard(mutex, ...) fail to build
under CONFIG_WERROR=y? In struct vkms_device, config is declared as
const struct vkms_config *, so &vkmsdev->config->lock discards the const
qualifier (-Werror=discarded-qualifiers). This is rewritten in a later patch
in the series, commit "drm/vkms: Introduce back pointer to connector", but
breaks bisection at this commit.
[Severity: Medium]
Can walking vkmsdev->config->connectors here without rcu_read_lock() or
holding config->lock across the loop trigger an RCU lockdep warning and race
with connector_release()?
CPU0 CPU1
vkms_connector_detect()
vkms_config_for_each_connector()
if (connector_cfg->connector == ...)
connector_release()
mutex_lock(&config->lock)
vkms_config_destroy_connector()
list_del_rcu(&connector_cfg->link)
kfree_rcu(connector_cfg, rcu)
mutex_unlock(&config->lock)
/* RCU grace period elapses */
mutex_lock(&config->lock)
vkms_config_connector_get_status(
connector_cfg) <-- use-after-free
Because vkmsdev->config->dev is non-NULL and neither rcu_read_lock() nor
config->lock is held across vkms_config_for_each_connector(), every call to
vkms_connector_detect() triggers RCU_LOCKDEP_WARN under
CONFIG_PROVE_RCU_LIST=y, and connector_cfg can be freed while CPU0 is
preempted or blocked on config->lock. Later patches in the series (commit
"drm/vkms: Reference-count vkms_config and vkms_config_connector" and commit
"drm/vkms: Introduce back pointer to connector") replace this traversal with
a reference-counted back-pointer.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=1
^ permalink raw reply [flat|nested] 81+ 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; 81+ 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 related [flat|nested] 81+ 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:40 ` sashiko-bot
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, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 03/43] drm/blend: Get a rotation name from its bitfield
2026-11-26 11:28 ` [PATCH v7 03/43] drm/blend: Get a rotation name from its bitfield Louis Chauvet
@ 2026-11-26 11:40 ` sashiko-bot
0 siblings, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:40 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/blend: unneeded extraction of rotation_props[] and
duplicated rotation names
--
commit 1ed6793c09db95dc37f1bc98ca275a5ad9c3ac91
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/blend: Get a rotation name from its bitfield
This commit adds the DRM_ROTATION_FMT and DRM_ROTATION_FMT_ARGS() helpers
to print human-readable rotation bitmasks and moves the rotation property
enum array to file scope.
> diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c
> index d17ae964fb21f..b62f1db9c3114 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 bebbb77a8f214..f000b10a16e70 100644
> --- a/include/drm/drm_blend.h
> +++ b/include/drm/drm_blend.h
[ ... ]
> +#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)
[Severity: Low]
Why move props[] out of drm_plane_create_rotation_property() to file-scope
rotation_props[] when DRM_ROTATION_FMT_ARGS() hardcodes its own copy of
the rotation strings? rotation_props[] remains static in drm_blend.c with
drm_plane_create_rotation_property() as its only user, so either the array
can stay local to that function (and the commit message updated) or the
string definitions should be shared.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=3
^ permalink raw reply [flat|nested] 81+ 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; 81+ 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 related [flat|nested] 81+ 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; 81+ 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 related [flat|nested] 81+ 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; 81+ 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 related [flat|nested] 81+ 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; 81+ 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 related [flat|nested] 81+ 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; 81+ 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 related [flat|nested] 81+ 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-12-01 15:01 ` Oarora Etimis
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, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 09/43] Documentation: ABI: vkms: Add current VKMS ABI documentation
2026-11-26 11:28 ` [PATCH v7 09/43] Documentation: ABI: vkms: Add current VKMS ABI documentation Louis Chauvet
@ 2026-12-01 15:01 ` Oarora Etimis
0 siblings, 0 replies; 81+ messages in thread
From: Oarora Etimis @ 2026-12-01 15:01 UTC (permalink / raw)
To: Louis Chauvet
Cc: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Harry Wentland, Lucas De Marchi,
Ville Syrjälä, Randy Dunlap, Nick Desaulniers,
Shuah Khan, Miguel Ojeda, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Luca Ceresoli, Kory Maincent,
sebastian.wick, victoria, thomas.petazzoni, dri-devel,
linux-kernel, linux-doc, llvm
On Thu, Nov 26, 2026 at 12:28:52PM +0100, Louis Chauvet wrote:
> 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
>
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
^ permalink raw reply [flat|nested] 81+ 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:48 ` sashiko-bot
2026-11-27 7:21 ` Oarora Etimis
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, 2 replies; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 10/43] drm/vkms: Reset config->dev when the device creation fails
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:48 ` sashiko-bot
2026-11-27 7:21 ` Oarora Etimis
1 sibling, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:48 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/vkms: missing Fixes trailer for vkms_create() dangling
config->dev fix
--
commit 83801dc57b80afdf7dea1ce28f5739fe30a5a8da
Author: Louis Chauvet <louis.chauvet@bootlin.com>
> drm/vkms: Reset config->dev when the device creation fails
>
> 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>
[Severity: Low]
This fixes a bug introduced when vkms_create() began storing vkms_device
in config->dev without clearing it on the out_devres failure path.
Should this include:
Fixes: 2df7af93fdad ("drm/vkms: Add vkms_config type")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=10
^ permalink raw reply [flat|nested] 81+ messages in thread* Re: [PATCH v7 10/43] drm/vkms: Reset config->dev when the device creation fails
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:48 ` sashiko-bot
@ 2026-11-27 7:21 ` Oarora Etimis
1 sibling, 0 replies; 81+ messages in thread
From: Oarora Etimis @ 2026-11-27 7:21 UTC (permalink / raw)
Cc: Oarora Etimis, To : Louis Chauvet, Haneen Mohammed, Simona Vetter,
Melissa Wen, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, jose.exposito89, Jonathan Corbet, Harry Wentland,
Lucas De Marchi, Ville Syrjälä, Randy Dunlap,
Nick Desaulniers, Shuah Khan, Miguel Ojeda, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt, Luca Ceresoli,
Kory Maincent, sebastian.wick, victoria, thomas.petazzoni,
dri-devel, linux-kernel, linux-doc, llvm
From: Oarora Etimis <oaroraetimis@gmail.com>, To: Louis Chauvet <louis.chauvet@bootlin.com>
On Thu, Nov 26, 2026 at 12:28:53PM +0100, Louis Chauvet wrote:
> 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
>
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
^ permalink raw reply [flat|nested] 81+ 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:49 ` sashiko-bot
2026-11-26 11:28 ` [PATCH v7 12/43] drm/vkms: Add KUnit test for device lifecycle Louis Chauvet
` (31 subsequent siblings)
42 siblings, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 11/43] drm/vkms: Reference-count vkms_config and vkms_config_connector
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:49 ` sashiko-bot
0 siblings, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:49 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] drm/vkms: premature config put in vkms_create() due to __free()
- [High] drm/vkms: use-after-free in vkms_config_connector_release() on
config drain
- [Low] drm/vkms: duplicate linux/list.h include in vkms_config.h
--
commit 58266f4f95b4eb422dfae060ca602a9c586df7ee
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Reference-count vkms_config and vkms_config_connector
This commit adds reference counting to struct vkms_config and struct
vkms_config_connector so configurations and connectors stay alive while
referenced outside configfs.
> diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
> index 6699ddae71260..8cd4fe6551fb8 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.c
> +++ b/drivers/gpu/drm/vkms/vkms_config.c
[ ... ]
> @@ -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);
> +}
[ ... ]
> @@ -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);
> }
[Severity: High]
Can vkms_config_connector_release() trigger a use-after-free on
config->connectors when a connector outlives its config without going
through vkms_config_destroy_connector()?
vkms_config_connector_get() increments connector_cfg->refcnt without
pinning connector_cfg->config. If config is released while a connector
still linked in config->connectors holds an extra reference,
vkms_config_release() drops the list reference and frees config via
kfree_rcu() while connector_cfg->link stays attached to config->connectors
with connector_cfg->unlinked set to false. When the final reference on
connector_cfg is later dropped, vkms_config_connector_release() runs
list_del_init(&connector_cfg->link) and writes into the freed
config->connectors list head.
> diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
> index 125273f67e7d7..95e5c3694742f 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>
[Severity: Low]
linux/list.h is included twice here.
> diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
> index 4cbb1173fcc62..24572bc779b41 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);
[Severity: High]
Does __free(vkms_config_put) drop the device's reference on cfg as soon as
vkms_create() returns?
Because cfg is never passed to no_free_ptr() on the success path (and
vkms_destroy() does not call vkms_config_put()), the cleanup handler runs
when vkms_create() exits scope. That leaves vkms_device->config without a
device-owned reference, so freeing the configuration while the DRM device
is still active causes a use-after-free when DRM or debugfs paths access
vkms_device->config.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=11
^ permalink raw reply [flat|nested] 81+ 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:55 ` sashiko-bot
2026-11-27 10:24 ` Oarora Etimis
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, 2 replies; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 12/43] drm/vkms: Add KUnit test for device lifecycle
2026-11-26 11:28 ` [PATCH v7 12/43] drm/vkms: Add KUnit test for device lifecycle Louis Chauvet
@ 2026-11-26 11:55 ` sashiko-bot
2026-11-27 10:24 ` Oarora Etimis
1 sibling, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:55 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [Medium] drm/vkms: missing vkms_destroy() call in uncreated-device
KUnit test
- [Medium] drm/vkms: missing second vkms_destroy() in
vkms_lifecycle_test_double_destroy()
- [Low] drm/vkms: missing connector detach before vkms_destroy() in
KUnit test
- [Low] drm/vkms: non-portable KASAN and KUNIT_ALL_TESTS in .kunitconfig
- [Low] drm/vkms: EXPORT_SYMBOL_IF_KUNIT(vkms_create) placed after
vkms_init()
--
commit 638d5ac8d39529e98a29a3faec3aa7ef9239a4d3
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Add KUnit test for device lifecycle
This commit adds a KUnit test suite exercising VKMS device creation,
destruction, and reference-counted configuration object lifetimes, and
exports vkms_create() and vkms_destroy() for KUnit testing.
> diff --git a/drivers/gpu/drm/vkms/tests/.kunitconfig b/drivers/gpu/drm/vkms/tests/.kunitconfig
> index 6a2d87068edc5..c9752bde84874 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
[Severity: Low]
Will hardcoding these KASAN options and CONFIG_KUNIT_ALL_TESTS=n break
kunit.py runs?
kunit.py rejects .kunitconfig options that are missing from the final
.config, so CONFIG_KASAN_INLINE=y and CONFIG_KASAN_VMALLOC=y fail on
architectures or build modes that do not support them (such as 32-bit
targets or UML with CONFIG_STATIC_LINK=y). CONFIG_KUNIT_ALL_TESTS=n also
conflicts with tools/testing/kunit/configs/all_tests.config when running
kunit.py with --alltests, causing kunit_kernel.py to abort with a multiple
values ConfigError.
[ ... ]
> 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 0000000000000..7f7b313687101
> --- /dev/null
> +++ b/drivers/gpu/drm/vkms/tests/vkms_lifecycle_test.c
[ ... ]
> +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);
> +}
[Severity: Medium]
Should vkms_lifecycle_test_destroy_uncreated_device() call
vkms_destroy(config) before vkms_config_destroy(config)? Without it, the
!config->dev early return in vkms_destroy() is never exercised.
> +
> +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);
> +}
[Severity: Medium]
Is a second vkms_destroy(config) call missing here? Calling
vkms_destroy(config) only once leaves double destruction untested.
[ ... ]
> +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);
> +}
[Severity: Low]
Does vkms_lifecycle_test_connector_static_drmm_release() actually test
releasing the last connector reference from the drmm action?
Even after commit "drm/vkms: Introduce back pointer to connector" adds
vkms_connector_static_cfg_release(), config->connectors still holds its
reference when vkms_destroy(config) runs unless the connector or config is
destroyed first, so this test only repeats a single iteration of
vkms_lifecycle_test_create_destroy_default().
[ ... ]
> diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
> index 24572bc779b41..f73f136e5588e 100644
> --- a/drivers/gpu/drm/vkms/vkms_drv.c
> +++ b/drivers/gpu/drm/vkms/vkms_drv.c
[ ... ]
> @@ -252,6 +253,7 @@ static int __init vkms_init(void)
>
> return 0;
> }
> +EXPORT_SYMBOL_IF_KUNIT(vkms_create);
[Severity: Low]
This isn't a bug, but EXPORT_SYMBOL_IF_KUNIT(vkms_create) is placed after
vkms_init() instead of right after vkms_create().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=12
^ permalink raw reply [flat|nested] 81+ messages in thread* Re: [PATCH v7 12/43] drm/vkms: Add KUnit test for device lifecycle
2026-11-26 11:28 ` [PATCH v7 12/43] drm/vkms: Add KUnit test for device lifecycle Louis Chauvet
2026-11-26 11:55 ` sashiko-bot
@ 2026-11-27 10:24 ` Oarora Etimis
1 sibling, 0 replies; 81+ messages in thread
From: Oarora Etimis @ 2026-11-27 10:24 UTC (permalink / raw)
To: Louis Chauvet
Cc: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Harry Wentland, Lucas De Marchi,
Ville Syrjälä, Randy Dunlap, Nick Desaulniers,
Shuah Khan, Miguel Ojeda, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Luca Ceresoli, Kory Maincent,
sebastian.wick, victoria, thomas.petazzoni, dri-devel,
linux-kernel, linux-doc, llvm
On Thu, Nov 26, 2026 at 12:28:55PM +0100, Louis Chauvet wrote:
> 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
>
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
^ permalink raw reply [flat|nested] 81+ 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-27 10:36 ` Oarora Etimis
2026-11-26 11:28 ` [PATCH v7 14/43] drm/vkms: Simplify plane_release code Louis Chauvet
` (29 subsequent siblings)
42 siblings, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 13/43] drm/vkms: Add error handling in plane config creation
2026-11-26 11:28 ` [PATCH v7 13/43] drm/vkms: Add error handling in plane config creation Louis Chauvet
@ 2026-11-27 10:36 ` Oarora Etimis
0 siblings, 0 replies; 81+ messages in thread
From: Oarora Etimis @ 2026-11-27 10:36 UTC (permalink / raw)
To: Louis Chauvet
Cc: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Harry Wentland, Lucas De Marchi,
Ville Syrjälä, Randy Dunlap, Nick Desaulniers,
Shuah Khan, Miguel Ojeda, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Luca Ceresoli, Kory Maincent,
sebastian.wick, victoria, thomas.petazzoni, dri-devel,
linux-kernel, linux-doc, llvm
On Thu, Nov 26, 2026 at 12:28:56PM +0100, Louis Chauvet wrote:
> 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
>
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
^ permalink raw reply [flat|nested] 81+ 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; 81+ 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 related [flat|nested] 81+ 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-27 10:40 ` Oarora Etimis
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, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 15/43] drm/vkms: Explicitly display plane type
2026-11-26 11:28 ` [PATCH v7 15/43] drm/vkms: Explicitly display plane type Louis Chauvet
@ 2026-11-27 10:40 ` Oarora Etimis
0 siblings, 0 replies; 81+ messages in thread
From: Oarora Etimis @ 2026-11-27 10:40 UTC (permalink / raw)
To: Louis Chauvet
Cc: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Harry Wentland, Lucas De Marchi,
Ville Syrjälä, Randy Dunlap, Nick Desaulniers,
Shuah Khan, Miguel Ojeda, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Luca Ceresoli, Kory Maincent,
sebastian.wick, victoria, thomas.petazzoni, dri-devel,
linux-kernel, linux-doc, llvm, José Expósito
On Thu, Nov 26, 2026 at 12:28:58PM +0100, Louis Chauvet wrote:
> 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
>
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
^ permalink raw reply [flat|nested] 81+ 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-27 10:41 ` Oarora Etimis
2026-11-26 11:29 ` [PATCH v7 17/43] drm/vkms: Introduce config for plane name Louis Chauvet
` (26 subsequent siblings)
42 siblings, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 16/43] drm/vkms: Use enabled/disabled instead of 1/0 for debug
2026-11-26 11:28 ` [PATCH v7 16/43] drm/vkms: Use enabled/disabled instead of 1/0 for debug Louis Chauvet
@ 2026-11-27 10:41 ` Oarora Etimis
0 siblings, 0 replies; 81+ messages in thread
From: Oarora Etimis @ 2026-11-27 10:41 UTC (permalink / raw)
To: Louis Chauvet
Cc: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Harry Wentland, Lucas De Marchi,
Ville Syrjälä, Randy Dunlap, Nick Desaulniers,
Shuah Khan, Miguel Ojeda, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Luca Ceresoli, Kory Maincent,
sebastian.wick, victoria, thomas.petazzoni, dri-devel,
linux-kernel, linux-doc, llvm, José Expósito
On Thu, Nov 26, 2026 at 12:28:59PM +0100, Louis Chauvet wrote:
> 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
>
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
^ permalink raw reply [flat|nested] 81+ 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:48 ` sashiko-bot
2026-11-27 11:39 ` Oarora Etimis
2026-11-26 11:29 ` [PATCH v7 18/43] drm/vkms: Use plane folder name as " Louis Chauvet
` (25 subsequent siblings)
42 siblings, 2 replies; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 17/43] drm/vkms: Introduce config for plane name
2026-11-26 11:29 ` [PATCH v7 17/43] drm/vkms: Introduce config for plane name Louis Chauvet
@ 2026-11-26 11:48 ` sashiko-bot
2026-11-27 11:39 ` Oarora Etimis
1 sibling, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:48 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] drm/vkms: missing rcu_barrier() on module exit after
call_rcu() in destroy
- [Low] drm/vkms: missing @name_len in vkms_config_plane_set_name()
kernel-doc
- [Low] drm/vkms: duplicate include of vkms_config.h in vkms_plane.c
--
commit f9614f6973483389b18d752f2c6d793287063437
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Introduce config for plane name
This commit adds plane name configuration support to vkms_config_plane and
passes the configured name to drmm_universal_plane_alloc() during plane
initialization.
> diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
> index e2b6567238987..56ab9ea6e1410 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.c
> +++ b/drivers/gpu/drm/vkms/vkms_config.c
[ ... ]
> @@ -436,25 +439,57 @@ struct vkms_config_plane __must_check *vkms_config_create_plane(struct vkms_conf
[ ... ]
> +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);
[Severity: Medium]
Can vkms_config_plane_rcu_free() run after the vkms module is unloaded?
Replacing kfree_rcu() with call_rcu() queues a callback located in the
vkms module text. When the module is unloaded, vkms_exit() drops the
last reference to default_config:
drivers/gpu/drm/vkms/vkms_drv.c:vkms_exit() {
...
vkms_destroy(default_config);
vkms_config_put(default_config);
}
vkms_config_put() -> vkms_config_release() -> vkms_config_destroy_plane()
queues vkms_config_plane_rcu_free() right before vkms_exit() returns,
without an rcu_barrier() to wait for pending callbacks before module text
is unmapped.
> diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
> index 8f038562afd4d..e428946cb70ea 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.h
> +++ b/drivers/gpu/drm/vkms/vkms_config.h
[ ... ]
> @@ -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);
[Severity: Low]
The kernel-doc comment for vkms_config_plane_set_name() is missing an
entry for @name_len.
> diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
> index fd3d34dcf0fe5..35aabec85b332 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"
[Severity: Low]
This isn't a bug, but vkms_plane.c already includes "vkms_config.h" at
the top of the file.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=17
^ permalink raw reply [flat|nested] 81+ messages in thread* Re: [PATCH v7 17/43] drm/vkms: Introduce config for plane name
2026-11-26 11:29 ` [PATCH v7 17/43] drm/vkms: Introduce config for plane name Louis Chauvet
2026-11-26 11:48 ` sashiko-bot
@ 2026-11-27 11:39 ` Oarora Etimis
1 sibling, 0 replies; 81+ messages in thread
From: Oarora Etimis @ 2026-11-27 11:39 UTC (permalink / raw)
To: Louis Chauvet
Cc: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Harry Wentland, Lucas De Marchi,
Ville Syrjälä, Randy Dunlap, Nick Desaulniers,
Shuah Khan, Miguel Ojeda, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Luca Ceresoli, Kory Maincent,
sebastian.wick, victoria, thomas.petazzoni, dri-devel,
linux-kernel, linux-doc, llvm
Hello,
vkms_config_destroy_plane() frees the plane through call_rcu() and
vkms_config_plane_rcu_free(), which is module text. vkms_exit() has no
rcu_barrier(), so a queued callback can still run after the module is
unloaded.
Thank you,
Oarora Etimis
^ permalink raw reply [flat|nested] 81+ 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-27 11:40 ` Oarora Etimis
2026-11-26 11:29 ` [PATCH v7 19/43] drm/vkms: Introduce config for plane rotation Louis Chauvet
` (24 subsequent siblings)
42 siblings, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 18/43] drm/vkms: Use plane folder name as plane name
2026-11-26 11:29 ` [PATCH v7 18/43] drm/vkms: Use plane folder name as " Louis Chauvet
@ 2026-11-27 11:40 ` Oarora Etimis
0 siblings, 0 replies; 81+ messages in thread
From: Oarora Etimis @ 2026-11-27 11:40 UTC (permalink / raw)
To: Louis Chauvet
Cc: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Harry Wentland, Lucas De Marchi,
Ville Syrjälä, Randy Dunlap, Nick Desaulniers,
Shuah Khan, Miguel Ojeda, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Luca Ceresoli, Kory Maincent,
sebastian.wick, victoria, thomas.petazzoni, dri-devel,
linux-kernel, linux-doc, llvm
On Thu, Nov 26, 2026 at 12:29:01PM +0100, Louis Chauvet wrote:
> 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
>
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
^ permalink raw reply [flat|nested] 81+ 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:46 ` sashiko-bot
2026-12-01 15:19 ` Oarora Etimis
2026-11-26 11:29 ` [PATCH v7 20/43] drm/vkms: Introduce configfs " Louis Chauvet
` (23 subsequent siblings)
42 siblings, 2 replies; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 19/43] drm/vkms: Introduce config for plane rotation
2026-11-26 11:29 ` [PATCH v7 19/43] drm/vkms: Introduce config for plane rotation Louis Chauvet
@ 2026-11-26 11:46 ` sashiko-bot
2026-12-01 15:19 ` Oarora Etimis
1 sibling, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:46 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/vkms: kernel-doc mismatch for supported_rotations in
vkms_config_plane
--
commit 870fc41a500e6a65ad8b80b4adbcbf45c3cc0ac6
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Introduce config for plane rotation
This commit adds configuration helpers and validation for per-plane
default and supported rotations in VKMS.
> diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
> index e428946cb70ea..8587a4a28b199 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;
[Severity: Low]
The kernel-doc tag uses @supported_rotation (singular) while the struct
member is named supported_rotations (plural), which causes
scripts/kernel-doc to warn about an excess description and an undescribed
member.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=19
^ permalink raw reply [flat|nested] 81+ messages in thread* Re: [PATCH v7 19/43] drm/vkms: Introduce config for plane rotation
2026-11-26 11:29 ` [PATCH v7 19/43] drm/vkms: Introduce config for plane rotation Louis Chauvet
2026-11-26 11:46 ` sashiko-bot
@ 2026-12-01 15:19 ` Oarora Etimis
1 sibling, 0 replies; 81+ messages in thread
From: Oarora Etimis @ 2026-12-01 15:19 UTC (permalink / raw)
To: Louis Chauvet
Cc: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Harry Wentland, Lucas De Marchi,
Ville Syrjälä, Randy Dunlap, Nick Desaulniers,
Shuah Khan, Miguel Ojeda, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Luca Ceresoli, Kory Maincent,
sebastian.wick, victoria, thomas.petazzoni, dri-devel,
linux-kernel, linux-doc, llvm
On Thu, Nov 26, 2026 at 12:29:02PM +0100, Louis Chauvet wrote:
> 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
>
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
^ permalink raw reply [flat|nested] 81+ 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-12-01 15:27 ` Oarora Etimis
2026-11-26 11:29 ` [PATCH v7 21/43] drm/vkms: Introduce config for plane color encoding Louis Chauvet
` (22 subsequent siblings)
42 siblings, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 20/43] drm/vkms: Introduce configfs for plane rotation
2026-11-26 11:29 ` [PATCH v7 20/43] drm/vkms: Introduce configfs " Louis Chauvet
@ 2026-12-01 15:27 ` Oarora Etimis
0 siblings, 0 replies; 81+ messages in thread
From: Oarora Etimis @ 2026-12-01 15:27 UTC (permalink / raw)
To: Louis Chauvet
Cc: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Harry Wentland, Lucas De Marchi,
Ville Syrjälä, Randy Dunlap, Nick Desaulniers,
Shuah Khan, Miguel Ojeda, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Luca Ceresoli, Kory Maincent,
sebastian.wick, victoria, thomas.petazzoni, dri-devel,
linux-kernel, linux-doc, llvm
On Thu, Nov 26, 2026 at 12:29:03PM +0100, Louis Chauvet wrote:
> 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
>
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
^ permalink raw reply [flat|nested] 81+ 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:48 ` sashiko-bot
2026-12-01 16:59 ` Oarora Etimis
2026-11-26 11:29 ` [PATCH v7 22/43] drm/vkms: Introduce configfs " Louis Chauvet
` (21 subsequent siblings)
42 siblings, 2 replies; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 21/43] drm/vkms: Introduce config for plane color encoding
2026-11-26 11:29 ` [PATCH v7 21/43] drm/vkms: Introduce config for plane color encoding Louis Chauvet
@ 2026-11-26 11:48 ` sashiko-bot
2026-12-01 16:59 ` Oarora Etimis
1 sibling, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:48 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/vkms: __nocfi indirect call to CFI function in
show_bitfield()
- [Low] drm/vkms: shift-out-of-bounds in show_bitfield() loop condition
--
commit d7f3545cf9bb01180602070fd069bfa2db6fb425
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Introduce config for plane color encoding
This commit adds configuration helpers, validation, debugfs reporting, and
KUnit tests to configure supported and default color encodings per VKMS
plane.
> diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
> index d4f15f1c53b06..90cc28f3d3860 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.c
> +++ b/drivers/gpu/drm/vkms/vkms_config.c
[ ... ]
> @@ -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) {
[Severity: Low]
Does this loop condition evaluate BIT(offset) before checking offset < 32?
On 32-bit architectures, if bit 31 is set in value, offset reaches 32 and
BIT(32) shifts out of bounds; on 64-bit architectures, BIT(32) exceeds
any uint32_t value, making offset < 32 dead code.
> + 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)
> {
[ ... ]
> @@ -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);
[Severity: Medium]
Can calling drm_get_color_encoding_name() indirectly from the __nocfi
show_bitfield() helper fault under FineIBT?
drm_get_color_encoding_name() takes enum drm_color_encoding rather than
unsigned int, and marking show_bitfield() __nocfi suppresses the kCFI type
hash check on callback(offset). On x86_64 with CONFIG_CFI_CLANG=y, this
triggers an objtool "no-cfi indirect call!" warning at build time, and
under FineIBT at runtime cfi_rewrite_endbr() poisons the endbr64 at
drm_get_color_encoding_name+0 while skipping the uninstrumented __nocfi
call site, causing a #CP (Missing ENDBR) kernel fault when reading the
vkms_config debugfs file.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=21
^ permalink raw reply [flat|nested] 81+ messages in thread* Re: [PATCH v7 21/43] drm/vkms: Introduce config for plane color encoding
2026-11-26 11:29 ` [PATCH v7 21/43] drm/vkms: Introduce config for plane color encoding Louis Chauvet
2026-11-26 11:48 ` sashiko-bot
@ 2026-12-01 16:59 ` Oarora Etimis
1 sibling, 0 replies; 81+ messages in thread
From: Oarora Etimis @ 2026-12-01 16:59 UTC (permalink / raw)
To: Louis Chauvet
Cc: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Harry Wentland, Lucas De Marchi,
Ville Syrjälä, Randy Dunlap, Nick Desaulniers,
Shuah Khan, Miguel Ojeda, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Luca Ceresoli, Kory Maincent,
sebastian.wick, victoria, thomas.petazzoni, dri-devel,
linux-kernel, linux-doc, llvm
On Thu, Nov 26, 2026 at 12:29:04PM +0100, Louis Chauvet wrote:
> 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)) {
Offset reaches 32 when bit 31 is set. BIT(32) is 1UL << 32, which UBSAN
reports as shift-out-of-bounds on 32-bit.
> + 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] 81+ 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:43 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 23/43] drm/vkms: Introduce config for plane color range Louis Chauvet
` (20 subsequent siblings)
42 siblings, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 22/43] drm/vkms: Introduce configfs for plane color encoding
2026-11-26 11:29 ` [PATCH v7 22/43] drm/vkms: Introduce configfs " Louis Chauvet
@ 2026-11-26 11:43 ` sashiko-bot
0 siblings, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:43 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/vkms: inaccurate COLOR_ENCODING values and attribute name in
docs
--
commit 5dbc58af236a05830b6c4e654122d665fcbe00b2
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Introduce configfs for plane color encoding
This commit adds supported_color_encodings and default_color_encoding
configfs attributes to configure the available and default color encodings
for VKMS planes, along with ABI and driver documentation.
> diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst
> index 6103054837168..7206cd2b231a0 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
[Severity: Low]
Are the bitmask values 0x01, 0x02, and 0x04 the same values as those
exposed by the plane's COLOR_ENCODING property?
Unlike the rotation property (created with drm_property_create_bitmask()),
drm_plane_create_color_properties() creates COLOR_ENCODING with
drm_property_create_enum(), exposing enum drm_color_encoding values 0, 1,
and 2 rather than bitmasks 0x01, 0x02, and 0x04.
Also, the commit message refers to the attribute as
supported_color_encoding (singular), whereas CONFIGFS_ATTR(plane_,
supported_color_encodings) and the documentation define it as
supported_color_encodings (plural). (Note that the forward reference to
supported_color_range here is updated to supported_color_ranges in the
follow-up commit "drm/vkms: Introduce configfs for plane color range" later
in this series.)
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=22
^ permalink raw reply [flat|nested] 81+ 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; 81+ 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 related [flat|nested] 81+ 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:45 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 25/43] drm/vkms: Introduce config for plane format Louis Chauvet
` (18 subsequent siblings)
42 siblings, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 24/43] drm/vkms: Introduce configfs for plane color range
2026-11-26 11:29 ` [PATCH v7 24/43] drm/vkms: Introduce configfs " Louis Chauvet
@ 2026-11-26 11:45 ` sashiko-bot
0 siblings, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:45 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] drm/vkms: plane_supported_color_ranges_store() rejects 0
bitmask
- [Medium] drm/vkms: plane_default_color_range_store() rejects hex
bitmasks via base 10
- [Low] drm/vkms: type mismatch in plane_default_color_range_store()
kstrtouint() call
--
commit 43491ccf15c9b0119d0720030c6887bb6debdc75
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Introduce configfs for plane color range
This commit adds supported_color_ranges and default_color_range configfs
attributes for VKMS planes and documents them.
> diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
> index c6efc6db64c46..a746fb5e22a37 100644
> --- a/drivers/gpu/drm/vkms/vkms_configfs.c
> +++ b/drivers/gpu/drm/vkms/vkms_configfs.c
[ ... ]
> @@ -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;
[Severity: Medium]
Should plane_supported_color_ranges_store() allow writing 0 to disable the
COLOR_RANGE property?
vkms_config_create_plane() initializes supported_color_ranges to a non-zero
mask, and vkms_config_is_valid() requires supported_color_encodings and
supported_color_ranges to either both be set or both be 0:
drivers/gpu/drm/vkms/vkms_config.c:vkms_config_is_valid() {
...
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;
}
...
}
While plane_supported_color_encodings_store() allows writing 0, rejecting 0
here prevents userspace from disabling YCbCr color properties on a plane via
configfs, and setting supported_color_encodings to 0 leaves the device
configuration invalid.
[ ... ]
> +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;
[Severity: Low]
This isn't a runtime bug because (val & ~VKMS_SUPPORTED_COLOR_RANGES) rejects
negative values, but val is declared as a signed int while kstrtouint() takes
an unsigned int *, triggering a -Wpointer-sign mismatch.
> +
> + ret = kstrtouint(page, 10, &val);
[Severity: Medium]
Should kstrtouint() use base 0 instead of base 10 here?
Documentation/gpu/vkms.rst states that default_color_range accepts the same
values as supported_color_ranges (documented as 0x1 and 0x2), and the other
bitmask store callbacks such as plane_default_color_encoding_store() use
base 0. Passing base 10 causes hexadecimal inputs like 0x1 or 0x2 to fail
with -EINVAL.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=24
^ permalink raw reply [flat|nested] 81+ 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:46 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 26/43] drm/vkms: Introduce configfs " Louis Chauvet
` (17 subsequent siblings)
42 siblings, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 25/43] drm/vkms: Introduce config for plane format
2026-11-26 11:29 ` [PATCH v7 25/43] drm/vkms: Introduce config for plane format Louis Chauvet
@ 2026-11-26 11:46 ` sashiko-bot
0 siblings, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:46 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/vkms: malformed kernel-doc on plane format helpers in
vkms_config.h
--
commit d93bc0319c8e32277faad2010bf0ce947960f6bf
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Introduce config for plane format
This commit adds configuration helpers to customize the list of supported
pixel formats per plane in vkms_config.
> diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
> index 20369e8d7c6e3..1b353556166c1 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.h
> +++ b/drivers/gpu/drm/vkms/vkms_config.h
[ ... ]
> @@ -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);
[Severity: Low]
In the kernel-doc comment for vkms_config_plane_add_format(), the function
name is on the opening /** line instead of the next line, and the body text
precedes the @plane_cfg and @drm_format parameter descriptions, which
scripts/kernel-doc rejects. Also, the Returns description for
vkms_config_plane_add_all_formats() has a stray "by VKMS" line left over
from vkms_config_plane_add_format().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=25
^ permalink raw reply [flat|nested] 81+ 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:49 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 27/43] drm/vkms: Properly render plane using their zpos Louis Chauvet
` (16 subsequent siblings)
42 siblings, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 26/43] drm/vkms: Introduce configfs for plane format
2026-11-26 11:29 ` [PATCH v7 26/43] drm/vkms: Introduce configfs " Louis Chauvet
@ 2026-11-26 11:49 ` sashiko-bot
0 siblings, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:49 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/vkms: endianness bug in plane_supported_formats_show()
and _store()
- [Medium] drm/vkms: UAF on supported_formats in
plane_supported_formats_store()
--
commit fdd01181d213d1bc98312c36d05a5fcad23b5664
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Introduce configfs for plane format
This commit adds a configfs attribute to configure the supported pixel
formats for each VKMS plane.
> diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
> index a746fb5e22a37..9f24e9e6ed6d0 100644
> --- a/drivers/gpu/drm/vkms/vkms_configfs.c
> +++ b/drivers/gpu/drm/vkms/vkms_configfs.c
[ ... ]
> @@ -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]);
[ ... ]
> +static ssize_t plane_supported_formats_store(struct config_item *item,
> + const char *page, size_t count)
> +{
[ ... ]
> + 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);
> + }
[Severity: Medium]
Are formats[i] and fourcc byte-reversed on big-endian architectures?
fourcc_code(a, b, c, d) defines DRM format constants as host-endian u32
values with 'a' in the least significant byte. On big-endian machines,
casting &formats[i] to char * in plane_supported_formats_show() prints the
four characters in reverse order (for example, "42RA" instead of "AR24"),
and copying fmt into fourcc with memcpy() in
plane_supported_formats_store() produces a byte-swapped value that never
matches vkms_supported_plane_formats[], causing additions to fail with
-EINVAL and removals to be ignored.
Building the format code with fourcc_code(fmt[0], fmt[1], fmt[2], fmt[3])
in _store() and unpacking each byte in _show() would make this independent
of host endianness.
[Severity: Medium]
Can plane_supported_formats_store() cause a use-after-free or NULL pointer
dereference in vkms_config_show()?
vkms_config_show() reads plane_cfg->supported_formats and
plane_cfg->supported_formats_count under RCU without holding config->lock.
When device_enabled_store() disables a device, it clears dev->enabled and
drops dev->config->lock before calling vkms_destroy(), while the
vkms_config debugfs file is still registered:
CPU0 CPU1
device_enabled_store()
lock(&dev->config->lock)
dev->enabled = false
unlock(&dev->config->lock)
vkms_config_show()
rcu_read_lock()
show_formats(m,
plane_cfg->supported_formats,
plane_cfg->supported_formats_count)
plane_supported_formats_store()
lock(&dev->config->lock)
/* sees !plane->dev->enabled */
vkms_config_plane_add_format()
krealloc_array(supported_formats, ...)
unlock(&dev->config->lock)
...
seq_printf(m, ..., &formats[i])
<-- use-after-free
vkms_destroy(dev->config)
Similarly, if plane_supported_formats_store() calls
vkms_config_plane_remove_all_formats(), kfree(plane_cfg->supported_formats)
runs immediately without waiting for an RCU grace period, and a concurrent
vkms_config_show() can pass either a freed pointer or NULL with a non-zero
count to show_formats().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=26
^ permalink raw reply [flat|nested] 81+ 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-12-01 17:23 ` Oarora Etimis
2026-11-26 11:29 ` [PATCH v7 28/43] drm/vkms: Introduce config for plane zpos property Louis Chauvet
` (15 subsequent siblings)
42 siblings, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 27/43] drm/vkms: Properly render plane using their zpos
2026-11-26 11:29 ` [PATCH v7 27/43] drm/vkms: Properly render plane using their zpos Louis Chauvet
@ 2026-12-01 17:23 ` Oarora Etimis
0 siblings, 0 replies; 81+ messages in thread
From: Oarora Etimis @ 2026-12-01 17:23 UTC (permalink / raw)
To: Louis Chauvet
Cc: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Harry Wentland, Lucas De Marchi,
Ville Syrjälä, Randy Dunlap, Nick Desaulniers,
Shuah Khan, Miguel Ojeda, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Luca Ceresoli, Kory Maincent,
sebastian.wick, victoria, thomas.petazzoni, dri-devel,
linux-kernel, linux-doc, llvm
On Thu, Nov 26, 2026 at 12:29:10PM +0100, Louis Chauvet wrote:
> 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
>
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
^ permalink raw reply [flat|nested] 81+ 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:46 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 29/43] drm/vkms: Introduce configfs " Louis Chauvet
` (14 subsequent siblings)
42 siblings, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 28/43] drm/vkms: Introduce config for plane zpos property
2026-11-26 11:29 ` [PATCH v7 28/43] drm/vkms: Introduce config for plane zpos property Louis Chauvet
@ 2026-11-26 11:46 ` sashiko-bot
0 siblings, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:46 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Low] drm/vkms: missing EXPORT_SYMBOL_IF_KUNIT for
vkms_config_valid_plane_zpos()
- [Low] drm/vkms: signed %d format used for unsigned int zpos in
vkms_config_show()
- [Low] drm/vkms: missing trailing newline in drm_info() in
vkms_config_is_valid()
--
commit 95ea58aa0af1d2c1724667a97c3ee561ebede801
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Introduce config for plane zpos property
This commit adds configuration fields, accessors, validation, debugfs output,
and KUnit tests for the plane zpos property in VKMS, and creates mutable or
immutable zpos properties during plane initialization when enabled.
> diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
> index 230346e56877f..342b844bfc6d4 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.c
> +++ b/drivers/gpu/drm/vkms/vkms_config.c
[ ... ]
> @@ -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;
> +}
[Severity: Low]
Should vkms_config_valid_plane_zpos() have an
EXPORT_SYMBOL_IF_KUNIT(vkms_config_valid_plane_zpos) macro?
It is marked VISIBLE_IF_KUNIT and declared in vkms_config.h under
CONFIG_KUNIT, so calling it from vkms_config_test.c when CONFIG_DRM_VKMS and
CONFIG_DRM_VKMS_KUNIT_TEST are built as separate modules will fail to link at
modpost.
Also, unlike the sibling rotation, color encoding, and color range tests,
vkms_config_test_valid_plane_zpos() in vkms_config_test.c never calls
vkms_config_valid_plane_zpos() directly, repeats the zpos_mutable=false test
block with min=0 and max=0 instead of testing min > max while immutable, and
does not test the multi-plane mixed zpos_enabled rejection path in
vkms_config_is_valid().
> @@ -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;
> + }
[Severity: Low]
This isn't a bug, but the drm_info() format string here is missing a trailing
newline.
> @@ -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));
> }
[Severity: Low]
Should zpos_min, zpos_initial, and zpos_max be formatted with %u instead of
%d? The underlying fields and getters use unsigned int, so values above
INT_MAX are printed as negative numbers in debugfs.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=28
^ permalink raw reply [flat|nested] 81+ 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; 81+ 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 related [flat|nested] 81+ 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:55 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 31/43] drm/vkms: Introduce connector type Louis Chauvet
` (12 subsequent siblings)
42 siblings, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 30/43] drm/vkms: Introduce back pointer to connector
2026-11-26 11:29 ` [PATCH v7 30/43] drm/vkms: Introduce back pointer to connector Louis Chauvet
@ 2026-11-26 11:55 ` sashiko-bot
0 siblings, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:55 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/vkms: use-after-free of vkms_config via drmm ref in
vkms_connector_init()
- [High] drm/vkms: deadlock on config->lock in vkms_connector_detect()
on hotplug
--
commit 7fc6833db3a67c967212a1eb72d07220a1c7dbd2
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Introduce back pointer to connector
This commit stores a reference-counted pointer to vkms_config_connector in
vkms_connector, released via a drmm action on device cleanup, and uses it
in vkms_connector_detect() instead of iterating the configuration list.
> diff --git a/drivers/gpu/drm/vkms/vkms_connector.c b/drivers/gpu/drm/vkms/vkms_connector.c
> index 080a0240d5e92..bb023b5af4e43 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);
> }
[Severity: High]
Does locking cfg->config->lock here deadlock when a connector's configfs
status attribute is updated while the device is enabled?
connector_status_store() holds config->lock while calling
vkms_trigger_connector_hotplug(), which synchronously notifies the in-kernel
fbdev client and probes the connector on the same thread:
connector_status_store()
mutex_lock(&connector->dev->config->lock)
vkms_trigger_connector_hotplug()
...
drm_client_modeset_probe()
mutex_lock(&dev->mode_config.mutex)
...
vkms_connector_detect()
mutex_lock(&cfg->config->lock) <-- self-deadlock
This also inverts the lock order against normal DRM connector probing (such
as DRM_IOCTL_MODE_GETCONNECTOR), which acquires dev->mode_config.mutex
before vkms_connector_detect() takes cfg->config->lock.
> @@ -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);
[Severity: High]
Can tying connector->cfg to a drmm action cause a use-after-free of
connector_cfg->config if an open DRM file descriptor keeps struct
drm_device alive past vkms_config_destroy()?
vkms_config_connector_get() only increments connector_cfg->refcnt;
connector_cfg does not pin connector_cfg->config unless it was individually
detached via vkms_config_destroy_connector() (which sets
connector_cfg->unlinked = true and calls vkms_config_get()). In addition,
vkms_create() declares cfg with __free(vkms_config_put), so its reference on
config is dropped as soon as vkms_create() returns.
If the device and config are torn down while userspace still holds an open
DRM fd, vkms_config_release() drops the list reference on connector_cfg
(from 2 to 1) without unlinking it and frees config:
drivers/gpu/drm/vkms/vkms_config.c:vkms_config_release() {
...
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_rcu(config, rcu);
}
After that point, vkms_connector_detect() dereferences freed memory at
&cfg->config->lock. When the final drm_dev_put() later runs
vkms_connector_static_cfg_release(), vkms_config_connector_release() sees
connector_cfg->unlinked == false and executes
list_del_init(&connector_cfg->link), writing to the freed
config->connectors list head.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=30
^ permalink raw reply [flat|nested] 81+ 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-27 7:15 ` Oarora Etimis
2026-11-26 11:29 ` [PATCH v7 32/43] drm/vkms: Introduce configfs for " Louis Chauvet
` (11 subsequent siblings)
42 siblings, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 31/43] drm/vkms: Introduce connector type
2026-11-26 11:29 ` [PATCH v7 31/43] drm/vkms: Introduce connector type Louis Chauvet
@ 2026-11-27 7:15 ` Oarora Etimis
0 siblings, 0 replies; 81+ messages in thread
From: Oarora Etimis @ 2026-11-27 7:15 UTC (permalink / raw)
To: Louis Chauvet
Cc: Haneen Mohammed, Simona Vetter, Melissa Wen, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, jose.exposito89,
Jonathan Corbet, Harry Wentland, Lucas De Marchi,
Ville Syrjälä, Randy Dunlap, Nick Desaulniers,
Shuah Khan, Miguel Ojeda, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Luca Ceresoli, Kory Maincent,
sebastian.wick, victoria, thomas.petazzoni, dri-devel,
linux-kernel, linux-doc, llvm
On Thu, Nov 26, 2026 at 12:29:14PM +0100, Louis Chauvet wrote:
> 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
>
Reviewed-by: Oarora Etimis <oaroraetimis@gmail.com>
^ permalink raw reply [flat|nested] 81+ 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; 81+ 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 related [flat|nested] 81+ 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; 81+ 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 related [flat|nested] 81+ 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 11:48 ` sashiko-bot
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, 2 replies; 81+ 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 related [flat|nested] 81+ 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 11:48 ` sashiko-bot
2026-11-26 16:44 ` kernel test robot
1 sibling, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:48 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/vkms: incomplete colorspace validation in
valid_connector_colorspaces()
- [Low] drm/vkms: malformed kernel-doc parameter syntax in
vkms_connector_init()
--
commit 2738e3373c723cbcc39db7e98d237f52472fa93d
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Introduce config for connector supported colorspace
This commit adds connector colorspace configuration to VKMS and attaches
the corresponding DRM colorspace and HDR output metadata properties on
HDMI, DisplayPort, and eDP connectors.
> diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
> index b415d4bf6edb0..fa4ca256b4b91 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;
> +}
[Severity: Medium]
Can valid_connector_colorspaces() accept a colorspaces mask that later
causes vkms_connector_init() to fail with -EINVAL?
drm_mode_create_hdmi_colorspace_property() and
drm_mode_create_dp_colorspace_property() mask a non-zero
supported_colorspaces argument with hdmi_colorspaces or dp_colorspaces
before calling drm_mode_create_colorspace_property(), which rejects a
zero mask with -EINVAL. Neither mask includes
BIT(DRM_MODE_COLORIMETRY_DEFAULT), and each excludes values specific to
the other connector type (such as DRM_MODE_COLORIMETRY_RGB_WIDE_FIXED on
HDMI or DRM_MODE_COLORIMETRY_SMPTE_170M_YCC on DP). If only excluded
bits are set, vkms_config_is_valid() succeeds, but vkms_connector_init()
fails and aborts device creation; if valid and excluded bits are mixed,
vkms_config_show() reports the unsupported bits in debugfs even though
DRM strips them from the property.
> diff --git a/drivers/gpu/drm/vkms/vkms_connector.c b/drivers/gpu/drm/vkms/vkms_connector.c
> index 7264ca84f910f..552d767c3976e 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)
[Severity: Low]
This kernel-doc comment uses hyphens instead of colons after @connector
and @connector_cfg, which causes scripts/kernel-doc (W=1) to warn that
both function parameters are not described.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=34
^ permalink raw reply [flat|nested] 81+ 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 11:48 ` sashiko-bot
@ 2026-11-26 16:44 ` kernel test robot
1 sibling, 0 replies; 81+ 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] 81+ 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:50 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 36/43] drm/vkms: Introduce config for connector EDID Louis Chauvet
` (7 subsequent siblings)
42 siblings, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 35/43] drm/vkms: Introduce configfs for connector supported colorspace
2026-11-26 11:29 ` [PATCH v7 35/43] drm/vkms: Introduce configfs " Louis Chauvet
@ 2026-11-26 11:50 ` sashiko-bot
0 siblings, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:50 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/vkms: connector_supported_colorspaces_store() accepts
invalid bitmasks
- [Low] drm/vkms: connector_supported_colorspaces_store() rejects hex
bitmasks
--
commit 803cc9979c038fca8f2b7f6789254e4be3274951
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Introduce configfs for connector supported colorspace
This commit adds a supported_colorspaces configfs attribute to configure
the supported colorspaces of VKMS connectors and updates the VKMS configfs
documentation.
> diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst
> index f2622b3fd8afd..11058b6e62507 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 fef731bdb0590..7377d967be75d 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;
[Severity: Low]
Should kstrtouint() use base 0 instead of base 10 here?
Documentation/gpu/vkms.rst documents supported_colorspaces using
hexadecimal bitmasks ("0x1 = NO_DATA, 0x2 = SMPTE_170M_YCC..."), and the
plane supported_* bitmask attributes in vkms_configfs.c accept hex input,
but base 10 rejects 0x-prefixed strings with -EINVAL.
> +
> + if ((val & -BIT(DRM_MODE_COLORIMETRY_COUNT)) != 0)
> + return -EINVAL;
[Severity: Medium]
Does connector_supported_colorspaces_store() allow non-zero bitmasks that
later cause device enablement to fail in vkms_connector_init()?
Both Documentation/ABI/testing/configfs-vkms and
Documentation/gpu/vkms.rst document bit 0 (1 / 0x1 = NO_DATA) and bit 1
(2 / 0x2 = SMPTE_170M_YCC) as valid supported_colorspaces values.
However, drm_mode_create_hdmi_colorspace_property() and
drm_mode_create_dp_colorspace_property() mask non-zero supported_colorspaces
against hdmi_colorspaces (bits 1..12) and dp_colorspaces (bits 2..11 and
13..15) before calling drm_mode_create_colorspace_property(), which
automatically adds BIT(DRM_MODE_COLORIMETRY_DEFAULT) only after checking
that the masked value is non-zero.
As a result, setting supported_colorspaces to 1 on any connector (or to
an HDMI-only bit such as 2 on a DP/eDP connector) succeeds here and passes
valid_connector_colorspaces(), but enabling the device fails in
drm_mode_create_colorspace_property() with drm_err("No supported
colorspaces provded...") and -EINVAL.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=35
^ permalink raw reply [flat|nested] 81+ 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:51 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 37/43] drm/vkms: Introduce configfs " Louis Chauvet
` (6 subsequent siblings)
42 siblings, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 36/43] drm/vkms: Introduce config for connector EDID
2026-11-26 11:29 ` [PATCH v7 36/43] drm/vkms: Introduce config for connector EDID Louis Chauvet
@ 2026-11-26 11:51 ` sashiko-bot
0 siblings, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:51 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] drm/vkms: sleeping in RCU read-side critical section in
vkms_conn_get_modes()
- [Medium] drm/vkms: pointer signedness mismatch in
vkms_config_connector_get_edid()
- [Low] drm/vkms: direct __rcu pointer dereference in
vkms_config_connector_release()
- [Low] drm/vkms: inaccurate kernel-doc for edid_enabled in
vkms_config_connector
--
commit 2562fe9d046d1f1711056464ad1f96e4ee4649be
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Introduce config for connector EDID
This commit adds RCU-protected EDID configuration to vkms_config_connector
and updates vkms_conn_get_modes() to read the configured EDID when enabled.
> diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
> index fa4ca256b4b91..173e88122bcb1 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.c
> +++ b/drivers/gpu/drm/vkms/vkms_config.c
[ ... ]
> @@ -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);
> }
[Severity: Low]
connector_cfg->edid is annotated with __rcu, so dereferencing
&connector_cfg->edid->rcu directly without rcu_dereference_protected()
triggers a Sparse noderef warning, unlike vkms_config_connector_set_edid()
below. Also, because vkms_config_edid_free() is a module function queued
via call_rcu(), unloading the module immediately after vkms_exit() drops
default_config could race with an in-flight callback unless vkms_exit()
calls rcu_barrier() or struct vkms_config_edid embeds the data as a
flexible array freed with kfree_rcu().
[ ... ]
> diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
> index 341e0638b5087..ef8de0316b94c 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.
[Severity: Low]
This isn't a bug, but the kernel-doc for @edid_enabled says it controls
creating the EDID property, whereas the EDID property is always attached
and edid_enabled instead controls whether vkms_conn_get_modes() exposes
the configured EDID.
[ ... ]
> +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);
[Severity: Medium]
Should the len parameter of vkms_config_connector_get_edid() be
unsigned int * instead of int *?
struct vkms_config_edid.edid_len and vkms_config_connector_set_edid() both
use unsigned int, and vkms_connector_read_block() passes &edid_len of type
unsigned int *, which triggers a -Wpointer-sign compiler warning (and a
build failure under CONFIG_WERROR=y).
> diff --git a/drivers/gpu/drm/vkms/vkms_connector.c b/drivers/gpu/drm/vkms/vkms_connector.c
> index 552d767c3976e..71a0ae15be653 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();
[Severity: High]
Does holding rcu_read_lock() across drm_edid_read_custom(),
drm_edid_connector_update(), and drm_edid_connector_add_modes() sleep in
an RCU read-side critical section?
All three helpers perform GFP_KERNEL allocations and acquire sleeping
mutexes: for example, drm_edid_read_custom() -> _drm_do_get_edid() takes
mutex_lock(&connector->edid_override_mutex) in drm_edid_override_get() and
allocates the EDID buffer with kmalloc(..., GFP_KERNEL). Also, because
vkms_connector_read_block() calls vkms_config_connector_get_edid() on each
128-byte block, a concurrent vkms_config_connector_set_edid() can swap the
RCU pointer between block 0 and extension blocks, causing a torn read.
Instead of drm_edid_read_custom(), could this snapshot the buffer under
rcu_read_lock() or pass the snapshot to drm_edid_alloc() outside the RCU
read-side critical section?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=36
^ permalink raw reply [flat|nested] 81+ 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:59 ` sashiko-bot
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, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 37/43] drm/vkms: Introduce configfs for connector EDID
2026-11-26 11:29 ` [PATCH v7 37/43] drm/vkms: Introduce configfs " Louis Chauvet
@ 2026-11-26 11:59 ` sashiko-bot
0 siblings, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:59 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] drm/vkms: self-deadlock on config->lock in connector EDID store
callbacks
- [High] drm/vkms: sleeping allocations under rcu_read_lock() in
vkms_conn_get_modes()
- [Medium] drm/vkms: race with device_enabled_store() passes NULL dev on
EDID store
- [Medium] drm/vkms: CONFIGFS_ATTR for connector edid truncates 4K EDID
and blocks clear
--
commit 08c0713c865d891af6ca094b53a173337d1d80d5
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Introduce configfs for connector EDID
This commit adds the edid_enabled and edid configfs attributes to configure
connector EDID data and trigger a connector hotplug when updated.
> diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
> index 7377d967be75d..32ac4d7c41944 100644
> --- a/drivers/gpu/drm/vkms/vkms_configfs.c
> +++ b/drivers/gpu/drm/vkms/vkms_configfs.c
[ ... ]
> @@ -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);
> + }
[Severity: High]
Does calling vkms_trigger_connector_hotplug() under
connector->dev->config->lock self-deadlock on config->lock (both here and in
connector_edid_store() below)?
vkms_create() registers in-kernel DRM clients with drm_client_setup(), so
hotplug notification probes the connector synchronously on the same task:
connector_edid_enabled_store()
mutex_lock(&connector->dev->config->lock)
vkms_trigger_connector_hotplug()
drm_kms_helper_hotplug_event()
drm_client_dev_hotplug()
...
drm_client_modeset_probe()
drm_helper_probe_single_connector_modes()
drm_helper_probe_detect()
vkms_connector_detect()
mutex_lock(&cfg->config->lock) <-- deadlocks
This also inverts the mode_config.mutex -> mode_config.connection_mutex ->
config->lock hierarchy used during normal connector probing. Dropping
config->lock before calling vkms_trigger_connector_hotplug() avoids the
deadlock.
[Severity: Medium]
Can connector->dev->config->dev still be NULL or unregistered when
connector->dev->enabled is true here and in connector_edid_store()?
device_enabled_store() sets dev->enabled = true and releases
dev->config->lock before calling vkms_create(dev->config):
CPU0 CPU1
device_enabled_store()
mutex_lock(&dev->config->lock)
dev->enabled = true
mutex_unlock(&dev->config->lock)
connector_edid_enabled_store()
mutex_lock(&dev->config->lock)
if (connector->dev->enabled && ...)
vkms_trigger_connector_hotplug(NULL)
drm_kms_helper_hotplug_event()
<-- NULL pointer dereference
vkms_create(dev->config)
[Severity: High]
When connector_edid_enabled_store() sets edid_enabled to true and triggers
mode probing, does vkms_conn_get_modes() sleep inside an RCU read-side
critical section?
connector_edid_enabled_store() is the first caller of
vkms_config_connector_set_edid_enabled(), activating the edid_enabled branch
in vkms_conn_get_modes():
drivers/gpu/drm/vkms/vkms_connector.c:vkms_conn_get_modes() {
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();
}
}
drm_edid_read_custom(), drm_edid_connector_update(), and
drm_edid_connector_add_modes() all perform GFP_KERNEL allocations and acquire
sleeping mutexes (such as connector->edid_override_mutex,
connector->eld_mutex, and dev->mode_config.blob_lock). Taking rcu_read_lock()
only inside vkms_connector_read_block() while dereferencing and copying the
EDID block would avoid sleeping under RCU.
> + 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);
[Severity: Medium]
Should edid be registered with CONFIGFS_BIN_ATTR() instead of
CONFIGFS_ATTR()?
Because CONFIGFS_ATTR() uses configfs text attribute handling
(SIMPLE_ATTR_SIZE == 4096):
1. fill_write_buffer() accepts at most SIMPLE_ATTR_SIZE - 1 (4095) bytes so
it can append a trailing NUL. Writing a 4096-byte (32-block) EDID truncates
the last checksum byte on the first write, and if userspace writes the
remaining 1 byte in a second write() call, connector_edid_store() replaces
the entire EDID with a 1-byte buffer.
2. The ABI documentation says writing zero bytes clears the EDID, and
vkms_config_connector_set_edid() checks for !len, but vfs_write() and
configfs_write_iter() never invoke .store() when count == 0, nor on
O_TRUNC, making the !len clear path unreachable.
3. In connector_edid_show(), copy_len is clamped to PAGE_SIZE rather than
SIMPLE_ATTR_SIZE (4096), which triggers WARN_ON_ONCE(count >
SIMPLE_ATTR_SIZE) and returns -EIO in fill_read_buffer() on architectures
with PAGE_SIZE > 4096.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=37
^ permalink raw reply [flat|nested] 81+ 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; 81+ 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 related [flat|nested] 81+ 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; 81+ 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 related [flat|nested] 81+ 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 12:05 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 41/43] drm/vkms: Introduce configfs for dynamic connector creation Louis Chauvet
` (2 subsequent siblings)
42 siblings, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 40/43] drm/vkms: Allow to hot-add connectors
2026-11-26 11:29 ` [PATCH v7 40/43] drm/vkms: Allow to hot-add connectors Louis Chauvet
@ 2026-11-26 12:05 ` sashiko-bot
0 siblings, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 12:05 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 8 potential
issues to consider:
- [High] drm/vkms: dynamic create/destroy of colorspace_property causes
UAF and WARN_ON
- [High] drm/vkms: ERR_PTR or dangling connector_cfg->connector
dereferenced in configfs
- [High] drm/vkms: lock inversion and race between mode_config.mutex and
config->lock
- [High] drm/vkms: missing unregistered check in vkms_connector_detect()
leaks connectors
- [High] drm/vkms: AB-BA deadlock in vkms_connector_hot_remove() on
mode_config.mutex
- [Medium] drm/vkms: vkms_connector_hot_attach_encoder() hits WARN_ON on
active connector
- [Medium] drm/vkms: unlocked RCU list and XArray traversal in
vkms_output_init()
- [Medium] drm/vkms: unsynchronized runtime mutation of
connector->base.possible_encoders
--
commit 972205cf7741df00d32510d0edacb3bc8edd0c9e
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Allow to hot-add connectors
This commit adds helpers to hot-add and hot-remove dynamic VKMS
connectors and attach or detach their possible encoders at runtime.
> diff --git a/drivers/gpu/drm/vkms/vkms_connector.c b/drivers/gpu/drm/vkms/vkms_connector.c
> index 71a0ae15be653..93bceba0a1ae6 100644
> --- a/drivers/gpu/drm/vkms/vkms_connector.c
> +++ b/drivers/gpu/drm/vkms/vkms_connector.c
[ ... ]
> @@ -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;
> + }
[Severity: High]
Can connector->colorspace_property be created and destroyed dynamically
while the DRM device is registered?
struct drm_property is a non-refcounted modeset object (free_cb is NULL)
linked into dev->mode_config.property_list without any lock. When
vkms_connector_hot_add() calls vkms_connector_init() after
drm_dev_register() on an HDMI, DisplayPort or eDP connector with
supported_colorspaces set, drm_property_create() hits
WARN_ON(!dev->driver->load && dev->registered && !obj_free_cb) in
__drm_mode_object_add() and performs an unlocked list_add_tail() on
dev->mode_config.property_list.
When the dynamic connector is destroyed, calling drm_property_destroy()
here hits the matching WARN_ON in drm_mode_object_unregister(), does an
unlocked list_del() on dev->mode_config.property_list, and frees the
property while a concurrent drm_mode_getproperty_ioctl() can be reading
property->values and property->enum_list without a reference:
CPU0 CPU1
drm_mode_getproperty_ioctl()
property = drm_property_find(...)
vkms_connector_hot_remove()
drm_connector_put()
vkms_connector_dynamic_destroy()
drm_property_destroy(property)
kfree(property)
copy_to_user(..., property->values) <-- use-after-free
In addition, if a dynamic connector reference outlives the connector loop
in drm_mode_config_cleanup() during device teardown,
drm_mode_config_cleanup() frees every property on property_list without
clearing connector->colorspace_property, and the later
vkms_connector_dynamic_destroy() double frees it.
> +
> + drm_connector_cleanup(connector);
> +
> + if (vkms_connector->cfg)
> + vkms_config_connector_put(vkms_connector->cfg);
> + kfree(vkms_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);
[Severity: High]
Does calling drm_connector_unregister() under mode_config.mutex cause an
ABBA deadlock with the connector's sysfs attributes?
drm_connector_unregister() calls drm_sysfs_connector_remove() ->
device_unregister(connector->kdev), which waits in kernfs_drain() for
active sysfs reads or writes on that connector to complete, while sysfs
callbacks such as modes_show(), status_store() and edid_show() acquire
dev->mode_config.mutex:
CPU0 CPU1
---- ----
lock(&dev->mode_config.mutex)
kernfs_fop_read_iter() (kn->active)
lock(&dev->mode_config.mutex)
kernfs_drain() (waits kn->active)
*** DEADLOCK ***
CPU0: vkms_connector_hot_remove() -> drm_connector_unregister() ->
drm_sysfs_connector_remove() -> device_unregister()
CPU1: vfs_read() -> modes_show()
Calling drm_connector_unregister() before acquiring mode_config.mutex
avoids this inversion.
> +
> + /*
> + * 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);
[Severity: High]
How do vkms_connector_hot_add() and vkms_connector_hot_remove() serialize
with config->lock?
During connector probing, drm_mode_getconnector() holds
dev->mode_config.mutex and calls vkms_connector_detect(), which acquires
cfg->config->lock, establishing the lock order mode_config.mutex ->
config->lock. If vkms_connector_hot_add() or vkms_connector_hot_remove()
is called while holding config->lock, acquiring mode_config.mutex inside
these functions inverts that order:
CPU0 CPU1
---- ----
lock(&config->lock)
lock(&dev->mode_config.mutex)
lock(&dev->mode_config.mutex)
lock(&config->lock)
*** DEADLOCK ***
CPU0: configfs hot-add / hot-remove -> vkms_connector_hot_add()
CPU1: drm_mode_getconnector() -> ... -> vkms_connector_detect()
Conversely, if vkms_connector_hot_remove() is called without config->lock,
clearing connector->cfg->connector under mode_config.mutex races with
connector_possible_encoders_drop_link(), which reads and dereferences
connector->config->connector under config->lock without holding
mode_config.mutex:
CPU0 CPU1
vkms_connector_hot_remove() connector_possible_encoders_drop_link()
lock(&config->lock)
conn = connector->config->connector
lock(&mode_config.mutex)
connector->cfg->connector = NULL
unlock(&mode_config.mutex)
drm_connector_put()
kfree(connector)
vkms_connector_hot_detach_encoder(conn)
<-- use-after-free
> +
> + drm_connector_put(&connector->base);
> +}
[Severity: High]
Does hot-removing a connected dynamic connector leak the drm_connector and
its connector_ida slot?
When a dynamic connector has an active modeset, references to
connector->base are held by its connector state and by the in-kernel DRM
client. vkms_connector_hot_remove() calls drm_connector_unregister() and
keeps connector->cfg non-NULL, but vkms_connector_detect() does not check
drm_connector_is_unregistered():
drivers/gpu/drm/vkms/vkms_connector.c:vkms_connector_detect() {
...
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;
}
Subsequent hotplug probes keep seeing the unregistered connector as
connector_status_connected, so clients never disable its CRTC or drop
their references, leaking the connector and exhausting the 32-connector
limit after repeated hot-removes. Checking
drm_connector_is_unregistered(connector) in vkms_connector_detect() and
returning connector_status_disconnected would allow clients to release it.
> +
> +int vkms_connector_hot_attach_encoder(struct vkms_connector *connector,
> + struct drm_encoder *encoder)
> +{
> + return drm_connector_attach_encoder(&connector->base, encoder);
> +}
[Severity: Medium]
Does vkms_connector_hot_attach_encoder() trigger a WARN_ON and fail with
-EINVAL whenever the connector has an active modeset?
drm_connector_attach_encoder() starts with:
drivers/gpu/drm/drm_connector.c:drm_connector_attach_encoder() {
if (WARN_ON(connector->encoder))
return -EINVAL;
connector->possible_encoders |= drm_encoder_mask(encoder);
return 0;
}
When a modeset is active on the connector (for instance via the in-kernel
fbdev client), drm_atomic_helper_update_legacy_modeset_state() sets
connector->encoder = new_conn_state->best_encoder, so hot-attaching
another encoder at runtime hits WARN_ON(connector->encoder) and fails.
> +
> +int vkms_connector_hot_detach_encoder(struct vkms_connector *connector,
> + struct drm_encoder *encoder)
> +{
> + return drm_connector_detach_encoder(&connector->base, encoder);
> +}
[Severity: Medium]
Can mutating connector->base.possible_encoders on a registered connector
race with drm_mode_getconnector() and write past the userspace encoder
buffer?
drm_mode_getconnector() computes encoders_count from
connector->possible_encoders without any lock, checks that the userspace
buffer has space for encoders_count entries, and then re-reads
connector->possible_encoders in drm_connector_for_each_possible_encoder():
CPU0 CPU1
drm_mode_getconnector()
encoders_count = hweight32(
connector->possible_encoders)
if (out_resp->count_encoders >=
encoders_count)
vkms_connector_hot_attach_encoder()
connector->possible_encoders |= ...
drm_connector_for_each_possible_encoder()
put_user(..., encoder_ptr + copied) <-- writes past count_encoders
> diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c
> index fb30cffc10ef8..b100ed0c91e6b 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) {
[Severity: Medium]
Doesn't vkms_config_for_each_connector_dynamic() trigger an RCU lockdep
warning here and race with concurrent configfs removals?
vkms_config_for_each_connector_dynamic() expands to
list_for_each_entry_rcu() with the lockdep condition
lockdep_is_held(&config->lock) || !config->dev. In device_enabled_store(),
config->lock is dropped before vkms_create() sets config->dev = vkms_device
and calls vkms_output_init(), so neither config->lock nor rcu_read_lock()
is held during this loop, and vkms_connector_hot_add() sleeps while
iterating connector_cfg->possible_encoders. While config->lock is not
held, connector_release() and connector_possible_encoders_drop_link() can
concurrently unlink connector_cfg or erase entries from
connector_cfg->possible_encoders.
> + 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);
> + }
> + }
[Severity: High]
Can connector_cfg->connector be left holding an ERR_PTR or a dangling
pointer that connector_possible_encoders_drop_link() later dereferences?
If vkms_connector_hot_add() fails here, connector_cfg->connector retains a
non-NULL ERR_PTR value. Likewise, when a device is torn down via
vkms_destroy(), drm_mode_config_cleanup() destroys dynamic connectors via
vkms_connector_dynamic_destroy() without clearing
vkms_connector->cfg->connector (and if connector_cfg->enabled is later set
to false before re-enabling the device, this loop skips it and leaves the
old pointer intact).
Because connector_possible_encoders_drop_link() only tests
connector->config->connector for non-NULL before calling
vkms_connector_hot_detach_encoder(connector->config->connector,
encoder->config->encoder), unlinking an encoder in configfs can
dereference an ERR_PTR or freed vkms_connector.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=40
^ permalink raw reply [flat|nested] 81+ 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 12:02 ` sashiko-bot
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, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 41/43] drm/vkms: Introduce configfs for dynamic connector creation
2026-11-26 11:29 ` [PATCH v7 41/43] drm/vkms: Introduce configfs for dynamic connector creation Louis Chauvet
@ 2026-11-26 12:02 ` sashiko-bot
0 siblings, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 12:02 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [High] drm/vkms: lock ordering inversion in connector_enabled_store()
and release
- [High] drm/vkms: hot-attach before validation in
connector_possible_encoders_allow_link()
- [High] drm/vkms: vkms_config_is_valid() in connector_enabled_store()
blocks disable/hot-add
- [Medium] drm/vkms: static connector with enabled=0 bypasses -EBUSY
check on encoder link
- [Medium] drm/vkms: missing connector_is_enabled() check on EDID store
hotplug trigger
- [Medium] drm/vkms: race and dangling connector pointer between device
enable and dynamic configfs
--
commit fa8dad28555bc1ce76cc884bdb3e5a07d26b3e35
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Introduce configfs for dynamic connector creation
This commit adds dynamic and enabled configfs attributes to VKMS
connectors to support creating, removing, and attaching encoders to
dynamic connectors at runtime.
> diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
> index 1822978879ff3..0681722e98e8d 100644
> --- a/drivers/gpu/drm/vkms/vkms_configfs.c
> +++ b/drivers/gpu/drm/vkms/vkms_configfs.c
[ ... ]
> @@ -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);
> }
[Severity: Medium]
Should connector_edid_store() and connector_edid_enabled_store() also
check connector_is_enabled() before calling
vkms_trigger_connector_hotplug(), as connector_status_store() does?
Because a newly created dynamic connector defaults to
connector_status_connected, configuring its EDID attributes while it is
still disabled triggers a hotplug event on the device before the connector
has been hot-added.
> + 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;
> + }
[Severity: High]
Does running vkms_config_is_valid() across the whole device here prevent
enabling or disabling a dynamic connector whenever any disabled dynamic
connector has no encoder linked?
valid_connector_possible_encoders() requires every connector in
config->connectors to have at least one possible encoder, regardless of
whether it is enabled:
drivers/gpu/drm/vkms/vkms_config.c:valid_connector_possible_encoders() {
...
vkms_config_for_each_connector(config, connector_cfg) {
if (xa_empty(&connector_cfg->possible_encoders)) {
drm_info(dev,
"All connectors must have at least one possible encoder\n");
return false;
}
}
...
}
As a result, creating a new connector directory while the device is
enabled (which starts with dynamic=true, enabled=false and an empty
possible_encoders xarray) causes vkms_config_is_valid() to fail for all
connectors until that disabled connector is also given an encoder.
Similarly, if a user unlinks the encoder from a dynamic connector and then
writes 0 to enabled to remove it, connector_enabled_store() rejects the
disable with -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;
> +}
[Severity: High]
Can calling vkms_connector_hot_add() and vkms_connector_hot_remove() under
connector->dev->config->lock in connector_enabled_store() (and in
connector_release() below) cause an ABBA deadlock with connector probing?
Both vkms_connector_hot_add() and vkms_connector_hot_remove() acquire
mode_config.mutex while config->lock is held. During connector probing,
the DRM core holds mode_config.mutex and calls vkms_connector_detect(),
which takes config->lock:
CPU0 CPU1
---- ----
lock(&config->lock)
lock(&dev->mode_config.mutex)
lock(&dev->mode_config.mutex)
lock(&config->lock)
*** DEADLOCK ***
CPU0: connector_enabled_store() -> vkms_connector_hot_add()
CPU1: drm_mode_getconnector() -> ... -> vkms_connector_detect()
[Severity: Medium]
Can connector_enabled_store(), connector_release(), or
connector_possible_encoders_allow_link() race with device_enabled_store()
and dereference an uninitialized or stale connector_cfg->connector or
config->dev pointer?
device_enabled_store() sets dev->enabled = true under config->lock and
then drops the lock before calling vkms_create(). In addition, when a
device is disabled, vkms_connector_dynamic_destroy() frees the dynamic
vkms_connector without clearing connector_cfg->connector.
CPU0 CPU1
device_enabled_store()
lock(&config->lock)
dev->enabled = true
unlock(&config->lock)
connector_enabled_store()
lock(&config->lock)
if (connector->dev->enabled)
vkms_connector_hot_remove(
connector_cfg->connector)
<-- NULL or use-after-free
vkms_create()
...
connector_cfg->connector = ...
[ ... ]
> @@ -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;
[Severity: High]
Can calling vkms_connector_hot_attach_encoder() before
vkms_config_connector_attach_encoder() cause a NULL pointer dereference
when linking an encoder from another disabled VKMS device?
vkms_config_connector_attach_encoder() is what checks
connector_cfg->config != encoder_cfg->config and checks for duplicate or
failed xarray insertions. Because vkms_connector_hot_attach_encoder()
runs first, linking an encoder that belongs to a different, disabled VKMS
device passes a NULL encoder->config->encoder to
drm_connector_attach_encoder() -> drm_encoder_mask(). Even for an encoder
on the same device, if vkms_config_connector_attach_encoder() fails with
-EEXIST or -ENOMEM, the encoder bit added to the live DRM connector by
vkms_connector_hot_attach_encoder() is not rolled back.
[Severity: Medium]
Should connector_possible_encoders_allow_link() check
connector_is_enabled(connector_cfg) instead of connector_cfg->enabled?
While the device is disabled, connector_enabled_store() allows setting
connector_cfg->enabled = false on a static connector. When the device is
subsequently enabled, vkms_output_init() still registers all static
connectors, so checking connector_cfg->enabled here skips the -EBUSY check
and allows mutating connector_cfg->possible_encoders on a live static
connector.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=41
^ permalink raw reply [flat|nested] 81+ 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:56 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 43/43] drm/vkms: Add ConfigFS interface for connector parent and port_id Louis Chauvet
42 siblings, 1 reply; 81+ 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 related [flat|nested] 81+ messages in thread* Re: [PATCH v7 42/43] drm/vkms: Add connector parent configuration in vkms_config
2026-11-26 11:29 ` [PATCH v7 42/43] drm/vkms: Add connector parent configuration in vkms_config Louis Chauvet
@ 2026-11-26 11:56 ` sashiko-bot
0 siblings, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:56 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [High] drm/vkms: use-after-free on stale connector_cfg->connector
across device reset
- [Medium] drm/vkms: vkms_config_connector_get_parent() fails to detect
destroyed parent
- [Medium] drm/vkms: reference cycle leak when parent connector is
destroyed before config
- [Medium] drm/vkms: valid_connector_parents() mishandles static
connectors with enabled=0
- [Low] drm/vkms: vkms_connector_build_path_property() drops port_id at
16 nesting hops
--
commit ce654c82414edd96edaad21d3e70ad4c756954e2
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Add connector parent configuration in vkms_config
This commit adds parent connector and port_id configuration to
vkms_config_connector and populates the DRM connector PATH property to
emulate MST topologies.
> diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
> index 2c6a53d6f7783..fb6368e53c076 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.c
> +++ b/drivers/gpu/drm/vkms/vkms_config.c
[ ... ]
> @@ -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;
> +}
[Severity: Medium]
Does valid_connector_parents() mishandle static connectors whose enabled
field is false?
Static connectors (!connector_cfg->dynamic) are always created and
registered by vkms_output_init() regardless of connector_cfg->enabled, and
configfs allows writing 0 to enabled while the device is disabled. If a
static child connector has enabled == false and is attached to a disabled
dynamic parent, valid_connector_parents() skips the parent check and
vkms_output_init() registers the child with an unpopulated PATH property of
0 while its root parent is never created. Conversely, an enabled child
attached to a static parent with enabled == false is rejected.
[ ... ]
> @@ -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);
> }
[Severity: Medium]
Does destroying a parent connector before vkms_config_destroy() leak
config and its remaining objects via a reference cycle?
When vkms_config_destroy_connector(config, parent) runs while a child in
config->connectors still has child->parent == parent, it takes a reference
on config with vkms_config_get(config) that is only dropped in
vkms_config_connector_release() once parent->refcnt reaches 0. Because
child->parent keeps parent->refcnt > 0 and child->parent is only cleared
in vkms_config_release() when config->refcnt reaches 0, a subsequent
vkms_config_destroy(config) leaves config, child, and parent pinning each
other permanently.
> diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
> index e5352aaea85e6..83869e677f157 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.h
> +++ b/drivers/gpu/drm/vkms/vkms_config.h
[ ... ]
> +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;
> +}
[Severity: Medium]
Does list_empty(&parent->link) ever detect a parent destroyed by
vkms_config_destroy_connector()?
vkms_config_destroy_connector() removes the connector with list_del_rcu()
and sets parent->unlinked = true, while the child's reference keeps
parent->refcnt > 0. list_del_rcu() intentionally leaves parent->link.next
unchanged for RCU readers, so list_empty(&parent->link) evaluates to false
and vkms_config_connector_get_parent() keeps returning the destroyed
parent instead of NULL. Checking parent->unlinked avoids this.
> diff --git a/drivers/gpu/drm/vkms/vkms_connector.c b/drivers/gpu/drm/vkms/vkms_connector.c
> index 93bceba0a1ae6..5655f8b649c66 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);
> +}
[Severity: Low]
Does vkms_connector_build_path_property() drop the first child's port_id
when the chain reaches 16 levels of nesting?
The loop records current_cfg->port_id before checking whether current_cfg
is the root connector, and the formatting loop starts at port_count - 2 to
skip the root's entry. At 16 hops below the root, port_ids[0..15] fills
with the 16 child port IDs before reaching root_cfg, so starting at
port_count - 2 skips port_ids[15], which holds the first child's port_id
rather than the root's.
> +
> +/**
> + * 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);
> +}
[ ... ]
> @@ -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
[Severity: High]
Can vkms_connector_build_path_property() and
vkms_connector_update_path_properties() trigger a use-after-free on stale
connector_cfg->connector pointers when a device is disabled and
re-enabled?
When vkms_destroy() tears down a device, neither
vkms_connector_static_cfg_release() nor vkms_connector_dynamic_destroy()
clears connector_cfg->connector. On the next vkms_create() ->
vkms_output_init(), two paths dereference the freed struct vkms_connector
from the previous device instance:
1. If a dynamic child connector was enabled during the first instance and
is then disabled while the device is disabled, the next
vkms_output_init() skips it in the if (connector_cfg->enabled) loop,
leaving connector_cfg->connector pointing to the freed connector.
vkms_connector_update_path_properties() then checks only
if (connector_cfg->connector) and calls
drm_connector_set_path_property() on the freed connector.
2. If an enabled dynamic child precedes its enabled dynamic root in
config->connectors, vkms_output_init() calls vkms_connector_hot_add() on
the child before root_cfg->connector is updated for the new device, and
vkms_connector_build_path_property() reads root_connector->base.base.id
from the old freed root connector.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=42
^ permalink raw reply [flat|nested] 81+ 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 11:52 ` sashiko-bot
2026-11-26 19:49 ` kernel test robot
42 siblings, 2 replies; 81+ 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 related [flat|nested] 81+ 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 11:52 ` sashiko-bot
2026-11-26 19:49 ` kernel test robot
1 sibling, 0 replies; 81+ messages in thread
From: sashiko-bot @ 2026-11-26 11:52 UTC (permalink / raw)
To: Louis Chauvet; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/vkms: missing connector_is_enabled() check when linking
parent
- [Low] drm/vkms: missing kernel-doc for parent_group in
vkms_configfs_connector
--
commit dd9fbb5c3f8a19fd7c549287852b5449c92c86f4
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Add ConfigFS interface for connector parent and port_id
This commit adds configfs attributes and a default subgroup to configure a
connector's port_id and parent connector for DP MST topology emulation.
> diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
> index e6222db02a2e7..55de6a06ab2df 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;
> };
[Severity: Low]
struct vkms_configfs_connector has a kernel-doc comment right above it,
so adding parent_group without documenting @parent_group triggers a W=1
kernel-doc warning.
[ ... ]
> @@ -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;
> +}
[Severity: Medium]
Should this check connector_is_enabled(connector_cfg) instead of
connector_cfg->enabled, like connector_port_id_store() does?
Static connectors (!connector_cfg->dynamic) are always active when the
device is enabled even if userspace set their enabled attribute to 0 while
the device was disabled. Checking connector_cfg->enabled directly allows
linking a parent to an active static connector while the device is enabled,
mutating connector_cfg->parent on a live connector and allowing a parent
cycle to be formed on an active device.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=43
^ permalink raw reply [flat|nested] 81+ 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 11:52 ` sashiko-bot
@ 2026-11-26 19:49 ` kernel test robot
1 sibling, 0 replies; 81+ 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] 81+ messages in thread