* [PATCH] Always use virt_to_phys() when translating kernel addresses @ 2007-03-19 9:41 Franck Bui-Huu 2007-03-19 16:02 ` Maxime Bizon 0 siblings, 1 reply; 5+ messages in thread From: Franck Bui-Huu @ 2007-03-19 9:41 UTC (permalink / raw) To: Ralf Baechle; +Cc: mbizon, linux-mips From: Franck Bui-Huu <fbuihuu@gmail.com> This patch fixes two places where we used plain 'x - PAGE_OFFSET' to achieve virtual to physical address convertion. 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> --- Ralf, Could you apply this patch. Unfortunately I failed to report back these changes when submitting the original patch, and without it, platforms which are using (or trying to use) PHYS_OFFSET will break. Thanks, Franck include/asm-mips/pgtable-64.h | 2 +- include/asm-mips/pgtable.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/asm-mips/pgtable-64.h b/include/asm-mips/pgtable-64.h index a5b1871..49f5a1a 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) { return pud_val(pud); } -#define pud_phys(pud) (pud_val(pud) - PAGE_OFFSET) +#define pud_phys(pud) virt_to_phys((void *)pud_val(pud)) #define pud_page(pud) (pfn_to_page(pud_phys(pud) >> PAGE_SHIFT)) /* Find an entry in the second-level page table.. */ diff --git a/include/asm-mips/pgtable.h b/include/asm-mips/pgtable.h index 3fcfd79..0d3295f 100644 --- a/include/asm-mips/pgtable.h +++ b/include/asm-mips/pgtable.h @@ -75,7 +75,7 @@ extern void paging_init(void); * Conversion functions: convert a page and protection to a page entry, * and a page entry and page directory to the page they refer to. */ -#define pmd_phys(pmd) (pmd_val(pmd) - PAGE_OFFSET) +#define pmd_phys(pmd) virt_to_phys((void *)pmd_val(pmd)) #define pmd_page(pmd) (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT)) #define pmd_page_vaddr(pmd) pmd_val(pmd) -- 1.4.4.3.ge6d4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Always use virt_to_phys() when translating kernel addresses 2007-03-19 9:41 [PATCH] Always use virt_to_phys() when translating kernel addresses Franck Bui-Huu @ 2007-03-19 16:02 ` Maxime Bizon 2007-03-19 16:16 ` Franck Bui-Huu 0 siblings, 1 reply; 5+ messages in thread From: Maxime Bizon @ 2007-03-19 16:02 UTC (permalink / raw) To: Franck; +Cc: Ralf Baechle, linux-mips On Mon, 2007-03-19 at 10:41 +0100, Franck Bui-Huu wrote: Hi Franck, > This patch fixes two places where we used plain 'x - PAGE_OFFSET' to > achieve virtual to physical address convertion. This type of convertion > is no more allowed since commit 6f284a2ce7b8bc49cb8455b1763357897a899abb. I think you should also review arch/mips/mm/dma-noncoherent.c, it seems to use PAGE_OFFSET directly in dma_unmap_single. I'm using OWN_DMA so this code is not used on my board. Regards, -- Maxime ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Always use virt_to_phys() when translating kernel addresses 2007-03-19 16:02 ` Maxime Bizon @ 2007-03-19 16:16 ` Franck Bui-Huu 2007-03-19 16:36 ` [PATCH] Always use virt_to_phys() when translating kernel addresses [take #2] Franck Bui-Huu 0 siblings, 1 reply; 5+ messages in thread From: Franck Bui-Huu @ 2007-03-19 16:16 UTC (permalink / raw) To: mbizon; +Cc: Ralf Baechle, linux-mips On 3/19/07, Maxime Bizon <mbizon@freebox.fr> wrote: > > On Mon, 2007-03-19 at 10:41 +0100, Franck Bui-Huu wrote: > > Hi Franck, > > > This patch fixes two places where we used plain 'x - PAGE_OFFSET' to > > achieve virtual to physical address convertion. This type of convertion > > is no more allowed since commit 6f284a2ce7b8bc49cb8455b1763357897a899abb. > > I think you should also review arch/mips/mm/dma-noncoherent.c, it seems dma-noncoherent.c has been removed since commit 9a88cbb5227970757881b1a65be01dea61fe2584. But you're right the new 'dma-default.c' still needs to be fixed... -- Franck ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] Always use virt_to_phys() when translating kernel addresses [take #2] 2007-03-19 16:16 ` Franck Bui-Huu @ 2007-03-19 16:36 ` Franck Bui-Huu 2007-03-19 22:28 ` Ralf Baechle 0 siblings, 1 reply; 5+ messages in thread From: Franck Bui-Huu @ 2007-03-19 16:36 UTC (permalink / raw) To: Franck Bui-Huu; +Cc: mbizon, Ralf Baechle, linux-mips From: Franck Bui-Huu <fbuihuu@gmail.com> 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> --- arch/mips/mm/dma-default.c | 10 +++++----- include/asm-mips/mach-generic/dma-coherence.h | 7 +++++++ include/asm-mips/pgtable-64.h | 2 +- include/asm-mips/pgtable.h | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c index f503d02..e1a58b5 100644 --- a/arch/mips/mm/dma-default.c +++ b/arch/mips/mm/dma-default.c @@ -140,7 +140,7 @@ void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, enum dma_data_direction direction) { if (cpu_is_noncoherent_r10000(dev)) - __dma_sync(plat_dma_addr_to_phys(dma_addr) + PAGE_OFFSET, size, + __dma_sync(plat_dma_addr_to_virt(dma_addr), size, direction); plat_unmap_dma_mem(dma_addr); @@ -234,7 +234,7 @@ void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, if (cpu_is_noncoherent_r10000(dev)) { unsigned long addr; - addr = PAGE_OFFSET + plat_dma_addr_to_phys(dma_handle); + addr = plat_dma_addr_to_virt(dma_handle); __dma_sync(addr, size, direction); } } @@ -249,7 +249,7 @@ void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, if (!plat_device_is_coherent(dev)) { unsigned long addr; - addr = PAGE_OFFSET + plat_dma_addr_to_phys(dma_handle); + addr = plat_dma_addr_to_virt(dma_handle); __dma_sync(addr, size, direction); } } @@ -264,7 +264,7 @@ void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle, if (cpu_is_noncoherent_r10000(dev)) { unsigned long addr; - addr = PAGE_OFFSET + plat_dma_addr_to_phys(dma_handle); + addr = plat_dma_addr_to_virt(dma_handle); __dma_sync(addr + offset, size, direction); } } @@ -279,7 +279,7 @@ void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle, if (!plat_device_is_coherent(dev)) { unsigned long addr; - addr = PAGE_OFFSET + plat_dma_addr_to_phys(dma_handle); + addr = plat_dma_addr_to_virt(dma_handle); __dma_sync(addr + offset, size, direction); } } diff --git a/include/asm-mips/mach-generic/dma-coherence.h b/include/asm-mips/mach-generic/dma-coherence.h index 76e04e7..3a2ac54 100644 --- a/include/asm-mips/mach-generic/dma-coherence.h +++ b/include/asm-mips/mach-generic/dma-coherence.h @@ -28,6 +28,13 @@ static inline unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr) return dma_addr; } +static inline unsigned long plat_dma_addr_to_virt(dma_addr_t dma_addr) +{ + unsigned long addr = plat_dma_addr_to_phys(dma_addr); + + return (unsigned long)phys_to_virt(addr); +} + static inline void plat_unmap_dma_mem(dma_addr_t dma_addr) { } diff --git a/include/asm-mips/pgtable-64.h b/include/asm-mips/pgtable-64.h index a5b1871..49f5a1a 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) { return pud_val(pud); } -#define pud_phys(pud) (pud_val(pud) - PAGE_OFFSET) +#define pud_phys(pud) virt_to_phys((void *)pud_val(pud)) #define pud_page(pud) (pfn_to_page(pud_phys(pud) >> PAGE_SHIFT)) /* Find an entry in the second-level page table.. */ diff --git a/include/asm-mips/pgtable.h b/include/asm-mips/pgtable.h index 3fcfd79..0d3295f 100644 --- a/include/asm-mips/pgtable.h +++ b/include/asm-mips/pgtable.h @@ -75,7 +75,7 @@ extern void paging_init(void); * Conversion functions: convert a page and protection to a page entry, * and a page entry and page directory to the page they refer to. */ -#define pmd_phys(pmd) (pmd_val(pmd) - PAGE_OFFSET) +#define pmd_phys(pmd) virt_to_phys((void *)pmd_val(pmd)) #define pmd_page(pmd) (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT)) #define pmd_page_vaddr(pmd) pmd_val(pmd) -- 1.4.4.3.ge6d4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Always use virt_to_phys() when translating kernel addresses [take #2] 2007-03-19 16:36 ` [PATCH] Always use virt_to_phys() when translating kernel addresses [take #2] Franck Bui-Huu @ 2007-03-19 22:28 ` Ralf Baechle 0 siblings, 0 replies; 5+ messages in thread From: Ralf Baechle @ 2007-03-19 22:28 UTC (permalink / raw) To: Franck Bui-Huu; +Cc: mbizon, linux-mips On Mon, Mar 19, 2007 at 05:36:42PM +0100, Franck Bui-Huu wrote: > diff --git a/include/asm-mips/mach-generic/dma-coherence.h b/include/asm-mips/mach-generic/dma-coherence.h > index 76e04e7..3a2ac54 100644 > --- a/include/asm-mips/mach-generic/dma-coherence.h > +++ b/include/asm-mips/mach-generic/dma-coherence.h > @@ -28,6 +28,13 @@ static inline unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr) > return dma_addr; > } > > +static inline unsigned long plat_dma_addr_to_virt(dma_addr_t dma_addr) > +{ > + unsigned long addr = plat_dma_addr_to_phys(dma_addr); > + > + return (unsigned long)phys_to_virt(addr); > +} > + Putting this function into include/asm-mips/mach-generic/dma-coherence.h breaks the build for all machines that don't include this header. I applied your patch with this issue fixed. Ralf ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-03-19 22:30 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-03-19 9:41 [PATCH] Always use virt_to_phys() when translating kernel addresses Franck Bui-Huu 2007-03-19 16:02 ` Maxime Bizon 2007-03-19 16:16 ` Franck Bui-Huu 2007-03-19 16:36 ` [PATCH] Always use virt_to_phys() when translating kernel addresses [take #2] Franck Bui-Huu 2007-03-19 22:28 ` Ralf Baechle
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox