|
@@ -268,6 +268,15 @@ bool try_wait_for_completion(struct completion *x)
|
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
|
int ret = 1;
|
|
int ret = 1;
|
|
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
|
+ * Since x->done will need to be locked only
|
|
|
|
|
+ * in the non-blocking case, we check x->done
|
|
|
|
|
+ * first without taking the lock so we can
|
|
|
|
|
+ * return early in the blocking case.
|
|
|
|
|
+ */
|
|
|
|
|
+ if (!ACCESS_ONCE(x->done))
|
|
|
|
|
+ return 0;
|
|
|
|
|
+
|
|
|
spin_lock_irqsave(&x->wait.lock, flags);
|
|
spin_lock_irqsave(&x->wait.lock, flags);
|
|
|
if (!x->done)
|
|
if (!x->done)
|
|
|
ret = 0;
|
|
ret = 0;
|