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