All of lore.kernel.org
 help / color / mirror / Atom feed
From: yanhua <yanh@lemote.com>
To: linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>
Cc: 彭亮锦 <penglj@lemote.com>, "zhangfx@lemote.com" <zhangfx@lemote.com>
Subject: [PATCH 9/14] lemote: define Loongson2F arch specific phys prot access
Date: Thu, 09 Apr 2009 13:04:37 +0800	[thread overview]
Message-ID: <49DD81E5.3020100@lemote.com> (raw)

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

                 reply	other threads:[~2009-04-09  5:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49DD81E5.3020100@lemote.com \
    --to=yanh@lemote.com \
    --cc=linux-mips@linux-mips.org \
    --cc=penglj@lemote.com \
    --cc=ralf@linux-mips.org \
    --cc=zhangfx@lemote.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.