drm/debugfs: remove dev->debugfs_list and debugfs_mutex v2
authorChristian König <ckoenig.leichtzumerken@gmail.com>
Tue, 29 Aug 2023 11:01:14 +0000 (13:01 +0200)
committerChristian König <christian.koenig@amd.com>
Fri, 1 Sep 2023 06:53:05 +0000 (08:53 +0200)
The mutex was completely pointless in the first place since any
parallel adding of files to this list would result in random
behavior since the list is filled and consumed multiple times.

Completely drop that approach and just create the files directly but
return -ENODEV while opening the file when the minors are not
registered yet.

v2: rebase on debugfs directory rework, limit access before minors are
    registered.

Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230829110115.3442-5-christian.koenig@amd.com
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
drivers/gpu/drm/drm_debugfs.c
drivers/gpu/drm/drm_drv.c
drivers/gpu/drm/drm_internal.h
drivers/gpu/drm/drm_mode_config.c
include/drm/drm_device.h

index 5ec28c0e12d9b21207db86c19fb1f0a11f762b85..d0c6492d5de1ff4acbcb1454c6982f5743c9d918 100644 (file)
@@ -308,7 +308,6 @@ int drm_debugfs_register(struct drm_minor *minor, int minor_id,
                         struct dentry *root)
 {
        struct drm_device *dev = minor->dev;
-       struct drm_debugfs_entry *entry, *tmp;
        char name[64];
 
        INIT_LIST_HEAD(&minor->debugfs_list);
@@ -323,30 +322,9 @@ int drm_debugfs_register(struct drm_minor *minor, int minor_id,
        if (dev->driver->debugfs_init && dev->render != minor)
                dev->driver->debugfs_init(minor);
 
-       list_for_each_entry_safe(entry, tmp, &dev->debugfs_list, list) {
-               debugfs_create_file(entry->file.name, 0444,
-                                   minor->debugfs_root, entry, &drm_debugfs_entry_fops);
-               list_del(&entry->list);
-       }
-
        return 0;
 }
 
-void drm_debugfs_late_register(struct drm_device *dev)
-{
-       struct drm_minor *minor = dev->primary;
-       struct drm_debugfs_entry *entry, *tmp;
-
-       if (!minor)
-               return;
-
-       list_for_each_entry_safe(entry, tmp, &dev->debugfs_list, list) {
-               debugfs_create_file(entry->file.name, 0444,
-                                   minor->debugfs_root, entry, &drm_debugfs_entry_fops);
-               list_del(&entry->list);
-       }
-}
-
 int drm_debugfs_remove_files(const struct drm_info_list *files, int count,
                             struct drm_minor *minor)
 {
@@ -416,9 +394,8 @@ void drm_debugfs_add_file(struct drm_device *dev, const char *name,
        entry->file.data = data;
        entry->dev = dev;
 
-       mutex_lock(&dev->debugfs_mutex);
-       list_add(&entry->list, &dev->debugfs_list);
-       mutex_unlock(&dev->debugfs_mutex);
+       debugfs_create_file(name, 0444, dev->debugfs_root, entry,
+                           &drm_debugfs_entry_fops);
 }
 EXPORT_SYMBOL(drm_debugfs_add_file);
 
index d28f415cd733f95d4ea4b49599b5f042703f4ac0..45053f3371ca7d0bb962e72f86f8ba930411b5bf 100644 (file)
@@ -597,7 +597,6 @@ static void drm_dev_init_release(struct drm_device *dev, void *res)
        mutex_destroy(&dev->clientlist_mutex);
        mutex_destroy(&dev->filelist_mutex);
        mutex_destroy(&dev->struct_mutex);
-       mutex_destroy(&dev->debugfs_mutex);
        drm_legacy_destroy_members(dev);
 }
 
@@ -638,14 +637,12 @@ static int drm_dev_init(struct drm_device *dev,
        INIT_LIST_HEAD(&dev->filelist_internal);
        INIT_LIST_HEAD(&dev->clientlist);
        INIT_LIST_HEAD(&dev->vblank_event_list);
-       INIT_LIST_HEAD(&dev->debugfs_list);
 
        spin_lock_init(&dev->event_lock);
        mutex_init(&dev->struct_mutex);
        mutex_init(&dev->filelist_mutex);
        mutex_init(&dev->clientlist_mutex);
        mutex_init(&dev->master_mutex);
-       mutex_init(&dev->debugfs_mutex);
 
        ret = drmm_add_action_or_reset(dev, drm_dev_init_release, NULL);
        if (ret)
index dee75a9cc59e9e61ed96a796a331d35b534fe6dd..ec8a1e9c19e86814c3a94caadc884bd5becc76fa 100644 (file)
@@ -185,7 +185,6 @@ void drm_debugfs_dev_register(struct drm_device *dev);
 int drm_debugfs_register(struct drm_minor *minor, int minor_id,
                         struct dentry *root);
 void drm_debugfs_cleanup(struct drm_minor *minor);
-void drm_debugfs_late_register(struct drm_device *dev);
 void drm_debugfs_connector_add(struct drm_connector *connector);
 void drm_debugfs_connector_remove(struct drm_connector *connector);
 void drm_debugfs_crtc_add(struct drm_crtc *crtc);
@@ -210,10 +209,6 @@ static inline void drm_debugfs_cleanup(struct drm_minor *minor)
 {
 }
 
-static inline void drm_debugfs_late_register(struct drm_device *dev)
-{
-}
-
 static inline void drm_debugfs_connector_add(struct drm_connector *connector)
 {
 }
index 87eb591fe9b5b8351b227a2d47433d1ed6b45e79..8525ef8515406ba956bed80d8e365cce82dd686d 100644 (file)
@@ -54,8 +54,6 @@ int drm_modeset_register_all(struct drm_device *dev)
        if (ret)
                goto err_connector;
 
-       drm_debugfs_late_register(dev);
-
        return 0;
 
 err_connector:
index 3cf12b14232dd4acd45d12e10491f5114cb2f15f..c490977ee250c956117ab286d8cfe742a6030096 100644 (file)
@@ -318,21 +318,6 @@ struct drm_device {
         */
        struct dentry *debugfs_root;
 
-       /**
-        * @debugfs_mutex:
-        *
-        * Protects &debugfs_list access.
-        */
-       struct mutex debugfs_mutex;
-
-       /**
-        * @debugfs_list:
-        *
-        * List of debugfs files to be created by the DRM device. The files
-        * must be added during drm_dev_register().
-        */
-       struct list_head debugfs_list;
-
        /* Everything below here is for legacy driver, never use! */
        /* private: */
 #if IS_ENABLED(CONFIG_DRM_LEGACY)