mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] Introduce arch_do_panic
@ 2026-07-27  8:58 Mete Durlu
  2026-07-27  8:58 ` [PATCH 1/3] panic: " Mete Durlu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mete Durlu @ 2026-07-27  8:58 UTC (permalink / raw)
  To: Andrew Morton, Petr Mladek, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Michael Holzheu, David S. Miller, Andreas Larsson
  Cc: linux-kernel, linux-s390, sparclinux, Mete Durlu

Replace architecture-specific ifdef sections in vpanic() with a clean
arch_do_panic() hook. Currently s390 and sparc embed their panic
handlers directly in vpanic() using preprocessor conditionals, making
the common code path harder to maintain.

Introduce arch_do_panic() as an architecture extension point called at
the end of vpanic(). Architectures can use this hook to implement their
specific panic handling without polluting the generic panic code.

Move s390 panic handling from the panic_notifier chain to
arch_do_panic(). This corrects the execution order so that the
panic_timeout is properly evaluated before architecture-specific
actions. The previous notifier-based approach executed too early in the
panic sequence. 

Move sparc panic handling from ifdef blocks to arch_do_panic(). Remove
the preprocessor conditionals from vpanic() and place the Stop-A
enablement code in architecture-specific files where it belongs.

The cleanup reduces vpanic() complexity and establishes a pattern for other
architectures needing custom panic behavior.

Signed-off-by: Mete Durlu <meted@linux.ibm.com>
---
Mete Durlu (3):
      panic: Introduce arch_do_panic
      s390: Implement arch_do_panic
      sparc: Implement arch_do_panic

 arch/s390/include/asm/ipl.h    |  1 +
 arch/s390/include/asm/setup.h  |  3 +++
 arch/s390/kernel/ipl.c         | 15 +--------------
 arch/sparc/include/asm/setup.h |  4 +++-
 arch/sparc/kernel/setup.c      |  8 ++++++++
 kernel/panic.c                 | 18 ++++++------------
 6 files changed, 22 insertions(+), 27 deletions(-)
---
base-commit: 48a5a7ab8d6ab7090564339e039c421f315de912
change-id: 20260724-arch_do_panic-a97f699aa332

Best regards,
-- 
Mete Durlu <meted@linux.ibm.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] panic: Introduce arch_do_panic
  2026-07-27  8:58 [PATCH 0/3] Introduce arch_do_panic Mete Durlu
@ 2026-07-27  8:58 ` Mete Durlu
  2026-07-27  8:58 ` [PATCH 2/3] s390: Implement arch_do_panic Mete Durlu
  2026-07-27  8:58 ` [PATCH 3/3] sparc: " Mete Durlu
  2 siblings, 0 replies; 4+ messages in thread
From: Mete Durlu @ 2026-07-27  8:58 UTC (permalink / raw)
  To: Andrew Morton, Petr Mladek, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Michael Holzheu, David S. Miller, Andreas Larsson
  Cc: linux-kernel, linux-s390, sparclinux, Mete Durlu

Introduce a hook for architectures to put their specific panic handlers.
s390 and sparc already has ifdef preprocessor checks to execute
architecture specific code. Pave the way for vpanic() cleanup.

Suggested-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
---
 kernel/panic.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/panic.c b/kernel/panic.c
index 213725b612aa..1eb0cdc159d9 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -567,6 +567,11 @@ static void panic_other_cpus_shutdown(bool crash_kexec)
 		crash_smp_send_stop();
 }
 
+#ifndef arch_do_panic
+#define arch_do_panic arch_do_panic
+static inline void arch_do_panic(void) {}
+#endif
+
 /**
  * vpanic - halt the system
  * @fmt: The text string to print
@@ -756,6 +761,7 @@ void vpanic(const char *fmt, va_list args)
 #endif
 	pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
 
+	arch_do_panic();
 	/* Do not scroll important messages printed above */
 	suppress_printk = 1;
 

