2 * CMA DebugFS Interface
4 * Copyright (c) 2015 Sasha Levin <sasha.levin@oracle.com>
8 #include <linux/debugfs.h>
13 static struct dentry
*cma_debugfs_root
;
15 static int cma_debugfs_get(void *data
, u64
*val
)
17 unsigned long *p
= data
;
24 DEFINE_SIMPLE_ATTRIBUTE(cma_debugfs_fops
, cma_debugfs_get
, NULL
, "%llu\n");
26 static void cma_debugfs_add_one(struct cma
*cma
, int idx
)
32 sprintf(name
, "cma-%d", idx
);
34 tmp
= debugfs_create_dir(name
, cma_debugfs_root
);
36 debugfs_create_file("base_pfn", S_IRUGO
, tmp
,
37 &cma
->base_pfn
, &cma_debugfs_fops
);
38 debugfs_create_file("count", S_IRUGO
, tmp
,
39 &cma
->count
, &cma_debugfs_fops
);
40 debugfs_create_file("order_per_bit", S_IRUGO
, tmp
,
41 &cma
->order_per_bit
, &cma_debugfs_fops
);
43 u32s
= DIV_ROUND_UP(cma_bitmap_maxno(cma
), BITS_PER_BYTE
* sizeof(u32
));
44 debugfs_create_u32_array("bitmap", S_IRUGO
, tmp
, (u32
*)cma
->bitmap
, u32s
);
47 static int __init
cma_debugfs_init(void)
51 cma_debugfs_root
= debugfs_create_dir("cma", NULL
);
52 if (!cma_debugfs_root
)
55 for (i
= 0; i
< cma_area_count
; i
++)
56 cma_debugfs_add_one(&cma_areas
[i
], i
);
60 late_initcall(cma_debugfs_init
);