Skip to content

Commit 5c850d3

Browse files
tialaChristoph Hellwig
authored andcommitted
swiotlb: fix passing local variable to debugfs_create_ulong()
Debugfs node will be run-timely checked and so local variable should be not passed to debugfs_create_ulong(). Fix it via debugfs_create_file() to create io_tlb_used node and calculate used io tlb number with fops_io_tlb_used attribute. Fixes: 20347fc ("swiotlb: split up the global swiotlb lock") Signed-off-by: Tianyu Lan <tiala@microsoft.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 8419702 commit 5c850d3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

kernel/dma/swiotlb.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -912,17 +912,23 @@ bool is_swiotlb_active(struct device *dev)
912912
}
913913
EXPORT_SYMBOL_GPL(is_swiotlb_active);
914914

915+
static int io_tlb_used_get(void *data, u64 *val)
916+
{
917+
*val = mem_used(&io_tlb_default_mem);
918+
return 0;
919+
}
920+
DEFINE_DEBUGFS_ATTRIBUTE(fops_io_tlb_used, io_tlb_used_get, NULL, "%llu\n");
921+
915922
static void swiotlb_create_debugfs_files(struct io_tlb_mem *mem,
916923
const char *dirname)
917924
{
918-
unsigned long used = mem_used(mem);
919-
920925
mem->debugfs = debugfs_create_dir(dirname, io_tlb_default_mem.debugfs);
921926
if (!mem->nslabs)
922927
return;
923928

924929
debugfs_create_ulong("io_tlb_nslabs", 0400, mem->debugfs, &mem->nslabs);
925-
debugfs_create_ulong("io_tlb_used", 0400, mem->debugfs, &used);
930+
debugfs_create_file("io_tlb_used", 0400, mem->debugfs, NULL,
931+
&fops_io_tlb_used);
926932
}
927933

928934
static int __init __maybe_unused swiotlb_create_default_debugfs(void)

0 commit comments

Comments
 (0)