summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-12-23 17:25:42 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2011-12-23 17:28:14 +0000
commit98f15fc61361b7f1e01969f8d4237c13e93e3fb0 (patch)
treedd7d2be229fa6d2834a63f40ee5f054eb6a44028
parent3850f4ad48986691e1fb98038ae921deb6c25423 (diff)
sna: Don't align pwrite to cachelines for doing discontiguous copies
The batch compaction breaks the 1:1 mapping between the cpu buffer and the bo, so we can no longer safely align the transfer to whole cachelines. References: https://bugs.freedesktop.org/show_bug.cgi?id=44091 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/kgem.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 539c20e4..c733da53 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -171,6 +171,23 @@ static void *gem_mmap(int fd, uint32_t handle, int size, int prot)
return ptr;
}
+static int __gem_write(int fd, uint32_t handle,
+ int offset, int length,
+ const void *src)
+{
+ struct drm_i915_gem_pwrite pwrite;
+
+ DBG(("%s(handle=%d, offset=%d, len=%d)\n", __FUNCTION__,
+ handle, offset, length));
+
+ VG_CLEAR(pwrite);
+ pwrite.handle = handle;
+ pwrite.offset = offset;
+ pwrite.size = length;
+ pwrite.data_ptr = (uintptr_t)src;
+ return drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
+}
+
static int gem_write(int fd, uint32_t handle,
int offset, int length,
const void *src)
@@ -1086,7 +1103,9 @@ static int kgem_batch_write(struct kgem *kgem, uint32_t handle, uint32_t size)
if (ret)
return ret;
- return gem_write(kgem->fd, handle,
+ assert(kgem->nbatch*sizeof(uint32_t) <=
+ sizeof(uint32_t)*kgem->surface - (sizeof(kgem->batch)-size));
+ return __gem_write(kgem->fd, handle,
sizeof(uint32_t)*kgem->surface - (sizeof(kgem->batch)-size),
sizeof(kgem->batch) - sizeof(uint32_t)*kgem->surface,
kgem->batch + kgem->surface);