Re: [PATCH v2 2/9] mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h

2015-09-29 Thread Nicolas Pitre
On Tue, 29 Sep 2015, Tyler Baker wrote:

> On 29 September 2015 at 12:21, Nicolas Pitre  wrote:
> > On Tue, 25 Aug 2015, Dan Williams wrote:
> >
> >> From: Christoph Hellwig 
> >>
> >> Three architectures already define these, and we'll need them genericly
> >> soon.
> >>
> >> Signed-off-by: Christoph Hellwig 
> >> Signed-off-by: Dan Williams 
> >> ---
> >>  arch/arm/include/asm/memory.h   |6 --
> >>  arch/arm64/include/asm/memory.h |6 --
> >>  arch/unicore32/include/asm/memory.h |6 --
> >>  include/asm-generic/memory_model.h  |6 ++
> >>  4 files changed, 6 insertions(+), 18 deletions(-)
> >>
> >> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
> >> index b7f6fb462ea0..98d58bb04ac5 100644
> >> --- a/arch/arm/include/asm/memory.h
> >> +++ b/arch/arm/include/asm/memory.h
> >> @@ -119,12 +119,6 @@
> >>  #endif
> >>
> >>  /*
> >> - * Convert a physical address to a Page Frame Number and back
> >> - */
> >> -#define  __phys_to_pfn(paddr)((unsigned long)((paddr) >> 
> >> PAGE_SHIFT))
> >> -#define  __pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
> >> -
> >> -/*
> >>   * Convert a page to/from a physical address
> >>   */
> >>  #define page_to_phys(page)   (__pfn_to_phys(page_to_pfn(page)))
> >
> > [...]
> >
> >> diff --git a/include/asm-generic/memory_model.h 
> >> b/include/asm-generic/memory_model.h
> >> index 14909b0b9cae..f20f407ce45d 100644
> >> --- a/include/asm-generic/memory_model.h
> >> +++ b/include/asm-generic/memory_model.h
> >> @@ -69,6 +69,12 @@
> >>  })
> >>  #endif /* CONFIG_FLATMEM/DISCONTIGMEM/SPARSEMEM */
> >>
> >> +/*
> >> + * Convert a physical address to a Page Frame Number and back
> >> + */
> >> +#define  __phys_to_pfn(paddr)((unsigned long)((paddr) >> 
> >> PAGE_SHIFT))
> >> +#define  __pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
> >> +
> >
> > This patch, currently in mainline as commit 012dcef3f0, breaks LPAE on
> > ARM32 with more than 4GB of RAM. The phys_addr_t cast in the original
> > ARM definition is important when LPAE is enabled as phys_addr_t is 64
> > bits while longs are 32 bits.
> 
> Dan sent my fix above to Linus already, which is in mainline as commit
> ae4f97696889.

Excellent.  Somehow I was looking at v4.3-rc1 and not the latest.


Nicolas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 2/9] mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h

2015-09-29 Thread Tyler Baker
On 29 September 2015 at 12:21, Nicolas Pitre  wrote:
> On Tue, 25 Aug 2015, Dan Williams wrote:
>
>> From: Christoph Hellwig 
>>
>> Three architectures already define these, and we'll need them genericly
>> soon.
>>
>> Signed-off-by: Christoph Hellwig 
>> Signed-off-by: Dan Williams 
>> ---
>>  arch/arm/include/asm/memory.h   |6 --
>>  arch/arm64/include/asm/memory.h |6 --
>>  arch/unicore32/include/asm/memory.h |6 --
>>  include/asm-generic/memory_model.h  |6 ++
>>  4 files changed, 6 insertions(+), 18 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
>> index b7f6fb462ea0..98d58bb04ac5 100644
>> --- a/arch/arm/include/asm/memory.h
>> +++ b/arch/arm/include/asm/memory.h
>> @@ -119,12 +119,6 @@
>>  #endif
>>
>>  /*
>> - * Convert a physical address to a Page Frame Number and back
>> - */
>> -#define  __phys_to_pfn(paddr)((unsigned long)((paddr) >> 
>> PAGE_SHIFT))
>> -#define  __pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
>> -
>> -/*
>>   * Convert a page to/from a physical address
>>   */
>>  #define page_to_phys(page)   (__pfn_to_phys(page_to_pfn(page)))
>
> [...]
>
>> diff --git a/include/asm-generic/memory_model.h 
>> b/include/asm-generic/memory_model.h
>> index 14909b0b9cae..f20f407ce45d 100644
>> --- a/include/asm-generic/memory_model.h
>> +++ b/include/asm-generic/memory_model.h
>> @@ -69,6 +69,12 @@
>>  })
>>  #endif /* CONFIG_FLATMEM/DISCONTIGMEM/SPARSEMEM */
>>
>> +/*
>> + * Convert a physical address to a Page Frame Number and back
>> + */
>> +#define  __phys_to_pfn(paddr)((unsigned long)((paddr) >> 
>> PAGE_SHIFT))
>> +#define  __pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
>> +
>
> This patch, currently in mainline as commit 012dcef3f0, breaks LPAE on
> ARM32 with more than 4GB of RAM. The phys_addr_t cast in the original
> ARM definition is important when LPAE is enabled as phys_addr_t is 64
> bits while longs are 32 bits.

Dan sent my fix above to Linus already, which is in mainline as commit
ae4f97696889.

Cheers,

Tyler
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 2/9] mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h

2015-09-29 Thread Nicolas Pitre
On Tue, 25 Aug 2015, Dan Williams wrote:

