From: Dave Airlie <[email protected]>

This undoes some stupid from earlier, wbinvd *does* need ipi,
clflush doesn't.

Signed-off-by: Dave Airlie <[email protected]>
---
 drivers/gpu/drm/drm_cache.c  |   18 +++++++++++-
 drivers/gpu/drm/ttm/ttm_tt.c |   61 +----------------------------------------
 include/drm/drm_cache.h      |   38 ++++++++++++++++++++++++++
 3 files changed, 57 insertions(+), 60 deletions(-)
 create mode 100644 include/drm/drm_cache.h

diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c
index 0e994a0..adf5af4 100644
--- a/drivers/gpu/drm/drm_cache.c
+++ b/drivers/gpu/drm/drm_cache.c
@@ -47,6 +47,12 @@ drm_clflush_page(struct page *page)
 }
 #endif
 
+static void
+drm_clflush_ipi_handler(void *null)
+{
+       wbinvd();
+}
+
 void
 drm_clflush_pages(struct page *pages[], unsigned long num_pages)
 {
@@ -63,7 +69,17 @@ drm_clflush_pages(struct page *pages[], unsigned long 
num_pages)
                return;
        }
 
-       wbinvd();
+       if (on_each_cpu(drm_clflush_ipi_handler, NULL, 1) != 0)
+               DRM_ERROR("Timed out waiting for cache flush.\n");
+
+#elif defined(__powerpc__)
+       unsigned long i;
+       for (i = 0; i < num_pages; i++) {
+               if (pages[i])
+                       unsigned long start = (unsigned 
long)page_address(pages[i]);
+                       flush_dcache_range(start, start + PAGE_SIZE);
+               }
+       }
 #endif
 }
 EXPORT_SYMBOL(drm_clflush_pages);
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 75dc8bd..1e692ff 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -34,70 +34,13 @@
 #include <linux/pagemap.h>
 #include <linux/file.h>
 #include <linux/swap.h>
+#include "drm_cache.h"
 #include "ttm/ttm_module.h"
 #include "ttm/ttm_bo_driver.h"
 #include "ttm/ttm_placement.h"
 
 static int ttm_tt_swapin(struct ttm_tt *ttm);
 
-#if defined(CONFIG_X86)
-static void ttm_tt_clflush_page(struct page *page)
-{
-       uint8_t *page_virtual;
-       unsigned int i;
-
-       if (unlikely(page == NULL))
-               return;
-
-       page_virtual = kmap_atomic(page, KM_USER0);
-
-       for (i = 0; i < PAGE_SIZE; i += boot_cpu_data.x86_clflush_size)
-               clflush(page_virtual + i);
-
-       kunmap_atomic(page_virtual, KM_USER0);
-}
-
-static void ttm_tt_cache_flush_clflush(struct page *pages[],
-                                      unsigned long num_pages)
-{
-       unsigned long i;
-
-       mb();
-       for (i = 0; i < num_pages; ++i)
-               ttm_tt_clflush_page(*pages++);
-       mb();
-}
-#elif !defined(__powerpc__)
-static void ttm_tt_ipi_handler(void *null)
-{
-       ;
-}
-#endif
-
-void ttm_tt_cache_flush(struct page *pages[], unsigned long num_pages)
-{
-
-#if defined(CONFIG_X86)
-       if (cpu_has_clflush) {
-               ttm_tt_cache_flush_clflush(pages, num_pages);
-               return;
-       }
-#elif defined(__powerpc__)
-       unsigned long i;
-
-       for (i = 0; i < num_pages; ++i) {
-               if (pages[i]) {
-                       unsigned long start = (unsigned 
long)page_address(pages[i]);
-                       flush_dcache_range(start, start + PAGE_SIZE);
-               }
-       }
-#else
-       if (on_each_cpu(ttm_tt_ipi_handler, NULL, 1) != 0)
-               printk(KERN_ERR TTM_PFX
-                      "Timed out waiting for drm cache flush.\n");
-#endif
-}
-
 /**
  * Allocates storage for pointers to the pages that back the ttm.
  *
@@ -297,7 +240,7 @@ static int ttm_tt_set_caching(struct ttm_tt *ttm,
        }
 
        if (ttm->caching_state == tt_cached)
-               ttm_tt_cache_flush(ttm->pages, ttm->num_pages);
+               drm_clflush_pages(ttm->pages, ttm->num_pages);
 
        for (i = 0; i < ttm->num_pages; ++i) {
                cur_page = ttm->pages[i];
diff --git a/include/drm/drm_cache.h b/include/drm/drm_cache.h
new file mode 100644
index 0000000..7bfb063
--- /dev/null
+++ b/include/drm/drm_cache.h
@@ -0,0 +1,38 @@
+/**************************************************************************
+ *
+ * Copyright 2009 Red Hat Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ **************************************************************************/
+/*
+ * Authors:
+ * Dave Airlie <[email protected]>
+ */
+
+#ifndef _DRM_CACHE_H_
+#define _DRM_CACHE_H_
+
+void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
+
+#endif
-- 
1.6.2.2


------------------------------------------------------------------------------
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to