Skip to content

Commit 638d503

Browse files
Anshuman Khandualctmarinas
authored andcommitted
arm64/panic: Unify all three existing notifier blocks
Currently there are three different registered panic notifier blocks. This unifies all of them into a single one i.e arm64_panic_block, hence reducing code duplication and required calling sequence during panic. This preserves the existing dump sequence. While here, just use device_initcall() directly instead of __initcall() which has been a legacy alias for the earlier. This replacement is a pure cleanup with no functional implications. Signed-off-by: Anshuman Khandual <[email protected]> Acked-by: Mark Rutland <[email protected]> Cc: Will Deacon <[email protected]> Cc: Steve Capper <[email protected]> Cc: Mark Rutland <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent d4e0340 commit 638d503

File tree

5 files changed

+18
-41
lines changed

5 files changed

+18
-41
lines changed

arch/arm64/include/asm/cpufeature.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ static inline unsigned int get_vmid_bits(u64 mmfr1)
774774
}
775775

776776
u32 get_kvm_ipa_limit(void);
777+
void dump_cpu_features(void);
777778

778779
#endif /* __ASSEMBLY__ */
779780

arch/arm64/include/asm/memory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ static inline void *phys_to_virt(phys_addr_t x)
322322
__is_lm_address(__addr) && pfn_valid(virt_to_pfn(__addr)); \
323323
})
324324

325+
void dump_mem_limit(void);
325326
#endif /* !ASSEMBLY */
326327

327328
/*

arch/arm64/kernel/cpufeature.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,24 +119,11 @@ static inline void finalize_system_capabilities(void)
119119
static_branch_enable(&arm64_const_caps_ready);
120120
}
121121

122-
static int dump_cpu_hwcaps(struct notifier_block *self, unsigned long v, void *p)
122+
void dump_cpu_features(void)
123123
{
124124
/* file-wide pr_fmt adds "CPU features: " prefix */
125125
pr_emerg("0x%*pb\n", ARM64_NCAPS, &cpu_hwcaps);
126-
return 0;
127-
}
128-
129-
static struct notifier_block cpu_hwcaps_notifier = {
130-
.notifier_call = dump_cpu_hwcaps
131-
};
132-
133-
static int __init register_cpu_hwcaps_dumper(void)
134-
{
135-
atomic_notifier_chain_register(&panic_notifier_list,
136-
&cpu_hwcaps_notifier);
137-
return 0;
138126
}
139-
__initcall(register_cpu_hwcaps_dumper);
140127

141128
DEFINE_STATIC_KEY_ARRAY_FALSE(cpu_hwcap_keys, ARM64_NCAPS);
142129
EXPORT_SYMBOL(cpu_hwcap_keys);

arch/arm64/kernel/setup.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -400,11 +400,7 @@ static int __init topology_init(void)
400400
}
401401
subsys_initcall(topology_init);
402402

403-
/*
404-
* Dump out kernel offset information on panic.
405-
*/
406-
static int dump_kernel_offset(struct notifier_block *self, unsigned long v,
407-
void *p)
403+
static void dump_kernel_offset(void)
408404
{
409405
const unsigned long offset = kaslr_offset();
410406

@@ -415,17 +411,25 @@ static int dump_kernel_offset(struct notifier_block *self, unsigned long v,
415411
} else {
416412
pr_emerg("Kernel Offset: disabled\n");
417413
}
414+
}
415+
416+
static int arm64_panic_block_dump(struct notifier_block *self,
417+
unsigned long v, void *p)
418+
{
419+
dump_kernel_offset();
420+
dump_cpu_features();
421+
dump_mem_limit();
418422
return 0;
419423
}
420424

421-
static struct notifier_block kernel_offset_notifier = {
422-
.notifier_call = dump_kernel_offset
425+
static struct notifier_block arm64_panic_block = {
426+
.notifier_call = arm64_panic_block_dump
423427
};
424428

425-
static int __init register_kernel_offset_dumper(void)
429+
static int __init register_arm64_panic_block(void)
426430
{
427431
atomic_notifier_chain_register(&panic_notifier_list,
428-
&kernel_offset_notifier);
432+
&arm64_panic_block);
429433
return 0;
430434
}
431-
__initcall(register_kernel_offset_dumper);
435+
device_initcall(register_arm64_panic_block);

arch/arm64/mm/init.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -563,27 +563,11 @@ void free_initmem(void)
563563
unmap_kernel_range((u64)__init_begin, (u64)(__init_end - __init_begin));
564564
}
565565

566-
/*
567-
* Dump out memory limit information on panic.
568-
*/
569-
static int dump_mem_limit(struct notifier_block *self, unsigned long v, void *p)
566+
void dump_mem_limit(void)
570567
{
571568
if (memory_limit != PHYS_ADDR_MAX) {
572569
pr_emerg("Memory Limit: %llu MB\n", memory_limit >> 20);
573570
} else {
574571
pr_emerg("Memory Limit: none\n");
575572
}
576-
return 0;
577-
}
578-
579-
static struct notifier_block mem_limit_notifier = {
580-
.notifier_call = dump_mem_limit,
581-
};
582-
583-
static int __init register_mem_limit_dumper(void)
584-
{
585-
atomic_notifier_chain_register(&panic_notifier_list,
586-
&mem_limit_notifier);
587-
return 0;
588573
}
589-
__initcall(register_mem_limit_dumper);

0 commit comments

Comments
 (0)