summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2007-02-26 15:04:56 -0800
committerEric Anholt <eric@anholt.net>2007-02-26 15:04:56 -0800
commit732885c08daaf17034da8f4855d0b957ec3df9d7 (patch)
treefb17561504705657f33deb21396ca471ab87d38d
parent0bfaeaab2838184827236c5c0fcc17f06d9e1372 (diff)
Bug #9604: Align the sizes of allocations to page increments as well.
Without this, the 965 DRI driver fell over when pitch * height wasn't page-size aligned. Since the allocator only allocates at page-aligned offsets anyway this shouldn't hurt us at all.
-rw-r--r--src/i830_dri.c3
-rw-r--r--src/i830_memory.c5
2 files changed, 7 insertions, 1 deletions
diff --git a/src/i830_dri.c b/src/i830_dri.c
index e14880f6..f81251a5 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -1449,7 +1449,8 @@ I830UpdateDRIBuffers(ScrnInfoPtr pScrn, drmI830Sarea *sarea)
/* Don't use front_buffer->size here as it includes the pixmap cache area
* Instead, calculate the entire framebuffer.
*/
- sarea->front_size = pScrn->displayWidth * pScrn->virtualY * pI830->cpp;
+ sarea->front_size = ROUND_TO_PAGE(pScrn->displayWidth * pScrn->virtualY *
+ pI830->cpp);
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"[drm] init sarea width,height = %d x %d (pitch %d)\n",
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 79c1b4d2..b83078a5 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -338,6 +338,8 @@ i830_allocate_aperture(ScrnInfoPtr pScrn, const char *name,
xfree(mem);
return NULL;
}
+ /* Only allocate page-sized increments. */
+ size = ALIGN(size, GTT_PAGE_SIZE);
mem->size = size;
if (alignment < GTT_PAGE_SIZE)
@@ -466,6 +468,9 @@ i830_allocate_memory_tiled(ScrnInfoPtr pScrn, const char *name,
if (tile_format == TILING_NONE)
return i830_allocate_memory(pScrn, name, size, alignment, flags);
+ /* Only allocate page-sized increments. */
+ size = ALIGN(size, GTT_PAGE_SIZE);
+
/* Check for maximum tiled region size */
if (IS_I9XX(pI830)) {
if (size > MB(128))