> From: Christoph Hellwig 
> 
> Three architectures already define these, and we'll need them genericly
> soon.
> 
> Signed-off-by: Christoph Hellwig 
> Signed-off-by: Dan Williams 
> ---
>  arch/arm/include/asm/memory.h   |6 --
>  arch/arm64/include/asm/memory.h |6 --
>  arch/unicore32/include/asm/memory.h |6 --
>  include/asm-generic/memory_model.h  |6 ++
>  4 files changed, 6 insertions(+), 18 deletions(-)
> 
> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
> index b7f6fb462ea0..98d58bb04ac5 100644
> --- a/arch/arm/include/asm/memory.h
> +++ b/arch/arm/include/asm/memory.h
> @@ -119,12 +119,6 @@
>  #endif
>  
>  /*
> - * Convert a physical address to a Page Frame Number and back
> - */
> -#define  __phys_to_pfn(paddr)((unsigned long)((paddr) >> PAGE_SHIFT))
> -#define  __pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
> -
> -/*
>   * Convert a page to/from a physical address
>   */
>  #define page_to_phys(page)   (__pfn_to_phys(page_to_pfn(page)))

[...]

> diff --git a/include/asm-generic/memory_model.h 
> b/include/asm-generic/memory_model.h
> index 14909b0b9cae..f20f407ce45d 100644
> --- a/include/asm-generic/memory_model.h
> +++ b/include/asm-generic/memory_model.h
> @@ -69,6 +69,12 @@
>  })
>  #endif /* CONFIG_FLATMEM/DISCONTIGMEM/SPARSEMEM */
>  
> +/*
> + * Convert a physical address to a Page Frame Number and back
> + */
> +#define  __phys_to_pfn(paddr)((unsigned long)((paddr) >> PAGE_SHIFT))
> +#define  __pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
> +

This patch, currently in mainline as commit 012dcef3f0, breaks LPAE on 
ARM32 with more than 4GB of RAM. The phys_addr_t cast in the original 
ARM definition is important when LPAE is enabled as phys_addr_t is 64 
bits while longs are 32 bits.


Nicolas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 2/9] mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h

2015-09-29 Thread Nicolas Pitre
On Tue, 25 Aug 2015, Dan Williams wrote:

> From: Christoph Hellwig 
> 
> Three architectures already define these, and we'll need them genericly
> soon.
> 
> Signed-off-by: Christoph Hellwig 
> Signed-off-by: Dan Williams 
> ---
>  arch/arm/include/asm/memory.h   |6 --
>  arch/arm64/include/asm/memory.h |6 --
>  arch/unicore32/include/asm/memory.h |6 --
>  include/asm-generic/memory_model.h  |6 ++
>  4 files changed, 6 insertions(+), 18 deletions(-)
> 
> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
> index b7f6fb462ea0..98d58bb04ac5 100644
> --- a/arch/arm/include/asm/memory.h
> +++ b/arch/arm/include/asm/memory.h
> @@ -119,12 +119,6 @@
>  #endif
>  
>  /*
> - * Convert a physical address to a Page Frame Number and back
> - */
> -#define  __phys_to_pfn(paddr)((unsigned long)((paddr) >> PAGE_SHIFT))
> -#define  __pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
> -
> -/*
>   * Convert a page to/from a physical address
>   */
>  #define page_to_phys(page)   (__pfn_to_phys(page_to_pfn(page)))

[...]

> diff --git a/include/asm-generic/memory_model.h 
> b/include/asm-generic/memory_model.h
> index 14909b0b9cae..f20f407ce45d 100644
> --- a/include/asm-generic/memory_model.h
> +++ b/include/asm-generic/memory_model.h
> @@ -69,6 +69,12 @@
>  })
>  #endif /* CONFIG_FLATMEM/DISCONTIGMEM/SPARSEMEM */
>  
> +/*
> + * Convert a physical address to a Page Frame Number and back
> + */
> +#define  __phys_to_pfn(paddr)((unsigned long)((paddr) >> PAGE_SHIFT))
> +#define  __pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
> +

This patch, currently in mainline as commit 012dcef3f0, breaks LPAE on 
ARM32 with more than 4GB of RAM. The phys_addr_t cast in the original 
ARM definition is important when LPAE is enabled as phys_addr_t is 64 
bits while longs are 32 bits.


Nicolas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 2/9] mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h

2015-09-29 Thread Tyler Baker
On 29 September 2015 at 12:21, Nicolas Pitre  wrote:
> On Tue, 25 Aug 2015, Dan Williams wrote:
>
>> From: Christoph Hellwig 
>>
>> Three architectures already define these, and we'll need them genericly
>> soon.
>>
>> Signed-off-by: Christoph Hellwig 
>> Signed-off-by: Dan Williams 
>> ---
>>  arch/arm/include/asm/memory.h   |6 --
>>  arch/arm64/include/asm/memory.h |6 --
>>  arch/unicore32/include/asm/memory.h |6 --
>>  include/asm-generic/memory_model.h  |6 ++
>>  4 files changed, 6 insertions(+), 18 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
>> index b7f6fb462ea0..98d58bb04ac5 100644
>> --- a/arch/arm/include/asm/memory.h
>> +++ b/arch/arm/include/asm/memory.h
>> @@ -119,12 +119,6 @@
>>  #endif
>>
>>  /*
>> - * Convert a physical address to a Page Frame Number and back
>> - */
>> -#define  __phys_to_pfn(paddr)((unsigned long)((paddr) >> 
>> PAGE_SHIFT))
>> -#define  __pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
>> -
>> -/*
>>   * Convert a page to/from a physical address
>>   */
>>  #define page_to_phys(page)   (__pfn_to_phys(page_to_pfn(page)))
>
> [...]
>
>> diff --git a/include/asm-generic/memory_model.h 
>> b/include/asm-generic/memory_model.h
>> index 14909b0b9cae..f20f407ce45d 100644
>> --- a/include/asm-generic/memory_model.h
>> +++ b/include/asm-generic/memory_model.h
>> @@ -69,6 +69,12 @@
>>  })
>>  #endif /* CONFIG_FLATMEM/DISCONTIGMEM/SPARSEMEM */
>>
>> +/*
>> + * Convert a physical address to a Page Frame Number and back
>> + */
>> +#define  __phys_to_pfn(paddr)((unsigned long)((paddr) >> 
>> PAGE_SHIFT))
>> +#define  __pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
>> +
>
> This patch, currently in mainline as commit 012dcef3f0, breaks LPAE on
> ARM32 with more than 4GB of RAM. The phys_addr_t cast in the original
> ARM definition is important when LPAE is enabled as phys_addr_t is 64
> bits while longs are 32 bits.

