udl unplug fixes
Subsystems (3)
Dave Airlie
maintainerI've sent two udl fixes for plugging in, these two fix the unplug scenario,
The first avoids hitting the unregister path twice, once in device unplug and once in last open fd release.
The second avoids uninit the modeset configs while userspace still has the open fd which can access them.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 1/2 drm: do lower level device put on unplugged releases
From: Dave Airlie <[email protected]>
When we release the file handle on a device that has been unplugged it has already called the unregister path, which doesn't like being called again. We should just do the dev put version instead.
This fixes some crashes unplugged in a udl device.
--- drivers/gpu/drm/drm_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_file.c +1 -1
@@ -492,7 +492,7 @@ int drm_release(struct inode *inode, struct file *filp)if (!--dev->open_count) {drm_lastclose (dev);if (drm_dev_is_unplugged (dev)) -drm_put_dev (dev); +drm_dev_put (dev); }mutex_unlock (&drm_global_mutex);
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/2] drm: do lower level device put on unplugged releases
Den 15.03.2019 06.13, skrev Dave Airlie:
Quoted 10 lines
From: Dave Airlie <[email protected]>
When we release the file handle on a device that has been unplugged it has already called the unregister path, which doesn't like being called again. We should just do the dev put version instead.
This fixes some crashes unplugged in a udl device.
Signed-off-by Dave Airlie <[email protected]>---
I believe this is fixed already in drm-misc-next:
drm: Fix drm_release() and device unplug
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=1ee57d4d75fbc74bb2ae601c8f334219165ef276
Noralf.
Quoted 9 lines
drivers/gpu/drm/drm_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_file.c +0
-0
drivers/gpu/drm/drm_file.c int drm_release(struct inode *inode, struct file *filp) · line 498
Quoted 8 lines
drivers/gpu/drm/drm_file.c +1
-1@@ -492,7 +492,7 @@ int drm_release(struct inode *inode, struct file *filp)if (!--dev->open_count) {drm_lastclose (dev);if (drm_dev_is_unplugged (dev)) -drm_put_dev (dev); +drm_dev_put (dev); }mutex_unlock (&drm_global_mutex);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 2/2 drm/udl: add a release method and delay modeset teardown
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
If we unplug a udl device, the usb callback with deinit the mode_config struct, however userspace will still have an open file descriptor and a framebuffer on that device. When userspace closes the fd, we'll oops because it'll try and look stuff up in the object idr which we've destroyed.
This punts destroying the mode objects until release time instead.
--- drivers/gpu/drm/udl/udl_drv.c | 1 + drivers/gpu/drm/udl/udl_drv.h | 1 + drivers/gpu/drm/udl/udl_main.c | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/udl/udl_drv.c +1 -0
@@ -52,6 +52,7 @@ static struct drm_driver driver = { .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME, .load = udl_driver_load, .unload = udl_driver_unload, + .release = udl_driver_release,/* gem hooks */ .gem_free_object_unlocked = udl_gem_free_object,
drivers/gpu/drm/udl/udl_drv.h +1 -0
@@ -104,6 +104,7 @@ void udl_urb_completion(struct urb *urb);int udl_driver_load (struct drm_device *dev,unsigned long flags);void udl_driver_unload (struct drm_device *dev); +void udl_driver_release (struct drm_device *dev);int udl_fbdev_init (struct drm_device *dev);void udl_fbdev_cleanup (struct drm_device *dev);
drivers/gpu/drm/udl/udl_main.c +7 -1
@@ -379,6 +379,12 @@ void udl_driver_unload(struct drm_device *dev)udl_free_urb_list (dev);udl_fbdev_cleanup (dev); -udl_modeset_cleanup (dev);kfree (udl); } + +void udl_driver_release (struct drm_device *dev) +{ +drm_mode_config_cleanup (dev); +drm_dev_fini (dev); +kfree (dev); +}
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/udl: add a release method and delay modeset teardown
Quoted 11 lines · Dave Airlie
From: Dave Airlie <[email protected]>
If we unplug a udl device, the usb callback with deinit the
mode_configstruct, however userspace will still have an open file descriptor and a framebuffer on that device. When userspace closes the fd, we'll oops because it'll try and look stuff up in the object idr which we've destroyed.This punts destroying the mode objects until release time instead.
Signed-off-by Dave Airlie <[email protected]>
For the first one pls ping Noralf to make sure it all aligns with the Grand Plan.
-Daniel
Quoted 55 lines
--- drivers/gpu/drm/udl/udl_drv.c | 1 + drivers/gpu/drm/udl/udl_drv.h | 1 + drivers/gpu/drm/udl/udl_main.c | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-)drivers/gpu/drm/udl/udl_drv.c +1
-0@@ -52,6 +52,7 @@ static struct drm_driver driver = { .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME, .load = udl_driver_load, .unload = udl_driver_unload, + .release = udl_driver_release,/* gem hooks */ .gem_free_object_unlocked = udl_gem_free_object,drivers/gpu/drm/udl/udl_drv.h +1
-0@@ -104,6 +104,7 @@ void udl_urb_completion(struct urb *urb);int udl_driver_load (struct drm_device *dev,unsigned long flags);void udl_driver_unload (struct drm_device *dev); +void udl_driver_release (struct drm_device *dev);int udl_fbdev_init (struct drm_device *dev);void udl_fbdev_cleanup (struct drm_device *dev);drivers/gpu/drm/udl/udl_main.c +7
-1@@ -379,6 +379,12 @@ void udl_driver_unload(struct drm_device *dev)udl_free_urb_list (dev);udl_fbdev_cleanup (dev); -udl_modeset_cleanup (dev);kfree (udl); } + +void udl_driver_release (struct drm_device *dev) +{ +drm_mode_config_cleanup (dev); +drm_dev_fini (dev); +kfree (dev); +}Signature · 6 lines
2.20.1 _______________________________________________ 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
Re: [PATCH 2/2] drm/udl: add a release method and delay modeset teardown
In reply to Dave AirlieDen 15.03.2019 06.13, skrev Dave Airlie:
Quoted 50 lines
From: Dave Airlie <[email protected]>
If we unplug a udl device, the usb callback with deinit the
mode_configstruct, however userspace will still have an open file descriptor and a framebuffer on that device. When userspace closes the fd, we'll oops because it'll try and look stuff up in the object idr which we've destroyed.This punts destroying the mode objects until release time instead.
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/udl/udl_drv.c | 1 + drivers/gpu/drm/udl/udl_drv.h | 1 + drivers/gpu/drm/udl/udl_main.c | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-)drivers/gpu/drm/udl/udl_drv.c +1
-0@@ -52,6 +52,7 @@ static struct drm_driver driver = { .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME, .load = udl_driver_load, .unload = udl_driver_unload, + .release = udl_driver_release,/* gem hooks */ .gem_free_object_unlocked = udl_gem_free_object,drivers/gpu/drm/udl/udl_drv.h +1
-0@@ -104,6 +104,7 @@ void udl_urb_completion(struct urb *urb);int udl_driver_load (struct drm_device *dev,unsigned long flags);void udl_driver_unload (struct drm_device *dev); +void udl_driver_release (struct drm_device *dev);int udl_fbdev_init (struct drm_device *dev);void udl_fbdev_cleanup (struct drm_device *dev);drivers/gpu/drm/udl/udl_main.c +0
-0@@ -379,6 +379,12 @@ void udl_driver_unload(struct drm_device *dev)udl_free_urb_list (dev);udl_fbdev_cleanup (dev);
drivers/gpu/drm/udl/udl_main.c void udl_driver_unload(struct drm_device *dev) · line 390
Quoted 10 lines
drivers/gpu/drm/udl/udl_main.c +7
-1-udl_modeset_cleanup (dev);kfree (udl); } + +void udl_driver_release (struct drm_device *dev) +{ +drm_mode_config_cleanup (dev); +drm_dev_fini (dev); +kfree (dev); +}
You can remove udl_modeset_cleanup() now.
There's still a problem here and that is if udl_driver_load() errors out before drm_mode_config_init() is called, drm_mode_config_cleanup() will crash on uninitialized lists etc.
I have solved this by calling drm_mode_config_init() right after drm_device has been initialized.
Noralf.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel