minigbm: i915: align to page size always
Upstream commit 2e7bd10e05af ("drm/i915: Prevent a race during
I915_GEM_MMAP ioctl with WC set") started checking this apparently.
BUG=b:126609463
TEST=gbmtest on octopus
Change-Id: Idfcef40b2c49c8ec6a8c18351d7da7d0edeaea1f
Reviewed-on: https://chromium-review.googlesource.com/1495920
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
diff --git a/i915.c b/i915.c
index 43e72c2..922d257 100644
--- a/i915.c
+++ b/i915.c
@@ -13,6 +13,7 @@
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
+#include <unistd.h>
#include <xf86drm.h>
#include "drv_priv.h"
@@ -314,15 +315,16 @@
{
uint32_t offset;
size_t plane;
- int ret;
+ int ret, pagesize;
offset = 0;
+ pagesize = getpagesize();
for (plane = 0; plane < drv_num_planes_from_format(format); plane++) {
uint32_t stride = drv_stride_from_format(format, width, plane);
uint32_t plane_height = drv_height_from_format(format, height, plane);
if (bo->tiling != I915_TILING_NONE)
- assert(IS_ALIGNED(offset, 4096));
+ assert(IS_ALIGNED(offset, pagesize));
ret = i915_align_dimensions(bo, bo->tiling, &stride, &plane_height);
if (ret)
@@ -334,7 +336,7 @@
offset += bo->sizes[plane];
}
- bo->total_size = offset;
+ bo->total_size = ALIGN(offset, pagesize);
return 0;
}