m68knommu: change definitions of __pa() and __va()
Fix compilation breakage of all m68knommu targets:
CC arch/m68knommu/kernel/asm-offsets.s
In file included from include/linux/sched.h:77,
from arch/m68knommu/kernel/asm-offsets.c:12:
include/linux/percpu.h: In function 'per_cpu_ptr_to_phys':
include/linux/percpu.h:161: error: implicit declaration of function 'virt_to_phy
This is broken in linux-2.6.33-rc3.
Change the definitions of __pa() and __va() to not use virt_to_phys()
and phys_to_virt(). Trivial 1:1 conversion required for the non-MMU case.
A side effect if this is that the m68knommu can now use asm/virtconvert.h
for the definition of virt_to_phys() and phys_to_virt().
Signed-off-by: Greg Ungerer <[email protected]>
---
arch/m68k/include/asm/io_no.h | 14 +-------------
arch/m68k/include/asm/page_no.h | 4 ++--
arch/m68k/include/asm/virtconvert.h | 5 +++++
3 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/arch/m68k/include/asm/io_no.h b/arch/m68k/include/asm/io_no.h
index 7f57436..359065d 100644
--- a/arch/m68k/include/asm/io_no.h
+++ b/arch/m68k/include/asm/io_no.h
@@ -3,6 +3,7 @@
#ifdef __KERNEL__
+#include <asm/virtconvert.h>
/*
* These are for ISA/PCI shared memory _only_ and should never be used
@@ -165,19 +166,6 @@ static inline void *ioremap_fullcache(unsigned long physaddr, unsigned long size
extern void iounmap(void *addr);
-/* Pages to physical address... */
-#define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
-#define page_to_bus(page) ((page - mem_map) << PAGE_SHIFT)
-
-/*
- * Macros used for converting between virtual and physical mappings.
- */
-#define phys_to_virt(vaddr) ((void *) (vaddr))
-#define virt_to_phys(vaddr) ((unsigned long) (vaddr))
-
-#define virt_to_bus virt_to_phys
-#define bus_to_virt phys_to_virt
-
/*
* Convert a physical pointer to a virtual kernel pointer for /dev/mem
* access
diff --git a/arch/m68k/include/asm/page_no.h b/arch/m68k/include/asm/page_no.h
index 1f31b06..8029a33 100644
--- a/arch/m68k/include/asm/page_no.h
+++ b/arch/m68k/include/asm/page_no.h
@@ -56,8 +56,8 @@ extern unsigned long memory_end;
#ifndef __ASSEMBLY__
-#define __pa(vaddr) virt_to_phys((void *)(vaddr))
-#define __va(paddr) phys_to_virt((unsigned long)(paddr))
+#define __pa(vaddr) ((unsigned long)(vaddr))
+#define __va(paddr) ((void *)(paddr))
#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
diff --git a/arch/m68k/include/asm/virtconvert.h b/arch/m68k/include/asm/virtconvert.h
index 22ab05c..8700d04 100644
--- a/arch/m68k/include/asm/virtconvert.h
+++ b/arch/m68k/include/asm/virtconvert.h
@@ -26,6 +26,7 @@ static inline void *phys_to_virt(unsigned long address)
}
/* Permanent address of a page. */
+#ifdef CONFIG_MMU
#ifdef CONFIG_SINGLE_MEMORY_CHUNK
#define page_to_phys(page) \
__pa(PAGE_OFFSET + (((page) - pg_data_map[0].node_mem_map) << PAGE_SHIFT))
@@ -37,6 +38,10 @@ static inline void *phys_to_virt(unsigned long address)
page_to_pfn(__page) << PAGE_SHIFT; \
})
#endif
+#else
+#define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
+#define page_to_bus(page) ((page - mem_map) << PAGE_SHIFT)
+#endif
/*
* IO bus memory addresses are 1:1 with the physical address,
On Tue, 12 Jan 2010, Greg Ungerer wrote:
> +#else
> +#define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
> +#define page_to_bus(page) ((page - mem_map) << PAGE_SHIFT)
> +#endif
Ok, so the old ones were total crap too, but when moving things around,
don't just copy the crap like this.
Look at those two #define's for five seconds, and ask yourself what is
wrong with them. Those macros are not good.
Linus
Hi Linus,
Linus Torvalds wrote:
> On Tue, 12 Jan 2010, Greg Ungerer wrote:
>> +#else
>> +#define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
>> +#define page_to_bus(page) ((page - mem_map) << PAGE_SHIFT)
>> +#endif
>
> Ok, so the old ones were total crap too, but when moving things around,
> don't just copy the crap like this.
>
> Look at those two #define's for five seconds, and ask yourself what is
> wrong with them. Those macros are not good.
Ok. Easily fixed.
page_to_bus() doesn't even look like it is used anywhere (and m68k
itself doesn't define it). So I'll remove it.
I propose changing page_to_phys() to be:
#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
Which seems consistent with many other arches. (And it works on
m68knommu too :-)
I'll generate a new patch with that changed.
A quick grep shows page_to_phys() defined this way in a couple of
other places too:
h8300/include/asm/io.h
sparc/include/asm/io_32.h
Regards
Greg
------------------------------------------------------------------------
Greg Ungerer -- Principal Engineer EMAIL: [email protected]
SnapGear Group, McAfee PHONE: +61 7 3435 2888
8 Gardner Close FAX: +61 7 3217 5323
Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com
On 01/12/2010 05:02 PM, Greg Ungerer wrote:
> Linus Torvalds wrote:
>> On Tue, 12 Jan 2010, Greg Ungerer wrote:
>>> +#else
>>> +#define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
>>> +#define page_to_bus(page) ((page - mem_map) << PAGE_SHIFT)
>>> +#endif
>>
>> Ok, so the old ones were total crap too, but when moving things
>> around, don't just copy the crap like this.
>>
>> Look at those two #define's for five seconds, and ask yourself what is
>> wrong with them. Those macros are not good.
>
> Ok. Easily fixed.
>
> page_to_bus() doesn't even look like it is used anywhere (and m68k
> itself doesn't define it). So I'll remove it.
>
> I propose changing page_to_phys() to be:
>
> #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
Hmmm, on second thoughts maybe that change is better left
for the next merge window. Perhaps best to just fix that
arg bracketization now?
> Which seems consistent with many other arches. (And it works on
> m68knommu too :-)
>
> I'll generate a new patch with that changed.
>
> A quick grep shows page_to_phys() defined this way in a couple of
> other places too:
>
> h8300/include/asm/io.h
> sparc/include/asm/io_32.h
Strike that, only the h8300 one needs arg fixing.
Regards
Greg
------------------------------------------------------------------------
Greg Ungerer -- Principal Engineer EMAIL: [email protected]
SnapGear Group, McAfee PHONE: +61 7 3435 2888
8 Gardner Close, FAX: +61 7 3891 3630
Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com