drm/connector: notify userspace on hotplug after register complete
Subsystems (2)
PATCH 1/1 drm/connector: notify userspace on hotplug after register complete
drm connector notifies userspace on hotplug event prematurely before late_register and mode_object register completes. This leads to a race between userspace and kernel on updating the IDR list. So, move the notification to end of connector register.
--- drivers/gpu/drm/drm_connector.c | 5 +++++ drivers/gpu/drm/drm_sysfs.c | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_connector.c +5 -0
@@ -27,6 +27,7 @@#include <drm/drm_print.h> #include <drm/drm_drv.h> #include <drm/drm_file.h> +#include <drm/drm_sysfs.h> #include <linux/uaccess.h>
@@ -523,6 +524,10 @@ int drm_connector_register(struct drm_connector *connector)drm_mode_object_register (connector->dev, &connector->base); connector->registration_state =DRM_CONNECTOR_REGISTERED ; + +/* Let userspace know we have a new connector */ +drm_sysfs_hotplug_event (connector->dev); + goto unlock; err_debugfs:
drivers/gpu/drm/drm_sysfs.c +0 -3
@@ -291,9 +291,6 @@ int drm_sysfs_connector_add(struct drm_connector *connector)return PTR_ERR (connector->kdev); } -/* Let userspace know we have a new connector */ -drm_sysfs_hotplug_event (dev); -if (connector->ddc)return sysfs_create_link (&connector->kdev->kobj, &connector->ddc->dev.kobj,"ddc" );
Signature · 7 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · Jeykumar Sankaran
drm connector notifies userspace on hotplug event prematurely before
late_registerandmode_objectregister completes. This leads to a race between userspace and kernel on updating the IDR list. So, move the notification to end of connector register.Signed-off-by Jeykumar Sankaran <[email protected]>Signed-off-by Steve Cohen <[email protected]>
Hm on the unregister side we don't have the race, there we remove everything and then send out the uevent. But there the uevent is also generated in a separate step, so I wonder whether we shouldn't do the same for register for symmetry ...
Anyway this looks good, nice catch, I'll add cc: stable and merge. -Daniel
Quoted 50 lines
--- drivers/gpu/drm/drm_connector.c | 5 +++++ drivers/gpu/drm/drm_sysfs.c | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_connector.c +5
-0@@ -27,6 +27,7 @@#include <drm/drm_print.h> #include <drm/drm_drv.h> #include <drm/drm_file.h> +#include <drm/drm_sysfs.h> #include <linux/uaccess.h> @@ -523,6 +524,10 @@ int drm_connector_register(struct drm_connector *connector)drm_mode_object_register (connector->dev, &connector->base); connector->registration_state =DRM_CONNECTOR_REGISTERED ; + +/* Let userspace know we have a new connector */ +drm_sysfs_hotplug_event (connector->dev); + goto unlock; err_debugfs:drivers/gpu/drm/drm_sysfs.c +0
-3@@ -291,9 +291,6 @@ int drm_sysfs_connector_add(struct drm_connector *connector)return PTR_ERR (connector->kdev); } -/* Let userspace know we have a new connector */ -drm_sysfs_hotplug_event (dev); -if (connector->ddc)return sysfs_create_link (&connector->kdev->kobj, &connector->ddc->dev.kobj,"ddc" );Signature · 7 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel