Module Name: src Committed By: riastradh Date: Sun Sep 8 16:02:51 UTC 2013
Modified Files: src/sys/external/bsd/drm2/include/drm [riastradh-drm2]: drm_wait_netbsd.h Log Message: Fix result of DRM_TIMED_WAIT_UNTIL. This has to return a positive number of ticks left if we haven't timed out in order to match the semantics of Linux waitqueues. This also fixes the amount of time for timeout if we ever wait for more than one iteration. Now we can actually wait for results from the ring buffers! To generate a diff of this commit: cvs rdiff -u -r1.1.2.6 -r1.1.2.7 \ 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.1.2.6 src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.1.2.7 --- src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h:1.1.2.6 Wed Jul 24 03:08:03 2013 +++ src/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h Sun Sep 8 16:02:50 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: drm_wait_netbsd.h,v 1.1.2.6 2013/07/24 03:08:03 riastradh Exp $ */ +/* $NetBSD: drm_wait_netbsd.h,v 1.1.2.7 2013/09/08 16:02:50 riastradh Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -112,13 +112,28 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, #define DRM_TIMED_WAIT_UNTIL(RET, Q, INTERLOCK, TICKS, CONDITION) do \ { \ + extern int hardclock_ticks; \ + const int _dtwu_start = hardclock_ticks; \ + int _dtwu_ticks = (TICKS); \ KASSERT(mutex_is_locked((INTERLOCK))); \ - while (!(CONDITION)) { \ + for (;;) { \ + if (CONDITION) { \ + (RET) = _dtwu_ticks; \ + break; \ + } \ /* XXX errno NetBSD->Linux */ \ (RET) = -cv_timedwait_sig((Q), &(INTERLOCK)->mtx_lock, \ - (TICKS)); \ + _dtwu_ticks); \ if (RET) \ 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; \ + break; \ + } \ } \ } while (0) @@ -136,13 +151,28 @@ DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, #define DRM_SPIN_TIMED_WAIT_UNTIL(RET, Q, INTERLOCK, TICKS, CONDITION) \ do \ { \ + extern int hardclock_ticks; \ + const int _dstwu_start = hardclock_ticks; \ + int _dstwu_ticks = (TICKS); \ KASSERT(spin_is_locked((INTERLOCK))); \ - while (!(CONDITION)) { \ + for (;;) { \ + if (CONDITION) { \ + (RET) = _dstwu_ticks; \ + break; \ + } \ /* XXX errno NetBSD->Linux */ \ (RET) = -cv_timedwait_sig((Q), &(INTERLOCK)->sl_lock, \ - (TICKS)); \ + _dstwu_ticks); \ if (RET) \ 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; \ + break; \ + } \ } \ } while (0)