diff options
author | Wu Zhangjin <wuzhangjin@gmail.com> | 2009-11-11 00:59:23 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2009-12-16 20:57:15 -0500 |
commit | 22f1fdfd62a5f6ab738ffe03dc2ee9f1f25dabc4 (patch) | |
tree | dbfd9b7b9b1a25f31cfb0af42becdb33e7418b4d /arch | |
parent | 55045ff5557bc804752e84dca5d1b1f1d4bb4e31 (diff) |
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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/mips/Kconfig | 3 | ||||
-rw-r--r-- | arch/mips/include/asm/pgtable.h | 13 | ||||
-rw-r--r-- | arch/mips/loongson/common/mem.c | 58 |
3 files changed, 74 insertions, 0 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 51e4e5b02f9d..e2116b1f968e 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig | |||
@@ -1336,6 +1336,7 @@ config SYS_HAS_CPU_LOONGSON2F | |||
1336 | bool | 1336 | bool |
1337 | select CPU_SUPPORTS_CPUFREQ | 1337 | select CPU_SUPPORTS_CPUFREQ |
1338 | select CPU_SUPPORTS_ADDRWINCFG if 64BIT | 1338 | select CPU_SUPPORTS_ADDRWINCFG if 64BIT |
1339 | select CPU_SUPPORTS_UNCACHED_ACCELERATED | ||
1339 | 1340 | ||
1340 | config SYS_HAS_CPU_MIPS32_R1 | 1341 | config SYS_HAS_CPU_MIPS32_R1 |
1341 | bool | 1342 | bool |
@@ -1451,6 +1452,8 @@ config CPU_SUPPORTS_ADDRWINCFG | |||
1451 | bool | 1452 | bool |
1452 | config CPU_SUPPORTS_HUGEPAGES | 1453 | config CPU_SUPPORTS_HUGEPAGES |
1453 | bool | 1454 | bool |
1455 | config CPU_SUPPORTS_UNCACHED_ACCELERATED | ||
1456 | bool | ||
1454 | config MIPS_PGD_C0_CONTEXT | 1457 | config MIPS_PGD_C0_CONTEXT |
1455 | bool | 1458 | bool |
1456 | default y if 64BIT && CPU_MIPSR2 | 1459 | default y if 64BIT && CPU_MIPSR2 |
diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h index d6eb6134abec..1854336e56a2 100644 --- a/arch/mips/include/asm/pgtable.h +++ b/arch/mips/include/asm/pgtable.h | |||
@@ -390,6 +390,19 @@ static inline int io_remap_pfn_range(struct vm_area_struct *vma, | |||
390 | #include <asm-generic/pgtable.h> | 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 | * We provide our own get_unmapped area to cope with the virtual aliasing | 406 | * We provide our own get_unmapped area to cope with the virtual aliasing |
394 | * constraints placed on us by the cache architecture. | 407 | * constraints placed on us by the cache architecture. |
395 | */ | 408 | */ |
diff --git a/arch/mips/loongson/common/mem.c b/arch/mips/loongson/common/mem.c index 981e9190f393..ceacd092b446 100644 --- a/arch/mips/loongson/common/mem.c +++ b/arch/mips/loongson/common/mem.c | |||
@@ -58,3 +58,61 @@ int __uncached_access(struct file *file, unsigned long addr) | |||
58 | ((addr >= LOONGSON_MMIO_MEM_START) && | 58 | ((addr >= LOONGSON_MMIO_MEM_START) && |
59 | (addr < LOONGSON_MMIO_MEM_END)); | 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 */ | ||