staging: android: ion: add 'heaps' debug node

console:/ # cat /sys/kernel/debug/ion/heaps
id      type    name
2       0       ion_system_heap
1       1       ion_system_contig_heap
0       0       ion_secure_heap

Change-Id: I0d798205573eb5a2b3177d51f784bf8c89ab7313
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
This commit is contained in:
Jianqun Xu
2021-03-03 17:34:53 +08:00
committed by Tao Huang
parent e603d7d441
commit b3bc336903

View File

@@ -777,6 +777,34 @@ static int ion_init_sysfs(void)
return 0;
}
#ifdef CONFIG_DEBUG_FS
static int ion_heaps_show(struct seq_file *s, void *unused)
{
struct ion_device *dev = internal_dev;
struct ion_heap *heap;
down_read(&dev->lock);
seq_printf(s, "%s\t%s\t%s\n", "id", "type", "name");
plist_for_each_entry(heap, &dev->heaps, node) {
seq_printf(s, "%u\t%u\t%s\n", heap->id, heap->type, heap->name);
}
up_read(&dev->lock);
return 0;
}
static int ion_heaps_open(struct inode *inode, struct file *file)
{
return single_open(file, ion_heaps_show, NULL);
}
static const struct file_operations ion_heaps_operations = {
.open = ion_heaps_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#endif
static int ion_device_create(void)
{
struct ion_device *idev;
@@ -803,6 +831,10 @@ static int ion_device_create(void)
}
idev->debug_root = debugfs_create_dir("ion", NULL);
#ifdef CONFIG_DEBUG_FS
debugfs_create_file("heaps", 0444, idev->debug_root, NULL,
&ion_heaps_operations);
#endif
idev->buffers = RB_ROOT;
mutex_init(&idev->buffer_lock);
init_rwsem(&idev->lock);