[PATCH v7 43/43] drm/vkms: Add ConfigFS interface for connector parent and port_id
From: Louis Chauvet
Date: Thu Nov 26 2026 - 06:33:46 EST
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@xxxxxxxxxxx>
---
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@xxxxxxxxxxxxxxxxxxxxx
+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@xxxxxxxxxxxxxxxxxxxxx
@@ -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@xxxxxxxxxxxxxxxxxxxxx
+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@xxxxxxxxxxxxxxxxxxxxx
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