diff mbox

[1/6] arm: fix crash on cubietruck

Message ID 1414684625-9445-2-git-send-email-drjones@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andrew Jones Oct. 30, 2014, 3:57 p.m. UTC
Cubietruck seems to be more sensitive than my Midway when
attempting to use [ldr|str]ex instructions without caches
enabled (mmu disabled). Fix this by making the spinlock
implementation (currently the only user of *ex instructions)
conditional on the mmu being enabled.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 lib/arm/asm/mmu.h  | 11 +++++++++++
 lib/arm/spinlock.c |  7 +++++++
 2 files changed, 18 insertions(+)
 create mode 100644 lib/arm/asm/mmu.h
diff mbox

Patch

diff --git a/lib/arm/asm/mmu.h b/lib/arm/asm/mmu.h
new file mode 100644
index 0000000000000..987928b2c432c
--- /dev/null
+++ b/lib/arm/asm/mmu.h
@@ -0,0 +1,11 @@ 
+#ifndef __ASMARM_MMU_H_
+#define __ASMARM_MMU_H_
+/*
+ * Copyright (C) 2014, Red Hat Inc, Andrew Jones <drjones@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+
+#define mmu_enabled() (0)
+
+#endif /* __ASMARM_MMU_H_ */
diff --git a/lib/arm/spinlock.c b/lib/arm/spinlock.c
index d8a6d4c3383d6..e2bb1ace43c4e 100644
--- a/lib/arm/spinlock.c
+++ b/lib/arm/spinlock.c
@@ -1,12 +1,19 @@ 
 #include "libcflat.h"
 #include "asm/spinlock.h"
 #include "asm/barrier.h"
+#include "asm/mmu.h"
 
 void spin_lock(struct spinlock *lock)
 {
 	u32 val, fail;
 
 	dmb();
+
+	if (!mmu_enabled()) {
+		lock->v = 1;
+		return;
+	}
+
 	do {
 		asm volatile(
 		"1:	ldrex	%0, [%2]\n"