--- /dev/null
+From e8c946cb56a9789ce707888a8198a8dd092cca85 Mon Sep 17 00:00:00 2001
+From: Carl Worth <cworth@cworth.org>
+Date: Tue, 10 Jul 2007 00:45:55 -0700
+Subject: [PATCH] Elminate gettimeofday as a hotspot in I830WaitLpRing
+
+---
+ src/i830_accel.c | 47 ++++++++++++++++++++++++-----------------------
+ 1 files changed, 24 insertions(+), 23 deletions(-)
+
+diff --git a/src/i830_accel.c b/src/i830_accel.c
+index 5cbad44..714af5a 100644
+--- a/src/i830_accel.c
++++ b/src/i830_accel.c
+@@ -120,36 +120,37 @@ I830WaitLpRing(ScrnInfoPtr pScrn, int n, int timeout_millis)
+ ring->space += ring->mem->size;
+
+ iters++;
+- now = GetTimeInMillis();
+- if (start == 0 || now < start || ring->head != last_head) {
+- if (I810_DEBUG & DEBUG_VERBOSE_ACCEL)
+- if (now > start)
+- ErrorF("space: %d wanted %d\n", ring->space, n);
+- start = now;
+- last_head = ring->head;
+- } else if (now - start > timeout_millis) {
+- ErrorF("Error in I830WaitLpRing(), timeout for %d seconds\n",
+- timeout_millis/1000);
+- if (IS_I965G(pI830))
+- i965_dump_error_state(pScrn);
+- else
+- i830_dump_error_state(pScrn);
+- ErrorF("space: %d wanted %d\n", ring->space, n);
++ if ((iters & 0xfff) == 0) {
++ now = GetTimeInMillis();
++ if (start == 0 || now < start || ring->head != last_head) {
++ if (I810_DEBUG & DEBUG_VERBOSE_ACCEL)
++ if (now > start)
++ ErrorF("space: %d wanted %d\n", ring->space, n);
++ start = now;
++ last_head = ring->head;
++ } else if (now - start > timeout_millis) {
++ ErrorF("Error in I830WaitLpRing(), timeout for %d seconds\n",
++ timeout_millis/1000);
++ if (IS_I965G(pI830))
++ i965_dump_error_state(pScrn);
++ else
++ i830_dump_error_state(pScrn);
++ ErrorF("space: %d wanted %d\n", ring->space, n);
+ #ifdef XF86DRI
+- if (pI830->directRenderingEnabled) {
+- DRIUnlock(screenInfo.screens[pScrn->scrnIndex]);
+- DRICloseScreen(screenInfo.screens[pScrn->scrnIndex]);
+- }
++ if (pI830->directRenderingEnabled) {
++ DRIUnlock(screenInfo.screens[pScrn->scrnIndex]);
++ DRICloseScreen(screenInfo.screens[pScrn->scrnIndex]);
++ }
+ #endif
+ #ifdef I830_USE_XAA
+- pI830->AccelInfoRec = NULL; /* Stops recursive behavior */
++ pI830->AccelInfoRec = NULL; /* Stops recursive behavior */
+ #endif
+ #ifdef I830_USE_EXA
+- pI830->EXADriverPtr = NULL;
++ pI830->EXADriverPtr = NULL;
+ #endif
+- FatalError("lockup\n");
++ FatalError("lockup\n");
++ }
+ }
+-
+ DELAY(10);
+ }
+
+--
+1.5.2
+