Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-7]: src/sys/external/bsd/drm2 Pull up following revision(s) (requ...



details:   https://anonhg.NetBSD.org/src/rev/3d90e26ad6f4
branches:  netbsd-7
changeset: 799033:3d90e26ad6f4
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Feb 27 11:23:53 2015 +0000

description:
Pull up following revision(s) (requested by snj in ticket #553):
        sys/external/bsd/drm2/dist/drm/i915/i915_gem.c: revision 1.20
        sys/external/bsd/drm2/dist/drm/i915/i915_gem.c: revision 1.21
        sys/external/bsd/drm2/dist/drm/i915/i915_gem.c: revision 1.22
        sys/external/bsd/drm2/dist/drm/i915/intel_i2c.c: revision 1.5
        sys/external/bsd/drm2/dist/drm/i915/intel_i2c.c: revision 1.6
        sys/external/bsd/drm2/dist/drm/i915/intel_i2c.c: revision 1.7
        sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h: revision 1.6
Fix returned timeout in wait_seqno: remaining time, not time slept.
-
Fix return code of __wait_seqno.
-
MAX(ret, 0) is 0 if ret is negative, but if ret is negative we want
to return that negative value, meaning error.  Should've been
MIN(ret, 0), but I'll just rewrite it to clarify a wee bit.
-
If the GPU reset, call i915_gem_check_wedge and always return failure
like Linux does.  Caller must retry in that case.
-
Limit scope of ret and omit needless use of it to reduce confusion.
-
Make gmbus_wait_hw_status consistently use 50ms timeout like Linux.
-
Another attempt to fix the drm timed wait blarf blugh blahhh.
...aaaaand one more fix for __wait_seqno return value.
-
Also get the sense of the condition to wait until right.

diffstat:

 sys/external/bsd/drm2/dist/drm/i915/i915_gem.c      |  30 ++++++++++++++++++--
 sys/external/bsd/drm2/dist/drm/i915/intel_i2c.c     |  19 +++++-------
 sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h |  29 ++++++++++++++++---
 3 files changed, 59 insertions(+), 19 deletions(-)

diffs (152 lines):

diff -r 1d9d7eb36808 -r 3d90e26ad6f4 sys/external/bsd/drm2/dist/drm/i915/i915_gem.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c    Fri Feb 27 10:10:32 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c    Fri Feb 27 11:23:53 2015 +0000
@@ -1441,9 +1441,33 @@
 
        if (!irq_test_in_progress)
                ring->irq_put(ring);
-       if (timeout)
-               timespecsub(&after, &before, timeout);
-       return MAX(ret, 0);     /* ignore remaining ticks */
+       if (timeout) {
+               struct timespec slept;
+
+               /* Compute slept = after - before.  */
+               timespecsub(&after, &before, &slept);
+
+               /*
+                * Return the time remaining, timeout - slept, if we
+                * slept for less time than the timeout; or zero if we
+                * timed out.
+                */
+               if (timespeccmp(&slept, timeout, <))
+                       timespecsub(timeout, &slept, timeout);
+               else
+                       timespecclear(timeout);
+       }
+       if (wedged) {           /* GPU reset while we were waiting.  */
+               ret = i915_gem_check_wedge(&dev_priv->gpu_error,
+                   interruptible);
+               if (ret == 0)
+                       ret = -EAGAIN;
+       }
+       if (ret < 0)            /* Error.  */
+               return ret;
+       if (ret == 0)           /* Seqno didn't pass.  */
+               return -ETIME;
+       return 0;               /* Seqno passed, maybe time to spare.  */
 }
 #else
 static int __wait_seqno(struct intel_ring_buffer *ring, u32 seqno,
diff -r 1d9d7eb36808 -r 3d90e26ad6f4 sys/external/bsd/drm2/dist/drm/i915/intel_i2c.c
--- a/sys/external/bsd/drm2/dist/drm/i915/intel_i2c.c   Fri Feb 27 10:10:32 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/intel_i2c.c   Fri Feb 27 11:23:53 2015 +0000
@@ -269,9 +269,7 @@
 #endif
        int reg_offset = dev_priv->gpio_mmio_base;
        u32 gmbus2 = 0;
-#ifdef __NetBSD__
-       int ret;
-#else
+#ifndef __NetBSD__
        DEFINE_WAIT(wait);
 #endif
 
@@ -291,21 +289,20 @@
 #ifdef __NetBSD__
        spin_lock(&dev_priv->gmbus_wait_lock);
        if (cold) {
-               unsigned timo = 1000;
-               ret = 0;
+               unsigned timo = 50;
+
                while (gmbus2 = I915_READ_NOTRACE(GMBUS2 + reg_offset),
                    !ISSET(gmbus2, (GMBUS_SATOER | gmbus2_status))) {
-                       if (timo-- == 0) {
-                               ret = -ETIMEDOUT;
+                       if (timo-- == 0)
                                break;
-                       }
-                       DELAY(100);
+                       DELAY(1000);
                }
        } else {
+               int ret;
                DRM_SPIN_TIMED_WAIT_UNTIL(ret, &dev_priv->gmbus_wait_queue,
-                   &dev_priv->gmbus_wait_lock, 1,
+                   &dev_priv->gmbus_wait_lock, mstohz(50),
                    (gmbus2 = I915_READ_NOTRACE(GMBUS2 + reg_offset),
-                       !ISSET(gmbus2, (GMBUS_SATOER | gmbus2_status))));
+                       ISSET(gmbus2, (GMBUS_SATOER | gmbus2_status))));
        }
        spin_unlock(&dev_priv->gmbus_wait_lock);
 #else
diff -r 1d9d7eb36808 -r 3d90e26ad6f4 sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h
--- a/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h       Fri Feb 27 10:10:32 2015 +0000
+++ b/sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h       Fri Feb 27 11:23:53 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_wait_netbsd.h,v 1.4.2.1 2014/09/21 18:00:33 snj Exp $      */
+/*     $NetBSD: drm_wait_netbsd.h,v 1.4.2.2 2015/02/27 11:23:54 martin Exp $   */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -129,6 +129,19 @@
 #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 @@
                /* 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 @@
                /* 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;                                          \
                }                                                       \
        }                                                               \



Home | Main Index | Thread Index | Old Index