summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2009-07-06 11:54:50 -0700
committerEric Anholt <eric@anholt.net>2009-07-08 08:57:33 -0700
commit40e7c9505265823786cf730214db84812a5e494e (patch)
treed3813d3bc8cca99e278a57d668f70372031fb227
parent6337cd23e692cae789d07f429442c425c18e1d4f (diff)
Refuse to allocate giant BOs on 32-bit systems.
The overcommit of address space combined with these buffers hitting SW fallbacks all the time means that we're probably better off telling the application "no" instead of likely silently failing later. Bug #22601.
-rw-r--r--src/i830_uxa.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/i830_uxa.c b/src/i830_uxa.c
index eb35014e..ef7ac84a 100644
--- a/src/i830_uxa.c
+++ b/src/i830_uxa.c
@@ -627,6 +627,22 @@ i830_uxa_create_pixmap (ScreenPtr screen, int w, int h, int depth, unsigned usag
* with drm_intel_bufmgr_check_aperture().
*/
size = i830_get_fence_size(i830, stride * h);
+ assert(size >= stride * h);
+ }
+
+ /* Fail very large allocations on 32-bit systems. Large BOs will
+ * tend to hit SW fallbacks frequently, and also will tend to fail
+ * to successfully map when doing SW fallbacks because we overcommit
+ * address space for BO access.
+ *
+ * Note that size should fit in 32 bits. We throw out >32767x32767x4,
+ * and pitch alignment could get us up to 32768x32767x4.
+ */
+ if (sizeof(unsigned int) == 4 &&
+ size > (unsigned int)(1024 * 1024 * 1024))
+ {
+ fbDestroyPixmap (pixmap);
+ return NullPixmap;
}
bo = drm_intel_bo_alloc_for_render(i830->bufmgr, "pixmap", size, 0);