Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Add support for uncached accelerated mappings.

Loongson2f support video acceleration.

Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
Cc: linux-mips@linux-mips.org
Patchwork: http://patchwork.linux-mips.org/patch/624/
Patchwork: http://patchwork.linux-mips.org/patch/625/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Wu Zhangjin and committed by
Ralf Baechle
22f1fdfd 55045ff5

+74
+3
arch/mips/Kconfig
··· 1336 1336 bool 1337 1337 select CPU_SUPPORTS_CPUFREQ 1338 1338 select CPU_SUPPORTS_ADDRWINCFG if 64BIT 1339 + select CPU_SUPPORTS_UNCACHED_ACCELERATED 1339 1340 1340 1341 config SYS_HAS_CPU_MIPS32_R1 1341 1342 bool ··· 1451 1450 config CPU_SUPPORTS_ADDRWINCFG 1452 1451 bool 1453 1452 config CPU_SUPPORTS_HUGEPAGES 1453 + bool 1454 + config CPU_SUPPORTS_UNCACHED_ACCELERATED 1454 1455 bool 1455 1456 config MIPS_PGD_C0_CONTEXT 1456 1457 bool
+13
arch/mips/include/asm/pgtable.h
··· 390 390 #include <asm-generic/pgtable.h> 391 391 392 392 /* 393 + * uncached accelerated TLB map for video memory access 394 + */ 395 + #ifdef CONFIG_CPU_SUPPORTS_UNCACHED_ACCELERATED 396 + #define __HAVE_PHYS_MEM_ACCESS_PROT 397 + 398 + struct file; 399 + pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, 400 + unsigned long size, pgprot_t vma_prot); 401 + int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn, 402 + unsigned long size, pgprot_t *vma_prot); 403 + #endif 404 + 405 + /* 393 406 * We provide our own get_unmapped area to cope with the virtual aliasing 394 407 * constraints placed on us by the cache architecture. 395 408 */
+58
arch/mips/loongson/common/mem.c
··· 58 58 ((addr >= LOONGSON_MMIO_MEM_START) && 59 59 (addr < LOONGSON_MMIO_MEM_END)); 60 60 } 61 + 62 + #ifdef CONFIG_CPU_SUPPORTS_UNCACHED_ACCELERATED 63 + 64 + #include <linux/pci.h> 65 + #include <linux/sched.h> 66 + #include <asm/current.h> 67 + 68 + static unsigned long uca_start, uca_end; 69 + 70 + pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, 71 + unsigned long size, pgprot_t vma_prot) 72 + { 73 + unsigned long offset = pfn << PAGE_SHIFT; 74 + unsigned long end = offset + size; 75 + 76 + if (__uncached_access(file, offset)) { 77 + if (((uca_start && offset) >= uca_start) && 78 + (end <= uca_end)) 79 + return __pgprot((pgprot_val(vma_prot) & 80 + ~_CACHE_MASK) | 81 + _CACHE_UNCACHED_ACCELERATED); 82 + else 83 + return pgprot_noncached(vma_prot); 84 + } 85 + return vma_prot; 86 + } 87 + 88 + static int __init find_vga_mem_init(void) 89 + { 90 + struct pci_dev *dev = 0; 91 + struct resource *r; 92 + int idx; 93 + 94 + if (uca_start) 95 + return 0; 96 + 97 + for_each_pci_dev(dev) { 98 + if ((dev->class >> 8) == PCI_CLASS_DISPLAY_VGA) { 99 + for (idx = 0; idx < PCI_NUM_RESOURCES; idx++) { 100 + r = &dev->resource[idx]; 101 + if (!r->start && r->end) 102 + continue; 103 + if (r->flags & IORESOURCE_IO) 104 + continue; 105 + if (r->flags & IORESOURCE_MEM) { 106 + uca_start = r->start; 107 + uca_end = r->end; 108 + return 0; 109 + } 110 + } 111 + } 112 + } 113 + 114 + return 0; 115 + } 116 + 117 + late_initcall(find_vga_mem_init); 118 + #endif /* !CONFIG_CPU_SUPPORTS_UNCACHED_ACCELERATED */