* [PATCH 9/14] lemote: define Loongson2F arch specific phys prot access
@ 2009-04-09 5:04 yanhua
0 siblings, 0 replies; only message in thread
From: yanhua @ 2009-04-09 5:04 UTC (permalink / raw)
To: linux-mips, Ralf Baechle; +Cc: 彭亮锦, zhangfx@lemote.com
The main purpose is to uncache accelerate for video memory access
---
arch/mips/include/asm/pgtable.h | 10 +++++++
arch/mips/lemote/lm2f/Kconfig | 10 +++++++
arch/mips/lemote/lm2f/common/mem.c | 53 ++++++++++++++++++++++++++++++++++++
3 files changed, 73 insertions(+), 0 deletions(-)
diff --git a/arch/mips/include/asm/pgtable.h
b/arch/mips/include/asm/pgtable.h
index 6a0edf7..9880f2e 100644
--- a/arch/mips/include/asm/pgtable.h
+++ b/arch/mips/include/asm/pgtable.h
@@ -369,6 +369,16 @@ static inline int io_remap_pfn_range(struct
vm_area_struct *vma,
#include <asm-generic/pgtable.h>
+#ifdef CONFIG_MACH_LM2F
+#define __HAVE_PHYS_MEM_ACCESS_PROT
+
+struct file;
+pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
+ unsigned long size, pgprot_t vma_prot);
+int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
+ unsigned long size, pgprot_t *vma_prot);
+#endif
+
/*
* We provide our own get_unmapped area to cope with the virtual aliasing
* constraints placed on us by the cache architecture.
diff --git a/arch/mips/lemote/lm2f/Kconfig b/arch/mips/lemote/lm2f/Kconfig
index bdf34e5..605a6af 100644
--- a/arch/mips/lemote/lm2f/Kconfig
+++ b/arch/mips/lemote/lm2f/Kconfig
@@ -75,3 +75,13 @@ config LEMOTE_NAS
help
Lemote's Loongson-2F based network attached system
+config UCA_SIZE
+ hex "Uncache Accelerated Region size"
+ depends on MACH_LM2F
+ default 0x400000 if LEMOTE_YELOONG2F
+ default 0x2000000 if LEMOTE_FULOONG2F
+ help
+ Uncached Acceleration(UCA) can greatly improve video performance.
+ Normally the Video memory can be accessed in Uncached Accelerated mode,
+ other peripheral spaces not.
+ Specify a zeroed size to disable this feature.
diff --git a/arch/mips/lemote/lm2f/common/mem.c
b/arch/mips/lemote/lm2f/common/mem.c
index aa25ad4..a0cf8fa 100644
--- a/arch/mips/lemote/lm2f/common/mem.c
+++ b/arch/mips/lemote/lm2f/common/mem.c
@@ -8,6 +8,13 @@
#include <linux/fcntl.h>
#include <linux/mm.h>
+#include <linux/pci.h>
+
+#include <linux/sched.h>
+#include <asm/current.h>
+
+static unsigned long uca_start;
+static unsigned long uca_size = CONFIG_UCA_SIZE;
/* override of arch/mips/mm/cache.c: __uncached_access */
int __uncached_access(struct file *file, unsigned long addr)
{
@@ -21,3 +28,49 @@ int __uncached_access(struct file *file, unsigned
long addr)
return addr >= __pa(high_memory) ||
((addr >= 0x10000000) && (addr < 0x80000000));
}
+
+pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
+ unsigned long size, pgprot_t vma_prot)
+{
+ unsigned long offset = pfn << PAGE_SHIFT;
+ unsigned long end = offset + size;
+
+ if (__uncached_access(file, offset)) {
+ if(uca_start && offset >= uca_start && end <= (uca_start + uca_size))
+ return __pgprot((pgprot_val(vma_prot) &
~_CACHE_MASK)|_CACHE_UNCACHED_ACCELERATED);
+ else
+ return pgprot_noncached(vma_prot);
+ }
+ return vma_prot;
+}
+
+static int __init find_vga_mem_init(void)
+{
+ struct pci_dev *dev = 0;
+ struct resource *r;
+ int idx;
+
+ if(uca_start)
+ return 0;
+ for_each_pci_dev(dev) {
+ if ((dev->class >> 8) == PCI_CLASS_DISPLAY_VGA){
+ for (idx=0; idx < PCI_NUM_RESOURCES; idx++) {
+ r = &dev->resource[idx];
+ if (!r->start && r->end) {
+ continue;
+ }
+ if (r->flags & IORESOURCE_IO)
+ continue;
+ if (r->flags & IORESOURCE_MEM){
+ uca_start = r->start;
+ printk("find the frame buffer:start=%lx\n", uca_start);
+ return 0;
+ }
+ }
+
+ }
+ }
+ return 0;
+}
+late_initcall(find_vga_mem_init);
+
--
1.5.6.5
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2009-04-09 5:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-09 5:04 [PATCH 9/14] lemote: define Loongson2F arch specific phys prot access yanhua
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.