Skip to content

Commit e6b3944

Browse files
Zhen Leictmarinas
authored andcommitted
arm64: Use insert_resource() to simplify code
insert_resource() traverses the subtree layer by layer from the root node until a proper location is found. Compared with request_resource(), the parent node does not need to be determined in advance. In addition, move the insertion of node 'crashk_res' into function reserve_crashkernel() to make the associated code close together. Signed-off-by: Zhen Lei <[email protected]> Acked-by: John Donnelly <[email protected]> Acked-by: Baoquan He <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 2e5920b commit e6b3944

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

arch/arm64/kernel/setup.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ static void __init request_standard_resources(void)
225225
kernel_code.end = __pa_symbol(__init_begin - 1);
226226
kernel_data.start = __pa_symbol(_sdata);
227227
kernel_data.end = __pa_symbol(_end - 1);
228+
insert_resource(&iomem_resource, &kernel_code);
229+
insert_resource(&iomem_resource, &kernel_data);
228230

229231
num_standard_resources = memblock.memory.cnt;
230232
res_size = num_standard_resources * sizeof(*standard_resources);
@@ -246,20 +248,7 @@ static void __init request_standard_resources(void)
246248
res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1;
247249
}
248250

249-
request_resource(&iomem_resource, res);
250-
251-
if (kernel_code.start >= res->start &&
252-
kernel_code.end <= res->end)
253-
request_resource(res, &kernel_code);
254-
if (kernel_data.start >= res->start &&
255-
kernel_data.end <= res->end)
256-
request_resource(res, &kernel_data);
257-
#ifdef CONFIG_KEXEC_CORE
258-
/* Userspace will find "Crash kernel" region in /proc/iomem. */
259-
if (crashk_res.end && crashk_res.start >= res->start &&
260-
crashk_res.end <= res->end)
261-
request_resource(res, &crashk_res);
262-
#endif
251+
insert_resource(&iomem_resource, res);
263252
}
264253
}
265254

arch/arm64/mm/init.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ static void __init reserve_crashkernel(void)
137137
kmemleak_ignore_phys(crash_base);
138138
crashk_res.start = crash_base;
139139
crashk_res.end = crash_base + crash_size - 1;
140+
insert_resource(&iomem_resource, &crashk_res);
140141
}
141142

142143
/*

0 commit comments

Comments
 (0)