Skip to contentSkip to conversation

sandbox: Improve dummy local_irq_save implementation

PATCH In review Tom Rini 1 participant 3 messages Aug 12, 2025 – Aug 19, 2025 Atomic infrastructure

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/2 sandbox: Improve dummy local_irq_save implementation

Normally, local_save_flags is used as part of the local_irq_* macros, so remove that as it's unused. Make local_irq_save do something to the passed variable so that it won't trigger unused variable warnings later.

---
 arch/sandbox/include/asm/system.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/sandbox/include/asm/system.h +1 -2
index 7933b6292e21..73f34683b275 100644
@@ -7,10 +7,9 @@
 #define __ASM_SANDBOX_SYSTEM_H
 
 /* Define this as nops for sandbox architecture */
-#define local_irq_save(x)
+#define local_irq_save(x)	do { (x) = 0; } while (0)
 #define local_irq_enable()
 #define local_irq_disable()
-#define local_save_flags(x)
 #define local_irq_restore(x)
 
 #endif
Signature · 1 line
2.43.0
author
#1 lore raw

PATCH 2/2 sandbox: Add generic asm/atomic.h

In order to compile code that uses <asm/atomic.h> on sandbox, we must provide this header. RISC-V shows us today how to do so with the generic header implementation, so copy that.

---
 arch/sandbox/include/asm/atomic.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 arch/sandbox/include/asm/atomic.h
arch/sandbox/include/asm/atomic.h new file +15 -0
new file mode 100644
index 000000000000..2fe49f52f34e
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Based on arch/riscv/include/asm/atomic.h which is:
+ * Copyright 2023 SiFive, Inc.
+ */
+
+#ifndef __SANDBOX_ATOMIC_H
+#define __SANDBOX_ATOMIC_H
+
+/* use the generic asm/atomic.h until we define a better one */
+
+#include <asm/system.h>
+#include <asm-generic/atomic.h>
+
+#endif
Signature · 1 line
2.43.0
author
#2 lore raw
In reply to Tom Rini
Quoted 5 lines · Tom Rini

Normally, local_save_flags is used as part of the local_irq_* macros, so remove that as it's unused. Make local_irq_save do something to the passed variable so that it won't trigger unused variable warnings later.

Applied to u-boot/next, thanks!

[1/2] sandbox: Improve dummy local_irq_save implementation

      commit: 58998fed9e63e8310a96229565d2996ad29d191e
[2/2] sandbox: Add generic asm/atomic.h
      commit: 66ff673a8e9f56d2c08a32d12867094c77ea5fd3
Signature · 1 line
Tom