Dan sent my fix above to Linus already, which is in mainline as commit
ae4f97696889.

Cheers,

Tyler
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 2/9] mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h

2015-09-29 Thread Nicolas Pitre
On Tue, 29 Sep 2015, Tyler Baker wrote:

> On 29 September 2015 at 12:21, Nicolas Pitre  wrote:
> > On Tue, 25 Aug 2015, Dan Williams wrote:
> >
> >> From: Christoph Hellwig 
> >>
> >> Three architectures already define these, and we'll need them genericly
> >> soon.
> >>
> >> Signed-off-by: Christoph Hellwig 
> >> Signed-off-by: Dan Williams 
> >> ---
> >>  arch/arm/include/asm/memory.h   |6 --
> >>  arch/arm64/include/asm/memory.h |6 --
> >>  arch/unicore32/include/asm/memory.h |6 --
> >>  include/asm-generic/memory_model.h  |6 ++
> >>  4 files changed, 6 insertions(+), 18 deletions(-)
> >>
> >> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
> >> index b7f6fb462ea0..98d58bb04ac5 100644
> >> --- a/arch/arm/include/asm/memory.h
> >> +++ b/arch/arm/include/asm/memory.h
> >> @@ -119,12 +119,6 @@
> >>  #endif
> >>
> >>  /*
> >> - * Convert a physical address to a Page Frame Number and back
> >> - */
> >> -#define  __phys_to_pfn(paddr)((unsigned long)((paddr) >> 
> >> PAGE_SHIFT))
> >> -#define  __pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
> >> -
> >> -/*
> >>   * Convert a page to/from a physical address
> >>   */
> >>  #define page_to_phys(page)   (__pfn_to_phys(page_to_pfn(page)))
> >
> > [...]
> >
> >> diff --git a/include/asm-generic/memory_model.h 
> >> b/include/asm-generic/memory_model.h
> >> index 14909b0b9cae..f20f407ce45d 100644
> >> --- a/include/asm-generic/memory_model.h
> >> +++ b/include/asm-generic/memory_model.h
> >> @@ -69,6 +69,12 @@
> >>  })
> >>  #endif /* CONFIG_FLATMEM/DISCONTIGMEM/SPARSEMEM */
> >>
> >> +/*
> >> + * Convert a physical address to a Page Frame Number and back
> >> + */
> >> +#define  __phys_to_pfn(paddr)((unsigned long)((paddr) >> 
> >> PAGE_SHIFT))
> >> +#define  __pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
> >> +
> >
> > This patch, currently in mainline as commit 012dcef3f0, breaks LPAE on
> > ARM32 with more than 4GB of RAM. The phys_addr_t cast in the original
> > ARM definition is important when LPAE is enabled as phys_addr_t is 64
> > bits while longs are 32 bits.
> 
> Dan sent my fix above to Linus already, which is in mainline as commit
> ae4f97696889.

Excellent.  Somehow I was looking at v4.3-rc1 and not the latest.


Nicolas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 2/9] mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h

2015-09-19 Thread Tyler Baker
On 18 September 2015 at 16:59, Dan Williams  wrote:
> On Fri, Sep 18, 2015 at 4:42 PM, Tyler Baker  wrote:
>> Hi,
>>
>> On 25 August 2015 at 18:27, Dan Williams  wrote:
>>> From: Christoph Hellwig 
>>>
>>> Three architectures already define these, and we'll need them genericly
>>> soon.
>>>
>>> Signed-off-by: Christoph Hellwig 
>>> Signed-off-by: Dan Williams 
>>> ---
>>>  arch/arm/include/asm/memory.h   |6 --
>>>  arch/arm64/include/asm/memory.h |6 --
>>>  arch/unicore32/include/asm/memory.h |6 --
>>>  include/asm-generic/memory_model.h  |6 ++
>>>  4 files changed, 6 insertions(+), 18 deletions(-)
>>>
>>> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
>>> index b7f6fb462ea0..98d58bb04ac5 100644
>>> --- a/arch/arm/include/asm/memory.h
>>> +++ b/arch/arm/include/asm/memory.h
>>> @@ -119,12 +119,6 @@
>>>  #endif
>>>
>>>  /*
>>> - * Convert a physical address to a Page Frame Number and back
>>> - */
>>> -#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
>>> PAGE_SHIFT))
>>> -#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
>>> -
>>> -/*
>>>   * Convert a page to/from a physical address
>>>   */
>>>  #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
>>> diff --git a/arch/arm64/include/asm/memory.h 
>>> b/arch/arm64/include/asm/memory.h
>>> index f800d45ea226..d808bb688751 100644
>>> --- a/arch/arm64/include/asm/memory.h
>>> +++ b/arch/arm64/include/asm/memory.h
>>> @@ -81,12 +81,6 @@
>>>  #define __phys_to_virt(x)  ((unsigned long)((x) - PHYS_OFFSET + 
>>> PAGE_OFFSET))
>>>
>>>  /*
>>> - * Convert a physical address to a Page Frame Number and back
>>> - */
>>> -#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
>>> PAGE_SHIFT))
>>> -#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
>>> -
>>> -/*
>>>   * Convert a page to/from a physical address
>>>   */
>>>  #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
>>> diff --git a/arch/unicore32/include/asm/memory.h 
>>> b/arch/unicore32/include/asm/memory.h
>>> index debafc40200a..3bb0a29fd2d7 100644
>>> --- a/arch/unicore32/include/asm/memory.h
>>> +++ b/arch/unicore32/include/asm/memory.h
>>> @@ -61,12 +61,6 @@
>>>  #endif
>>>
>>>  /*
>>> - * Convert a physical address to a Page Frame Number and back
>>> - */
>>> -#define__phys_to_pfn(paddr)((paddr) >> PAGE_SHIFT)
>>> -#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
>>> -
>>> -/*
>>>   * Convert a page to/from a physical address
>>>   */
>>>  #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
>>> diff --git a/include/asm-generic/memory_model.h 
>>> b/include/asm-generic/memory_model.h
>>> index 14909b0b9cae..f20f407ce45d 100644
>>> --- a/include/asm-generic/memory_model.h
>>> +++ b/include/asm-generic/memory_model.h
>>> @@ -69,6 +69,12 @@
>>>  })
>>>  #endif /* CONFIG_FLATMEM/DISCONTIGMEM/SPARSEMEM */
>>>
>>> +/*
>>> + * Convert a physical address to a Page Frame Number and back
>>> + */
>>> +#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
>>> PAGE_SHIFT))
>>> +#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
>>
>> The kernelci.org bot has been reporting complete boot failures[1] on
>> ARM platforms with more than 4GB of memory and LPAE enabled. I've
>> bisected[2] the failures down to this commit, and reverting it on top
>> of the latest mainline resolves the boot issue. I took a closer look
>> at this patch and noticed the cast to phys_addr_t was dropped in the
>> generic function. Adding this to the new generic function solves the
>> boot issue I'm reporting.
>>
>> diff --git a/include/asm-generic/memory_model.h
>> b/include/asm-generic/memory_model.h
>> index f20f407..db9f5c7 100644
>> --- a/include/asm-generic/memory_model.h
>> +++ b/include/asm-generic/memory_model.h
>> @@ -73,7 +73,7 @@
>>   * Convert a physical address to a Page Frame Number and back
>>   */
>>  #define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
>> PAGE_SHIFT))
>> -#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
>> +#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
>>
>>  #define page_to_pfn __page_to_pfn
>>  #define pfn_to_page __pfn_to_page
>>
>> If this fix is valid, I can send a formal patch or it can be squashed
>> into the original commit.
>
> This fix is valid, but I wonder if it should just use the existing
> PFN_PHYS() definition in include/linux/pfn.h?

