Skip to contentSkip to conversation

drm/udl: Fix USB disconnect

PATCH In review Thomas Zimmermann 2 participants 7 messages Mar 3, 2025 – Mar 12, 2025

Subsystems (5)
lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

cover drm/udl: Fix USB disconnect

The udl drivers prints warnings about dropped URBs from its disconnect handler. This is because the poll helper doesn't yet know that the USB device is gone. Fix the disconnect clean-up logic and use managed cleanup for poll helpers.

Thomas Zimmermann (3):
drm/udl: Unregister device before cleaning up on disconnect drm/udl: Switch poll helpers to managed cleanup drm/probe-helper: Do not fail from drmm_kms_helper_poll_init()

 drivers/gpu/drm/ast/ast_mode.c     |  5 +----
 drivers/gpu/drm/drm_probe_helper.c | 11 ++++++-----
 drivers/gpu/drm/udl/udl_drv.c      |  3 +--
 drivers/gpu/drm/udl/udl_main.c     |  2 --
 drivers/gpu/drm/udl/udl_modeset.c  |  1 +
 include/drm/drm_probe_helper.h     |  2 +-
 6 files changed, 10 insertions(+), 14 deletions(-)
Signature · 1 line
2.48.1
author maintainer
#1 lore raw

PATCH 1/3 drm/udl: Unregister device before cleaning up on disconnect

Disconnecting a DisplayLink device results in the following kernel error messages

[   93.041748] [drm:udl_urb_completion [udl]] *ERROR* udl_urb_completion - nonzero write bulk status received: -115
[   93.055299] [drm:udl_submit_urb [udl]] *ERROR* usb_submit_urb error fffffffe
[   93.065363] [drm:udl_urb_completion [udl]] *ERROR* udl_urb_completion - nonzero write bulk status received: -115
[   93.078207] [drm:udl_submit_urb [udl]] *ERROR* usb_submit_urb error fffffffe

coming from KMS poll helpers. Shutting down poll helpers runs them one final time when the USB device is already gone.

Run drm_dev_unplug() first in udl's USB disconnect handler. Udl's polling code already handles disconnects gracefully if the device has been marked as unplugged.

Fixes b1a981bd5576 ("drm/udl: drop drm_driver.release hook")
Cc <[email protected]> # v5.8+
---
 drivers/gpu/drm/udl/udl_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/udl/udl_drv.c +1 -1
