Commit 290b20a6 authored by Chris Wilson's avatar Chris Wilson

drm/i915: Add might_sleep() check to wait_for()

We should long past the time of trying to use wait_for() from inside
atomic contexts, so add a might_sleep() check to prevent misuse.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20171114215655.4849-1-chris@chris-wilson.co.ukReviewed-by: default avatarMika Kuoppala <mika.kuoppala@linux.intel.com>
Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
parent 55bd6bd7
...@@ -47,14 +47,11 @@ ...@@ -47,14 +47,11 @@
* contexts. Note that it's important that we check the condition again after * contexts. Note that it's important that we check the condition again after
* having timed out, since the timeout could be due to preemption or similar and * having timed out, since the timeout could be due to preemption or similar and
* we've never had a chance to check the condition before the timeout. * we've never had a chance to check the condition before the timeout.
*
* TODO: When modesetting has fully transitioned to atomic, the below
* drm_can_sleep() can be removed and in_atomic()/!in_atomic() asserts
* added.
*/ */
#define _wait_for(COND, US, W) ({ \ #define _wait_for(COND, US, W) ({ \
unsigned long timeout__ = jiffies + usecs_to_jiffies(US) + 1; \ unsigned long timeout__ = jiffies + usecs_to_jiffies(US) + 1; \
int ret__; \ int ret__; \
might_sleep(); \
for (;;) { \ for (;;) { \
bool expired__ = time_after(jiffies, timeout__); \ bool expired__ = time_after(jiffies, timeout__); \
if (COND) { \ if (COND) { \
...@@ -65,11 +62,7 @@ ...@@ -65,11 +62,7 @@
ret__ = -ETIMEDOUT; \ ret__ = -ETIMEDOUT; \
break; \ break; \
} \ } \
if ((W) && drm_can_sleep()) { \ usleep_range((W), (W) * 2); \
usleep_range((W), (W)*2); \
} else { \
cpu_relax(); \
} \
} \ } \
ret__; \ ret__; \
}) })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment