Module Name: src Committed By: riastradh Date: Thu Feb 26 23:27:41 UTC 2015
Modified Files: src/sys/external/bsd/drm2/include/drm: drm_wait_netbsd.h Log Message: Another attempt to fix the drm timed wait blarf blugh blahhh. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 \ src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h diff -u src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.5 src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.6 --- src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.5 Tue Aug 26 00:48:29 2014 +++ src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h Thu Feb 26 23:27:41 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: drm_wait_netbsd.h,v 1.5 2014/08/26 00:48:29 riastradh Exp $ */ +/* $NetBSD: drm_wait_netbsd.h,v 1.6 2015/02/26 23:27:41 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -129,6 +129,19 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, #define DRM_WAIT_UNTIL(RET, Q, I, C) \ _DRM_WAIT_UNTIL(RET, cv_wait_sig, Q, I, C) +/* + * Timed wait. Return: + * + * - 0 if condition is false after timeout, + * - 1 if condition is true after timeout or one tick before timeout, + * - number of ticks left if condition evaluated to true before timeout, or + * - error if failure (e.g., interrupted). + * + * XXX Comments in Linux say it returns -ERESTARTSYS if interrupted. + * What if by a signal without SA_RESTART? Shouldn't it be -EINTR + * then? I'm going to leave it as what cv_timedwait returned, which is + * ERESTART for signals with SA_RESTART and EINTR otherwise. + */ #define _DRM_TIMED_WAIT_UNTIL(RET, WAIT, Q, INTERLOCK, TICKS, CONDITION) do \ { \ extern int hardclock_ticks; \ @@ -145,14 +158,17 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, /* XXX errno NetBSD->Linux */ \ (RET) = -WAIT((Q), &(INTERLOCK)->mtx_lock, \ _dtwu_ticks); \ - if (RET) \ + if (RET) { \ + if ((RET) == -EWOULDBLOCK) \ + (RET) = (CONDITION) ? 1 : 0; \ break; \ + } \ const int _dtwu_now = hardclock_ticks; \ KASSERT(_dtwu_start <= _dtwu_now); \ if ((_dtwu_now - _dtwu_start) < _dtwu_ticks) { \ _dtwu_ticks -= (_dtwu_now - _dtwu_start); \ } else { \ - (RET) = 0; \ + (RET) = (CONDITION) ? 1 : 0; \ break; \ } \ } \ @@ -210,14 +226,17 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, /* XXX errno NetBSD->Linux */ \ (RET) = -WAIT((Q), &(INTERLOCK)->sl_lock, \ _dstwu_ticks); \ - if (RET) \ + if (RET) { \ + if ((RET) == -EWOULDBLOCK) \ + (RET) = (CONDITION) ? 1 : 0; \ break; \ + } \ const int _dstwu_now = hardclock_ticks; \ KASSERT(_dstwu_start <= _dstwu_now); \ if ((_dstwu_now - _dstwu_start) < _dstwu_ticks) { \ _dstwu_ticks -= (_dstwu_now - _dstwu_start); \ } else { \ - (RET) = 0; \ + (RET) = (CONDITION) ? 1 : 0; \ break; \ } \ } \