Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / arch / sparc / mm / sun4c.c
index 4b9fc1d..49f28c1 100644 (file)
@@ -379,7 +379,7 @@ extern unsigned long invalid_segment_patch1, invalid_segment_patch1_ff;
 extern unsigned long invalid_segment_patch2, invalid_segment_patch2_ff;
 extern unsigned long invalid_segment_patch1_1ff, invalid_segment_patch2_1ff;
 extern unsigned long num_context_patch1, num_context_patch1_16;
-extern unsigned long num_context_patch2, num_context_patch2_16;
+extern unsigned long num_context_patch2_16;
 extern unsigned long vac_linesize_patch, vac_linesize_patch_32;
 extern unsigned long vac_hwflush_patch1, vac_hwflush_patch1_on;
 extern unsigned long vac_hwflush_patch2, vac_hwflush_patch2_on;
@@ -497,7 +497,7 @@ static void __init sun4c_probe_mmu(void)
        patch_kernel_fault_handler();
 }
 
-volatile unsigned long *sun4c_memerr_reg = 0;
+volatile unsigned long __iomem *sun4c_memerr_reg = NULL;
 
 void __init sun4c_probe_memerr_reg(void)
 {
@@ -511,7 +511,8 @@ void __init sun4c_probe_memerr_reg(void)
                node = prom_searchsiblings(prom_root_node, "memory-error");
                if (!node)
                        return;
-               prom_getproperty(node, "reg", (char *)regs, sizeof(regs));
+               if (prom_getproperty(node, "reg", (char *)regs, sizeof(regs)) <= 0)
+                       return;
                /* hmm I think regs[0].which_io is zero here anyways */
                sun4c_memerr_reg = ioremap(regs[0].phys_addr, regs[0].reg_size);
        }
@@ -599,13 +600,13 @@ static void __init sun4c_init_mmu_entry_pool(void)
 
        for (i=0; i < SUN4C_MAX_SEGMAPS; i++) {
                mmu_entry_pool[i].pseg = i;
-               mmu_entry_pool[i].next = 0;
-               mmu_entry_pool[i].prev = 0;
+               mmu_entry_pool[i].next = NULL;
+               mmu_entry_pool[i].prev = NULL;
                mmu_entry_pool[i].vaddr = 0;
                mmu_entry_pool[i].locked = 0;
                mmu_entry_pool[i].ctx = 0;
-               mmu_entry_pool[i].lru_next = 0;
-               mmu_entry_pool[i].lru_prev = 0;
+               mmu_entry_pool[i].lru_next = NULL;
+               mmu_entry_pool[i].lru_prev = NULL;
        }
        mmu_entry_pool[invalid_segment].locked = 1;
 }
@@ -1170,7 +1171,7 @@ abend:
        local_irq_restore(flags);
        printk("DMA vaddr=0x%p size=%08lx\n", vaddr, size);
        panic("Out of iobuffer table");
-       return 0;
+       return NULL;
 }
 
 static void sun4c_unlockarea(char *vaddr, unsigned long size)
@@ -1588,7 +1589,10 @@ static void sun4c_flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
 
 static inline void sun4c_mapioaddr(unsigned long physaddr, unsigned long virt_addr)
 {
-       unsigned long page_entry;
+       unsigned long page_entry, pg_iobits;
+
+       pg_iobits = _SUN4C_PAGE_PRESENT | _SUN4C_READABLE | _SUN4C_WRITEABLE |
+                   _SUN4C_PAGE_IO | _SUN4C_PAGE_NOCACHE;
 
        page_entry = ((physaddr >> PAGE_SHIFT) & SUN4C_PFN_MASK);
        page_entry |= ((pg_iobits | _SUN4C_PAGE_PRIV) & ~(_SUN4C_PAGE_PRESENT));
@@ -1745,6 +1749,11 @@ static int sun4c_pte_present(pte_t pte)
 }
 static void sun4c_pte_clear(pte_t *ptep)       { *ptep = __pte(0); }
 
