Re: [PATCH RESEND v7 1/2] drm: Introduce pending_hp to drm_connector

Dmitry Baryshkov
2026-04-19T00:45:55Z

On Wed, Apr 15, 2026 at 07:59:39PM +0200, Nicolas Frattaroli wrote:
> From: Marius Vlad <marius.vlad@collabora.com>
>
> Introduce a new boolean variable used to track whether a connector has
> changed its status since the last hotplug event for it was sent to
> userspace. It is used by both the polling and HPD path.
>
> A subsequent change will make use of this new member to propagate
> per-connector udev hotplug events to userspace, rather than sending a
> global hotplug event.
>
> Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> ---
> drivers/gpu/drm/drm_connector.c | 1 +
> drivers/gpu/drm/drm_probe_helper.c | 17 +++++++++++++++++
> drivers/gpu/drm/drm_sysfs.c | 2 ++
> include/drm/drm_connector.h | 3 +++
> 4 files changed, 23 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index 3fa4d2082cd7..b1abdef6778a 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -274,6 +274,7 @@ static int drm_connector_init_only(struct drm_device *dev,
>
> /* provide ddc symlink in sysfs */
> connector->ddc = ddc;
> + connector->pending_hp = false;

Can we use epoch_counter directly instead of adding a new property?

>
> INIT_LIST_HEAD(&connector->head);
> INIT_LIST_HEAD(&connector->global_connector_list_entry);
> diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
> index d4dc8cb45bce..f8cbd6713960 100644
> --- a/drivers/gpu/drm/drm_probe_helper.c
> +++ b/drivers/gpu/drm/drm_probe_helper.c
> @@ -732,6 +732,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->pending_hp = 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 +759,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->pending_hp = false;
> + mutex_unlock(&dev->mode_config.mutex);
> +
> drm_sysfs_connector_hotplug_event(connector);
> drm_client_dev_hotplug(dev);
> }
> @@ -837,6 +852,7 @@ static void output_poll_execute(struct work_struct *work)
> old_epoch_counter, connector->epoch_counter);
>
> changed = true;
> + connector->pending_hp = true;
> }
> }
> drm_connector_list_iter_end(&conn_iter);
> @@ -1101,6 +1117,7 @@ bool drm_helper_hpd_irq_event(struct drm_device *dev)
> first_changed_connector = connector;
> }
>
> + connector->pending_hp = true;
> changed++;
> }
> }
> diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> index ef4e923a8728..47a6b322e873 100644
> --- a/drivers/gpu/drm/drm_sysfs.c
> +++ b/drivers/gpu/drm/drm_sysfs.c
> @@ -216,6 +216,8 @@ static ssize_t status_store(struct device *device,
> connector->base.id, connector->name,
> old_force, connector->force);
>
> + connector->pending_hp = true;
> +
> connector->funcs->fill_modes(connector,
> dev->mode_config.max_width,
> dev->mode_config.max_height);
> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index 3e422a4f2e72..70a740301089 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
> @@ -2251,6 +2251,9 @@ struct drm_connector {
> /** @force: a DRM_FORCE_<foo> state for forced mode sets */
> enum drm_connector_force force;
>
> + /** @pending_hp: true if connector changed since last hotplug event */
> + bool pending_hp;
> +
> /**
> * @edid_override: Override EDID set via debugfs.
> *
>
> --
> 2.53.0
>

--
With best wishes
Dmitry