Merge branch 'linux-next' of git://git.infradead.org/ubifs-2.6
[cascardo/linux.git] / arch / powerpc / lib / dma-noncoherent.c
index 6656d47..31734c0 100644 (file)
@@ -203,7 +203,7 @@ __dma_alloc_coherent(size_t size, dma_addr_t *handle, gfp_t gfp)
                /*
                 * Set the "dma handle"
                 */
-               *handle = page_to_bus(page);
+               *handle = page_to_phys(page);
 
                do {
                        BUG_ON(!pte_none(*pte));
@@ -348,8 +348,15 @@ void __dma_sync(void *vaddr, size_t size, int direction)
        switch (direction) {
        case DMA_NONE:
                BUG();
-       case DMA_FROM_DEVICE:   /* invalidate only */
-               invalidate_dcache_range(start, end);
+       case DMA_FROM_DEVICE:
+               /*
+                * invalidate only when cache-line aligned otherwise there is
+                * the potential for discarding uncommitted data from the cache
+                */
+               if ((start & (L1_CACHE_BYTES - 1)) || (size & (L1_CACHE_BYTES - 1)))
+                       flush_dcache_range(start, end);
+               else
+                       invalidate_dcache_range(start, end);
                break;
        case DMA_TO_DEVICE:             /* writeback only */
                clean_dcache_range(start, end);