diff mbox

[1/8] drm: Clean up debugfs upon shutdown

Message ID 1373223745-9095-1-git-send-email-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson July 7, 2013, 7:02 p.m. UTC
Driver authors are a forgetful breed, and having to manually clean up
all inodes from debugfs during module unload is tedious and rarely
encountered by users; leftover inodes fester. But behold, the drm core
already tracks all inodes created under the DRI debugfs minor so that we
can do all the teardown ourselves.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/drm_debugfs.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Rob Clark July 7, 2013, 11:39 p.m. UTC | #1
On Sun, Jul 7, 2013 at 3:02 PM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> Driver authors are a forgetful breed, and having to manually clean up
> all inodes from debugfs during module unload is tedious and rarely
> encountered by users; leftover inodes fester. But behold, the drm core
> already tracks all inodes created under the DRI debugfs minor so that we
> can do all the teardown ourselves.

Seems like a pretty sane idea.

Reviewed-by: Rob Clark <robdclark@gmail.com>


> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/drm_debugfs.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
> index a05087c..b855fd7 100644
> --- a/drivers/gpu/drm/drm_debugfs.c
> +++ b/drivers/gpu/drm/drm_debugfs.c
> @@ -229,7 +229,16 @@ int drm_debugfs_cleanup(struct drm_minor *minor)
>         if (dev->driver->debugfs_cleanup)
>                 dev->driver->debugfs_cleanup(minor);
>
> -       drm_debugfs_remove_files(drm_debugfs_list, DRM_DEBUGFS_ENTRIES, minor);
> +       while (!list_empty(&minor->debugfs_list)) {
> +               struct drm_info_node *node =
> +                       list_first_entry(&minor->debugfs_list,
> +                                        struct drm_info_node,
> +                                        list);
> +
> +               debugfs_remove(node->dent);
> +               list_del(&node->list);
> +               kfree(node);
> +       }
>
>         debugfs_remove(minor->debugfs_root);
>         minor->debugfs_root = NULL;
> --
> 1.8.3.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index a05087c..b855fd7 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -229,7 +229,16 @@  int drm_debugfs_cleanup(struct drm_minor *minor)
 	if (dev->driver->debugfs_cleanup)
 		dev->driver->debugfs_cleanup(minor);
 
-	drm_debugfs_remove_files(drm_debugfs_list, DRM_DEBUGFS_ENTRIES, minor);
+	while (!list_empty(&minor->debugfs_list)) {
+		struct drm_info_node *node =
+			list_first_entry(&minor->debugfs_list,
+					 struct drm_info_node,
+					 list);
+
+		debugfs_remove(node->dent);
+		list_del(&node->list);
+		kfree(node);
+	}
 
 	debugfs_remove(minor->debugfs_root);
 	minor->debugfs_root = NULL;