summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-12-13 11:20:25 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2011-12-13 11:27:17 +0000
commit1128825efb3179a5a5d951fa24db6b769ee41219 (patch)
treed1fbfb84e81d4d2b00c0bfbcf939d013c1fca5f9
parentdb7c9e8561afcc1ca7ab16b3bf2d5b49938e26d9 (diff)
uxa: Wakeup 3s after the last rendering to reap the bo-cache
libdrm expires its bo 2s after entry into the cache, but we need to free a buffer to trigger the reaper. So schedule a timer event to trigger 3s after the last rendering is submitted to free any resident bo during long periods of idleness. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/intel.h1
-rw-r--r--src/intel_driver.c3
-rw-r--r--src/intel_uxa.c20
3 files changed, 24 insertions, 0 deletions
diff --git a/src/intel.h b/src/intel.h
index 28f049e7..5423c20a 100644
--- a/src/intel.h
+++ b/src/intel.h
@@ -279,6 +279,7 @@ typedef struct intel_screen_private {
struct list flush_pixmaps;
struct list in_flight;
drm_intel_bo *wa_scratch_bo;
+ OsTimerPtr cache_expire;
/* For Xvideo */
Bool use_overlay;
diff --git a/src/intel_driver.c b/src/intel_driver.c
index 2828ed63..066aa5f2 100644
--- a/src/intel_driver.c
+++ b/src/intel_driver.c
@@ -1200,6 +1200,9 @@ static Bool I830CloseScreen(int scrnIndex, ScreenPtr screen)
intel_glamor_close_screen(screen);
+ TimerFree(intel->cache_expire);
+ intel->cache_expire = NULL;
+
if (intel->uxa_driver) {
uxa_driver_fini(screen);
free(intel->uxa_driver);
diff --git a/src/intel_uxa.c b/src/intel_uxa.c
index 5f2959b4..e4a52706 100644
--- a/src/intel_uxa.c
+++ b/src/intel_uxa.c
@@ -965,6 +965,23 @@ static Bool intel_uxa_get_image(PixmapPtr pixmap,
return ret;
}
+static CARD32 intel_cache_expire(OsTimerPtr timer, CARD32 now, pointer data)
+{
+ intel_screen_private *intel = data;
+
+ /* We just want to create and destroy a bo as this causes libdrm
+ * to reap its caches. However, since we can't remove that buffer
+ * from the cache due to its own activity, we want to use something
+ * that we know we will reuse later. The most frequently reused buffer
+ * we have is the batchbuffer, and the best way to trigger its
+ * reallocation is to submit a flush.
+ */
+ intel_batch_emit_flush(intel->scrn);
+ intel_batch_submit(intel->scrn);
+
+ return 0;
+}
+
static void intel_flush_rendering(intel_screen_private *intel)
{
if (intel->needs_flush == 0)
@@ -978,6 +995,9 @@ static void intel_flush_rendering(intel_screen_private *intel)
intel_batch_submit(intel->scrn);
}
+ intel->cache_expire = TimerSet(intel->cache_expire, 0, 3000,
+ intel_cache_expire, intel);
+
intel->needs_flush = 0;
}