Pass down hot-plug CONNECTOR ID to user-space
v5 cover Pass down hot-plug CONNECTOR ID to user-space
Patch series addresses a shortcoming where we're sending a hot plug event without passing the actual CONNECTOR that caused it. This takes into consideration both the polling path and the HPD (Hot Plug Detect) path. It also adds support for the vkms driver (using ConfigFS) for propagating the CONNECTOR ID when changing the connector's status.
v5:
- vkms: add support for sending the CONNECTOR ID when hot-plugging through ConfigFS - as reported by Louis, vkms can now make use of ConfigFS to simulate connector status.
- vkms: add a small change to ignore previous/old drm connector status when sending out hot-plug uevent.
v4:
- removed the "This patch" bit - Dmitry
- added a short note when the flag is set and cleared - Dmitry
- address double dead-locking detected - kbot: https://lore.kernel.org/dri-devel/[email protected]/
- virtual connectors do not seem have any kind of hotplug - added
polling in vkms - as noted by Ian
- v4 is at https://lore.kernel.org/dri-devel/[email protected]/
v3: Address comments from Dmitry
- guard connector status write with mode_config.mutex
- avoid setting up the connector status and immediately unset it. Do the
unset in drm_kms_helper_hotplug_event/drm_kms_helper_connector_hotplug_event
- v3 is at https://lore.kernel.org/dri-devel/[email protected]/
v2: Address comments from Daniel
- split patch into 2, one that introduces a bool to track connector
connection status change and a patch that uses that to be able to send
hot plug events with the proper CONNECTOR ID to udev and further pass
that down to user-space
- nuke out mutex when iterating connector list
- fix typo
- v2 is at https://lore.kernel.org/dri-devel/[email protected]/
Marius Vlad (4):
drm: Introduce a new connector status
drm: Propagate connector status change
vkms: Do not send hotplug events for same connector status
vkms: Pass the vkms connector as opposed to the vkms device
drivers/gpu/drm/drm_connector.c | 1 + drivers/gpu/drm/drm_probe_helper.c | 39 +++++++++++++++++++++++---- drivers/gpu/drm/drm_sysfs.c | 1 + drivers/gpu/drm/vkms/vkms_configfs.c | 12 +++++++-- drivers/gpu/drm/vkms/vkms_connector.c | 6 ++--- drivers/gpu/drm/vkms/vkms_connector.h | 4 +-- include/drm/drm_connector.h | 3 +++ 7 files changed, 54 insertions(+), 12 deletions(-)
Signature · 1 line
2.47.2
PATCH v5 1/4 drm: Introduce a new connector status
Introduce a new boolean variable used to track connector's connect/disconnect status and it is being used on both polling and the HPD (Hot Plug Detect) paths.
A subsequent change would make use of this connector status to propagate per-connector udev hotplug events.
The connector status is set in the drm_connector_funcs.fill_modes/vkms ConfigFS connector's status and cleared out when firing out KMS uevents.
Allows user-space to receive the connector's ID, rather than having a generic hot-plug event for all connectors, or in the HPD path, just the first one found with a connection status change.
--- drivers/gpu/drm/drm_connector.c | 1 + drivers/gpu/drm/drm_probe_helper.c | 17 +++++++++++++++++ drivers/gpu/drm/drm_sysfs.c | 1 + drivers/gpu/drm/vkms/vkms_configfs.c | 6 ++++++ include/drm/drm_connector.h | 3 +++ 5 files changed, 28 insertions(+)
drivers/gpu/drm/drm_connector.c +1 -0
@@ -274,6 +274,7 @@ static int drm_connector_init_only(struct drm_device *dev,/* provide ddc symlink in sysfs */ connector->ddc = ddc; + connector->status_changed = false;INIT_LIST_HEAD (&connector->head);INIT_LIST_HEAD (&connector->global_connector_list_entry);
drivers/gpu/drm/drm_probe_helper.c +17 -0
@@ -629,6 +629,8 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,mod_delayed_work (system_wq, &dev->mode_config.output_poll_work,0 ); + + connector->status_changed = true; }/*
@@ -732,6 +734,17 @@ EXPORT_SYMBOL(drm_helper_probe_single_connector_modes);*/ void drm_kms_helper_hotplug_event (struct drm_device *dev) { +struct drm_connector *connector; +struct drm_connector_list_iter conn_iter; + +mutex_lock (&dev->mode_config.mutex); +drm_connector_list_iter_begin (dev, &conn_iter); +drm_for_each_connector_iter (connector, &conn_iter) { + connector->status_changed = false; + } +drm_connector_list_iter_end (&conn_iter); +mutex_unlock (&dev->mode_config.mutex); +drm_sysfs_hotplug_event (dev);drm_client_dev_hotplug (dev); }
@@ -748,6 +761,10 @@ void drm_kms_helper_connector_hotplug_event(struct drm_connector *connector) {struct drm_device *dev = connector->dev; +mutex_lock (&dev->mode_config.mutex); + connector->status_changed = false; +mutex_unlock (&dev->mode_config.mutex); +drm_sysfs_connector_hotplug_event (connector);drm_client_dev_hotplug (dev); }
drivers/gpu/drm/drm_sysfs.c +1 -0
@@ -199,6 +199,7 @@ static ssize_t status_store(struct device *device,return ret; old_force = connector->force; + connector->status_changed = true;if (sysfs_streq (buf,"detect" )) connector->force =0 ;
drivers/gpu/drm/vkms/vkms_configfs.c +6 -0
@@ -537,8 +537,14 @@ static ssize_t connector_status_store(struct config_item *item, {struct vkms_configfs_connector *connector;enum drm_connector_status status; +struct vkms_connector *vkms_connector; +struct vkms_device *vkms_dev; connector =connector_item_to_vkms_configfs_connector (item); + vkms_connector = connector->config->connector; + vkms_dev = connector->config->config->dev; + scoped_guard(mutex, &vkms_dev->drm.mode_config.mutex) + vkms_connector->base.status_changed = true;if (kstrtouint (page,10 , &status))return -EINVAL ;
include/drm/drm_connector.h +3 -0
@@ -2146,6 +2146,9 @@ struct drm_connector {/** @force: a DRM_FORCE_<foo> state for forced mode sets */ enum drm_connector_force force; +/** @status_changed: if the old status doesn't match current connection status */ +bool status_changed; +/** * @edid_override: Override EDID set via debugfs. *
Signature · 1 line
2.47.2
Re: [PATCH 1/4] drm: Introduce a new connector status
Quoted 40 lines · Marius Vlad
Introduce a new boolean variable used to track connector's connect/disconnect status and it is being used on both polling and the HPD (Hot Plug Detect) paths.
A subsequent change would make use of this connector status to propagate per-connector udev hotplug events.
The connector status is set in the drm_connector_funcs.fill_modes/vkms ConfigFS connector's status and cleared out when firing out KMS uevents.
Allows user-space to receive the connector's ID, rather than having a generic hot-plug event for all connectors, or in the HPD path, just the first one found with a connection status change.
Signed-off-by Marius Vlad <[email protected]>--- drivers/gpu/drm/drm_connector.c | 1 + drivers/gpu/drm/drm_probe_helper.c | 17 +++++++++++++++++ drivers/gpu/drm/drm_sysfs.c | 1 + drivers/gpu/drm/vkms/vkms_configfs.c | 6 ++++++ include/drm/drm_connector.h | 3 +++ 5 files changed, 28 insertions(+)drivers/gpu/drm/drm_connector.c +1
-0@@ -274,6 +274,7 @@ static int drm_connector_init_only(struct drm_device *dev,/* provide ddc symlink in sysfs */ connector->ddc = ddc; + connector->status_changed = false;INIT_LIST_HEAD (&connector->head);INIT_LIST_HEAD (&connector->global_connector_list_entry);drivers/gpu/drm/drm_probe_helper.c +0
-0
drivers/gpu/drm/drm_probe_helper.c int drm_helper_probe_single_connector_modes(struct drm_connector *connector, · line 633
Quoted 5 lines
drivers/gpu/drm/drm_probe_helper.c +2
-0@@ -629,6 +629,8 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,mod_delayed_work (system_wq, &dev->mode_config.output_poll_work,0 ); + + connector->status_changed = true;
.fill_modes() gets exectued from the getconnector() ioctl which userspace issues in response to the uevent. Not the other way around. So looks like you have the chicken and egg the wrong way around here.
Quoted 79 lines
drivers/gpu/drm/drm_probe_helper.c +15
-0}/* @@ -732,6 +734,17 @@ EXPORT_SYMBOL(drm_helper_probe_single_connector_modes);*/ void drm_kms_helper_hotplug_event (struct drm_device *dev) { +struct drm_connector *connector; +struct drm_connector_list_iter conn_iter; + +mutex_lock (&dev->mode_config.mutex); +drm_connector_list_iter_begin (dev, &conn_iter); +drm_for_each_connector_iter (connector, &conn_iter) { + connector->status_changed = false; + } +drm_connector_list_iter_end (&conn_iter); +mutex_unlock (&dev->mode_config.mutex); +drm_sysfs_hotplug_event (dev);drm_client_dev_hotplug (dev); }@@ -748,6 +761,10 @@ void drm_kms_helper_connector_hotplug_event(struct drm_connector *connector) {struct drm_device *dev = connector->dev; +mutex_lock (&dev->mode_config.mutex); + connector->status_changed = false; +mutex_unlock (&dev->mode_config.mutex); +drm_sysfs_connector_hotplug_event (connector);drm_client_dev_hotplug (dev); }drivers/gpu/drm/drm_sysfs.c +1
-0@@ -199,6 +199,7 @@ static ssize_t status_store(struct device *device,return ret; old_force = connector->force; + connector->status_changed = true;if (sysfs_streq (buf,"detect" )) connector->force =0 ;drivers/gpu/drm/vkms/vkms_configfs.c +6
-0@@ -537,8 +537,14 @@ static ssize_t connector_status_store(struct config_item *item, {struct vkms_configfs_connector *connector;enum drm_connector_status status; +struct vkms_connector *vkms_connector; +struct vkms_device *vkms_dev; connector =connector_item_to_vkms_configfs_connector (item); + vkms_connector = connector->config->connector; + vkms_dev = connector->config->config->dev; + scoped_guard(mutex, &vkms_dev->drm.mode_config.mutex) + vkms_connector->base.status_changed = true;if (kstrtouint (page,10 , &status))return -EINVAL ;include/drm/drm_connector.h +3
-0@@ -2146,6 +2146,9 @@ struct drm_connector {/** @force: a DRM_FORCE_<foo> state for forced mode sets */ enum drm_connector_force force; +/** @status_changed: if the old status doesn't match current connection status */ +bool status_changed; +/** * @edid_override: Override EDID set via debugfs. * Signature · 1 line
2.47.2
Signature · 2 lines
Ville Syrjälä Intel
Re: [PATCH 1/4] drm: Introduce a new connector status
Quoted 34 lines · Ville Syrjälä
Quoted 33 lines · Marius Vlad
Introduce a new boolean variable used to track connector's connect/disconnect status and it is being used on both polling and the HPD (Hot Plug Detect) paths.
A subsequent change would make use of this connector status to propagate per-connector udev hotplug events.
The connector status is set in the drm_connector_funcs.fill_modes/vkms ConfigFS connector's status and cleared out when firing out KMS uevents.
Allows user-space to receive the connector's ID, rather than having a generic hot-plug event for all connectors, or in the HPD path, just the first one found with a connection status change.
Signed-off-by Marius Vlad <[email protected]>--- drivers/gpu/drm/drm_connector.c | 1 + drivers/gpu/drm/drm_probe_helper.c | 17 +++++++++++++++++ drivers/gpu/drm/drm_sysfs.c | 1 + drivers/gpu/drm/vkms/vkms_configfs.c | 6 ++++++ include/drm/drm_connector.h | 3 +++ 5 files changed, 28 insertions(+)drivers/gpu/drm/drm_connector.c +1
-0@@ -274,6 +274,7 @@ static int drm_connector_init_only(struct drm_device *dev,/* provide ddc symlink in sysfs */ connector->ddc = ddc; + connector->status_changed = false;
Quoted 16 lines
drivers/gpu/drm/drm_probe_helper.c int drm_helper_probe_single_connector_modes(struct drm_connector *connector, · line 633
Quoted 12 lines
drivers/gpu/drm/drm_connector.c +0
-0INIT_LIST_HEAD (&connector->head);INIT_LIST_HEAD (&connector->global_connector_list_entry);drivers/gpu/drm/drm_probe_helper.c +2
-0@@ -629,6 +629,8 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,mod_delayed_work (system_wq, &dev->mode_config.output_poll_work,0 ); + + connector->status_changed = true;.fill_modes() gets exectued from the
getconnector()ioctl which userspace issues in response to the uevent. Not the other way around. So looks like you have the chicken and egg the wrong way around here.
Oh, and we already have a connector->epoch_counter which is supposed track whether anything on the connector has changed. So I'm not sure what extra this new boolean is supposed to achieve on top of that?
Quoted 83 lines
Quoted 79 lines
drivers/gpu/drm/drm_probe_helper.c +15
-0}/* @@ -732,6 +734,17 @@ EXPORT_SYMBOL(drm_helper_probe_single_connector_modes);*/ void drm_kms_helper_hotplug_event (struct drm_device *dev) { +struct drm_connector *connector; +struct drm_connector_list_iter conn_iter; + +mutex_lock (&dev->mode_config.mutex); +drm_connector_list_iter_begin (dev, &conn_iter); +drm_for_each_connector_iter (connector, &conn_iter) { + connector->status_changed = false; + } +drm_connector_list_iter_end (&conn_iter); +mutex_unlock (&dev->mode_config.mutex); +drm_sysfs_hotplug_event (dev);drm_client_dev_hotplug (dev); }@@ -748,6 +761,10 @@ void drm_kms_helper_connector_hotplug_event(struct drm_connector *connector) {struct drm_device *dev = connector->dev; +mutex_lock (&dev->mode_config.mutex); + connector->status_changed = false; +mutex_unlock (&dev->mode_config.mutex); +drm_sysfs_connector_hotplug_event (connector);drm_client_dev_hotplug (dev); }drivers/gpu/drm/drm_sysfs.c +1
-0@@ -199,6 +199,7 @@ static ssize_t status_store(struct device *device,return ret; old_force = connector->force; + connector->status_changed = true;if (sysfs_streq (buf,"detect" )) connector->force =0 ;drivers/gpu/drm/vkms/vkms_configfs.c +6
-0@@ -537,8 +537,14 @@ static ssize_t connector_status_store(struct config_item *item, {struct vkms_configfs_connector *connector;enum drm_connector_status status; +struct vkms_connector *vkms_connector; +struct vkms_device *vkms_dev; connector =connector_item_to_vkms_configfs_connector (item); + vkms_connector = connector->config->connector; + vkms_dev = connector->config->config->dev; + scoped_guard(mutex, &vkms_dev->drm.mode_config.mutex) + vkms_connector->base.status_changed = true;if (kstrtouint (page,10 , &status))return -EINVAL ;include/drm/drm_connector.h +3
-0@@ -2146,6 +2146,9 @@ struct drm_connector {/** @force: a DRM_FORCE_<foo> state for forced mode sets */ enum drm_connector_force force; +/** @status_changed: if the old status doesn't match current connection status */ +bool status_changed; +/** * @edid_override: Override EDID set via debugfs. * Signature · 1 line
2.47.2Signature · 2 lines
Ville Syrjälä Intel
Signature · 2 lines
Ville Syrjälä Intel
Re: [PATCH 1/4] drm: Introduce a new connector status
Quoted 52 lines · Ville Syrjälä
Quoted 34 lines · Ville Syrjälä
Quoted 33 lines · Marius Vlad
Introduce a new boolean variable used to track connector's connect/disconnect status and it is being used on both polling and the HPD (Hot Plug Detect) paths.
A subsequent change would make use of this connector status to propagate per-connector udev hotplug events.
The connector status is set in the drm_connector_funcs.fill_modes/vkms ConfigFS connector's status and cleared out when firing out KMS uevents.
Allows user-space to receive the connector's ID, rather than having a generic hot-plug event for all connectors, or in the HPD path, just the first one found with a connection status change.
Signed-off-by Marius Vlad <[email protected]>--- drivers/gpu/drm/drm_connector.c | 1 + drivers/gpu/drm/drm_probe_helper.c | 17 +++++++++++++++++ drivers/gpu/drm/drm_sysfs.c | 1 + drivers/gpu/drm/vkms/vkms_configfs.c | 6 ++++++ include/drm/drm_connector.h | 3 +++ 5 files changed, 28 insertions(+)drivers/gpu/drm/drm_connector.c +1
-0@@ -274,6 +274,7 @@ static int drm_connector_init_only(struct drm_device *dev,/* provide ddc symlink in sysfs */ connector->ddc = ddc; + connector->status_changed = false;Quoted 16 lines
drivers/gpu/drm/drm_probe_helper.c int drm_helper_probe_single_connector_modes(struct drm_connector *connector, · line 633
Quoted 12 lines
drivers/gpu/drm/drm_connector.c +0
-0INIT_LIST_HEAD (&connector->head);INIT_LIST_HEAD (&connector->global_connector_list_entry);drivers/gpu/drm/drm_probe_helper.c +2
-0@@ -629,6 +629,8 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,mod_delayed_work (system_wq, &dev->mode_config.output_poll_work,0 ); + + connector->status_changed = true;.fill_modes() gets exectued from the
getconnector()ioctl which userspace issues in response to the uevent. Not the other way around. So looks like you have the chicken and egg the wrong way around here.
Quoted 3 lines
Oh, and we already have a
connector->epoch_counterwhich is supposed track whether anything on the connector has changed. So I'm not sure what extra this new boolean is supposed to achieve on top of that?
epoch_counter doesn't take all cases into consideration. For the instance the connector list loop in output_poll_execute will be a no-op if we try to simulate a hot-plug event with drm_sysfs. I suppose we could've have used it for (real) HW hot-plug.
There's a few use-cases:
- 2 with real HW hot-plug - one for polling and one for HPD
- 2 for with virtual connectors - one for VKMS and one for drm_sysfs
The bool helps to know -- in case you have multiple connectors -- which of them had a hot-plug event.
Quoted 88 lines
Quoted 84 lines
Quoted 80 lines
drivers/gpu/drm/drm_probe_helper.c +15
-0}/* @@ -732,6 +734,17 @@ EXPORT_SYMBOL(drm_helper_probe_single_connector_modes);*/ void drm_kms_helper_hotplug_event (struct drm_device *dev) { +struct drm_connector *connector; +struct drm_connector_list_iter conn_iter; + +mutex_lock (&dev->mode_config.mutex); +drm_connector_list_iter_begin (dev, &conn_iter); +drm_for_each_connector_iter (connector, &conn_iter) { + connector->status_changed = false; + } +drm_connector_list_iter_end (&conn_iter); +mutex_unlock (&dev->mode_config.mutex); +drm_sysfs_hotplug_event (dev);drm_client_dev_hotplug (dev); }@@ -748,6 +761,10 @@ void drm_kms_helper_connector_hotplug_event(struct drm_connector *connector) {struct drm_device *dev = connector->dev; +mutex_lock (&dev->mode_config.mutex); + connector->status_changed = false; +mutex_unlock (&dev->mode_config.mutex); +drm_sysfs_connector_hotplug_event (connector);drm_client_dev_hotplug (dev); }drivers/gpu/drm/drm_sysfs.c +1
-0@@ -199,6 +199,7 @@ static ssize_t status_store(struct device *device,return ret; old_force = connector->force; + connector->status_changed = true;if (sysfs_streq (buf,"detect" )) connector->force =0 ;drivers/gpu/drm/vkms/vkms_configfs.c +6
-0@@ -537,8 +537,14 @@ static ssize_t connector_status_store(struct config_item *item, {struct vkms_configfs_connector *connector;enum drm_connector_status status; +struct vkms_connector *vkms_connector; +struct vkms_device *vkms_dev; connector =connector_item_to_vkms_configfs_connector (item); + vkms_connector = connector->config->connector; + vkms_dev = connector->config->config->dev; + scoped_guard(mutex, &vkms_dev->drm.mode_config.mutex) + vkms_connector->base.status_changed = true;if (kstrtouint (page,10 , &status))return -EINVAL ;include/drm/drm_connector.h +3
-0@@ -2146,6 +2146,9 @@ struct drm_connector {/** @force: a DRM_FORCE_<foo> state for forced mode sets */ enum drm_connector_force force; +/** @status_changed: if the old status doesn't match current connection status */ +bool status_changed; +/** * @edid_override: Override EDID set via debugfs. * Signature · 1 line
2.47.2Signature · 2 lines
Ville Syrjälä IntelSignature · 2 lines
Ville Syrjälä Intel
Re: [PATCH 1/4] drm: Introduce a new connector status
In reply to Ville SyrjäläHi Ville,
Quoted 34 lines · Ville Syrjälä
Quoted 33 lines · Marius Vlad
Introduce a new boolean variable used to track connector's connect/disconnect status and it is being used on both polling and the HPD (Hot Plug Detect) paths.
A subsequent change would make use of this connector status to propagate per-connector udev hotplug events.
The connector status is set in the drm_connector_funcs.fill_modes/vkms ConfigFS connector's status and cleared out when firing out KMS uevents.
Allows user-space to receive the connector's ID, rather than having a generic hot-plug event for all connectors, or in the HPD path, just the first one found with a connection status change.
Signed-off-by Marius Vlad <[email protected]>--- drivers/gpu/drm/drm_connector.c | 1 + drivers/gpu/drm/drm_probe_helper.c | 17 +++++++++++++++++ drivers/gpu/drm/drm_sysfs.c | 1 + drivers/gpu/drm/vkms/vkms_configfs.c | 6 ++++++ include/drm/drm_connector.h | 3 +++ 5 files changed, 28 insertions(+)drivers/gpu/drm/drm_connector.c +1
-0@@ -274,6 +274,7 @@ static int drm_connector_init_only(struct drm_device *dev,/* provide ddc symlink in sysfs */ connector->ddc = ddc; + connector->status_changed = false;
Quoted 16 lines
drivers/gpu/drm/drm_probe_helper.c int drm_helper_probe_single_connector_modes(struct drm_connector *connector, · line 633
Quoted 12 lines
drivers/gpu/drm/drm_connector.c +0
-0INIT_LIST_HEAD (&connector->head);INIT_LIST_HEAD (&connector->global_connector_list_entry);drivers/gpu/drm/drm_probe_helper.c +2
-0@@ -629,6 +629,8 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,mod_delayed_work (system_wq, &dev->mode_config.output_poll_work,0 ); + + connector->status_changed = true;.fill_modes() gets exectued from the
getconnector()ioctl which userspace issues in response to the uevent. Not the other way around. So looks like you have the chicken and egg the wrong way around here.
.fill_modes() is for drm_sysfs path to simulate a hot-plug event. There's no getconnector in that case.
Quoted 84 lines
Quoted 80 lines
drivers/gpu/drm/drm_probe_helper.c +15
-0}/* @@ -732,6 +734,17 @@ EXPORT_SYMBOL(drm_helper_probe_single_connector_modes);*/ void drm_kms_helper_hotplug_event (struct drm_device *dev) { +struct drm_connector *connector; +struct drm_connector_list_iter conn_iter; + +mutex_lock (&dev->mode_config.mutex); +drm_connector_list_iter_begin (dev, &conn_iter); +drm_for_each_connector_iter (connector, &conn_iter) { + connector->status_changed = false; + } +drm_connector_list_iter_end (&conn_iter); +mutex_unlock (&dev->mode_config.mutex); +drm_sysfs_hotplug_event (dev);drm_client_dev_hotplug (dev); }@@ -748,6 +761,10 @@ void drm_kms_helper_connector_hotplug_event(struct drm_connector *connector) {struct drm_device *dev = connector->dev; +mutex_lock (&dev->mode_config.mutex); + connector->status_changed = false; +mutex_unlock (&dev->mode_config.mutex); +drm_sysfs_connector_hotplug_event (connector);drm_client_dev_hotplug (dev); }drivers/gpu/drm/drm_sysfs.c +1
-0@@ -199,6 +199,7 @@ static ssize_t status_store(struct device *device,return ret; old_force = connector->force; + connector->status_changed = true;if (sysfs_streq (buf,"detect" )) connector->force =0 ;drivers/gpu/drm/vkms/vkms_configfs.c +6
-0@@ -537,8 +537,14 @@ static ssize_t connector_status_store(struct config_item *item, {struct vkms_configfs_connector *connector;enum drm_connector_status status; +struct vkms_connector *vkms_connector; +struct vkms_device *vkms_dev; connector =connector_item_to_vkms_configfs_connector (item); + vkms_connector = connector->config->connector; + vkms_dev = connector->config->config->dev; + scoped_guard(mutex, &vkms_dev->drm.mode_config.mutex) + vkms_connector->base.status_changed = true;if (kstrtouint (page,10 , &status))return -EINVAL ;include/drm/drm_connector.h +3
-0@@ -2146,6 +2146,9 @@ struct drm_connector {/** @force: a DRM_FORCE_<foo> state for forced mode sets */ enum drm_connector_force force; +/** @status_changed: if the old status doesn't match current connection status */ +bool status_changed; +/** * @edid_override: Override EDID set via debugfs. * Signature · 1 line
2.47.2Signature · 2 lines
Ville Syrjälä Intel
PATCH v5 2/4 drm: Propagate connector status change
In reply to Marius VladOn the HPD (Hot Plug Detect) path this change makes use of the connector status to notify all connectors, rather than just first one found that suffered a status change.
Similarly on the polling side, this also takes into consideration sending per-connector udev hotplug events.
--- drivers/gpu/drm/drm_probe_helper.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
drivers/gpu/drm/drm_probe_helper.c +17 -5
@@ -861,8 +861,14 @@ static void output_poll_execute(struct work_struct *work)mutex_unlock (&dev->mode_config.mutex); out: -if (changed) -drm_kms_helper_hotplug_event (dev); +if (changed) { +drm_connector_list_iter_begin (dev, &conn_iter); +drm_for_each_connector_iter (connector, &conn_iter) { +if (connector->status_changed) +drm_kms_helper_connector_hotplug_event (connector); + } +drm_connector_list_iter_end (&conn_iter); + }if (repoll)schedule_delayed_work (delayed_work,DRM_OUTPUT_POLL_PERIOD );
@@ -1124,10 +1130,16 @@ bool drm_helper_hpd_irq_event(struct drm_device *dev)drm_connector_list_iter_end (&conn_iter);mutex_unlock (&dev->mode_config.mutex); -if (changed ==1 ) +if (changed ==1 ) {drm_kms_helper_connector_hotplug_event (first_changed_connector); -else if (changed >0 ) -drm_kms_helper_hotplug_event (dev); + }else if (changed >0 ) { +drm_connector_list_iter_begin (dev, &conn_iter); +drm_for_each_connector_iter (connector, &conn_iter) { +if (connector->status_changed) +drm_kms_helper_connector_hotplug_event (connector); + } +drm_connector_list_iter_end (&conn_iter); + }if (first_changed_connector)drm_connector_put (first_changed_connector);
Signature · 1 line
2.47.2
PATCH v5 3/4 vkms: Do not send hotplug events for same connector status
In reply to Marius VladRather than sending the same hotplug events just do it when the new drm connector status has been changed.
--- drivers/gpu/drm/vkms/vkms_configfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/vkms/vkms_configfs.c +3 -1
@@ -555,9 +555,11 @@ static ssize_t connector_status_store(struct config_item *item,return -EINVAL ; scoped_guard(mutex, &connector->dev->lock) { +enum drm_connector_status old_status = +vkms_config_connector_get_status (connector->config);vkms_config_connector_set_status (connector->config, status); -if (connector->dev->enabled) +if (connector->dev->enabled && old_status != status)vkms_trigger_connector_hotplug (connector->dev->config->dev); }
Signature · 1 line
2.47.2
PATCH v5 4/4 vkms: Pass the vkms connector as opposed to the vkms device
In reply to Marius VladThis way we can pass straight in the CONNECTOR ID.
--- drivers/gpu/drm/vkms/vkms_configfs.c | 2 +- drivers/gpu/drm/vkms/vkms_connector.c | 6 +++--- drivers/gpu/drm/vkms/vkms_connector.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/vkms/vkms_configfs.c +1 -1
@@ -560,7 +560,7 @@ static ssize_t connector_status_store(struct config_item *item,vkms_config_connector_set_status (connector->config, status);if (connector->dev->enabled && old_status != status) -vkms_trigger_connector_hotplug (connector->dev->config->dev); +vkms_trigger_connector_hotplug (vkms_connector); }return (ssize_t )count;
drivers/gpu/drm/vkms/vkms_connector.c +3 -3
@@ -88,9 +88,9 @@ struct vkms_connector *vkms_connector_init(struct vkms_device *vkmsdev)return connector; } -void vkms_trigger_connector_hotplug (struct vkms_device *vkmsdev) +void vkms_trigger_connector_hotplug (struct vkms_connector *vkms_connector) { -struct drm_device *dev = &vkmsdev->drm; +struct drm_connector *connector = &vkms_connector->base; -drm_kms_helper_hotplug_event (dev); +drm_kms_helper_connector_hotplug_event (connector); }
drivers/gpu/drm/vkms/vkms_connector.h +2 -2
@@ -28,8 +28,8 @@ struct vkms_connector *vkms_connector_init(struct vkms_device *vkmsdev);/** * vkms_trigger_connector_hotplug() - Update the device's connectors status -* @vkmsdev: VKMS device to update +* @vkms_connector: VKMS connector to update */ -void vkms_trigger_connector_hotplug (struct vkms_device *vkmsdev); +void vkms_trigger_connector_hotplug (struct vkms_connector *vkms_connector);#endif /* _VKMS_CONNECTOR_H_ */
Signature · 1 line
2.47.2