diff options
author | Franck Bui-Huu <fbuihuu@gmail.com> | 2007-03-19 12:36:42 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2007-03-24 13:01:49 -0400 |
commit | c9d06962233bd0ce9bf46b007900eb88e716e948 (patch) | |
tree | 95f051515a704367604db3d814e48f9b54de3ea1 | |
parent | f33bc55c472295966e520c9347822fdd8b1082cd (diff) |
[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>
-rw-r--r-- | arch/mips/mm/dma-default.c | 17 | ||||
-rw-r--r-- | include/asm-mips/pgtable-64.h | 2 | ||||
-rw-r--r-- | include/asm-mips/pgtable.h | 2 |
3 files changed, 14 insertions, 7 deletions
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c index f503d02e403b..f0eb29917d9a 100644 --- a/arch/mips/mm/dma-default.c +++ b/arch/mips/mm/dma-default.c | |||
@@ -19,6 +19,13 @@ | |||
19 | 19 | ||
20 | #include <dma-coherence.h> | 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 | * Warning on the terminology - Linux calls an uncached area coherent; | 30 | * Warning on the terminology - Linux calls an uncached area coherent; |
24 | * MIPS terminology calls memory areas with hardware maintained coherency | 31 | * MIPS terminology calls memory areas with hardware maintained coherency |
@@ -140,7 +147,7 @@ void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, | |||
140 | enum dma_data_direction direction) | 147 | enum dma_data_direction direction) |
141 | { | 148 | { |
142 | if (cpu_is_noncoherent_r10000(dev)) | 149 | if (cpu_is_noncoherent_r10000(dev)) |
143 | __dma_sync(plat_dma_addr_to_phys(dma_addr) + PAGE_OFFSET, size, | 150 | __dma_sync(dma_addr_to_virt(dma_addr), size, |
144 | direction); | 151 | direction); |
145 | 152 | ||
146 | plat_unmap_dma_mem(dma_addr); | 153 | plat_unmap_dma_mem(dma_addr); |
@@ -234,7 +241,7 @@ void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, | |||
234 | if (cpu_is_noncoherent_r10000(dev)) { | 241 | if (cpu_is_noncoherent_r10000(dev)) { |
235 | unsigned long addr; | 242 | unsigned long addr; |
236 | 243 | ||
237 | addr = PAGE_OFFSET + plat_dma_addr_to_phys(dma_handle); | 244 | addr = dma_addr_to_virt(dma_handle); |
238 | __dma_sync(addr, size, direction); | 245 | __dma_sync(addr, size, direction); |
239 | } | 246 | } |
240 | } | 247 | } |
@@ -249,7 +256,7 @@ void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, | |||
249 | if (!plat_device_is_coherent(dev)) { | 256 | if (!plat_device_is_coherent(dev)) { |
250 | unsigned long addr; | 257 | unsigned long addr; |
251 | 258 | ||
252 | addr = PAGE_OFFSET + plat_dma_addr_to_phys(dma_handle); | 259 | addr = dma_addr_to_virt(dma_handle); |
253 | __dma_sync(addr, size, direction); | 260 | __dma_sync(addr, size, direction); |
254 | } | 261 | } |
255 | } | 262 | } |
@@ -264,7 +271,7 @@ void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle, | |||
264 | if (cpu_is_noncoherent_r10000(dev)) { | 271 | if (cpu_is_noncoherent_r10000(dev)) { |
265 | unsigned long addr; | 272 | unsigned long addr; |
266 | 273 | ||
267 | addr = PAGE_OFFSET + plat_dma_addr_to_phys(dma_handle); | 274 | addr = dma_addr_to_virt(dma_handle); |
268 | __dma_sync(addr + offset, size, direction); | 275 | __dma_sync(addr + offset, size, direction); |
269 | } | 276 | } |
270 | } | 277 | } |
@@ -279,7 +286,7 @@ void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle, | |||
279 | if (!plat_device_is_coherent(dev)) { | 286 | if (!plat_device_is_coherent(dev)) { |
280 | unsigned long addr; | 287 | unsigned long addr; |
281 | 288 | ||
282 | addr = PAGE_OFFSET + plat_dma_addr_to_phys(dma_handle); | 289 | addr = dma_addr_to_virt(dma_handle); |
283 | __dma_sync(addr + offset, size, direction); | 290 | __dma_sync(addr + offset, size, direction); |
284 | } | 291 | } |
285 | } | 292 | } |
diff --git a/include/asm-mips/pgtable-64.h b/include/asm-mips/pgtable-64.h index a5b18710b6a4..49f5a1a2dfcd 100644 --- a/include/asm-mips/pgtable-64.h +++ b/include/asm-mips/pgtable-64.h | |||
@@ -199,7 +199,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud) | |||
199 | { | 199 | { |
200 | return pud_val(pud); | 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 | #define pud_page(pud) (pfn_to_page(pud_phys(pud) >> PAGE_SHIFT)) | 203 | #define pud_page(pud) (pfn_to_page(pud_phys(pud) >> PAGE_SHIFT)) |
204 | 204 | ||
205 | /* Find an entry in the second-level page table.. */ | 205 | /* Find an entry in the second-level page table.. */ |
diff --git a/include/asm-mips/pgtable.h b/include/asm-mips/pgtable.h index 3fcfd7979de5..0d3295f57a95 100644 --- a/include/asm-mips/pgtable.h +++ b/include/asm-mips/pgtable.h | |||
@@ -75,7 +75,7 @@ extern void paging_init(void); | |||
75 | * Conversion functions: convert a page and protection to a page entry, | 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. | 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 | #define pmd_page(pmd) (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT)) | 79 | #define pmd_page(pmd) (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT)) |
80 | #define pmd_page_vaddr(pmd) pmd_val(pmd) | 80 | #define pmd_page_vaddr(pmd) pmd_val(pmd) |
81 | 81 | ||