index 05b3a152cc33..7e7d704be0c0 100644
@@ -127,9 +127,9 @@ static void udl_usb_disconnect(struct usb_interface *interface)
 {
 	struct drm_device *dev = usb_get_intfdata(interface);
 
+	drm_dev_unplug(dev);
 	drm_kms_helper_poll_fini(dev);
 	udl_drop_usb(dev);
-	drm_dev_unplug(dev);
 }
 
 /*
Signature · 1 line
2.48.1
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] drm/udl: Unregister device before cleaning up on disconnect

Quoted 12 lines · Thomas Zimmermann

Disconnecting a DisplayLink device results in the following kernel error messages

[   93.041748] [drm:udl_urb_completion [udl]] *ERROR* udl_urb_completion - nonzero write bulk status received: -115
[   93.055299] [drm:udl_submit_urb [udl]] *ERROR* usb_submit_urb error fffffffe
[   93.065363] [drm:udl_urb_completion [udl]] *ERROR* udl_urb_completion - nonzero write bulk status received: -115
[   93.078207] [drm:udl_submit_urb [udl]] *ERROR* usb_submit_urb error fffffffe

coming from KMS poll helpers. Shutting down poll helpers runs them one final time when the USB device is already gone.

Quoted 8 lines

Run drm_dev_unplug() first in udl's USB disconnect handler. Udl's polling code already handles disconnects gracefully if the device has been marked as unplugged.

Fixes b1a981bd5576 ("drm/udl: drop drm_driver.release hook")
Cc <[email protected]> # v5.8+

Hi Thomas,
Looks good.

Quoted 22 lines
---
 drivers/gpu/drm/udl/udl_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/udl/udl_drv.c +1 -2
index 05b3a152cc33..7e7d704be0c0 100644
@@ -127,9 +127,9 @@ static void udl_usb_disconnect(struct usb_interface *interface)
 {
        struct drm_device *dev = usb_get_intfdata(interface);
 
+       drm_dev_unplug(dev);
        drm_kms_helper_poll_fini(dev);
        udl_drop_usb(dev);
-       drm_dev_unplug(dev);
 }
 
 /*
--

2.48.1

author maintainer
#3 lore raw

PATCH 2/3 drm/udl: Switch poll helpers to managed cleanup

In reply to Thomas Zimmermann

Call drmm_kms_helper_poll_init() to set up managed cleanup for connector polling.

---
 drivers/gpu/drm/udl/udl_drv.c     | 1 -
 drivers/gpu/drm/udl/udl_main.c    | 2 --
 drivers/gpu/drm/udl/udl_modeset.c | 1 +
 3 files changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/udl/udl_drv.c +0 -1
index 7e7d704be0c0..29f34b4a732d 100644
@@ -128,7 +128,6 @@ static void udl_usb_disconnect(struct usb_interface *interface)
 	struct drm_device *dev = usb_get_intfdata(interface);
 
 	drm_dev_unplug(dev);
-	drm_kms_helper_poll_fini(dev);
 	udl_drop_usb(dev);
 }
 
drivers/gpu/drm/udl/udl_main.c +0 -2
index 3ebe2ce55dfd..a76b8f57917e 100644
@@ -336,8 +336,6 @@ int udl_init(struct udl_device *udl)
 	if (ret)
 		goto err;
 
-	drm_kms_helper_poll_init(dev);
-
 	return 0;
 
 err:
drivers/gpu/drm/udl/udl_modeset.c +1 -0
index bbb04f98886a..3b65e93ea0ae 100644
@@ -535,6 +535,7 @@ int udl_modeset_init(struct drm_device *dev)
 		return ret;
 
 	drm_mode_config_reset(dev);
+	drmm_kms_helper_poll_init(dev);
 
 	return 0;
 }
Signature · 1 line
2.48.1
Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] drm/udl: Switch poll helpers to managed cleanup

Quoted 5 lines · Thomas Zimmermann

Call drmm_kms_helper_poll_init() to set up managed cleanup for connector polling.

Quoted 46 lines
---
 drivers/gpu/drm/udl/udl_drv.c     | 1 -
 drivers/gpu/drm/udl/udl_main.c    | 2 --
 drivers/gpu/drm/udl/udl_modeset.c | 1 +
 3 files changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/udl/udl_drv.c +0 -1
index 7e7d704be0c0..29f34b4a732d 100644
@@ -128,7 +128,6 @@ static void udl_usb_disconnect(struct usb_interface *interface)
        struct drm_device *dev = usb_get_intfdata(interface);
 
        drm_dev_unplug(dev);
-       drm_kms_helper_poll_fini(dev);
        udl_drop_usb(dev);
 }
 
drivers/gpu/drm/udl/udl_main.c +0 -2
index 3ebe2ce55dfd..a76b8f57917e 100644
@@ -336,8 +336,6 @@ int udl_init(struct udl_device *udl)
        if (ret)
                goto err;
 
-       drm_kms_helper_poll_init(dev);
-
        return 0;
 
 err:
drivers/gpu/drm/udl/udl_modeset.c +1 -1
index bbb04f98886a..3b65e93ea0ae 100644
@@ -535,6 +535,7 @@ int udl_modeset_init(struct drm_device *dev)
                return ret;
 
        drm_mode_config_reset(dev);
+       drmm_kms_helper_poll_init(dev);
 
        return 0;
 }
--

2.48.1

author maintainer
#5 lore raw

PATCH 3/3 drm/probe-helper: Do not fail from drmm_kms_helper_poll_init()

In reply to Thomas Zimmermann

Failing to set up connector polling is not significant enough to fail device probing. Print a warning and return nothing from the init helper.

This only affects the managed init function. The unmanaged init already never fails with an error.

---
 drivers/gpu/drm/ast/ast_mode.c     |  5 +----
 drivers/gpu/drm/drm_probe_helper.c | 11 ++++++-----
 include/drm/drm_probe_helper.h     |  2 +-
 3 files changed, 8 insertions(+), 10 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +1 -4
index c3b950675485..4f2543730b97 100644
@@ -1018,10 +1018,7 @@ int ast_mode_config_init(struct ast_device *ast)
 		return ret;
 
 	drm_mode_config_reset(dev);
-
-	ret = drmm_kms_helper_poll_init(dev);
-	if (ret)
-		return ret;
+	drmm_kms_helper_poll_init(dev);
 
 	return 0;
 }
drivers/gpu/drm/drm_probe_helper.c +6 -5
index 7ba16323e7c2..6b3541159c0f 100644
@@ -958,15 +958,16 @@ static void drm_kms_helper_poll_init_release(struct drm_device *dev, void *res)
  * cleaned up when the DRM device goes away.
  *
  * See drm_kms_helper_poll_init() for more information.
- *
- * Returns:
- * 0 on success, or a negative errno code otherwise.
  */