Good suggestion, seems like the rational thing to do. FWIW, I gave the
patch below a spin through the kernelci.org build/boot ci loop[1]. All
went well, no new regressions were detected.

From: Tyler Baker 
Date: Fri, 18 Sep 2015 17:56:26 -0700
Subject: [PATCH] mm: fix type cast in __pfn_to_phys()

The various definitions of __pfn_to_phys() have been consolidated to
use a generic macro in include/asm-generic/memory_model.h. This hit
mainline in the form of 012dcef3f058 

Re: [PATCH v2 2/9] mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h

2015-09-19 Thread Tyler Baker
On 18 September 2015 at 16:59, Dan Williams  wrote:
> On Fri, Sep 18, 2015 at 4:42 PM, Tyler Baker  wrote:
>> Hi,
>>
>> On 25 August 2015 at 18:27, Dan Williams  wrote:
>>> From: Christoph Hellwig 
>>>
>>> Three architectures already define these, and we'll need them genericly
>>> soon.
>>>
>>> Signed-off-by: Christoph Hellwig 
>>> Signed-off-by: Dan Williams 
>>> ---
>>>  arch/arm/include/asm/memory.h   |6 --
>>>  arch/arm64/include/asm/memory.h |6 --
>>>  arch/unicore32/include/asm/memory.h |6 --
>>>  include/asm-generic/memory_model.h  |6 ++
>>>  4 files changed, 6 insertions(+), 18 deletions(-)
>>>
>>> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
>>> index b7f6fb462ea0..98d58bb04ac5 100644
>>> --- a/arch/arm/include/asm/memory.h
>>> +++ b/arch/arm/include/asm/memory.h
>>> @@ -119,12 +119,6 @@
>>>  #endif
>>>
>>>  /*
>>> - * Convert a physical address to a Page Frame Number and back
>>> - */
>>> -#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
>>> PAGE_SHIFT))
>>> -#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
>>> -
>>> -/*
>>>   * Convert a page to/from a physical address
>>>   */
>>>  #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
>>> diff --git a/arch/arm64/include/asm/memory.h 
>>> b/arch/arm64/include/asm/memory.h
>>> index f800d45ea226..d808bb688751 100644
>>> --- a/arch/arm64/include/asm/memory.h
>>> +++ b/arch/arm64/include/asm/memory.h
>>> @@ -81,12 +81,6 @@
>>>  #define __phys_to_virt(x)  ((unsigned long)((x) - PHYS_OFFSET + 
>>> PAGE_OFFSET))
>>>
>>>  /*
>>> - * Convert a physical address to a Page Frame Number and back
>>> - */
>>> -#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
>>> PAGE_SHIFT))
>>> -#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
>>> -
>>> -/*
>>>   * Convert a page to/from a physical address
>>>   */
>>>  #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
>>> diff --git a/arch/unicore32/include/asm/memory.h 
>>> b/arch/unicore32/include/asm/memory.h
>>> index debafc40200a..3bb0a29fd2d7 100644
>>> --- a/arch/unicore32/include/asm/memory.h
>>> +++ b/arch/unicore32/include/asm/memory.h
>>> @@ -61,12 +61,6 @@
>>>  #endif
>>>
>>>  /*
>>> - * Convert a physical address to a Page Frame Number and back
>>> - */
>>> -#define__phys_to_pfn(paddr)((paddr) >> PAGE_SHIFT)
>>> -#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
>>> -
>>> -/*
>>>   * Convert a page to/from a physical address
>>>   */
>>>  #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
>>> diff --git a/include/asm-generic/memory_model.h 
>>> b/include/asm-generic/memory_model.h
>>> index 14909b0b9cae..f20f407ce45d 100644
>>> --- a/include/asm-generic/memory_model.h
>>> +++ b/include/asm-generic/memory_model.h
>>> @@ -69,6 +69,12 @@
>>>  })
>>>  #endif /* CONFIG_FLATMEM/DISCONTIGMEM/SPARSEMEM */
>>>
>>> +/*
>>> + * Convert a physical address to a Page Frame Number and back
>>> + */
>>> +#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
>>> PAGE_SHIFT))
>>> +#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
>>
>> The kernelci.org bot has been reporting complete boot failures[1] on
>> ARM platforms with more than 4GB of memory and LPAE enabled. I've
>> bisected[2] the failures down to this commit, and reverting it on top
>> of the latest mainline resolves the boot issue. I took a closer look
>> at this patch and noticed the cast to phys_addr_t was dropped in the
>> generic function. Adding this to the new generic function solves the
>> boot issue I'm reporting.
>>
>> diff --git a/include/asm-generic/memory_model.h
>> b/include/asm-generic/memory_model.h
>> index f20f407..db9f5c7 100644
>> --- a/include/asm-generic/memory_model.h
>> +++ b/include/asm-generic/memory_model.h
>> @@ -73,7 +73,7 @@
>>   * Convert a physical address to a Page Frame Number and back
>>   */
>>  #define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
>> PAGE_SHIFT))
>> -#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
>> +#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
>>
>>  #define page_to_pfn __page_to_pfn
>>  #define pfn_to_page __pfn_to_page
>>
>> If this fix is valid, I can send a formal patch or it can be squashed
>> into the original commit.
>
> This fix is valid, but I wonder if it should just use the existing
> PFN_PHYS() definition in include/linux/pfn.h?