-- 
2.55.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] s390: Implement arch_do_panic
  2026-07-27  8:58 [PATCH 0/3] Introduce arch_do_panic Mete Durlu
  2026-07-27  8:58 ` [PATCH 1/3] panic: " Mete Durlu
@ 2026-07-27  8:58 ` Mete Durlu
  2026-07-27  8:58 ` [PATCH 3/3] sparc: " Mete Durlu
  2 siblings, 0 replies; 4+ messages in thread
From: Mete Durlu @ 2026-07-27  8:58 UTC (permalink / raw)
  To: Andrew Morton, Petr Mladek, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Michael Holzheu, David S. Miller, Andreas Larsson
  Cc: linux-kernel, linux-s390, sparclinux, Mete Durlu

s390 has a custom panic handler which carries out user specified actions
during a panic scenario. This handler is invoked via the panic_notifier
call chain and executed before panic_timeout value is evaluated in
common code.

Use arch_do_panic() hook to invoke arch specific panic handling instead
of using panic_notifier call chain. The execution order of panic
handlers now allow for user specified panic_timeout value to be taken
into account.

Fixes: ff6b8ea68f4b ("[S390] ipl/dump on panic.")
Suggested-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
---
 arch/s390/include/asm/ipl.h   |  1 +
 arch/s390/include/asm/setup.h |  3 +++
 arch/s390/kernel/ipl.c        | 15 +--------------
 kernel/panic.c                |  3 ---
 4 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/arch/s390/include/asm/ipl.h b/arch/s390/include/asm/ipl.h
index b0d00032479d..38924c4a5d1d 100644
--- a/arch/s390/include/asm/ipl.h
+++ b/arch/s390/include/asm/ipl.h
@@ -166,5 +166,6 @@ enum diag308_rc {
 extern int diag308(unsigned long subcode, void *addr);
 extern void store_status(void (*fn)(void *), void *data);
 extern void lgr_info_log(void);
+void s390_do_panic(void);
 
 #endif /* _ASM_S390_IPL_H */
diff --git a/arch/s390/include/asm/setup.h b/arch/s390/include/asm/setup.h
index cbf60ade741d..6b38017f7cf3 100644
--- a/arch/s390/include/asm/setup.h
+++ b/arch/s390/include/asm/setup.h
@@ -90,6 +90,9 @@ extern void (*_machine_restart)(char *command);
 extern void (*_machine_halt)(void);
 extern void (*_machine_power_off)(void);
 
+void arch_do_panic(void);
+#define arch_do_panic arch_do_panic
+
 struct oldmem_data {
 	unsigned long start;
 	unsigned long size;
diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
index 3c346b02ceb9..8ab02e821256 100644
--- a/arch/s390/kernel/ipl.c
+++ b/arch/s390/kernel/ipl.c
@@ -2115,7 +2115,7 @@ static ssize_t on_panic_store(struct kobject *kobj,
 }
 static struct kobj_attribute on_panic_attr = __ATTR_RW(on_panic);
 
-static void do_panic(void)
+void arch_do_panic(void)
 {
 	lgr_info_log();
 	on_panic_trigger.action->fn(&on_panic_trigger);
@@ -2331,18 +2331,6 @@ static int __init vmcmd_on_poff_setup(char *str)
 }
 __setup("vmpoff=", vmcmd_on_poff_setup);
 
-static int on_panic_notify(struct notifier_block *self,
-			   unsigned long event, void *data)
-{
-	do_panic();
-	return NOTIFY_OK;
-}
-
-static struct notifier_block on_panic_nb = {
-	.notifier_call = on_panic_notify,
-	.priority = INT_MIN,
-};
-
 void __init setup_ipl(void)
 {
 	BUILD_BUG_ON(sizeof(struct ipl_parameter_block) != PAGE_SIZE);
@@ -2375,7 +2363,6 @@ void __init setup_ipl(void)
 		/* We have no info to copy */
 		break;
 	}
-	atomic_notifier_chain_register(&panic_notifier_list, &on_panic_nb);
 }
 
 void __no_stack_protector s390_reset_system(void)
diff --git a/kernel/panic.c b/kernel/panic.c
index 1eb0cdc159d9..de0bda946cab 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -755,9 +755,6 @@ void vpanic(const char *fmt, va_list args)
 		pr_emerg("Press Stop-A (L1-A) from sun keyboard or send break\n"
 			 "twice on console to return to the boot prom\n");
 	}
-#endif
-#if defined(CONFIG_S390)
-	disabled_wait();
 #endif
 	pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
 

-- 
2.55.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] sparc: Implement arch_do_panic
  2026-07-27  8:58 [PATCH 0/3] Introduce arch_do_panic Mete Durlu
  2026-07-27  8:58 ` [PATCH 1/3] panic: " Mete Durlu
  2026-07-27  8:58 ` [PATCH 2/3] s390: Implement arch_do_panic Mete Durlu
@ 2026-07-27  8:58 ` Mete Durlu
  2 siblings, 0 replies; 4+ messages in thread
