Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/agpgart
[linux-drm-fsl-dcu.git] / arch / sh / mm / pg-sh4.c
index 07371ed7a31328e49fcf34377abc3b7b247cffb5..969efeceb9282ae1b434dfc025a9728923e696c2 100644 (file)
@@ -6,24 +6,14 @@
  *
  * Released under the terms of the GNU GPL v2.0.
  */
-#include <linux/init.h>
-#include <linux/mman.h>
 #include <linux/mm.h>
-#include <linux/threads.h>
-#include <asm/addrspace.h>
-#include <asm/page.h>
-#include <asm/pgtable.h>
-#include <asm/processor.h>
-#include <asm/cache.h>
-#include <asm/io.h>
-#include <asm/uaccess.h>
-#include <asm/pgalloc.h>
+#include <linux/mutex.h>
 #include <asm/mmu_context.h>
 #include <asm/cacheflush.h>
 
-extern struct semaphore p3map_sem[];
+extern struct mutex p3map_mutex[];
 
-#define CACHE_ALIAS (cpu_data->dcache.alias_mask)
+#define CACHE_ALIAS (current_cpu_data.dcache.alias_mask)
 
 /*
  * clear_user_page
@@ -33,14 +23,9 @@ extern struct semaphore p3map_sem[];
  */
 void clear_user_page(void *to, unsigned long address, struct page *page)
 {
-       __set_bit(PG_mapped, &page->flags);
        if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0)
                clear_page(to);
        else {
-               pgprot_t pgprot = __pgprot(_PAGE_PRESENT |
-                                          _PAGE_RW | _PAGE_CACHABLE |
-                                          _PAGE_DIRTY | _PAGE_ACCESSED |
-                                          _PAGE_HW_SHARED | _PAGE_FLAGS_HARD);
                unsigned long phys_addr = PHYSADDR(to);
                unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS);
                pgd_t *pgd = pgd_offset_k(p3_addr);
@@ -50,16 +35,16 @@ void clear_user_page(void *to, unsigned long address, struct page *page)
                pte_t entry;
                unsigned long flags;
 
-               entry = pfn_pte(phys_addr >> PAGE_SHIFT, pgprot);
-               down(&p3map_sem[(address & CACHE_ALIAS)>>12]);
+               entry = pfn_pte(phys_addr >> PAGE_SHIFT, PAGE_KERNEL);
+               mutex_lock(&p3map_mutex[(address & CACHE_ALIAS)>>12]);
                set_pte(pte, entry);
                local_irq_save(flags);
-               __flush_tlb_page(get_asid(), p3_addr);
+               flush_tlb_one(get_asid(), p3_addr);
                local_irq_restore(flags);
                update_mmu_cache(NULL, p3_addr, entry);
                __clear_user_page((void *)p3_addr, to);
                pte_clear(&init_mm, p3_addr, pte);
-               up(&p3map_sem[(address & CACHE_ALIAS)>>12]);
+               mutex_unlock(&p3map_mutex[(address & CACHE_ALIAS)>>12]);
        }
 }
 
@@ -73,14 +58,9 @@ void clear_user_page(void *to, unsigned long address, struct page *page)
 void copy_user_page(void *to, void *from, unsigned long address,
                    struct page *page)
 {
-       __set_bit(PG_mapped, &page->flags);
        if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0)
                copy_page(to, from);
        else {
-               pgprot_t pgprot = __pgprot(_PAGE_PRESENT |
-                                          _PAGE_RW | _PAGE_CACHABLE |
-                                          _PAGE_DIRTY | _PAGE_ACCESSED |
-                                          _PAGE_HW_SHARED | _PAGE_FLAGS_HARD);
                unsigned long phys_addr = PHYSADDR(to);
                unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS);
                pgd_t *pgd = pgd_offset_k(p3_addr);
@@ -90,36 +70,15 @@ void copy_user_page(void *to, void *from, unsigned long address,
                pte_t entry;
                unsigned long flags;
 
-               entry = pfn_pte(phys_addr >> PAGE_SHIFT, pgprot);
-               down(&p3map_sem[(address & CACHE_ALIAS)>>12]);
+               entry = pfn_pte(phys_addr >> PAGE_SHIFT, PAGE_KERNEL);
+               mutex_lock(&p3map_mutex[(address & CACHE_ALIAS)>>12]);
                set_pte(pte, entry);
                local_irq_save(flags);
-               __flush_tlb_page(get_asid(), p3_addr);
+               flush_tlb_one(get_asid(), p3_addr);
                local_irq_restore(flags);
                update_mmu_cache(NULL, p3_addr, entry);
                __copy_user_page((void *)p3_addr, from, to);
                pte_clear(&init_mm, p3_addr, pte);
-               up(&p3map_sem[(address & CACHE_ALIAS)>>12]);
+               mutex_unlock(&p3map_mutex[(address & CACHE_ALIAS)>>12]);
        }
 }
-
-/*
- * For SH-4, we have our own implementation for ptep_get_and_clear
- */
-inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
-{
-       pte_t pte = *ptep;
-
-       pte_clear(mm, addr, ptep);
-       if (!pte_not_present(pte)) {
-               unsigned long pfn = pte_pfn(pte);
-               if (pfn_valid(pfn)) {
-                       struct page *page = pfn_to_page(pfn);
-                       struct address_space *mapping = page_mapping(page);
-                       if (!mapping || !mapping_writably_mapped(mapping))
-                               __clear_bit(PG_mapped, &page->flags);
-               }
-       }
-       return pte;
-}
-