hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/mm/cma_debug.c
....@@ -21,8 +21,6 @@
2121 unsigned long n;
2222 };
2323
24
-static struct dentry *cma_debugfs_root;
25
-
2624 static int cma_debugfs_get(void *data, u64 *val)
2725 {
2826 unsigned long *p = data;
....@@ -31,7 +29,7 @@
3129
3230 return 0;
3331 }
34
-DEFINE_SIMPLE_ATTRIBUTE(cma_debugfs_fops, cma_debugfs_get, NULL, "%llu\n");
32
+DEFINE_DEBUGFS_ATTRIBUTE(cma_debugfs_fops, cma_debugfs_get, NULL, "%llu\n");
3533
3634 static int cma_used_get(void *data, u64 *val)
3735 {
....@@ -46,7 +44,7 @@
4644
4745 return 0;
4846 }
49
-DEFINE_SIMPLE_ATTRIBUTE(cma_used_fops, cma_used_get, NULL, "%llu\n");
47
+DEFINE_DEBUGFS_ATTRIBUTE(cma_used_fops, cma_used_get, NULL, "%llu\n");
5048
5149 static int cma_maxchunk_get(void *data, u64 *val)
5250 {
....@@ -68,7 +66,7 @@
6866
6967 return 0;
7068 }
71
-DEFINE_SIMPLE_ATTRIBUTE(cma_maxchunk_fops, cma_maxchunk_get, NULL, "%llu\n");
69
+DEFINE_DEBUGFS_ATTRIBUTE(cma_maxchunk_fops, cma_maxchunk_get, NULL, "%llu\n");
7270
7371 static void cma_add_to_cma_mem_list(struct cma *cma, struct cma_mem *mem)
7472 {
....@@ -128,7 +126,7 @@
128126
129127 return cma_free_mem(cma, pages);
130128 }
131
-DEFINE_SIMPLE_ATTRIBUTE(cma_free_fops, NULL, cma_free_write, "%llu\n");
129
+DEFINE_DEBUGFS_ATTRIBUTE(cma_free_fops, NULL, cma_free_write, "%llu\n");
132130
133131 static int cma_alloc_mem(struct cma *cma, int count)
134132 {
....@@ -139,7 +137,7 @@
139137 if (!mem)
140138 return -ENOMEM;
141139
142
- p = cma_alloc(cma, count, 0, false);
140
+ p = cma_alloc(cma, count, 0, GFP_KERNEL);
143141 if (!p) {
144142 kfree(mem);
145143 return -ENOMEM;
....@@ -160,17 +158,16 @@
160158
161159 return cma_alloc_mem(cma, pages);
162160 }
163
-DEFINE_SIMPLE_ATTRIBUTE(cma_alloc_fops, NULL, cma_alloc_write, "%llu\n");
161
+DEFINE_DEBUGFS_ATTRIBUTE(cma_alloc_fops, NULL, cma_alloc_write, "%llu\n");
164162
165
-static void cma_debugfs_add_one(struct cma *cma, int idx)
163
+static void cma_debugfs_add_one(struct cma *cma, struct dentry *root_dentry)
166164 {
167165 struct dentry *tmp;
168166 char name[16];
169
- int u32s;
170167
171168 scnprintf(name, sizeof(name), "cma-%s", cma->name);
172169
173
- tmp = debugfs_create_dir(name, cma_debugfs_root);
170
+ tmp = debugfs_create_dir(name, root_dentry);
174171
175172 debugfs_create_file("alloc", 0200, tmp, cma, &cma_alloc_fops);
176173 debugfs_create_file("free", 0200, tmp, cma, &cma_free_fops);
....@@ -182,20 +179,21 @@
182179 debugfs_create_file("used", 0444, tmp, cma, &cma_used_fops);
183180 debugfs_create_file("maxchunk", 0444, tmp, cma, &cma_maxchunk_fops);
184181
185
- u32s = DIV_ROUND_UP(cma_bitmap_maxno(cma), BITS_PER_BYTE * sizeof(u32));
186
- debugfs_create_u32_array_hex("bitmap", 0444, tmp, (u32 *)cma->bitmap, u32s);
182
+ cma->dfs_bitmap.array = (u32 *)cma->bitmap;
183
+ cma->dfs_bitmap.n_elements = DIV_ROUND_UP(cma_bitmap_maxno(cma),
184
+ BITS_PER_BYTE * sizeof(u32));
185
+ debugfs_create_u32_array("bitmap", 0444, tmp, &cma->dfs_bitmap);
187186 }
188187
189188 static int __init cma_debugfs_init(void)
190189 {
190
+ struct dentry *cma_debugfs_root;
191191 int i;
192192
193193 cma_debugfs_root = debugfs_create_dir("cma", NULL);
194
- if (!cma_debugfs_root)
195
- return -ENOMEM;
196194
197195 for (i = 0; i < cma_area_count; i++)
198
- cma_debugfs_add_one(&cma_areas[i], i);
196
+ cma_debugfs_add_one(&cma_areas[i], cma_debugfs_root);
199197
200198 return 0;
201199 }