The i830 DRM driver contains empty for loops used for short
delays.  Modern gcc and other compilers, when used with
optimization switches will optimize these empty for loops out,
leaving no delay.  In addition, CPU's such as the Pentium 4, will
needlessly overheat when executing empty for loops such as this
(assuming they're not optimized out by the compiler) which can
cause the chip to kick in it's thermal protection and lower the
CPU speed.

Instead of using empty for loops for delays, udelay() should be 
used to provide delays.

I've sent this patch into the XFree86 patch list as well for 
application to xf-4_2-branch.

Credits to Arjan Van de Ven <[EMAIL PROTECTED]> for catching
these issues.

TIA

-- 
----------------------------------------------------------------------
Mike A. Harris                  Shipping/mailing address:
OS Systems Engineer             190 Pittsburgh Ave., Sault Ste. Marie,
XFree86 maintainer              Ontario, Canada, P6C 5B3
Red Hat Inc.                    Phone: (705)949-2136
http://www.redhat.com           ftp://people.redhat.com/mharris
Red Hat XFree86 mailing list:   [EMAIL PROTECTED]
General open IRC discussion:    #xfree86 on irc.openprojects.net
----------------------------------------------------------------------

---------- Forwarded message ----------
Date: Sun, 20 Jan 2002 11:06:14 GMT
From: Arjan Van de Ven <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]

diff -urN Linux/drivers/char/drm/i830_dma.c linux/drivers/char/drm/i830_dma.c
--- Linux/drivers/char/drm/i830_dma.c   Sun Jan 20 11:04:53 2002
+++ linux/drivers/char/drm/i830_dma.c   Sun Jan 20 11:04:25 2002
@@ -36,7 +36,7 @@
 #include "drmP.h"
 #include "i830_drv.h"
 #include <linux/interrupt.h>   /* For task queue support */
-
+#include <linux/delay.h>
 /* in case we don't have a 2.3.99-pre6 kernel or later: */
 #ifndef VM_DONTCOPY
 #define VM_DONTCOPY 0
@@ -60,7 +60,7 @@
    do {                                                        \
       _head = I830_READ(LP_RING + RING_HEAD) & HEAD_ADDR;      \
       _tail = I830_READ(LP_RING + RING_TAIL) & TAIL_ADDR;      \
-      for(_i = 0; _i < 65535; _i++);                           \
+      udelay(1);                                               \
    } while(_head != _tail);                                    \
 } while(0)
 
@@ -375,13 +375,13 @@
                }
          
                iters++;
-               if((signed)(end - jiffies) <= 0) {
+               if(time_before(end,jiffies)) {
                        DRM_ERROR("space: %d wanted %d\n", ring->space, n);
                        DRM_ERROR("lockup\n");
                        goto out_wait_ring;
                }
 
-               for (i = 0 ; i < 2000 ; i++) ;
+               udelay(1);
        }
 
 out_wait_ring:   
@@ -1136,7 +1136,7 @@
                current->state = TASK_INTERRUPTIBLE;
                i830_dma_quiescent_emit(dev);
                if (atomic_read(&dev_priv->flush_done) == 1) break;
-               if((signed)(end - jiffies) <= 0) {
+               if(time_before(end, jiffies)) {
                        DRM_ERROR("lockup\n");
                        break;
                }          
@@ -1170,7 +1170,7 @@
                current->state = TASK_INTERRUPTIBLE;
                i830_dma_emit_flush(dev);
                if (atomic_read(&dev_priv->flush_done) == 1) break;
-               if((signed)(end - jiffies) <= 0) {
+               if(time_before(end, jiffies)) {
                        DRM_ERROR("lockup\n");
                        break;
                }          



_______________________________________________
Dri-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to