Re: [PATCH 1/2] add phys_addr_t for holding physical addresses

Benjamin Herrenschmidt
2008-08-11T21:59:59Z

On Mon, 2008-08-11 at 12:38 -0700, Jeremy Fitzhardinge wrote:
> Add a kernel-wide "phys_addr_t" which is guaranteed to be able to hold
> any physical address. By default it equals the word size of the
> architecture, but a 32-bit architecture can set ARCH_PHYS_ADDR_T_64BIT
> if it needs a 64-bit phys_addr_t.

I've been wondering for some time why can't we make phys_addr_t and
resource_size_t the same thing... I don't like having two ARCH_* thing
especially since I believe the one for resources is already what we
want.

Ben.

> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> diff -r 4909b40dbdc5 arch/powerpc/Kconfig
> --- a/arch/powerpc/Kconfig Fri Aug 08 13:40:52 2008 -0700
> +++ b/arch/powerpc/Kconfig Mon Aug 11 10:32:52 2008 -0700
> @@ -21,6 +21,9 @@
>
> config PPC_MERGE
> def_bool y
> +
> +config ARCH_PHYS_ADDR_T_64BIT
> + def_bool PPC64 || PHYS_64BIT
>
> config MMU
> bool
> diff -r 4909b40dbdc5 arch/x86/Kconfig
> --- a/arch/x86/Kconfig Fri Aug 08 13:40:52 2008 -0700
> +++ b/arch/x86/Kconfig Mon Aug 11 10:32:53 2008 -0700
> @@ -1002,6 +1002,9 @@
> has the cost of more pagetable lookup overhead, and also
> consumes more pagetable space per process.
>
> +config ARCH_PHYS_ADDR_T_64BIT
> + def_bool X86_64 || X86_PAE
> +
> # Common NUMA Features
> config NUMA
> bool "Numa Memory Allocation and Scheduler Support (EXPERIMENTAL)"
> diff -r 4909b40dbdc5 include/asm-powerpc/types.h
> --- a/include/asm-powerpc/types.h Fri Aug 08 13:40:52 2008 -0700
> +++ b/include/asm-powerpc/types.h Mon Aug 11 10:32:53 2008 -0700
> @@ -48,13 +48,6 @@
>
> typedef __vector128 vector128;
>
> -/* Physical address used by some IO functions */
> -#if defined(CONFIG_PPC64) || defined(CONFIG_PHYS_64BIT)
> -typedef u64 phys_addr_t;
> -#else
> -typedef u32 phys_addr_t;
> -#endif
> -
> #ifdef __powerpc64__
> typedef u64 dma_addr_t;
> #else
> diff -r 4909b40dbdc5 include/asm-x86/page_32.h
> --- a/include/asm-x86/page_32.h Fri Aug 08 13:40:52 2008 -0700
> +++ b/include/asm-x86/page_32.h Mon Aug 11 10:32:53 2008 -0700
> @@ -33,7 +33,6 @@
> typedef u64 pudval_t;
> typedef u64 pgdval_t;
> typedef u64 pgprotval_t;
> -typedef u64 phys_addr_t;
>
> typedef union {
> struct {
> @@ -54,7 +53,6 @@
> typedef unsigned long pudval_t;
> typedef unsigned long pgdval_t;
> typedef unsigned long pgprotval_t;
> -typedef unsigned long phys_addr_t;
>
> typedef union {
> pteval_t pte;
> diff -r 4909b40dbdc5 include/asm-x86/page_64.h
> --- a/include/asm-x86/page_64.h Fri Aug 08 13:40:52 2008 -0700
> +++ b/include/asm-x86/page_64.h Mon Aug 11 10:32:53 2008 -0700
> @@ -79,7 +79,6 @@
> typedef unsigned long pudval_t;
> typedef unsigned long pgdval_t;
> typedef unsigned long pgprotval_t;
> -typedef unsigned long phys_addr_t;
>
> typedef struct page *pgtable_t;
>
> diff -r 4909b40dbdc5 include/linux/types.h
> --- a/include/linux/types.h Fri Aug 08 13:40:52 2008 -0700
> +++ b/include/linux/types.h Mon Aug 11 10:32:53 2008 -0700
> @@ -197,6 +197,12 @@
> typedef u32 resource_size_t;
> #endif
>
> +#ifdef CONFIG_PHYS_ADDR_T_64BIT
> +typedef u64 phys_addr_t;
> +#else
> +typedef u32 phys_addr_t;
> +#endif
> +
> struct ustat {
> __kernel_daddr_t f_tfree;
> __kernel_ino_t f_tinode;
> diff -r 4909b40dbdc5 mm/Kconfig
> --- a/mm/Kconfig Fri Aug 08 13:40:52 2008 -0700
> +++ b/mm/Kconfig Mon Aug 11 10:32:53 2008 -0700
> @@ -190,6 +190,9 @@
> help
> This option allows memory and IO resources to be 64 bit.
>
> +config PHYS_ADDR_T_64BIT
> + def_bool 64BIT || ARCH_PHYS_ADDR_T_64BIT
> +
> config ZONE_DMA_FLAG
> int
> default "0" if !ZONE_DMA
>