dma-buf: Rename debugfs symbols
authorT.J. Mercier <tjmercier@google.com>
Thu, 22 May 2025 23:04:25 +0000 (23:04 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 27 May 2025 16:51:25 +0000 (09:51 -0700)
Rename the debugfs list and mutex so it's clear they are now usable
without the need for CONFIG_DEBUG_FS. The list will always be populated
to support the creation of a BPF iterator for dmabufs.

Signed-off-by: T.J. Mercier <tjmercier@google.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Acked-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20250522230429.941193-2-tjmercier@google.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
drivers/dma-buf/dma-buf.c
include/linux/dma-buf.h

index 5baa83b855156516a0a766bee0789b122473efb3..8d151784e3024280da9fbd98647c3eb5b46f3795 100644 (file)
 
 static inline int is_dma_buf_file(struct file *);
 
-#if IS_ENABLED(CONFIG_DEBUG_FS)
-static DEFINE_MUTEX(debugfs_list_mutex);
-static LIST_HEAD(debugfs_list);
+static DEFINE_MUTEX(dmabuf_list_mutex);
+static LIST_HEAD(dmabuf_list);
 
-static void __dma_buf_debugfs_list_add(struct dma_buf *dmabuf)
+static void __dma_buf_list_add(struct dma_buf *dmabuf)
 {
-       mutex_lock(&debugfs_list_mutex);
-       list_add(&dmabuf->list_node, &debugfs_list);
-       mutex_unlock(&debugfs_list_mutex);
+       mutex_lock(&dmabuf_list_mutex);
+       list_add(&dmabuf->list_node, &dmabuf_list);
+       mutex_unlock(&dmabuf_list_mutex);
 }
 
-static void __dma_buf_debugfs_list_del(struct dma_buf *dmabuf)
+static void __dma_buf_list_del(struct dma_buf *dmabuf)
 {
        if (!dmabuf)
                return;
 
-       mutex_lock(&debugfs_list_mutex);
+       mutex_lock(&dmabuf_list_mutex);
        list_del(&dmabuf->list_node);
-       mutex_unlock(&debugfs_list_mutex);
+       mutex_unlock(&dmabuf_list_mutex);
 }
-#else
-static void __dma_buf_debugfs_list_add(struct dma_buf *dmabuf)
-{
-}
-
-static void __dma_buf_debugfs_list_del(struct dma_buf *dmabuf)
-{
-}
-#endif
 
 static char *dmabuffs_dname(struct dentry *dentry, char *buffer, int buflen)
 {
@@ -115,7 +105,7 @@ static int dma_buf_file_release(struct inode *inode, struct file *file)
        if (!is_dma_buf_file(file))
                return -EINVAL;
 
-       __dma_buf_debugfs_list_del(file->private_data);
+       __dma_buf_list_del(file->private_data);
 
        return 0;
 }
@@ -689,7 +679,7 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
        file->f_path.dentry->d_fsdata = dmabuf;
        dmabuf->file = file;
 
-       __dma_buf_debugfs_list_add(dmabuf);
+       __dma_buf_list_add(dmabuf);
 
        return dmabuf;
 
@@ -1630,7 +1620,7 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)
        size_t size = 0;
        int ret;
 
-       ret = mutex_lock_interruptible(&debugfs_list_mutex);
+       ret = mutex_lock_interruptible(&dmabuf_list_mutex);
 
        if (ret)
                return ret;
@@ -1639,7 +1629,7 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)
        seq_printf(s, "%-8s\t%-8s\t%-8s\t%-8s\texp_name\t%-8s\tname\n",
                   "size", "flags", "mode", "count", "ino");
 
-       list_for_each_entry(buf_obj, &debugfs_list, list_node) {
+       list_for_each_entry(buf_obj, &dmabuf_list, list_node) {
 
                ret = dma_resv_lock_interruptible(buf_obj->resv, NULL);
                if (ret)
@@ -1676,11 +1666,11 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)
 
        seq_printf(s, "\nTotal %d objects, %zu bytes\n", count, size);
 
-       mutex_unlock(&debugfs_list_mutex);
+       mutex_unlock(&dmabuf_list_mutex);
        return 0;
 
 error_unlock:
-       mutex_unlock(&debugfs_list_mutex);
+       mutex_unlock(&dmabuf_list_mutex);
        return ret;
 }
 
index 36216d28d8bdc01a9c9c47e27c392413f7f6c5fb..8ff4add71f8833dc318fd71aad84cf7d20b4570b 100644 (file)
@@ -370,10 +370,8 @@ struct dma_buf {
         */
        struct module *owner;
 
-#if IS_ENABLED(CONFIG_DEBUG_FS)
        /** @list_node: node for dma_buf accounting and debugging. */
        struct list_head list_node;
-#endif
 
        /** @priv: exporter specific private data for this buffer object. */
        void *priv;