summaryrefslogtreecommitdiff
path: root/include/linux/compiler.h
diff options
context:
space:
mode:
authorRodrigo Vivi <rodrigo.vivi@intel.com>2021-01-08 06:03:51 -0500
committerRodrigo Vivi <rodrigo.vivi@intel.com>2021-01-08 06:03:51 -0500
commit10205618052908770451acd33eaeaa7685e97ed2 (patch)
tree4d025943e32f343fa917db7abed8a606faa17775 /include/linux/compiler.h
parent6fdb335f1c9c0845b50625de1624d8445c4c4a07 (diff)
parentcb3cfbf79aff7decb4e5ee69a7c74864497f61dc (diff)
downloadlinux-10205618052908770451acd33eaeaa7685e97ed2.tar.gz
linux-10205618052908770451acd33eaeaa7685e97ed2.tar.bz2
linux-10205618052908770451acd33eaeaa7685e97ed2.zip
Merge drm/drm-next into drm-intel-next
sync-up to not fall too much behind. Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Diffstat (limited to 'include/linux/compiler.h')
-rw-r--r--include/linux/compiler.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index e512f5505dad..b8fe0c23cfff 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -80,11 +80,25 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
/* Optimization barrier */
#ifndef barrier
-# define barrier() __memory_barrier()
+/* The "volatile" is due to gcc bugs */
+# define barrier() __asm__ __volatile__("": : :"memory")
#endif
#ifndef barrier_data
-# define barrier_data(ptr) barrier()
+/*
+ * This version is i.e. to prevent dead stores elimination on @ptr
+ * where gcc and llvm may behave differently when otherwise using
+ * normal barrier(): while gcc behavior gets along with a normal
+ * barrier(), llvm needs an explicit input variable to be assumed
+ * clobbered. The issue is as follows: while the inline asm might
+ * access any memory it wants, the compiler could have fit all of
+ * @ptr into memory registers instead, and since @ptr never escaped
+ * from that, it proved that the inline asm wasn't touching any of
+ * it. This version works well with both compilers, i.e. we're telling
+ * the compiler that the inline asm absolutely may see the contents
+ * of @ptr. See also: https://llvm.org/bugs/show_bug.cgi?id=15495
+ */
+# define barrier_data(ptr) __asm__ __volatile__("": :"r"(ptr) :"memory")
#endif
/* workaround for GCC PR82365 if needed */