]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - arch/blackfin/kernel/cplb-nompu/cplbinit.c
Blackfin: support smaller uncached DMA chunks for memory constrained systems
[net-next-2.6.git] / arch / blackfin / kernel / cplb-nompu / cplbinit.c
index fd9a2f31e686f63ceabe2354b401df5c919bb1f6..c9b0a4d53dc15f2b8cb5cb8453ecbc7e6b8cb43a 100644 (file)
@@ -89,15 +89,25 @@ void __init generate_cplb_tables_cpu(unsigned int cpu)
 
 void __init generate_cplb_tables_all(void)
 {
+       unsigned long uncached_end;
        int i_d, i_i;
 
        i_d = 0;
        /* Normal RAM, including MTD FS.  */
 #ifdef CONFIG_MTD_UCLINUX
-       dcplb_bounds[i_d].eaddr = memory_mtd_start + mtd_size;
+       uncached_end = memory_mtd_start + mtd_size;
 #else
-       dcplb_bounds[i_d].eaddr = memory_end;
+       uncached_end = memory_end;
 #endif
+       /*
+        * if DMA uncached is less than 1MB, mark the 1MB chunk as uncached
+        * so that we don't have to use 4kB pages and cause CPLB thrashing
+        */
+       if ((DMA_UNCACHED_REGION >= 1 * 1024 * 1024) || !DMA_UNCACHED_REGION ||
+           ((_ramend - uncached_end) >= 1 * 1024 * 1024))
+               dcplb_bounds[i_d].eaddr = uncached_end;
+       else
+               dcplb_bounds[i_d].eaddr = uncached_end & ~(1 * 1024 * 1024);
        dcplb_bounds[i_d++].data = SDRAM_DGENERIC;
        /* DMA uncached region.  */
        if (DMA_UNCACHED_REGION) {
@@ -135,11 +145,7 @@ void __init generate_cplb_tables_all(void)
 
        i_i = 0;
        /* Normal RAM, including MTD FS.  */
-#ifdef CONFIG_MTD_UCLINUX
-       icplb_bounds[i_i].eaddr = memory_mtd_start + mtd_size;
-#else
-       icplb_bounds[i_i].eaddr = memory_end;
-#endif
+       icplb_bounds[i_i].eaddr = uncached_end;
        icplb_bounds[i_i++].data = SDRAM_IGENERIC;
        /* DMA uncached region.  */
        if (DMA_UNCACHED_REGION) {