Source-Changes-HG archive

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

[src/trunk]: src/sys/external/bsd/drm2/dist/drm/i915 Adapt Linux i915 wait_fo...



details:   https://anonhg.NetBSD.org/src/rev/08d05afb349a
branches:  trunk
changeset: 328958:08d05afb349a
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Apr 25 18:38:54 2014 +0000

description:
Adapt Linux i915 wait_for to use DELAY so it works while cold.

Adapted from a patch by nonaka@ in PR 48706.

diffstat:

 sys/external/bsd/drm2/dist/drm/i915/intel_drv.h |  54 +++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

diffs (71 lines):

diff -r f53bc912c77a -r 08d05afb349a sys/external/bsd/drm2/dist/drm/i915/intel_drv.h
--- a/sys/external/bsd/drm2/dist/drm/i915/intel_drv.h   Fri Apr 25 18:37:38 2014 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/intel_drv.h   Fri Apr 25 18:38:54 2014 +0000
@@ -34,6 +34,59 @@
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_dp_helper.h>
 
+#ifdef __NetBSD__
+#define _wait_for(COND, MS, W) ({ \
+       int ret__ = 0;                                                  \
+       if (cold) {                                                     \
+               int ms = (MS);                                          \
+               while (!(COND)) {                                       \
+                       if (--ms < 0) {                                 \
+                               ret__ = -ETIMEDOUT;                     \
+                               break;                                  \
+                       }                                               \
+                       DELAY(1000);                                    \
+               }                                                       \
+       } else {                                                        \
+               unsigned long timeout__ = jiffies + msecs_to_jiffies(MS); \
+               while (!(COND)) {                                       \
+                       if (time_after(jiffies, timeout__)) {           \
+                               ret__ = -ETIMEDOUT;                     \
+                               break;                                  \
+                       }                                               \
+                       if ((W) && drm_can_sleep())  {                  \
+                               msleep(W);                              \
+                       } else {                                        \
+                               cpu_relax();                            \
+                       }                                               \
+               }                                                       \
+       }                                                               \
+       ret__;                                                          \
+})
+
+#define wait_for_atomic_us(COND, US) ({ \
+       int ret__ = 0;                                                  \
+       if (cold) {                                                     \
+               int us = (US);                                          \
+               while (!(COND)) {                                       \
+                       if (--us < 0) {                                 \
+                               ret__ = -ETIMEDOUT;                     \
+                               break;                                  \
+                       }                                               \
+                       DELAY(1);                                       \
+               }                                                       \
+       } else {                                                        \
+               unsigned long timeout__ = jiffies + usecs_to_jiffies(US); \
+               while (!(COND)) {                                       \
+                       if (time_after(jiffies, timeout__)) {           \
+                               ret__ = -ETIMEDOUT;                     \
+                               break;                                  \
+                       }                                               \
+                       cpu_relax();                                    \
+               }                                                       \
+       }                                                               \
+       ret__;                                                          \
+})
+#else  /* !NetBSD */
 #define _wait_for(COND, MS, W) ({ \
        unsigned long timeout__ = jiffies + msecs_to_jiffies(MS);       \
        int ret__ = 0;                                                  \
@@ -63,6 +116,7 @@
        }                                                               \
        ret__;                                                          \
 })
+#endif /* NetBSD */
 
 #define wait_for(COND, MS) _wait_for(COND, MS, 1)
 #define wait_for_atomic(COND, MS) _wait_for(COND, MS, 0)



Home | Main Index | Thread Index | Old Index