Merge mulgrave-w:git/scsi-misc-2.6
[pandora-kernel.git] / arch / sparc64 / mm / generic.c
index 112c316..af9d81d 100644 (file)
@@ -39,24 +39,29 @@ static inline void io_remap_pte_range(struct mm_struct *mm, pte_t * pte,
                pte_t entry;
                unsigned long curend = address + PAGE_SIZE;
                
-               entry = mk_pte_io(offset, prot, space);
+               entry = mk_pte_io(offset, prot, space, PAGE_SIZE);
                if (!(address & 0xffff)) {
-                       if (!(address & 0x3fffff) && !(offset & 0x3ffffe) && end >= address + 0x400000) {
-                               entry = mk_pte_io(offset,
-                                                 __pgprot(pgprot_val (prot) | _PAGE_SZ4MB),
-                                                 space);
+                       if (PAGE_SIZE < (4 * 1024 * 1024) &&
+                           !(address & 0x3fffff) &&
+                           !(offset & 0x3ffffe) &&
+                           end >= address + 0x400000) {
+                               entry = mk_pte_io(offset, prot, space,
+                                                 4 * 1024 * 1024);
                                curend = address + 0x400000;
                                offset += 0x400000;
-                       } else if (!(address & 0x7ffff) && !(offset & 0x7fffe) && end >= address + 0x80000) {
-                               entry = mk_pte_io(offset,
-                                                 __pgprot(pgprot_val (prot) | _PAGE_SZ512K),
-                                                 space);
+                       } else if (PAGE_SIZE < (512 * 1024) &&
+                                  !(address & 0x7ffff) &&
+                                  !(offset & 0x7fffe) &&
+                                  end >= address + 0x80000) {
+                               entry = mk_pte_io(offset, prot, space,
+                                                 512 * 1024 * 1024);
                                curend = address + 0x80000;
                                offset += 0x80000;
-                       } else if (!(offset & 0xfffe) && end >= address + 0x10000) {
-                               entry = mk_pte_io(offset,
-                                                 __pgprot(pgprot_val (prot) | _PAGE_SZ64K),
-                                                 space);
+                       } else if (PAGE_SIZE < (64 * 1024) &&
+                                  !(offset & 0xfffe) &&
+                                  end >= address + 0x10000) {
+                               entry = mk_pte_io(offset, prot, space,
+                                                 64 * 1024);
                                curend = address + 0x10000;
                                offset += 0x10000;
                        } else
@@ -64,10 +69,13 @@ static inline void io_remap_pte_range(struct mm_struct *mm, pte_t * pte,
                } else
                        offset += PAGE_SIZE;
 
+               if (pte_write(entry))
+                       entry = pte_mkdirty(entry);
                do {
                        BUG_ON(!pte_none(*pte));
                        set_pte_at(mm, address, pte, entry);
                        address += PAGE_SIZE;
+                       pte_val(entry) += PAGE_SIZE;
                        pte++;
                } while (address < curend);
        } while (address < end);
@@ -126,11 +134,14 @@ int io_remap_pfn_range(struct vm_area_struct *vma, unsigned long from,
        struct mm_struct *mm = vma->vm_mm;
        int space = GET_IOSPACE(pfn);
        unsigned long offset = GET_PFN(pfn) << PAGE_SHIFT;
+       unsigned long phys_base;
+
+       phys_base = offset | (((unsigned long) space) << 32UL);
 
        /* See comment in mm/memory.c remap_pfn_range */
-       vma->vm_flags |= VM_IO | VM_RESERVED;
+       vma->vm_flags |= VM_IO | VM_RESERVED | VM_PFNMAP;
+       vma->vm_pgoff = phys_base >> PAGE_SHIFT;
 
-       prot = __pgprot(pg_iobits);
        offset -= from;
        dir = pgd_offset(mm, from);
        flush_cache_range(vma, beg, end);