diff options
Diffstat (limited to 'drivers/gpu/drm/msm/msm_drv.c')
-rw-r--r-- | drivers/gpu/drm/msm/msm_drv.c | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 864c9773636b..008d772384c7 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c | |||
@@ -499,25 +499,41 @@ int msm_wait_fence_interruptable(struct drm_device *dev, uint32_t fence, | |||
499 | struct timespec *timeout) | 499 | struct timespec *timeout) |
500 | { | 500 | { |
501 | struct msm_drm_private *priv = dev->dev_private; | 501 | struct msm_drm_private *priv = dev->dev_private; |
502 | unsigned long timeout_jiffies = timespec_to_jiffies(timeout); | ||
503 | unsigned long start_jiffies = jiffies; | ||
504 | unsigned long remaining_jiffies; | ||
505 | int ret; | 502 | int ret; |
506 | 503 | ||
507 | if (time_after(start_jiffies, timeout_jiffies)) | 504 | if (!priv->gpu) |
508 | remaining_jiffies = 0; | 505 | return 0; |
509 | else | 506 | |
510 | remaining_jiffies = timeout_jiffies - start_jiffies; | 507 | if (fence > priv->gpu->submitted_fence) { |
511 | 508 | DRM_ERROR("waiting on invalid fence: %u (of %u)\n", | |
512 | ret = wait_event_interruptible_timeout(priv->fence_event, | 509 | fence, priv->gpu->submitted_fence); |
513 | priv->completed_fence >= fence, | 510 | return -EINVAL; |
514 | remaining_jiffies); | 511 | } |
515 | if (ret == 0) { | 512 | |
516 | DBG("timeout waiting for fence: %u (completed: %u)", | 513 | if (!timeout) { |
517 | fence, priv->completed_fence); | 514 | /* no-wait: */ |
518 | ret = -ETIMEDOUT; | 515 | ret = fence_completed(dev, fence) ? 0 : -EBUSY; |
519 | } else if (ret != -ERESTARTSYS) { | 516 | } else { |
520 | ret = 0; | 517 | unsigned long timeout_jiffies = timespec_to_jiffies(timeout); |
518 | unsigned long start_jiffies = jiffies; | ||
519 | unsigned long remaining_jiffies; | ||
520 | |||
521 | if (time_after(start_jiffies, timeout_jiffies)) | ||
522 | remaining_jiffies = 0; | ||
523 | else | ||
524 | remaining_jiffies = timeout_jiffies - start_jiffies; | ||
525 | |||
526 | ret = wait_event_interruptible_timeout(priv->fence_event, | ||
527 | fence_completed(dev, fence), | ||
528 | remaining_jiffies); | ||
529 | |||
530 | if (ret == 0) { | ||
531 | DBG("timeout waiting for fence: %u (completed: %u)", | ||
532 | fence, priv->completed_fence); | ||
533 | ret = -ETIMEDOUT; | ||
534 | } else if (ret != -ERESTARTSYS) { | ||
535 | ret = 0; | ||
536 | } | ||
521 | } | 537 | } |
522 | 538 | ||
523 | return ret; | 539 | return ret; |