drm/ttm, drm/radeon: Replace EINTR/ERESTART by ERESTARTSYS...

... for msleep/cv_*wait() return values, where wait_event*() is used
on Linux. ERESTARTSYS is the return code expected by callers when the
operation was interrupted.

For instance, this is the case of radeon_cs_ioctl() (radeon_cs.c): if
an error occurs, and the code isn't ERESTARTSYS (eg. EINTR), it logs an
error.

Note that ERESTARTSYS is defined as ERESTART, but this keeps callers'
code close to Linux.

Submitted by:	avg@ (previous version)
This commit is contained in:
Jean-Sébastien Pédron 2013-12-21 15:40:36 +00:00
parent a9e4b73480
commit a883f5eadb
4 changed files with 18 additions and 2 deletions

View File

@ -321,6 +321,8 @@ static int radeon_fence_wait_seq(struct radeon_device *rdev, u64 target_seq,
&rdev->fence_queue_mtx,
timeout);
}
if (r == EINTR)
r = ERESTARTSYS;
if (r != 0) {
if (r == EWOULDBLOCK) {
signaled =
@ -334,7 +336,7 @@ static int radeon_fence_wait_seq(struct radeon_device *rdev, u64 target_seq,
mtx_unlock(&rdev->fence_queue_mtx);
}
radeon_irq_kms_sw_irq_put(rdev, ring);
if (unlikely(r == EINTR || r == ERESTART)) {
if (unlikely(r == ERESTARTSYS)) {
return -r;
}
CTR2(KTR_DRM, "radeon fence: wait end (ring=%d, seq=%d)",
@ -514,6 +516,8 @@ static int radeon_fence_wait_any_seq(struct radeon_device *rdev,
&rdev->fence_queue_mtx,
timeout);
}
if (r == EINTR)
r = ERESTARTSYS;
if (r != 0) {
if (r == EWOULDBLOCK) {
signaled =
@ -531,7 +535,7 @@ static int radeon_fence_wait_any_seq(struct radeon_device *rdev,
radeon_irq_kms_sw_irq_put(rdev, i);
}
}
if (unlikely(r == EINTR || r == ERESTART)) {
if (unlikely(r == ERESTARTSYS)) {
return -r;
}
CTR2(KTR_DRM, "radeon fence: wait end (ring=%d, target_seq=%d)",

View File

@ -363,6 +363,8 @@ int radeon_sa_bo_new(struct radeon_device *rdev,
while (!radeon_sa_event(sa_manager, size, align)) {
r = -cv_wait_sig(&sa_manager->wq,
&sa_manager->wq_lock);
if (r == -EINTR)
r = -ERESTARTSYS;
if (r != 0)
break;
}

View File

@ -147,6 +147,8 @@ ttm_bo_wait_unreserved_locked(struct ttm_buffer_object *bo, bool interruptible)
}
while (ttm_bo_is_reserved(bo)) {
ret = -msleep(bo, &bo->glob->lru_lock, flags, wmsg, 0);
if (ret == -EINTR)
ret = -ERESTARTSYS;
if (ret != 0)
break;
}

View File

@ -107,6 +107,8 @@ ttm_read_lock(struct ttm_lock *lock, bool interruptible)
mtx_lock(&lock->lock);
while (!__ttm_read_lock(lock)) {
ret = msleep(lock, &lock->lock, flags, wmsg, 0);
if (ret == EINTR)
ret = ERESTARTSYS;
if (ret != 0)
break;
}
@ -151,6 +153,8 @@ int ttm_read_trylock(struct ttm_lock *lock, bool interruptible)
mtx_lock(&lock->lock);
while (!__ttm_read_trylock(lock, &locked)) {
ret = msleep(lock, &lock->lock, flags, wmsg, 0);
if (ret == EINTR)
ret = ERESTARTSYS;
if (ret != 0)
break;
}
@ -204,6 +208,8 @@ ttm_write_lock(struct ttm_lock *lock, bool interruptible)
/* XXXKIB: linux uses __ttm_read_lock for uninterruptible sleeps */
while (!__ttm_write_lock(lock)) {
ret = msleep(lock, &lock->lock, flags, wmsg, 0);
if (ret == EINTR)
ret = ERESTARTSYS;
if (interruptible && ret != 0) {
lock->flags &= ~TTM_WRITE_LOCK_PENDING;
wakeup(lock);
@ -280,6 +286,8 @@ int ttm_vt_lock(struct ttm_lock *lock,
mtx_lock(&lock->lock);
while (!__ttm_vt_lock(lock)) {
ret = msleep(lock, &lock->lock, flags, wmsg, 0);
if (ret == EINTR)
ret = ERESTARTSYS;
if (interruptible && ret != 0) {
lock->flags &= ~TTM_VT_LOCK_PENDING;
wakeup(lock);