Skip to contentSkip to conversation

powerpc/machdep: warn when machine_is() used too early

PATCH Superseded Nathan Lynch 1 participant 1 message Feb 10, 2023 PowerPC

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/machdep: warn when machine_is() used too early

From: Nathan Lynch <[email protected]>

machine_is() can't provide correct results before probe_machine() has run. Warn when it's used too early in boot.

---
Prompted by my attempts to do some pseries-specific setup during rtas_initialize() and being puzzled for a while that it wasn't working.

---
 arch/powerpc/include/asm/machdep.h | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/machdep.h +7 -5
index 378b8d5836a7..8c0a799d18cd 100644
@@ -220,11 +220,13 @@ extern struct machdep_calls *machine_id;
 	EXPORT_SYMBOL(mach_##name);				\
 	struct machdep_calls mach_##name __machine_desc =
 
-#define machine_is(name) \
-	({ \
-		extern struct machdep_calls mach_##name \
-			__attribute__((weak));		 \
-		machine_id == &mach_##name; \
+#define machine_is(name)                                            \
+	({                                                          \
+		extern struct machdep_calls mach_##name             \
+			__attribute__((weak));                      \
+		WARN(!machine_id,                                   \
+		     "machine_is() called before probe_machine()"); \
+		machine_id == &mach_##name;                         \
 	})
 
 static inline void log_error(char *buf, unsigned int err_type, int fatal)

---
base-commit: 0bfb97203f5f300777624a2ad6f8f84aea3e8658
change-id: 20230210-warn-on-machine-is-before-probe-machine-37515b1f43bb

Best regards,

Signature · 1 line
Nathan Lynch <[email protected]>