]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ia64/mmiowb: Add unconditional mmiowb() to arch_spin_unlock()
authorWill Deacon <will.deacon@arm.com>
Fri, 22 Feb 2019 13:37:21 +0000 (13:37 +0000)
committerWill Deacon <will.deacon@arm.com>
Mon, 8 Apr 2019 11:00:32 +0000 (12:00 +0100)
The mmiowb() macro is horribly difficult to use and drivers will continue
to work most of the time if they omit a call when it is required.

Rather than rely on driver authors getting this right, push mmiowb() into
arch_spin_unlock() for ia64. If this is deemed to be a performance issue,
a subsequent optimisation could make use of ARCH_HAS_MMIOWB to elide
the barrier in cases where no I/O writes were performed inside the
critical section.

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/ia64/include/asm/Kbuild
arch/ia64/include/asm/io.h
arch/ia64/include/asm/mmiowb.h [new file with mode: 0644]
arch/ia64/include/asm/spinlock.h

index cabfe0280c33d871e63e7d994f6c4f57d8c45551..11f191689c9e8445a77ede3555452fb8d008a3d7 100644 (file)
@@ -5,7 +5,6 @@ generic-y += irq_work.h
 generic-y += kvm_para.h
 generic-y += mcs_spinlock.h
 generic-y += mm-arch-hooks.h
-generic-y += mmiowb.h
 generic-y += preempt.h
 generic-y += trace_clock.h
 generic-y += vtime.h
index 1e6fef69bb01c26286df9ea7963d092b442e66ab..a511d62d447ac1b3071a64cb2ee50c20bfaa76a9 100644 (file)
@@ -113,20 +113,6 @@ extern int valid_mmap_phys_addr_range (unsigned long pfn, size_t count);
  */
 #define __ia64_mf_a()  ia64_mfa()
 
-/**
- * ___ia64_mmiowb - I/O write barrier
- *
- * Ensure ordering of I/O space writes.  This will make sure that writes
- * following the barrier will arrive after all previous writes.  For most
- * ia64 platforms, this is a simple 'mf.a' instruction.
- *
- * See Documentation/driver-api/device-io.rst for more information.
- */
-static inline void ___ia64_mmiowb(void)
-{
-       ia64_mfa();
-}
-
 static inline void*
 __ia64_mk_io_addr (unsigned long port)
 {
@@ -161,7 +147,6 @@ __ia64_mk_io_addr (unsigned long port)
 #define __ia64_writew  ___ia64_writew
 #define __ia64_writel  ___ia64_writel
 #define __ia64_writeq  ___ia64_writeq
-#define __ia64_mmiowb  ___ia64_mmiowb
 
 /*
  * For the in/out routines, we need to do "mf.a" _after_ doing the I/O access to ensure
@@ -296,7 +281,6 @@ __outsl (unsigned long port, const void *src, unsigned long count)
 #define __outb         platform_outb
 #define __outw         platform_outw
 #define __outl         platform_outl
-#define __mmiowb       platform_mmiowb
 
 #define inb(p)         __inb(p)
 #define inw(p)         __inw(p)
@@ -310,7 +294,6 @@ __outsl (unsigned long port, const void *src, unsigned long count)
 #define outsb(p,s,c)   __outsb(p,s,c)
 #define outsw(p,s,c)   __outsw(p,s,c)
 #define outsl(p,s,c)   __outsl(p,s,c)
-#define mmiowb()       __mmiowb()
 
 /*
  * The address passed to these functions are ioremap()ped already.
diff --git a/arch/ia64/include/asm/mmiowb.h b/arch/ia64/include/asm/mmiowb.h
new file mode 100644 (file)
index 0000000..297b85a
--- /dev/null
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _ASM_IA64_MMIOWB_H
+#define _ASM_IA64_MMIOWB_H
+
+#include <asm/machvec.h>
+
+/**
+ * ___ia64_mmiowb - I/O write barrier
+ *
+ * Ensure ordering of I/O space writes.  This will make sure that writes
+ * following the barrier will arrive after all previous writes.  For most
+ * ia64 platforms, this is a simple 'mf.a' instruction.
+ */
+static inline void ___ia64_mmiowb(void)
+{
+       ia64_mfa();
+}
+
+#define __ia64_mmiowb  ___ia64_mmiowb
+#define mmiowb()       platform_mmiowb()
+
+#include <asm-generic/mmiowb.h>
+
+#endif /* _ASM_IA64_MMIOWB_H */
index afd0b3121b4c9565cd5c20d85e813e92fea50039..5f620e66384e37079396f0f177d49d19c5724c94 100644 (file)
@@ -73,6 +73,8 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
 {
        unsigned short  *p = (unsigned short *)&lock->lock + 1, tmp;
 
+       /* This could be optimised with ARCH_HAS_MMIOWB */
+       mmiowb();
        asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
        WRITE_ONCE(*p, (tmp + 2) & ~1);
 }