From: Mete Durlu @ 2026-07-27  8:58 UTC (permalink / raw)
  To: Andrew Morton, Petr Mladek, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Michael Holzheu, David S. Miller, Andreas Larsson
  Cc: linux-kernel, linux-s390, sparclinux, Mete Durlu

Implement sparc specific arch_do_panic() instead of using sparc specific
ifdef sections in vpanic() code.

Signed-off-by: Mete Durlu <meted@linux.ibm.com>
---
 arch/sparc/include/asm/setup.h | 4 +++-
 arch/sparc/kernel/setup.c      | 8 ++++++++
 kernel/panic.c                 | 9 ---------
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/arch/sparc/include/asm/setup.h b/arch/sparc/include/asm/setup.h
index 21bed5514028..557e8277a640 100644
--- a/arch/sparc/include/asm/setup.h
+++ b/arch/sparc/include/asm/setup.h
@@ -43,7 +43,6 @@ void __init device_scan(void);
 
 /* unaligned_32.c */
 unsigned long safe_compute_effective_address(struct pt_regs *, unsigned int);
-
 #endif
 
 #ifdef CONFIG_SPARC64
@@ -67,4 +66,7 @@ void sun_do_break(void);
 extern int stop_a_enabled;
 extern int scons_pwroff;
 
+void arch_do_panic(void);
+#define arch_do_panic arch_do_panic
+
 #endif /* _SPARC_SETUP_H */
diff --git a/arch/sparc/kernel/setup.c b/arch/sparc/kernel/setup.c
index 4975867d9001..87d3569c520f 100644
--- a/arch/sparc/kernel/setup.c
+++ b/arch/sparc/kernel/setup.c
@@ -36,6 +36,14 @@ static const struct ctl_table sparc_sysctl_table[] = {
 #endif
 };
 
+void arch_do_panic(void)
+{
+	extern int stop_a_enabled;
+	/* Make sure the user can actually press Stop-A (L1-A) */
+	stop_a_enabled = 1;
+	pr_emerg("Press Stop-A (L1-A) from sun keyboard or send break\n"
+		 "twice on console to return to the boot prom\n");
+}
 
 static int __init init_sparc_sysctls(void)
 {
diff --git a/kernel/panic.c b/kernel/panic.c
index de0bda946cab..593aa2c24d93 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -747,15 +747,6 @@ void vpanic(const char *fmt, va_list args)
 			reboot_mode = panic_reboot_mode;
 		emergency_restart();
 	}
-#ifdef __sparc__
-	{
-		extern int stop_a_enabled;
-		/* Make sure the user can actually press Stop-A (L1-A) */
-		stop_a_enabled = 1;
-		pr_emerg("Press Stop-A (L1-A) from sun keyboard or send break\n"
-			 "twice on console to return to the boot prom\n");
-	}
-#endif
 	pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
 
 	arch_do_panic();

-- 
2.55.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-07-27  9:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-27  8:58 [PATCH 0/3] Introduce arch_do_panic Mete Durlu
2026-07-27  8:58 ` [PATCH 1/3] panic: " Mete Durlu
2026-07-27  8:58 ` [PATCH 2/3] s390: Implement arch_do_panic Mete Durlu
2026-07-27  8:58 ` [PATCH 3/3] sparc: " Mete Durlu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®