Explorar el Código

drm/i915: Add compiler barrier to wait_for

We need to be careful to not let compiler evaluate
the expiration and the operation on it's terms.

Document and enforce that COND will be evaluated
before checking timeout expiration.

Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20180423113754.28424-2-mika.kuoppala@linux.intel.com
Mika Kuoppala hace 7 años
padre
commit
1c3c1dc66a
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  1. 4 0
      drivers/gpu/drm/i915/intel_drv.h

+ 4 - 0
drivers/gpu/drm/i915/intel_drv.h

@@ -56,6 +56,8 @@
 	for (;;) {							\
 	for (;;) {							\
 		const bool expired__ = ktime_after(ktime_get_raw(), end__); \
 		const bool expired__ = ktime_after(ktime_get_raw(), end__); \
 		OP;							\
 		OP;							\
+		/* Guarantee COND check prior to timeout */		\
+		barrier();						\
 		if (COND) {						\
 		if (COND) {						\
 			ret__ = 0;					\
 			ret__ = 0;					\
 			break;						\
 			break;						\
@@ -96,6 +98,8 @@
 		u64 now = local_clock(); \
 		u64 now = local_clock(); \
 		if (!(ATOMIC)) \
 		if (!(ATOMIC)) \
 			preempt_enable(); \
 			preempt_enable(); \
+		/* Guarantee COND check prior to timeout */ \
+		barrier(); \
 		if (COND) { \
 		if (COND) { \
 			ret = 0; \
 			ret = 0; \
 			break; \
 			break; \