Hi, pinging and refreshing this patch

What it does:
allow arm64 cpus to break from the loop of waiting to start core and
drop to DDB or OS.

Patch based on same concept in amd64 cpu.c

Any suggestions? Good to go?

ср, 19 апр. 2023 г. в 02:32, S V <ner...@gmail.com>:
>
> Hello, tech!
>
> I'm attaching simple patch that adds two "features" to mp kernel for arm64 
> arch:
> 1. It allows to enable debug flag to drop to DDB to debug mp init problems
> 2. It allows some buggy arm64 processors to break from loop and dirty
> (or not so dirty) boot to multicore instead of eternal hang in while.
>
> This based on same idea as amd64 cpu.c function - instead of waiting for 
> while()
> to boot secondary core either continue to try boot next one or drop to DDB.
>
>
>
> --
> Nerfur Dragon
> -==(UDIC)==-
Index: sys/arch/arm64/arm64/cpu.c
===================================================================
RCS file: /cvs/src/sys/arch/arm64/arm64/cpu.c,v
retrieving revision 1.97
diff -u -p -r1.97 cpu.c
--- sys/arch/arm64/arm64/cpu.c	16 Jul 2023 16:13:46 -0000	1.97
+++ sys/arch/arm64/arm64/cpu.c	25 Jul 2023 10:24:17 -0000
@@ -1087,6 +1087,8 @@ cpu_start_secondary(struct cpu_info *ci,
 void
 cpu_boot_secondary(struct cpu_info *ci)
 {
+	int i;
+
 	atomic_setbits_int(&ci->ci_flags, CPUF_GO);
 	__asm volatile("dsb sy; sev" ::: "memory");
 
@@ -1096,8 +1098,17 @@ cpu_boot_secondary(struct cpu_info *ci)
 	 */
 	arm_send_ipi(ci, ARM_IPI_NOP);
 
-	while ((ci->ci_flags & CPUF_RUNNING) == 0)
+	for (i = 1000; (!(ci->ci_flags & CPUF_RUNNING)) && i>0;i--) {
 		__asm volatile("wfe");
+	}
+	if (! (ci->ci_flags & CPUF_RUNNING)) {
+		printf("cpu %d failed to start\n", ci->ci_cpuid);
+#if defined(MPDEBUG) && defined(DDB)
+		printf("dropping into debugger; continue from here to resume boot\n");
+		db_enter();
+#endif
+	}
+
 }
 
 void

Reply via email to