linux-mips
[Top] [All Lists]

[PATCH -queue 2/2] [loongson] 2f: Improve video performance via uncached

To: Ralf Baechle <ralf@linux-mips.org>
Subject: [PATCH -queue 2/2] [loongson] 2f: Improve video performance via uncached accelerated TLB map
From: Wu Zhangjin <wuzhangjin@gmail.com>
Date: Wed, 11 Nov 2009 13:59:24 +0800
Cc: linux-mips@linux-mips.org, Wu Zhangjin <wuzhangjin@gmail.com>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references:in-reply-to:references; bh=H3j1xOjD6/CccPgS94bTHeAP9QlmC8Qgv4j7gkHvobY=; b=hVKrliXXf0l4HtBDY/rypLcPE/GMn4oQ82M7zcySrxag4jpElcpyyBrFXHdgEFV3xG j7r5SYK1FlwDGzFWArCKp/UQXyKfKTGACMQJRPo+kF++G2K/HZezNRs8igj1K+Qs+ayP PAQ91h04eI5KKorp/NCopFpQg/3z7GoFCMXPs=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=Vp0tvt+pMXC/SEknHGpn77XOB5LPhkx1VhdYlNDB40jk11MyVvYvW5oI7kJ3sH3gC1 Y9xXJ9oageuNGYW3LtrpeOuRDGJHTkZu8F2qyVMLno6OrK4lBleJw7jKxu5g4X1rY6Ak EmpR1MXSItRLKdEleG3jdpLjtVcpdm09zDCrI=
In-reply-to: <ff4228281d1e0fcadf2f34b922c2324d095fd938.1257918796.git.wuzhangjin@gmail.com>
In-reply-to: <cover.1257918796.git.wuzhangjin@gmail.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <cover.1257918796.git.wuzhangjin@gmail.com> <ff4228281d1e0fcadf2f34b922c2324d095fd938.1257918796.git.wuzhangjin@gmail.com>
References: <cover.1257918796.git.wuzhangjin@gmail.com>
Sender: linux-mips-bounce@linux-mips.org
Loongson2F support video acceleration, and need to enable Uncached
Accelerated TLB map.

Uncached Accelerated TLB map can greatly improve video performance.
Normally the Video memory can be accessed in Uncached Accelerated mode,
other peripheral spaces not.

Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
 arch/mips/include/asm/pgtable.h |   13 +++++++++
 arch/mips/loongson/common/mem.c |   58 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
index d6eb613..56b8621 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,
 #include <asm-generic/pgtable.h>
 
 /*
+ * uncached accelerated TLB map for video memory access
+ */
+#ifdef CONFIG_CPU_SUPPORT_VIDEO_ACC
+#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/loongson/common/mem.c b/arch/mips/loongson/common/mem.c
index 467a91e..cf19393 100644
--- a/arch/mips/loongson/common/mem.c
+++ b/arch/mips/loongson/common/mem.c
@@ -59,3 +59,61 @@ int __uncached_access(struct file *file, unsigned long addr)
            ((addr >= LOONGSON_MMIO_MEM_START) &&
             (addr < LOONGSON_MMIO_MEM_END));
 }
+
+#ifdef CONFIG_CPU_SUPPORT_VIDEO_ACC
+
+#include <linux/pci.h>
+#include <linux/sched.h>
+#include <asm/current.h>
+
+static unsigned long uca_start, uca_end;
+
+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_end))
+                       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;
+                                       uca_end = r->end;
+                                       return 0;
+                               }
+                       }
+               }
+       }
+
+       return 0;
+}
+
+late_initcall(find_vga_mem_init);
+#endif                         /* !CONFIG_CPU_SUPPORT_VIDEO_ACC */
-- 
1.6.2.1


<Prev in Thread] Current Thread [Next in Thread>