Commit b04d4a38 authored by Ben Widawsky's avatar Ben Widawsky Committed by Daniel Vetter

drm/cache: Use wbinvd helpers

When the original drm code was written there were no centralized functions for
doing a coordinated wbinvd across all CPUs. Now (since 2010) there are, so use
them instead of rolling a new one.

v2: On x86 UP systems the wbinvd_on_all_cpus() is defined as a static inline in
smp.h. We must therefore include this file so we don't get compiler errors.
This error was found by 0-DAY kernel test infrastructure. We only need this for
x86.

Cc: Intel GFX <intel-gfx@lists.freedesktop.org>
Signed-off-by: default avatarBen Widawsky <ben@bwidawsk.net>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> (v1)
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 7432ca5a
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <drm/drmP.h> #include <drm/drmP.h>
#if defined(CONFIG_X86) #if defined(CONFIG_X86)
#include <asm/smp.h>
/* /*
* clflushopt is an unordered instruction which needs fencing with mfence or * clflushopt is an unordered instruction which needs fencing with mfence or
...@@ -64,12 +65,6 @@ static void drm_cache_flush_clflush(struct page *pages[], ...@@ -64,12 +65,6 @@ static void drm_cache_flush_clflush(struct page *pages[],
drm_clflush_page(*pages++); drm_clflush_page(*pages++);
mb(); mb();
} }
static void
drm_clflush_ipi_handler(void *null)
{
wbinvd();
}
#endif #endif
void void
...@@ -82,7 +77,7 @@ drm_clflush_pages(struct page *pages[], unsigned long num_pages) ...@@ -82,7 +77,7 @@ drm_clflush_pages(struct page *pages[], unsigned long num_pages)
return; return;
} }
if (on_each_cpu(drm_clflush_ipi_handler, NULL, 1) != 0) if (wbinvd_on_all_cpus())
printk(KERN_ERR "Timed out waiting for cache flush.\n"); printk(KERN_ERR "Timed out waiting for cache flush.\n");
#elif defined(__powerpc__) #elif defined(__powerpc__)
...@@ -121,7 +116,7 @@ drm_clflush_sg(struct sg_table *st) ...@@ -121,7 +116,7 @@ drm_clflush_sg(struct sg_table *st)
return; return;
} }
if (on_each_cpu(drm_clflush_ipi_handler, NULL, 1) != 0) if (wbinvd_on_all_cpus())
printk(KERN_ERR "Timed out waiting for cache flush.\n"); printk(KERN_ERR "Timed out waiting for cache flush.\n");
#else #else
printk(KERN_ERR "Architecture has no drm_cache.c support\n"); printk(KERN_ERR "Architecture has no drm_cache.c support\n");
...@@ -144,7 +139,7 @@ drm_clflush_virt_range(void *addr, unsigned long length) ...@@ -144,7 +139,7 @@ drm_clflush_virt_range(void *addr, unsigned long length)
return; return;
} }
if (on_each_cpu(drm_clflush_ipi_handler, NULL, 1) != 0) if (wbinvd_on_all_cpus())
printk(KERN_ERR "Timed out waiting for cache flush.\n"); printk(KERN_ERR "Timed out waiting for cache flush.\n");
#else #else
printk(KERN_ERR "Architecture has no drm_cache.c support\n"); printk(KERN_ERR "Architecture has no drm_cache.c support\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment