drm: add helper to clflush a virtual address range
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Sun, 25 Mar 2012 17:47:30 +0000 (19:47 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 27 Mar 2012 11:19:45 +0000 (13:19 +0200)
Useful when the page is already mapped to copy date in/out.

For -stable because the next patch (fixing phys obj pwrite) needs this
little helper function.

Tested-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/drm_cache.c
include/drm/drmP.h

index 592865381c6e84acb5ec66fef2e865e897d586e0..c7c8f6b5786fc4fd29e87dbbe66d9c5b4c9f9b95 100644 (file)
@@ -98,3 +98,26 @@ drm_clflush_pages(struct page *pages[], unsigned long num_pages)
 #endif
 }
 EXPORT_SYMBOL(drm_clflush_pages);
+
+void
+drm_clflush_virt_range(char *addr, unsigned long length)
+{
+#if defined(CONFIG_X86)
+       if (cpu_has_clflush) {
+               char *end = addr + length;
+               mb();
+               for (; addr < end; addr += boot_cpu_data.x86_clflush_size)
+                       clflush(addr);
+               clflush(end - 1);
+               mb();
+               return;
+       }
+
+       if (on_each_cpu(drm_clflush_ipi_handler, NULL, 1) != 0)
+               printk(KERN_ERR "Timed out waiting for cache flush.\n");
+#else
+       printk(KERN_ERR "Architecture has no drm_cache.c support\n");
+       WARN_ON_ONCE(1);
+#endif
+}
+EXPORT_SYMBOL(drm_clflush_virt_range);
index 92f0981b5fb862e214ecf8b5c906ad98ef065a92..d33597bcc77c15d41f018cfe2119d114621ea8a3 100644 (file)
@@ -1332,6 +1332,7 @@ extern int drm_remove_magic(struct drm_master *master, drm_magic_t magic);
 
 /* Cache management (drm_cache.c) */
 void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
+void drm_clflush_virt_range(char *addr, unsigned long length);
 
                                /* Locking IOCTL support (drm_lock.h) */
 extern int drm_lock(struct drm_device *dev, void *data,