[Intel-gfx] [PATCH] Fix system lockup when a client tries to allocate a huge BO

Chris Wilson chris at chris-wilson.co.uk
Mon Jul 6 11:23:48 CEST 2009


On Mon, 2009-07-06 at 10:10 +0100, Simon Farnsworth wrote:
> Eric Anholt wrote:
> > Anyway, we could just cap allocations at aperture size and avoid any
> > trickiness.  There's no reason to allow a BO to be allocated that won't
> > fit in the GPU, right?
> > 
> Sounds very reasonable; how do I code that?

I think adding a defensive guard to bo_alloc of
  if(size > bufmgr->gtt_size) return NULL;
would be the first step -- which for now also ensures that size will be
less than ULONG_MAX/2.

However the fix I think Eric is alluding to is this:
>From aae30a03aba0fbe33ca51f052aaa8d57ebcb9eaf Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu, 2 Jul 2009 14:31:49 +0100
Subject: [PATCH] Limit bo pixmap to hw constraints

---
 src/i830_uxa.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/i830_uxa.c b/src/i830_uxa.c
index eb35014..c472824 100644
--- a/src/i830_uxa.c
+++ b/src/i830_uxa.c
@@ -592,7 +592,7 @@ i830_uxa_create_pixmap (ScreenPtr screen, int w, int h, int depth, unsigned usag
     ScrnInfoPtr scrn = xf86Screens[screen->myNum];
     I830Ptr i830 = I830PTR(scrn);
     dri_bo *bo;
-    int stride;
+    int max_size, stride;
     PixmapPtr pixmap;
     
     if (w > 32767 || h > 32767)
@@ -601,6 +601,14 @@ i830_uxa_create_pixmap (ScreenPtr screen, int w, int h, int depth, unsigned usag
     if (usage == CREATE_PIXMAP_USAGE_GLYPH_PICTURE)
 	return fbCreatePixmap (screen, w, h, depth, usage);
 
+    if (IS_I965G(i830))
+	max_size = 8192;
+    else
+	max_size = 2048;
+
+    if (w > max_size || h > max_size)
+	return fbCreatePixmap (screen, w, h, depth, usage);
+
     pixmap = fbCreatePixmap (screen, 0, 0, depth, usage);
 
     if (w && h)
-- 
1.6.3.3





More information about the Intel-gfx mailing list