From 2305100c0fce9ec86a22660e5fed54791cff030b Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Fri, 29 Feb 2008 13:25:55 +0100 Subject: More post-ioctl work. --- linux-core/drm_ttm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux-core/drm_ttm.c') diff --git a/linux-core/drm_ttm.c b/linux-core/drm_ttm.c index a9d87338..58568452 100644 --- a/linux-core/drm_ttm.c +++ b/linux-core/drm_ttm.c @@ -298,7 +298,7 @@ int drm_ttm_populate(struct drm_ttm *ttm) return 0; be = ttm->be; - if (ttm->page_flags & DRM_TTM_PAGE_WRITE) { + if (1 || (ttm->page_flags & DRM_TTM_PAGE_WRITE)) { for (i = 0; i < ttm->num_pages; ++i) { page = drm_ttm_get_page(ttm, i); if (!page) -- cgit v1.2.3 From c3888b97f60fbbc0b1382e5a16689eecaa2f79a5 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Sun, 6 Apr 2008 10:32:02 +0200 Subject: Use clflush() when available for cache flushing. --- linux-core/drm_ttm.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'linux-core/drm_ttm.c') diff --git a/linux-core/drm_ttm.c b/linux-core/drm_ttm.c index e991254f..da202a58 100644 --- a/linux-core/drm_ttm.c +++ b/linux-core/drm_ttm.c @@ -30,13 +30,48 @@ #include "drmP.h" +#if defined( CONFIG_X86 ) && (LINUX_VERSION_CODE >= (2,6,24)) +static void drm_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 drm_ttm_cache_flush_clflush(struct page *pages[], unsigned long num_pages) +{ + unsigned long i; + + mb(); + for (i=0; i < num_pages; ++i) + drm_clflush_page(*pages++); + mb(); +} +#endif + static void drm_ttm_ipi_handler(void *null) { flush_agp_cache(); } -void drm_ttm_cache_flush(void) +void drm_ttm_cache_flush(struct page *pages[], unsigned long num_pages) { + +#if defined( CONFIG_X86 ) && (LINUX_VERSION_CODE >= (2,6,24)) + if (cpu_has_clflush) { + drm_ttm_cache_flush_clflush(pages, num_pages); + return; + } +#endif if (on_each_cpu(drm_ttm_ipi_handler, NULL, 1, 1) != 0) DRM_ERROR("Timed out waiting for drm cache flush.\n"); } @@ -114,7 +149,7 @@ static int drm_ttm_set_caching(struct drm_ttm *ttm, int noncached) return 0; if (noncached) - drm_ttm_cache_flush(); + drm_ttm_cache_flush(ttm->pages, ttm->num_pages); for (i = 0; i < ttm->num_pages; ++i) { cur_page = ttm->pages + i; -- cgit v1.2.3 From e89710bef7691e4e9d0bc7d427542bfae6ce4258 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Sun, 6 Apr 2008 11:21:22 +0200 Subject: Place highmem pages last in the ttm page array. --- linux-core/drm_ttm.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'linux-core/drm_ttm.c') diff --git a/linux-core/drm_ttm.c b/linux-core/drm_ttm.c index da202a58..c306a2c0 100644 --- a/linux-core/drm_ttm.c +++ b/linux-core/drm_ttm.c @@ -263,12 +263,16 @@ struct page *drm_ttm_get_page(struct drm_ttm *ttm, int index) struct page *p; struct drm_buffer_manager *bm = &ttm->dev->bm; - p = ttm->pages[index]; - if (!p) { + while(NULL == (p = ttm->pages[index])) { p = drm_ttm_alloc_page(); if (!p) return NULL; - ttm->pages[index] = p; + + if (PageHighMem(p)) + ttm->pages[--ttm->first_himem_page] = p; + else + ttm->pages[++ttm->last_lomem_page] = p; + ++bm->cur_pages; } return p; @@ -376,6 +380,8 @@ struct drm_ttm *drm_ttm_create(struct drm_device *dev, unsigned long size, ttm->destroy = 0; ttm->num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; + ttm->first_himem_page = ttm->num_pages; + ttm->last_lomem_page = -1; ttm->page_flags = page_flags; -- cgit v1.2.3 From db61f02bd7e4b9d5ac416f1ef98bac1bd4d984bc Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Mon, 7 Apr 2008 22:24:24 +0200 Subject: Missing KERNEL_VERSION macro --- linux-core/drm_ttm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'linux-core/drm_ttm.c') diff --git a/linux-core/drm_ttm.c b/linux-core/drm_ttm.c index c306a2c0..80a8ff5d 100644 --- a/linux-core/drm_ttm.c +++ b/linux-core/drm_ttm.c @@ -30,7 +30,7 @@ #include "drmP.h" -#if defined( CONFIG_X86 ) && (LINUX_VERSION_CODE >= (2,6,24)) +#if defined( CONFIG_X86 ) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) static void drm_clflush_page(struct page *page) { uint8_t *page_virtual; @@ -66,7 +66,7 @@ static void drm_ttm_ipi_handler(void *null) void drm_ttm_cache_flush(struct page *pages[], unsigned long num_pages) { -#if defined( CONFIG_X86 ) && (LINUX_VERSION_CODE >= (2,6,24)) +#if defined( CONFIG_X86 ) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) if (cpu_has_clflush) { drm_ttm_cache_flush_clflush(pages, num_pages); return; -- cgit v1.2.3