Patch "riscv,mmio: Fix readX()-to-delay() ordering" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    riscv,mmio: Fix readX()-to-delay() ordering

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     riscv-mmio-fix-readx-to-delay-ordering.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 7ef32e3e7eea1d41b5a7b283a715e565114328a9
Author: Andrea Parri <parri.andrea@xxxxxxxxx>
Date:   Thu Aug 3 06:27:38 2023 +0200

    riscv,mmio: Fix readX()-to-delay() ordering
    
    [ Upstream commit 4eb2eb1b4c0eb07793c240744843498564a67b83 ]
    
    Section 2.1 of the Platform Specification [1] states:
    
      Unless otherwise specified by a given I/O device, I/O devices are on
      ordering channel 0 (i.e., they are point-to-point strongly ordered).
    
    which is not sufficient to guarantee that a readX() by a hart completes
    before a subsequent delay() on the same hart (cf. memory-barriers.txt,
    "Kernel I/O barrier effects").
    
    Set the I(nput) bit in __io_ar() to restore the ordering, align inline
    comments.
    
    [1] https://github.com/riscv/riscv-platform-specs
    
    Signed-off-by: Andrea Parri <parri.andrea@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20230803042738.5937-1-parri.andrea@xxxxxxxxx
    Fixes: fab957c11efe ("RISC-V: Atomic and Locking Code")
    Cc: stable@xxxxxxxxxxxxxxx
    Signed-off-by: Palmer Dabbelt <palmer@xxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/riscv/include/asm/mmio.h b/arch/riscv/include/asm/mmio.h
index 308b98f857539..2c08dd4292b27 100644
--- a/arch/riscv/include/asm/mmio.h
+++ b/arch/riscv/include/asm/mmio.h
@@ -114,9 +114,9 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
  * Relaxed I/O memory access primitives. These follow the Device memory
  * ordering rules but do not guarantee any ordering relative to Normal memory
  * accesses.  These are defined to order the indicated access (either a read or
- * write) with all other I/O memory accesses. Since the platform specification
- * defines that all I/O regions are strongly ordered on channel 2, no explicit
- * fences are required to enforce this ordering.
+ * write) with all other I/O memory accesses to the same peripheral. Since the
+ * platform specification defines that all I/O regions are strongly ordered on
+ * channel 0, no explicit fences are required to enforce this ordering.
  */
 /* FIXME: These are now the same as asm-generic */
 #define __io_rbr()		do {} while (0)
@@ -138,14 +138,14 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
 #endif
 
 /*
- * I/O memory access primitives. Reads are ordered relative to any
- * following Normal memory access. Writes are ordered relative to any prior
- * Normal memory access.  The memory barriers here are necessary as RISC-V
+ * I/O memory access primitives.  Reads are ordered relative to any following
+ * Normal memory read and delay() loop.  Writes are ordered relative to any
+ * prior Normal memory write.  The memory barriers here are necessary as RISC-V
  * doesn't define any ordering between the memory space and the I/O space.
  */
 #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_ar(v)	({ __asm__ __volatile__ ("fence i,ir" : : : "memory"); })
+#define __io_bw()	({ __asm__ __volatile__ ("fence w,o" : : : "memory"); })
 #define __io_aw()	mmiowb_set_pending()
 
 #define readb(c)	({ u8  __v; __io_br(); __v = readb_cpu(c); __io_ar(__v); __v; })



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux