From 31d3486bd2dda4b9dd65c8b24544b8f8cb54054b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg=20Kristensen?= Date: Fri, 29 Jan 2016 12:07:34 -0800 Subject: [PATCH] anv: Limit flushing to the range of mapped memory --- src/vulkan/anv_device.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c index 27968bdf371..c7a9fd15c1d 100644 --- a/src/vulkan/anv_device.c +++ b/src/vulkan/anv_device.c @@ -1148,7 +1148,12 @@ clflush_mapped_ranges(struct anv_device *device, for (uint32_t i = 0; i < count; i++) { ANV_FROM_HANDLE(anv_device_memory, mem, ranges[i].memory); void *p = mem->map + (ranges[i].offset & ~CACHELINE_MASK); - void *end = mem->map + ranges[i].offset + ranges[i].size; + void *end; + + if (ranges[i].offset + ranges[i].size > mem->map_size) + end = mem->map + mem->map_size; + else + end = mem->map + ranges[i].offset + ranges[i].size; while (p < end) { __builtin_ia32_clflush(p); -- 2.30.2