[MIPS] Always use virt_to_phys() when translating kernel addresses

This patch fixes two places where we used plain 'x - PAGE_OFFSET' to
achieve virtual to physical address convertions. This type of convertion
is no more allowed since commit 6f284a2ce7b8bc49cb8455b1763357897a899abb.

Reported-by: Maxime Bizon <mbizon@freebox.fr>
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>

[Build fixes for machines that don't use the generic dma-coherence.h]

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by Franck Bui-Huu and committed by Ralf Baechle c9d06962 f33bc55c

+14 -7
+12 -5
arch/mips/mm/dma-default.c
··· 19 19 20 20 #include <dma-coherence.h> 21 21 22 + static inline unsigned long dma_addr_to_virt(dma_addr_t dma_addr) 23 + { 24 + unsigned long addr = plat_dma_addr_to_phys(dma_addr); 25 + 26 + return (unsigned long)phys_to_virt(addr); 27 + } 28 + 22 29 /* 23 30 * Warning on the terminology - Linux calls an uncached area coherent; 24 31 * MIPS terminology calls memory areas with hardware maintained coherency ··· 147 140 enum dma_data_direction direction) 148 141 { 149 142 if (cpu_is_noncoherent_r10000(dev)) 150 - __dma_sync(plat_dma_addr_to_phys(dma_addr) + PAGE_OFFSET, size, 143 + __dma_sync(dma_addr_to_virt(dma_addr), size, 151 144 direction); 152 145 153 146 plat_unmap_dma_mem(dma_addr); ··· 241 234 if (cpu_is_noncoherent_r10000(dev)) { 242 235 unsigned long addr; 243 236 244 - addr = PAGE_OFFSET + plat_dma_addr_to_phys(dma_handle); 237 + addr = dma_addr_to_virt(dma_handle); 245 238 __dma_sync(addr, size, direction); 246 239 } 247 240 } ··· 256 249 if (!plat_device_is_coherent(dev)) { 257 250 unsigned long addr; 258 251 259 - addr = PAGE_OFFSET + plat_dma_addr_to_phys(dma_handle); 252 + addr = dma_addr_to_virt(dma_handle); 260 253 __dma_sync(addr, size, direction); 261 254 } 262 255 } ··· 271 264 if (cpu_is_noncoherent_r10000(dev)) { 272 265 unsigned long addr; 273 266 274 - addr = PAGE_OFFSET + plat_dma_addr_to_phys(dma_handle); 267 + addr = dma_addr_to_virt(dma_handle); 275 268 __dma_sync(addr + offset, size, direction); 276 269 } 277 270 } ··· 286 279 if (!plat_device_is_coherent(dev)) { 287 280 unsigned long addr; 288 281 289 - addr = PAGE_OFFSET + plat_dma_addr_to_phys(dma_handle); 282 + addr = dma_addr_to_virt(dma_handle); 290 283 __dma_sync(addr + offset, size, direction); 291 284 } 292 285 }
+1 -1
include/asm-mips/pgtable-64.h
··· 199 199 { 200 200 return pud_val(pud); 201 201 } 202 - #define pud_phys(pud) (pud_val(pud) - PAGE_OFFSET) 202 + #define pud_phys(pud) virt_to_phys((void *)pud_val(pud)) 203 203 #define pud_page(pud) (pfn_to_page(pud_phys(pud) >> PAGE_SHIFT)) 204 204 205 205 /* Find an entry in the second-level page table.. */
+1 -1
include/asm-mips/pgtable.h
··· 75 75 * Conversion functions: convert a page and protection to a page entry, 76 76 * and a page entry and page directory to the page they refer to. 77 77 */ 78 - #define pmd_phys(pmd) (pmd_val(pmd) - PAGE_OFFSET) 78 + #define pmd_phys(pmd) virt_to_phys((void *)pmd_val(pmd)) 79 79 #define pmd_page(pmd) (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT)) 80 80 #define pmd_page_vaddr(pmd) pmd_val(pmd) 81 81