Good suggestion, seems like the rational thing to do. FWIW, I gave the
patch below a spin through the kernelci.org build/boot ci loop[1]. All
went well, no new regressions were detected.

From: Tyler Baker 
Date: Fri, 18 Sep 2015 17:56:26 -0700
Subject: [PATCH] mm: fix type cast in __pfn_to_phys()

The various definitions 

Re: [PATCH v2 2/9] mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h

2015-09-18 Thread Dan Williams
On Fri, Sep 18, 2015 at 4:42 PM, Tyler Baker  wrote:
> Hi,
>
> On 25 August 2015 at 18:27, Dan Williams  wrote:
>> From: Christoph Hellwig 
>>
>> Three architectures already define these, and we'll need them genericly
>> soon.
>>
>> Signed-off-by: Christoph Hellwig 
>> Signed-off-by: Dan Williams 
>> ---
>>  arch/arm/include/asm/memory.h   |6 --
>>  arch/arm64/include/asm/memory.h |6 --
>>  arch/unicore32/include/asm/memory.h |6 --
>>  include/asm-generic/memory_model.h  |6 ++
>>  4 files changed, 6 insertions(+), 18 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
>> index b7f6fb462ea0..98d58bb04ac5 100644
>> --- a/arch/arm/include/asm/memory.h
>> +++ b/arch/arm/include/asm/memory.h
>> @@ -119,12 +119,6 @@
>>  #endif
>>
>>  /*
>> - * Convert a physical address to a Page Frame Number and back
>> - */
>> -#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
>> PAGE_SHIFT))
>> -#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
>> -
>> -/*
>>   * Convert a page to/from a physical address
>>   */
>>  #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
>> diff --git a/arch/arm64/include/asm/memory.h 
>> b/arch/arm64/include/asm/memory.h
>> index f800d45ea226..d808bb688751 100644
>> --- a/arch/arm64/include/asm/memory.h
>> +++ b/arch/arm64/include/asm/memory.h
>> @@ -81,12 +81,6 @@
>>  #define __phys_to_virt(x)  ((unsigned long)((x) - PHYS_OFFSET + 
>> PAGE_OFFSET))
>>
>>  /*
>> - * Convert a physical address to a Page Frame Number and back
>> - */
>> -#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
>> PAGE_SHIFT))
>> -#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
>> -
>> -/*
>>   * Convert a page to/from a physical address
>>   */
>>  #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
>> diff --git a/arch/unicore32/include/asm/memory.h 
>> b/arch/unicore32/include/asm/memory.h
>> index debafc40200a..3bb0a29fd2d7 100644
>> --- a/arch/unicore32/include/asm/memory.h
>> +++ b/arch/unicore32/include/asm/memory.h
>> @@ -61,12 +61,6 @@
>>  #endif
>>
>>  /*
>> - * Convert a physical address to a Page Frame Number and back
>> - */
>> -#define__phys_to_pfn(paddr)((paddr) >> PAGE_SHIFT)
>> -#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
>> -
>> -/*
>>   * Convert a page to/from a physical address
>>   */
>>  #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
>> diff --git a/include/asm-generic/memory_model.h 
>> b/include/asm-generic/memory_model.h
>> index 14909b0b9cae..f20f407ce45d 100644
>> --- a/include/asm-generic/memory_model.h
>> +++ b/include/asm-generic/memory_model.h
>> @@ -69,6 +69,12 @@
>>  })
>>  #endif /* CONFIG_FLATMEM/DISCONTIGMEM/SPARSEMEM */
>>
>> +/*
>> + * Convert a physical address to a Page Frame Number and back
>> + */
>> +#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
>> PAGE_SHIFT))
>> +#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
>
> The kernelci.org bot has been reporting complete boot failures[1] on
> ARM platforms with more than 4GB of memory and LPAE enabled. I've
> bisected[2] the failures down to this commit, and reverting it on top
> of the latest mainline resolves the boot issue. I took a closer look
> at this patch and noticed the cast to phys_addr_t was dropped in the
> generic function. Adding this to the new generic function solves the
> boot issue I'm reporting.
>
> diff --git a/include/asm-generic/memory_model.h
> b/include/asm-generic/memory_model.h
> index f20f407..db9f5c7 100644
> --- a/include/asm-generic/memory_model.h
> +++ b/include/asm-generic/memory_model.h
> @@ -73,7 +73,7 @@
>   * Convert a physical address to a Page Frame Number and back
>   */
>  #define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
> PAGE_SHIFT))
> -#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
> +#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
>
>  #define page_to_pfn __page_to_pfn
>  #define pfn_to_page __pfn_to_page
>
> If this fix is valid, I can send a formal patch or it can be squashed
> into the original commit.

This fix is valid, but I wonder if it should just use the existing
PFN_PHYS() definition in include/linux/pfn.h?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 2/9] mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h

