Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: Avoid the double clflush on the last cache line in drm_clflush_virt_range()

As the clflush operates on cache lines, and we can flush any byte
address, in order to flush all bytes given in the range we issue an
extra clflush on the last byte to ensure the last cacheline is flushed.
We can can the iteration to be over the actual cache lines to avoid this
double clflush on the last byte.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Imre Deak <imre.deak@intel.com>
Reviewed-by: Imre Deak <imre.deak@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

authored by

Chris Wilson and committed by
Daniel Vetter
afcd950c 2465ff62

+3 -2
+3 -2
drivers/gpu/drm/drm_cache.c
··· 130 130 { 131 131 #if defined(CONFIG_X86) 132 132 if (cpu_has_clflush) { 133 + const int size = boot_cpu_data.x86_clflush_size; 133 134 void *end = addr + length; 135 + addr = (void *)(((unsigned long)addr) & -size); 134 136 mb(); 135 - for (; addr < end; addr += boot_cpu_data.x86_clflush_size) 137 + for (; addr < end; addr += size) 136 138 clflushopt(addr); 137 - clflushopt(end - 1); 138 139 mb(); 139 140 return; 140 141 }