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 <drjo...@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 --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 <drjo...@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"
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to