2015-09-18 Thread Tyler Baker
Hi,

On 25 August 2015 at 18:27, Dan Williams  wrote:
> From: Christoph Hellwig 
>
> Three architectures already define these, and we'll need them genericly
> soon.
>
> Signed-off-by: Christoph Hellwig 
> Signed-off-by: Dan Williams 
> ---
>  arch/arm/include/asm/memory.h   |6 --
>  arch/arm64/include/asm/memory.h |6 --
>  arch/unicore32/include/asm/memory.h |6 --
>  include/asm-generic/memory_model.h  |6 ++
>  4 files changed, 6 insertions(+), 18 deletions(-)
>
> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
> index b7f6fb462ea0..98d58bb04ac5 100644
> --- a/arch/arm/include/asm/memory.h
> +++ b/arch/arm/include/asm/memory.h
> @@ -119,12 +119,6 @@
>  #endif
>
>  /*
> - * Convert a physical address to a Page Frame Number and back
> - */
> -#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
> PAGE_SHIFT))
> -#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
> -
> -/*
>   * Convert a page to/from a physical address
>   */
>  #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> index f800d45ea226..d808bb688751 100644
> --- a/arch/arm64/include/asm/memory.h
> +++ b/arch/arm64/include/asm/memory.h
> @@ -81,12 +81,6 @@
>  #define __phys_to_virt(x)  ((unsigned long)((x) - PHYS_OFFSET + 
> PAGE_OFFSET))
>
>  /*
> - * Convert a physical address to a Page Frame Number and back
> - */
> -#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
> PAGE_SHIFT))
> -#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
> -
> -/*
>   * Convert a page to/from a physical address
>   */
>  #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
> diff --git a/arch/unicore32/include/asm/memory.h 
> b/arch/unicore32/include/asm/memory.h
> index debafc40200a..3bb0a29fd2d7 100644
> --- a/arch/unicore32/include/asm/memory.h
> +++ b/arch/unicore32/include/asm/memory.h
> @@ -61,12 +61,6 @@
>  #endif
>
>  /*
> - * Convert a physical address to a Page Frame Number and back
> - */
> -#define__phys_to_pfn(paddr)((paddr) >> PAGE_SHIFT)
> -#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
> -
> -/*
>   * Convert a page to/from a physical address
>   */
>  #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
> diff --git a/include/asm-generic/memory_model.h 
> b/include/asm-generic/memory_model.h
> index 14909b0b9cae..f20f407ce45d 100644
> --- a/include/asm-generic/memory_model.h
> +++ b/include/asm-generic/memory_model.h
> @@ -69,6 +69,12 @@
>  })
>  #endif /* CONFIG_FLATMEM/DISCONTIGMEM/SPARSEMEM */
>
> +/*
> + * Convert a physical address to a Page Frame Number and back
> + */
> +#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
> PAGE_SHIFT))
> +#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)

The kernelci.org bot has been reporting complete boot failures[1] on
ARM platforms with more than 4GB of memory and LPAE enabled. I've
bisected[2] the failures down to this commit, and reverting it on top
of the latest mainline resolves the boot issue. I took a closer look
at this patch and noticed the cast to phys_addr_t was dropped in the
generic function. Adding this to the new generic function solves the
boot issue I'm reporting.

diff --git a/include/asm-generic/memory_model.h
b/include/asm-generic/memory_model.h
index f20f407..db9f5c7 100644
--- a/include/asm-generic/memory_model.h
+++ b/include/asm-generic/memory_model.h
@@ -73,7 +73,7 @@
  * Convert a physical address to a Page Frame Number and back
  */
 #define__phys_to_pfn(paddr)((unsigned long)((paddr) >> PAGE_SHIFT))
-#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
+#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)

 #define page_to_pfn __page_to_pfn
 #define pfn_to_page __pfn_to_page

If this fix is valid, I can send a formal patch or it can be squashed
into the original commit.

Cheers,

Tyler

[1] http://kernelci.org/boot/?d01
[2] http://hastebin.com/tuhefudage.vhdl
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 2/9] mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h

2015-09-18 Thread Tyler Baker
Hi,

On 25 August 2015 at 18:27, Dan Williams  wrote:
> From: Christoph Hellwig 
>
> Three architectures already define these, and we'll need them genericly
> soon.
>
> Signed-off-by: Christoph Hellwig 
> Signed-off-by: Dan Williams 
> ---
>  arch/arm/include/asm/memory.h   |6 --
>  arch/arm64/include/asm/memory.h |6 --
>  arch/unicore32/include/asm/memory.h |6 --
>  include/asm-generic/memory_model.h  |6 ++
>  4 files changed, 6 insertions(+), 18 deletions(-)
>
> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
> index b7f6fb462ea0..98d58bb04ac5 100644
> --- a/arch/arm/include/asm/memory.h
> +++ b/arch/arm/include/asm/memory.h
> @@ -119,12 +119,6 @@
>  #endif
>
>  /*
> - * Convert a physical address to a Page Frame Number and back
> - */
> -#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
> PAGE_SHIFT))
> -#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
> -
> -/*
>   * Convert a page to/from a physical address
>   */
>  #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> index f800d45ea226..d808bb688751 100644
> --- a/arch/arm64/include/asm/memory.h
> +++ b/arch/arm64/include/asm/memory.h
> @@ -81,12 +81,6 @@
>  #define __phys_to_virt(x)  ((unsigned long)((x) - PHYS_OFFSET + 
> PAGE_OFFSET))
>
>  /*
> - * Convert a physical address to a Page Frame Number and back
> - */
> -#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
> PAGE_SHIFT))
> -#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
> -
> -/*
>   * Convert a page to/from a physical address
>   */
>  #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
> diff --git a/arch/unicore32/include/asm/memory.h 
> b/arch/unicore32/include/asm/memory.h
> index debafc40200a..3bb0a29fd2d7 100644
> --- a/arch/unicore32/include/asm/memory.h
> +++ b/arch/unicore32/include/asm/memory.h
> @@ -61,12 +61,6 @@
>  #endif
>
>  /*
> - * Convert a physical address to a Page Frame Number and back
> - */
> -#define__phys_to_pfn(paddr)((paddr) >> PAGE_SHIFT)
> -#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
> -
> -/*
>   * Convert a page to/from a physical address
>   */
>  #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
> diff --git a/include/asm-generic/memory_model.h 
> b/include/asm-generic/memory_model.h
> index 14909b0b9cae..f20f407ce45d 100644
> --- a/include/asm-generic/memory_model.h
> +++ b/include/asm-generic/memory_model.h
> @@ -69,6 +69,12 @@
>  })
>  #endif /* CONFIG_FLATMEM/DISCONTIGMEM/SPARSEMEM */
>
> +/*
> + * Convert a physical address to a Page Frame Number and back
> + */
> +#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
> PAGE_SHIFT))
> +#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)

