void drm_clflush_pages(struct page *pages[], unsigned long num_pages) { #if defined(CONFIG_X86) if (cpu_has_clflush) { drm_cache_flush_clflush(pages, num_pages); return; } if (wbinvd_on_all_cpus()) printk(KERN_ERR "Timed out waiting for cache flush.\n"); #elif defined(__powerpc__) unsigned long i; for (i = 0; i < num_pages; i++) { struct page *page = pages[i]; void *page_virtual; if (unlikely(page == NULL)) continue; page_virtual = kmap_atomic(page); flush_dcache_range((unsigned long)page_virtual, (unsigned long)page_virtual + PAGE_SIZE); kunmap_atomic(page_virtual); } #else printk(KERN_ERR "Architecture has no drm_cache.c support\n"); WARN_ON_ONCE(1); #endif }
/* flush all cpus cache */ void kfm_cache_flush_all(void) { EnterFunction(6); wbinvd_on_all_cpus(); LeaveFunction(6); }
static void *ion_page_pool_alloc_pages(struct ion_page_pool *pool) { struct page *page = alloc_pages(pool->gfp_mask, pool->order); if (!page) return NULL; #ifdef CONFIG_ARM /* this is only being used to flush the page for dma, this api is not really suitable for calling from a driver but no better way to flush a page for dma exist at this time */ __dma_page_cpu_to_dev(page, 0, PAGE_SIZE << pool->order, DMA_BIDIRECTIONAL); #elif defined(CONFIG_X86) wbinvd_on_all_cpus(); #endif return page; }
void drm_clflush_virt_range(void *addr, unsigned long length) { #if defined(CONFIG_X86) if (cpu_has_clflush) { void *end = addr + length; mb(); for (; addr < end; addr += boot_cpu_data.x86_clflush_size) clflushopt(addr); clflushopt(end - 1); mb(); return; } if (wbinvd_on_all_cpus()) 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 }
void drm_clflush_sg(struct sg_table *st) { #if defined(CONFIG_X86) if (cpu_has_clflush) { struct sg_page_iter sg_iter; mb(); for_each_sg_page(st->sgl, &sg_iter, st->nents, 0) drm_clflush_page(sg_page_iter_page(&sg_iter)); mb(); return; } if (wbinvd_on_all_cpus()) 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 }