From 677ffa4448bd0b9ff79d99bd7a486ae56934826a Mon Sep 17 00:00:00 2001
From: Armin Luntzer <armin.luntzer@univie.ac.at>
Date: Tue, 12 Nov 2019 11:22:34 +0100
Subject: [PATCH] SPARC: add spin locks in bootmem_alloc(), bootmem_free()

---
 arch/sparc/kernel/bootmem.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/sparc/kernel/bootmem.c b/arch/sparc/kernel/bootmem.c
index 8673731..f554ccf 100644
--- a/arch/sparc/kernel/bootmem.c
+++ b/arch/sparc/kernel/bootmem.c
@@ -29,13 +29,14 @@
 #include <kernel/printk.h>
 #include <kernel/kernel.h>
 #include <asm/irqflags.h>
+#include <asm/spinlock.h>
 
 #include <chunk.h>
 
 
 /* the pool we use for our boot memory allocator */
 static struct chunk_pool phys_mem_pool;
-
+static struct spinlock bootmem_lock;
 
 /**
  * @brief boot memory allocator wrapper
@@ -103,7 +104,9 @@ void *bootmem_alloc(size_t size)
 		return NULL;
 
 	arch_local_irq_disable();
+	spin_lock_raw(&bootmem_lock);
 	ptr = chunk_alloc(&phys_mem_pool, size);
+	spin_unlock(&bootmem_lock);
 	arch_local_irq_enable();
 
 	if (!ptr) {
@@ -123,9 +126,17 @@ void *bootmem_alloc(size_t size)
 
 void bootmem_free(void *ptr)
 {
+#if 0
 	arch_local_irq_disable();
+#endif
+	spin_lock_raw(&bootmem_lock);
+
 	chunk_free(&phys_mem_pool, ptr);
+
+	spin_unlock(&bootmem_lock);
+#if 0
 	arch_local_irq_enable();
+#endif
 }
 
 
-- 
GitLab