arm64/panic: Unify all three existing notifier blocks
authorAnshuman Khandual <anshuman.khandual@arm.com>
Mon, 29 Jun 2020 04:38:31 +0000 (10:08 +0530)
committerCatalin Marinas <catalin.marinas@arm.com>
Thu, 2 Jul 2020 14:44:50 +0000 (15:44 +0100)
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 <anshuman.khandual@arm.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Steve Capper <steve.capper@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Link: https://lore.kernel.org/r/1593405511-7625-1-git-send-email-anshuman.khandual@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/cpufeature.h
arch/arm64/include/asm/memory.h
arch/arm64/kernel/cpufeature.c
arch/arm64/kernel/setup.c
arch/arm64/mm/init.c

index 5d1f4ae..e375529 100644 (file)
@@ -774,6 +774,7 @@ static inline unsigned int get_vmid_bits(u64 mmfr1)
 }
 
 u32 get_kvm_ipa_limit(void);
+void dump_cpu_features(void);
 
 #endif /* __ASSEMBLY__ */
 
index a1871bb..2a88cb7 100644 (file)
@@ -322,6 +322,7 @@ static inline void *phys_to_virt(phys_addr_t x)
        __is_lm_address(__addr) && pfn_valid(virt_to_pfn(__addr));      \
 })
 
+void dump_mem_limit(void);
 #endif /* !ASSEMBLY */
 
 /*
index 9f63053..9b79df9 100644 (file)
@@ -119,24 +119,11 @@ static inline void finalize_system_capabilities(void)
        static_branch_enable(&arm64_const_caps_ready);
 }
 
-static int dump_cpu_hwcaps(struct notifier_block *self, unsigned long v, void *p)
+void dump_cpu_features(void)
 {
        /* file-wide pr_fmt adds "CPU features: " prefix */
        pr_emerg("0x%*pb\n", ARM64_NCAPS, &cpu_hwcaps);
-       return 0;
-}
-
-static struct notifier_block cpu_hwcaps_notifier = {
-       .notifier_call = dump_cpu_hwcaps
-};
-
-static int __init register_cpu_hwcaps_dumper(void)
-{
-       atomic_notifier_chain_register(&panic_notifier_list,
-                                      &cpu_hwcaps_notifier);
-       return 0;
 }
-__initcall(register_cpu_hwcaps_dumper);
 
 DEFINE_STATIC_KEY_ARRAY_FALSE(cpu_hwcap_keys, ARM64_NCAPS);
 EXPORT_SYMBOL(cpu_hwcap_keys);
index 93b3844..c793276 100644 (file)
@@ -400,11 +400,7 @@ static int __init topology_init(void)
 }
 subsys_initcall(topology_init);
 
-/*
- * Dump out kernel offset information on panic.
- */
-static int dump_kernel_offset(struct notifier_block *self, unsigned long v,
-                             void *p)
+static void dump_kernel_offset(void)
 {
        const unsigned long offset = kaslr_offset();
 
@@ -415,17 +411,25 @@ static int dump_kernel_offset(struct notifier_block *self, unsigned long v,
        } else {
                pr_emerg("Kernel Offset: disabled\n");
        }
+}
+
+static int arm64_panic_block_dump(struct notifier_block *self,
+                                 unsigned long v, void *p)
+{
+       dump_kernel_offset();
+       dump_cpu_features();
+       dump_mem_limit();
        return 0;
 }
 
-static struct notifier_block kernel_offset_notifier = {
-       .notifier_call = dump_kernel_offset
+static struct notifier_block arm64_panic_block = {
+       .notifier_call = arm64_panic_block_dump
 };
 
-static int __init register_kernel_offset_dumper(void)
+static int __init register_arm64_panic_block(void)
 {
        atomic_notifier_chain_register(&panic_notifier_list,
-                                      &kernel_offset_notifier);
+                                      &arm64_panic_block);
        return 0;
 }
-__initcall(register_kernel_offset_dumper);
+device_initcall(register_arm64_panic_block);
index 1e93cfc..6c3eb42 100644 (file)
@@ -563,27 +563,11 @@ void free_initmem(void)
        unmap_kernel_range((u64)__init_begin, (u64)(__init_end - __init_begin));
 }
 
-/*
- * Dump out memory limit information on panic.
- */
-static int dump_mem_limit(struct notifier_block *self, unsigned long v, void *p)
+void dump_mem_limit(void)
 {
        if (memory_limit != PHYS_ADDR_MAX) {
                pr_emerg("Memory Limit: %llu MB\n", memory_limit >> 20);
        } else {
                pr_emerg("Memory Limit: none\n");
        }
-       return 0;
-}
-
-static struct notifier_block mem_limit_notifier = {
-       .notifier_call = dump_mem_limit,
-};
-
-static int __init register_mem_limit_dumper(void)
-{
-       atomic_notifier_chain_register(&panic_notifier_list,
-                                      &mem_limit_notifier);
-       return 0;
 }
-__initcall(register_mem_limit_dumper);