]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
riscv/mmiowb: Hook up mmwiob() implementation to asm-generic code
authorWill Deacon <will.deacon@arm.com>
Fri, 22 Feb 2019 14:45:42 +0000 (14:45 +0000)
committerWill Deacon <will.deacon@arm.com>
Mon, 8 Apr 2019 11:00:40 +0000 (12:00 +0100)
In a bid to kill off explicit mmiowb() usage in driver code, hook up
the asm-generic mmiowb() tracking code for riscv, so that an mmiowb()
is automatically issued from spin_unlock() if an I/O write was performed
in the critical section.

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

index eb56c82d8aa14caf0e6f5507102dd22fb208b9ac..6e30e8126799f1e7bb453c01353c6e39a457765f 100644 (file)
@@ -48,6 +48,7 @@ config RISCV
        select RISCV_TIMER
        select GENERIC_IRQ_MULTI_HANDLER
        select ARCH_HAS_PTE_SPECIAL
+       select ARCH_HAS_MMIOWB
        select HAVE_EBPF_JIT if 64BIT
 
 config MMU
index 221cd2ec78a4a1831ca62e107a866dcd63ff4014..cccd12cf27d44d134f274f49067d294cde3498b0 100644 (file)
@@ -21,7 +21,6 @@ generic-y += kvm_para.h
 generic-y += local.h
 generic-y += local64.h
 generic-y += mm-arch-hooks.h
-generic-y += mmiowb.h
 generic-y += mutex.h
 generic-y += percpu.h
 generic-y += preempt.h
index 1d9c1376dc642fb3fffb2ef764a6e88d9e8bc914..744fd92e77bc726f7a67aa7d68cb1beba1235f53 100644 (file)
@@ -20,6 +20,7 @@
 #define _ASM_RISCV_IO_H
 
 #include <linux/types.h>
+#include <asm/mmiowb.h>
 
 extern void __iomem *ioremap(phys_addr_t offset, unsigned long size);
 
@@ -99,18 +100,6 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
 }
 #endif
 
-/*
- * FIXME: I'm flip-flopping on whether or not we should keep this or enforce
- * the ordering with I/O on spinlocks like PowerPC does.  The worry is that
- * drivers won't get this correct, but I also don't want to introduce a fence
- * into the lock code that otherwise only uses AMOs (and is essentially defined
- * by the ISA to be correct).   For now I'm leaving this here: "o,w" is
- * sufficient to ensure that all writes to the device have completed before the
- * write to the spinlock is allowed to commit.  I surmised this from reading
- * "ACQUIRES VS I/O ACCESSES" in memory-barriers.txt.
- */
-#define mmiowb()       __asm__ __volatile__ ("fence o,w" : : : "memory");
-
 /*
  * Unordered I/O memory access primitives.  These are even more relaxed than
  * the relaxed versions, as they don't even order accesses between successive
@@ -165,7 +154,7 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
 #define __io_br()      do {} while (0)
 #define __io_ar(v)     __asm__ __volatile__ ("fence i,r" : : : "memory");
 #define __io_bw()      __asm__ __volatile__ ("fence w,o" : : : "memory");
-#define __io_aw()      do {} while (0)
+#define __io_aw()      mmiowb_set_pending()
 
 #define readb(c)       ({ u8  __v; __io_br(); __v = readb_cpu(c); __io_ar(__v); __v; })
 #define readw(c)       ({ u16 __v; __io_br(); __v = readw_cpu(c); __io_ar(__v); __v; })
diff --git a/arch/riscv/include/asm/mmiowb.h b/arch/riscv/include/asm/mmiowb.h
new file mode 100644 (file)
index 0000000..5d7e3a2
--- /dev/null
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _ASM_RISCV_MMIOWB_H
+#define _ASM_RISCV_MMIOWB_H
+
+/*
+ * "o,w" is sufficient to ensure that all writes to the device have completed
+ * before the write to the spinlock is allowed to commit.
+ */
+#define mmiowb()       __asm__ __volatile__ ("fence o,w" : : : "memory");
+
+#include <asm-generic/mmiowb.h>
+
+#endif /* ASM_RISCV_MMIOWB_H */