git: 0c5a770cc450 - main - fdt: fix panic in fdt_slicer/geom due to recent geom changes

From: Adrian Chadd <adrian_at_FreeBSD.org>
Date: Tue, 08 Apr 2025 03:47:33 UTC
The branch main has been updated by adrian:

URL: https://cgit.FreeBSD.org/src/commit/?id=0c5a770cc4504f3becb8df0bbfca57c7a47b71f2

commit 0c5a770cc4504f3becb8df0bbfca57c7a47b71f2
Author:     Adrian Chadd <adrian@FreeBSD.org>
AuthorDate: 2025-04-06 23:52:29 +0000
Commit:     Adrian Chadd <adrian@FreeBSD.org>
CommitDate: 2025-04-08 03:47:09 +0000

    fdt: fix panic in fdt_slicer/geom due to recent geom changes
    
    A recent change in GEOM ordering (c11b701915116bf512f3d77dfdac7a867f51ca0a -
    "geom: Push GEOM sysinit ordering to after devctl" changed the GEOM init
    ordering to SI_ORDER_THIRD.  However, the FDT slicer / GEOM flash
    slice code needs the GEOM subsystem to be initialised before it
    starts loading in flash slices from FDT, and will panic because
    the mutex isn't initialised.
    
    So bump this now to SI_ORDER_FOURTH, so it occurs after the GEOM
    initialisation.
    
    Differential Revision:  https://reviews.freebsd.org/D49692
    Reviewed by:    jhibbits
---
 sys/dev/fdt/fdt_slicer.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/dev/fdt/fdt_slicer.c b/sys/dev/fdt/fdt_slicer.c
index 5c1d11cfdcf5..3ba4eddf8b61 100644
--- a/sys/dev/fdt/fdt_slicer.c
+++ b/sys/dev/fdt/fdt_slicer.c
@@ -156,12 +156,12 @@ fdt_slicer_cleanup(void)
 }
 
 /*
- * Must be initialized after GEOM classes (SI_SUB_DRIVERS/SI_ORDER_SECOND),
+ * Must be initialized after GEOM classes (SI_SUB_DRIVERS/SI_ORDER_THIRD),
  * i. e. after g_init() is called, due to the use of the GEOM topology_lock
  * in flash_register_slicer().  However, must be before SI_SUB_CONFIGURE.
  */
-SYSINIT(fdt_slicer, SI_SUB_DRIVERS, SI_ORDER_THIRD, fdt_slicer_init, NULL);
-SYSUNINIT(fdt_slicer, SI_SUB_DRIVERS, SI_ORDER_THIRD, fdt_slicer_cleanup, NULL);
+SYSINIT(fdt_slicer, SI_SUB_DRIVERS, SI_ORDER_FOURTH, fdt_slicer_init, NULL);
+SYSUNINIT(fdt_slicer, SI_SUB_DRIVERS, SI_ORDER_FOURTH, fdt_slicer_cleanup, NULL);
 
 static int
 mod_handler(module_t mod, int type, void *data)
@@ -178,6 +178,6 @@ static moduledata_t fdt_slicer_mod = {
 	"fdt_slicer", mod_handler, NULL
 };
 
-DECLARE_MODULE(fdt_slicer, fdt_slicer_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD);
+DECLARE_MODULE(fdt_slicer, fdt_slicer_mod, SI_SUB_DRIVERS, SI_ORDER_FOURTH);
 MODULE_DEPEND(fdt_slicer, geom_flashmap, 0, 0, 0);
 MODULE_VERSION(fdt_slicer, 1);