anv: Limit flushing to the range of mapped memory
authorKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Fri, 29 Jan 2016 20:07:34 +0000 (12:07 -0800)
committerKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Fri, 29 Jan 2016 22:56:41 +0000 (14:56 -0800)
src/vulkan/anv_device.c

index 27968bdf3714d7d5162c956cf07a2652041a6573..c7a9fd15c1d1809d3c5dd9eb7bee6ad9d6fccc98 100644 (file)
@@ -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);