diff mbox series

[1/4] mm: ioremap: Setup phys_addr of struct vm_struct

Message ID 20220427121413.168468-2-wangkefeng.wang@huawei.com (mailing list archive)
State New
Headers show
Series arm64: Cleanup ioremap() and support ioremap_prot() | expand

Commit Message

Kefeng Wang April 27, 2022, 12:14 p.m. UTC
Show physical address in /proc/vmallocinfo.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 mm/ioremap.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Andrew Morton April 27, 2022, 5:10 p.m. UTC | #1
On Wed, 27 Apr 2022 20:14:10 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote:

> Show physical address in /proc/vmallocinfo.
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>  mm/ioremap.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mm/ioremap.c b/mm/ioremap.c
> index 5fe598ecd9b7..522ef899c35f 100644
> --- a/mm/ioremap.c
> +++ b/mm/ioremap.c
> @@ -32,6 +32,7 @@ void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot)
>  	if (!area)
>  		return NULL;
>  	vaddr = (unsigned long)area->addr;
> +	area->phys_addr = addr;
>  
>  	if (ioremap_page_range(vaddr, vaddr + size, addr, __pgprot(prot))) {
>  		free_vm_area(area);

Acked-by: Andrew Morton <akpm@linux-foundation.org>

I checked a bunch of arch-specific implementations of ioremap_prot()
and they're already doing this.  As far as I can tell, only csky and
riscv actually use this file (CONFIG_GENERIC_IOREMAP=y).  But you're
ARM(?) so I'm wondering how come you're patching it?

Someone should do s/addr/phys_addr/ in this function, like the rest of
the world (sensibly) does.
Kefeng Wang April 28, 2022, 1:40 a.m. UTC | #2
On 2022/4/28 1:10, Andrew Morton wrote:
> On Wed, 27 Apr 2022 20:14:10 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>
>> Show physical address in /proc/vmallocinfo.
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>>   mm/ioremap.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/mm/ioremap.c b/mm/ioremap.c
>> index 5fe598ecd9b7..522ef899c35f 100644
>> --- a/mm/ioremap.c
>> +++ b/mm/ioremap.c
>> @@ -32,6 +32,7 @@ void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot)
>>   	if (!area)
>>   		return NULL;
>>   	vaddr = (unsigned long)area->addr;
>> +	area->phys_addr = addr;
>>   
>>   	if (ioremap_page_range(vaddr, vaddr + size, addr, __pgprot(prot))) {
>>   		free_vm_area(area);
> Acked-by: Andrew Morton <akpm@linux-foundation.org>
>
> I checked a bunch of arch-specific implementations of ioremap_prot()
> and they're already doing this.  As far as I can tell, only csky and
> riscv actually use this file (CONFIG_GENERIC_IOREMAP=y).  But you're
> ARM(?) so I'm wondering how come you're patching it?

Hi Andrew,

I found this via reading code when debug some other issue, meanwhile,  there

are some code duplication of ioremap between arm64 and generic ioremap, so

1) bugfix: fix the above issue and test on riscv

2) cleanup: convert arm64 to use GENERIC_IOREMAP,

3) feature: after that, enable HAVE_IOREMAP_PROT on arm64

>
> Someone should do s/addr/phys_addr/ in this function, like the rest of
> the world (sensibly) does.
I will make it in next version.
>
>
> .
Christoph Hellwig April 28, 2022, 3:41 p.m. UTC | #3
On Wed, Apr 27, 2022 at 08:14:10PM +0800, Kefeng Wang wrote:
> Show physical address in /proc/vmallocinfo.

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/mm/ioremap.c b/mm/ioremap.c
index 5fe598ecd9b7..522ef899c35f 100644
--- a/mm/ioremap.c
+++ b/mm/ioremap.c
@@ -32,6 +32,7 @@  void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot)
 	if (!area)
 		return NULL;
 	vaddr = (unsigned long)area->addr;
+	area->phys_addr = addr;
 
 	if (ioremap_page_range(vaddr, vaddr + size, addr, __pgprot(prot))) {
 		free_vm_area(area);