Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Dec 2013 21:18:21 +0000 (UTC)
From:      Jean-Sebastien Pedron <dumbbell@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r259742 - in stable/10/sys/dev/drm2: radeon ttm
Message-ID:  <201312222118.rBMLILG9033323@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dumbbell
Date: Sun Dec 22 21:18:21 2013
New Revision: 259742
URL: http://svnweb.freebsd.org/changeset/base/259742

Log:
  MFC r259684:
  
  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)

Modified:
  stable/10/sys/dev/drm2/radeon/radeon_fence.c
  stable/10/sys/dev/drm2/radeon/radeon_sa.c
  stable/10/sys/dev/drm2/ttm/ttm_bo.c
  stable/10/sys/dev/drm2/ttm/ttm_lock.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/drm2/radeon/radeon_fence.c
==============================================================================
--- stable/10/sys/dev/drm2/radeon/radeon_fence.c	Sun Dec 22 21:09:43 2013	(r259741)
+++ stable/10/sys/dev/drm2/radeon/radeon_fence.c	Sun Dec 22 21:18:21 2013	(r259742)
@@ -321,6 +321,8 @@ static int radeon_fence_wait_seq(struct 
 				    &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 
 			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(str
 				    &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(str
 				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)",

Modified: stable/10/sys/dev/drm2/radeon/radeon_sa.c
==============================================================================
--- stable/10/sys/dev/drm2/radeon/radeon_sa.c	Sun Dec 22 21:09:43 2013	(r259741)
+++ stable/10/sys/dev/drm2/radeon/radeon_sa.c	Sun Dec 22 21:18:21 2013	(r259742)
@@ -363,6 +363,8 @@ int radeon_sa_bo_new(struct radeon_devic
 			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;
 			}

Modified: stable/10/sys/dev/drm2/ttm/ttm_bo.c
==============================================================================
--- stable/10/sys/dev/drm2/ttm/ttm_bo.c	Sun Dec 22 21:09:43 2013	(r259741)
+++ stable/10/sys/dev/drm2/ttm/ttm_bo.c	Sun Dec 22 21:18:21 2013	(r259742)
@@ -147,6 +147,8 @@ ttm_bo_wait_unreserved_locked(struct ttm
 	}
 	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;
 	}

Modified: stable/10/sys/dev/drm2/ttm/ttm_lock.c
==============================================================================
--- stable/10/sys/dev/drm2/ttm/ttm_lock.c	Sun Dec 22 21:09:43 2013	(r259741)
+++ stable/10/sys/dev/drm2/ttm/ttm_lock.c	Sun Dec 22 21:18:21 2013	(r259742)
@@ -107,6 +107,8 @@ ttm_read_lock(struct ttm_lock *lock, boo
 	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 *lo
 	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, bo
 	/* 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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201312222118.rBMLILG9033323>