The kernelci.org bot has been reporting complete boot failures[1] on
ARM platforms with more than 4GB of memory and LPAE enabled. I've
bisected[2] the failures down to this commit, and reverting it on top
of the latest mainline resolves the boot issue. I took a closer look
at this patch and noticed the cast to phys_addr_t was dropped in the
generic function. Adding this to the new generic function solves the
boot issue I'm reporting.

diff --git a/include/asm-generic/memory_model.h
b/include/asm-generic/memory_model.h
index f20f407..db9f5c7 100644
--- a/include/asm-generic/memory_model.h
+++ b/include/asm-generic/memory_model.h
@@ -73,7 +73,7 @@
  * Convert a physical address to a Page Frame Number and back
  */
 #define__phys_to_pfn(paddr)((unsigned long)((paddr) >> PAGE_SHIFT))
-#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
+#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)

 #define page_to_pfn __page_to_pfn
 #define pfn_to_page __pfn_to_page

If this fix is valid, I can send a formal patch or it can be squashed
into the original commit.

Cheers,

Tyler

[1] http://kernelci.org/boot/?d01
[2] http://hastebin.com/tuhefudage.vhdl
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 2/9] mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h

2015-09-18 Thread Dan Williams
On Fri, Sep 18, 2015 at 4:42 PM, Tyler Baker  wrote:
> Hi,
>
> On 25 August 2015 at 18:27, Dan Williams  wrote:
>> From: Christoph Hellwig 
>>
>> Three architectures already define these, and we'll need them genericly
>> soon.
>>
>> Signed-off-by: Christoph Hellwig 
>> Signed-off-by: Dan Williams 
>> ---
>>  arch/arm/include/asm/memory.h   |6 --
>>  arch/arm64/include/asm/memory.h |6 --
>>  arch/unicore32/include/asm/memory.h |6 --
>>  include/asm-generic/memory_model.h  |6 ++
>>  4 files changed, 6 insertions(+), 18 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
>> index b7f6fb462ea0..98d58bb04ac5 100644
>> --- a/arch/arm/include/asm/memory.h
>> +++ b/arch/arm/include/asm/memory.h
>> @@ -119,12 +119,6 @@
>>  #endif
>>
>>  /*
>> - * Convert a physical address to a Page Frame Number and back
>> - */
>> -#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
>> PAGE_SHIFT))
>> -#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
>> -
>> -/*
>>   * Convert a page to/from a physical address
>>   */
>>  #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
>> diff --git a/arch/arm64/include/asm/memory.h 
>> b/arch/arm64/include/asm/memory.h
>> index f800d45ea226..d808bb688751 100644
>> --- a/arch/arm64/include/asm/memory.h
>> +++ b/arch/arm64/include/asm/memory.h
>> @@ -81,12 +81,6 @@
>>  #define __phys_to_virt(x)  ((unsigned long)((x) - PHYS_OFFSET + 
>> PAGE_OFFSET))
>>
>>  /*
>> - * Convert a physical address to a Page Frame Number and back
>> - */
>> -#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
>> PAGE_SHIFT))
>> -#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
>> -
>> -/*
>>   * Convert a page to/from a physical address
>>   */
>>  #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
>> diff --git a/arch/unicore32/include/asm/memory.h 
>> b/arch/unicore32/include/asm/memory.h
>> index debafc40200a..3bb0a29fd2d7 100644
>> --- a/arch/unicore32/include/asm/memory.h
>> +++ b/arch/unicore32/include/asm/memory.h
>> @@ -61,12 +61,6 @@
>>  #endif
>>
>>  /*
>> - * Convert a physical address to a Page Frame Number and back
>> - */
>> -#define__phys_to_pfn(paddr)((paddr) >> PAGE_SHIFT)
>> -#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
>> -
>> -/*
>>   * Convert a page to/from a physical address
>>   */
>>  #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
>> diff --git a/include/asm-generic/memory_model.h 
>> b/include/asm-generic/memory_model.h
>> index 14909b0b9cae..f20f407ce45d 100644
>> --- a/include/asm-generic/memory_model.h
>> +++ b/include/asm-generic/memory_model.h
>> @@ -69,6 +69,12 @@
>>  })
>>  #endif /* CONFIG_FLATMEM/DISCONTIGMEM/SPARSEMEM */
>>
>> +/*
>> + * Convert a physical address to a Page Frame Number and back
>> + */
>> +#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
>> PAGE_SHIFT))
>> +#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
>
> The kernelci.org bot has been reporting complete boot failures[1] on
> ARM platforms with more than 4GB of memory and LPAE enabled. I've
> bisected[2] the failures down to this commit, and reverting it on top
> of the latest mainline resolves the boot issue. I took a closer look
> at this patch and noticed the cast to phys_addr_t was dropped in the
> generic function. Adding this to the new generic function solves the
> boot issue I'm reporting.
>
> diff --git a/include/asm-generic/memory_model.h
> b/include/asm-generic/memory_model.h
> index f20f407..db9f5c7 100644
> --- a/include/asm-generic/memory_model.h
> +++ b/include/asm-generic/memory_model.h
> @@ -73,7 +73,7 @@
>   * Convert a physical address to a Page Frame Number and back
>   */
>  #define__phys_to_pfn(paddr)((unsigned long)((paddr) >> 
> PAGE_SHIFT))
> -#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
> +#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
>
>  #define page_to_pfn __page_to_pfn
>  #define pfn_to_page __pfn_to_page
>
> If this fix is valid, I can send a formal patch or it can be squashed
> into the original commit.

