drm/atomic: cleanup debugfs entries on un-registering the driver.
authorLiviu Dudau <Liviu.Dudau@arm.com>
Thu, 17 Nov 2016 11:41:29 +0000 (11:41 +0000)
committerSean Paul <seanpaul@chromium.org>
Mon, 21 Nov 2016 18:22:08 +0000 (13:22 -0500)
Cleanup the debugfs entries created by
commit 6559c901cb48:  drm/atomic: add debugfs file to dump out atomic state
when the driver's minor gets un-registered. Without it, DRM drivers
compiled as modules cannot be rmmod-ed and modprobed again.

Tested-by: Brian Starkey <brian.starkey@arm.com>
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/20161117114129.2627-1-Liviu.Dudau@arm.com
Fixes: 6559c901cb48 ("drm/atomic: add debugfs file to dump out atomic state")

drivers/gpu/drm/drm_atomic.c
drivers/gpu/drm/drm_debugfs.c
include/drm/drm_atomic.h

index 85466cc67819a80e8eaf37f6037a1e89d0083e6a..ccbffaf14de0ced79e422ae331a2270161a0cee5 100644 (file)
@@ -1686,6 +1686,13 @@ int drm_atomic_debugfs_init(struct drm_minor *minor)
                        ARRAY_SIZE(drm_atomic_debugfs_list),
                        minor->debugfs_root, minor);
 }
+
+int drm_atomic_debugfs_cleanup(struct drm_minor *minor)
+{
+       return drm_debugfs_remove_files(drm_atomic_debugfs_list,
+                                       ARRAY_SIZE(drm_atomic_debugfs_list),
+                                       minor);
+}
 #endif
 
 /*
index 206a4fe7ea2642dfeb8e5f4e2ff80b8055c7bfbf..2e3e46a538052a7575b07ffc0bbca622021a6542 100644 (file)
@@ -228,6 +228,7 @@ EXPORT_SYMBOL(drm_debugfs_remove_files);
 int drm_debugfs_cleanup(struct drm_minor *minor)
 {
        struct drm_device *dev = minor->dev;
+       int ret;
 
        if (!minor->debugfs_root)
                return 0;
@@ -235,6 +236,14 @@ int drm_debugfs_cleanup(struct drm_minor *minor)
        if (dev->driver->debugfs_cleanup)
                dev->driver->debugfs_cleanup(minor);
 
+       if (drm_core_check_feature(dev, DRIVER_ATOMIC)) {
+               ret = drm_atomic_debugfs_cleanup(minor);
+               if (ret) {
+                       DRM_ERROR("DRM: Failed to remove atomic debugfs entries\n");
+                       return ret;
+               }
+       }
+
        drm_debugfs_remove_files(drm_debugfs_list, DRM_DEBUGFS_ENTRIES, minor);
 
        debugfs_remove(minor->debugfs_root);
index c0eaec70a2030634e0c627f9e9b60cac003d9a0d..5d5f85db43f01b8ad84b8ccc277f4ea9a3fb30ba 100644 (file)
@@ -372,6 +372,7 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
 #ifdef CONFIG_DEBUG_FS
 struct drm_minor;
 int drm_atomic_debugfs_init(struct drm_minor *minor);
+int drm_atomic_debugfs_cleanup(struct drm_minor *minor);
 #endif
 
 #define for_each_connector_in_state(__state, connector, connector_state, __i) \