-int drmm_kms_helper_poll_init(struct drm_device *dev)
+void drmm_kms_helper_poll_init(struct drm_device *dev)
 {
+	int ret;
+
 	drm_kms_helper_poll_init(dev);
 
-	return drmm_add_action_or_reset(dev, drm_kms_helper_poll_init_release, dev);
+	ret = drmm_add_action_or_reset(dev, drm_kms_helper_poll_init_release, dev);
+	if (ret)
+		drm_warn(dev, "Connector status will not be updated, error %d\n", ret);
 }
 EXPORT_SYMBOL(drmm_kms_helper_poll_init);
 
include/drm/drm_probe_helper.h +1 -1
index d6ce7b218b77..840ae5f798c2 100644
@@ -17,7 +17,7 @@ int drm_helper_probe_detect(struct drm_connector *connector,
 			    struct drm_modeset_acquire_ctx *ctx,
 			    bool force);
 
-int drmm_kms_helper_poll_init(struct drm_device *dev);
+void drmm_kms_helper_poll_init(struct drm_device *dev);
 void drm_kms_helper_poll_init(struct drm_device *dev);
 void drm_kms_helper_poll_fini(struct drm_device *dev);
 bool drm_helper_hpd_irq_event(struct drm_device *dev);
Signature · 1 line
2.48.1
Reviewed-by on v1 3/3
#6 lore raw

Re: [PATCH 3/3] drm/probe-helper: Do not fail from drmm_kms_helper_poll_init()

Quoted 9 lines · Thomas Zimmermann

Failing to set up connector polling is not significant enough to fail device probing. Print a warning and return nothing from the init helper.

This only affects the managed init function. The unmanaged init already never fails with an error.

Quoted 64 lines
---
 drivers/gpu/drm/ast/ast_mode.c     |  5 +----
 drivers/gpu/drm/drm_probe_helper.c | 11 ++++++-----
 include/drm/drm_probe_helper.h     |  2 +-
 3 files changed, 8 insertions(+), 10 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +1 -4
index c3b950675485..4f2543730b97 100644
@@ -1018,10 +1018,7 @@ int ast_mode_config_init(struct ast_device *ast)
                return ret;
 
        drm_mode_config_reset(dev);
-
-       ret = drmm_kms_helper_poll_init(dev);
-       if (ret)
-               return ret;
+       drmm_kms_helper_poll_init(dev);
 
        return 0;
 }
drivers/gpu/drm/drm_probe_helper.c +6 -5
index 7ba16323e7c2..6b3541159c0f 100644
@@ -958,15 +958,16 @@ static void drm_kms_helper_poll_init_release(struct drm_device *dev, void *res)
  * cleaned up when the DRM device goes away.
  *
  * See drm_kms_helper_poll_init() for more information.
- *
- * Returns:
- * 0 on success, or a negative errno code otherwise.
  */
-int drmm_kms_helper_poll_init(struct drm_device *dev)
+void drmm_kms_helper_poll_init(struct drm_device *dev)
 {
+       int ret;
+
        drm_kms_helper_poll_init(dev);
 
-       return drmm_add_action_or_reset(dev, drm_kms_helper_poll_init_release, dev);
+       ret = drmm_add_action_or_reset(dev, drm_kms_helper_poll_init_release, dev);
+       if (ret)
+               drm_warn(dev, "Connector status will not be updated, error %d\n", ret);
 }
 EXPORT_SYMBOL(drmm_kms_helper_poll_init);
 
include/drm/drm_probe_helper.h +1 -2
index d6ce7b218b77..840ae5f798c2 100644
@@ -17,7 +17,7 @@ int drm_helper_probe_detect(struct drm_connector *connector,
                            struct drm_modeset_acquire_ctx *ctx,
                            bool force);
 
-int drmm_kms_helper_poll_init(struct drm_device *dev);
+void drmm_kms_helper_poll_init(struct drm_device *dev);
 void drm_kms_helper_poll_init(struct drm_device *dev);
 void drm_kms_helper_poll_fini(struct drm_device *dev);
 bool drm_helper_hpd_irq_event(struct drm_device *dev);
--

2.48.1