[PATCH v7 41/43] drm/vkms: Introduce configfs for dynamic connector creation
From: Louis Chauvet
Date: Thu Nov 26 2026 - 06:33:37 EST
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@xxxxxxxxx>
Signed-off-by: José Expósito <jose.exposito89@xxxxxxxxx>
Signed-off-by: Louis Chauvet <louis.chauvet@xxxxxxxxxxx>
---
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@xxxxxxxxxxxxxxxxxxxxx
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@xxxxxxxxxxxxxxxxxxxxx
@@ -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@xxxxxxxxxxxxxxxxxxxxx
+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@xxxxxxxxxxxxxxxxxxxxx
+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@xxxxxxxxxxxxxxxxxxxxx
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