+static int sun4c_pte_read(pte_t pte)
+{
+       return (pte_val(pte) & _SUN4C_PAGE_READ);
+}
+
 static int sun4c_pmd_bad(pmd_t pmd)
 {
        return (((pmd_val(pmd) & ~PAGE_MASK) != PGD_TABLE) ||
@@ -2114,9 +2123,8 @@ void __init sun4c_paging_init(void)
                zones_size[ZONE_HIGHMEM] = npages;
                zholes_size[ZONE_HIGHMEM] = npages - calc_highpages();
 
-               free_area_init_node(0, &contig_page_data, NULL, zones_size,
+               free_area_init_node(0, &contig_page_data, zones_size,
                                    pfn_base, zholes_size);
-               mem_map = contig_page_data.node_mem_map;
        }
 
        cnt = 0;
@@ -2129,6 +2137,13 @@ void __init sun4c_paging_init(void)
        printk("SUN4C: %d mmu entries for the kernel\n", cnt);
 }
 
+static pgprot_t sun4c_pgprot_noncached(pgprot_t prot)
+{
+       prot |= __pgprot(_SUN4C_PAGE_IO | _SUN4C_PAGE_NOCACHE);
+
+       return prot;
+}
+
 /* Load up routines and constants for sun4c mmu */
 void __init ld_mmu_sun4c(void)
 {
@@ -2137,14 +2152,10 @@ void __init ld_mmu_sun4c(void)
        printk("Loading sun4c MMU routines\n");
 
        /* First the constants */
-       BTFIXUPSET_SIMM13(pmd_shift, SUN4C_PMD_SHIFT);
-       BTFIXUPSET_SETHI(pmd_size, SUN4C_PMD_SIZE);
-       BTFIXUPSET_SETHI(pmd_mask, SUN4C_PMD_MASK);
        BTFIXUPSET_SIMM13(pgdir_shift, SUN4C_PGDIR_SHIFT);
        BTFIXUPSET_SETHI(pgdir_size, SUN4C_PGDIR_SIZE);
        BTFIXUPSET_SETHI(pgdir_mask, SUN4C_PGDIR_MASK);
 
-       BTFIXUPSET_SIMM13(ptrs_per_pte, SUN4C_PTRS_PER_PTE);
        BTFIXUPSET_SIMM13(ptrs_per_pmd, SUN4C_PTRS_PER_PMD);
        BTFIXUPSET_SIMM13(ptrs_per_pgd, SUN4C_PTRS_PER_PGD);
        BTFIXUPSET_SIMM13(user_ptrs_per_pgd, KERNBASE / SUN4C_PGDIR_SIZE);
@@ -2155,10 +2166,9 @@ void __init ld_mmu_sun4c(void)
        BTFIXUPSET_INT(page_readonly, pgprot_val(SUN4C_PAGE_READONLY));
        BTFIXUPSET_INT(page_kernel, pgprot_val(SUN4C_PAGE_KERNEL));
        page_kernel = pgprot_val(SUN4C_PAGE_KERNEL);
-       pg_iobits = _SUN4C_PAGE_PRESENT | _SUN4C_READABLE | _SUN4C_WRITEABLE |
-                   _SUN4C_PAGE_IO | _SUN4C_PAGE_NOCACHE;
 
        /* Functions */
+       BTFIXUPSET_CALL(pgprot_noncached, sun4c_pgprot_noncached, BTFIXUPCALL_NORM);
        BTFIXUPSET_CALL(___xchg32, ___xchg32_sun4c, BTFIXUPCALL_NORM);
        BTFIXUPSET_CALL(do_check_pgt_cache, sun4c_check_pgt_cache, BTFIXUPCALL_NORM);
        
@@ -2203,6 +2213,7 @@ void __init ld_mmu_sun4c(void)
 
        BTFIXUPSET_CALL(pte_present, sun4c_pte_present, BTFIXUPCALL_NORM);
        BTFIXUPSET_CALL(pte_clear, sun4c_pte_clear, BTFIXUPCALL_STG0O0);
+       BTFIXUPSET_CALL(pte_read, sun4c_pte_read, BTFIXUPCALL_NORM);
 
        BTFIXUPSET_CALL(pmd_bad, sun4c_pmd_bad, BTFIXUPCALL_NORM);
        BTFIXUPSET_CALL(pmd_present, sun4c_pmd_present, BTFIXUPCALL_NORM);