Skip to content

Commit 3526589

Browse files
rmurphy-armChristoph Hellwig
authored andcommitted
swiotlb: simplify debugfs setup
Debugfs functions are already stubbed out for !CONFIG_DEBUG_FS, so we can remove most of the #ifdefs, just keeping one to manually optimise away the initcall when it would do nothing. We can also simplify the code itself by factoring out the directory creation and realising that the global io_tlb_default_mem now makes debugfs_dir redundant. Signed-off-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent dfcf2e0 commit 3526589

1 file changed

Lines changed: 10 additions & 30 deletions

File tree

kernel/dma/swiotlb.c

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@
3636
#include <linux/scatterlist.h>
3737
#include <linux/cc_platform.h>
3838
#include <linux/set_memory.h>
39-
#ifdef CONFIG_DEBUG_FS
4039
#include <linux/debugfs.h>
41-
#endif
4240
#ifdef CONFIG_DMA_RESTRICTED_POOL
4341
#include <linux/io.h>
4442
#include <linux/of.h>
@@ -756,47 +754,29 @@ bool is_swiotlb_active(struct device *dev)
756754
}
757755
EXPORT_SYMBOL_GPL(is_swiotlb_active);
758756

759-
#ifdef CONFIG_DEBUG_FS
760-
static struct dentry *debugfs_dir;
761-
762-
static void swiotlb_create_debugfs_files(struct io_tlb_mem *mem)
757+
static void swiotlb_create_debugfs_files(struct io_tlb_mem *mem,
758+
const char *dirname)
763759
{
760+
mem->debugfs = debugfs_create_dir(dirname, io_tlb_default_mem.debugfs);
761+
if (!mem->nslabs)
762+
return;
763+
764764
debugfs_create_ulong("io_tlb_nslabs", 0400, mem->debugfs, &mem->nslabs);
765765
debugfs_create_ulong("io_tlb_used", 0400, mem->debugfs, &mem->used);
766766
}
767767

768-
static int __init swiotlb_create_default_debugfs(void)
768+
static int __init __maybe_unused swiotlb_create_default_debugfs(void)
769769
{
770-
struct io_tlb_mem *mem = &io_tlb_default_mem;
771-
772-
debugfs_dir = debugfs_create_dir("swiotlb", NULL);
773-
if (mem->nslabs) {
774-
mem->debugfs = debugfs_dir;
775-
swiotlb_create_debugfs_files(mem);
776-
}
770+
swiotlb_create_debugfs_files(&io_tlb_default_mem, "swiotlb");
777771
return 0;
778772
}
779773

774+
#ifdef CONFIG_DEBUG_FS
780775
late_initcall(swiotlb_create_default_debugfs);
781-
782776
#endif
783777

784778
#ifdef CONFIG_DMA_RESTRICTED_POOL
785779

786-
#ifdef CONFIG_DEBUG_FS
787-
static void rmem_swiotlb_debugfs_init(struct reserved_mem *rmem)
788-
{
789-
struct io_tlb_mem *mem = rmem->priv;
790-
791-
mem->debugfs = debugfs_create_dir(rmem->name, debugfs_dir);
792-
swiotlb_create_debugfs_files(mem);
793-
}
794-
#else
795-
static void rmem_swiotlb_debugfs_init(struct reserved_mem *rmem)
796-
{
797-
}
798-
#endif
799-
800780
struct page *swiotlb_alloc(struct device *dev, size_t size)
801781
{
802782
struct io_tlb_mem *mem = dev->dma_io_tlb_mem;
@@ -858,7 +838,7 @@ static int rmem_swiotlb_device_init(struct reserved_mem *rmem,
858838

859839
rmem->priv = mem;
860840

861-
rmem_swiotlb_debugfs_init(rmem);
841+
swiotlb_create_debugfs_files(mem, rmem->name);
862842
}
863843

864844
dev->dma_io_tlb_mem = mem;

0 commit comments

Comments
 (0)