This fix is valid, but I wonder if it should just use the existing
PFN_PHYS() definition in include/linux/pfn.h?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 2/9] mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h

2015-08-25 Thread Dan Williams
From: Christoph Hellwig 

Three architectures already define these, and we'll need them genericly
soon.

Signed-off-by: Christoph Hellwig 
Signed-off-by: Dan Williams 
---
 arch/arm/include/asm/memory.h   |6 --
 arch/arm64/include/asm/memory.h |6 --
 arch/unicore32/include/asm/memory.h |6 --
 include/asm-generic/memory_model.h  |6 ++
 4 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index b7f6fb462ea0..98d58bb04ac5 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -119,12 +119,6 @@
 #endif
 
 /*
- * Convert a physical address to a Page Frame Number and back
- */
-#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> PAGE_SHIFT))
-#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
-
-/*
  * Convert a page to/from a physical address
  */
 #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index f800d45ea226..d808bb688751 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -81,12 +81,6 @@
 #define __phys_to_virt(x)  ((unsigned long)((x) - PHYS_OFFSET + 
PAGE_OFFSET))
 
 /*
- * Convert a physical address to a Page Frame Number and back
- */
-#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> PAGE_SHIFT))
-#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn) << PAGE_SHIFT)
-
-/*
  * Convert a page to/from a physical address
  */
 #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
diff --git a/arch/unicore32/include/asm/memory.h 
b/arch/unicore32/include/asm/memory.h
index debafc40200a..3bb0a29fd2d7 100644
--- a/arch/unicore32/include/asm/memory.h
+++ b/arch/unicore32/include/asm/memory.h
@@ -61,12 +61,6 @@
 #endif
 
 /*
- * Convert a physical address to a Page Frame Number and back
- */
-#define__phys_to_pfn(paddr)((paddr) >> PAGE_SHIFT)
-#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
-
-/*
  * Convert a page to/from a physical address
  */
 #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
diff --git a/include/asm-generic/memory_model.h 
b/include/asm-generic/memory_model.h
index 14909b0b9cae..f20f407ce45d 100644
--- a/include/asm-generic/memory_model.h
+++ b/include/asm-generic/memory_model.h
@@ -69,6 +69,12 @@
 })
 #endif /* CONFIG_FLATMEM/DISCONTIGMEM/SPARSEMEM */
 
+/*
+ * Convert a physical address to a Page Frame Number and back
+ */
+#define__phys_to_pfn(paddr)((unsigned long)((paddr) >> PAGE_SHIFT))
+#define__pfn_to_phys(pfn)  ((pfn) << PAGE_SHIFT)
+
 #define page_to_pfn __page_to_pfn
 #define pfn_to_page __pfn_to_page
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 2/9] mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h

2015-08-25 Thread Dan Williams
From: Christoph Hellwig h...@lst.de

Three architectures already define these, and we'll need them genericly
soon.

Signed-off-by: Christoph Hellwig h...@lst.de
Signed-off-by: Dan Williams dan.j.willi...@intel.com
---
 arch/arm/include/asm/memory.h   |6 --
 arch/arm64/include/asm/memory.h |6 --
 arch/unicore32/include/asm/memory.h |6 --
 include/asm-generic/memory_model.h  |6 ++
 4 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index b7f6fb462ea0..98d58bb04ac5 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -119,12 +119,6 @@
 #endif
 
 /*
- * Convert a physical address to a Page Frame Number and back
- */
-#define__phys_to_pfn(paddr)((unsigned long)((paddr)  PAGE_SHIFT))
-#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn)  PAGE_SHIFT)
-
-/*
  * Convert a page to/from a physical address
  */
 #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index f800d45ea226..d808bb688751 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -81,12 +81,6 @@
 #define __phys_to_virt(x)  ((unsigned long)((x) - PHYS_OFFSET + 
PAGE_OFFSET))
 
 /*
- * Convert a physical address to a Page Frame Number and back
- */
-#define__phys_to_pfn(paddr)((unsigned long)((paddr)  PAGE_SHIFT))
-#define__pfn_to_phys(pfn)  ((phys_addr_t)(pfn)  PAGE_SHIFT)
-
-/*
  * Convert a page to/from a physical address
  */
 #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
diff --git a/arch/unicore32/include/asm/memory.h 
b/arch/unicore32/include/asm/memory.h
index debafc40200a..3bb0a29fd2d7 100644
--- a/arch/unicore32/include/asm/memory.h
+++ b/arch/unicore32/include/asm/memory.h
@@ -61,12 +61,6 @@
 #endif
 
 /*
- * Convert a physical address to a Page Frame Number and back
- */
-#define__phys_to_pfn(paddr)((paddr)  PAGE_SHIFT)
-#define__pfn_to_phys(pfn)  ((pfn)  PAGE_SHIFT)
-
-/*
  * Convert a page to/from a physical address
  */
 #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page)))
diff --git a/include/asm-generic/memory_model.h 
b/include/asm-generic/memory_model.h
index 14909b0b9cae..f20f407ce45d 100644
--- a/include/asm-generic/memory_model.h
+++ b/include/asm-generic/memory_model.h
@@ -69,6 +69,12 @@
 })
 #endif /* CONFIG_FLATMEM/DISCONTIGMEM/SPARSEMEM */
 
+/*
+ * Convert a physical address to a Page Frame Number and back
+ */
+#define__phys_to_pfn(paddr)((unsigned long)((paddr)  PAGE_SHIFT))
+#define__pfn_to_phys(pfn)  ((pfn)  PAGE_SHIFT)
+
 #define page_to_pfn __page_to_pfn
 #define pfn_to_page __pfn_to_page
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/