Re: [PATCH 02/11] mm: ioremap: fixup the physical address
From: Baoquan He <hidden>
Date: 2022-08-07 02:11:27
Also in:
linux-mm, lkml
On 08/04/22 at 06:02pm, Alexander Gordeev wrote:
On Mon, Aug 01, 2022 at 10:40:20PM +0800, Baoquan He wrote:quoted
This is a preparation patch, no functionality change.There is, please see below.quoted
@@ -3,11 +3,17 @@ #include <linux/mm.h> #include <linux/io.h> -void __iomem *ioremap_allowed(phys_addr_t phys_addr, size_t size, unsigned long prot) +void __iomem * +ioremap_allowed(phys_addr_t *paddr, size_t size, unsigned long *prot_val) { - unsigned long last_addr = phys_addr + size - 1; + unsigned long last_addr, offset, phys_addr = *paddr; int ret = -EINVAL; + offset = phys_addr & (~PAGE_MASK); + phys_addr -= offset;FWIW, phys_addr &= PAGE_MASK looks much more usual.
Sure, will change.
quoted
@@ -11,13 +11,20 @@ #include <linux/io.h> #include <linux/export.h> -void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, +void __iomem *ioremap_prot(phys_addr_t paddr, size_t size, unsigned long prot) { unsigned long offset, vaddr; - phys_addr_t last_addr; + phys_addr_t last_addr, phys_addr = paddr; struct vm_struct *area; void __iomem *base; + unsigned long prot_val = prot;Why prot_val is needed?
I will remove it and pass &prot to ioremap_allowed(). I could think too much when I made change here. Thanks.
quoted
+ base = ioremap_allowed(&phys_addr, size, &prot_val); + if (IS_ERR(base)) + return NULL; + else if (base) + return base;By moving ioremap_allowed() here you allow it to be called before the wrap-around check, including architectures that do not do fixups.
Yes, just as you say.
And now ioremap_allowed() semantics, prototype and name turn less than obvious. Why not introduce a separate fixup callback?
I can do that, while a little worried if too many hooks introduced. I will introduce another fixup hook in v2 if no other suggestion or concern. Thanks.
quoted
/* Disallow wrap-around or zero size */ last_addr = phys_addr + size - 1;@@ -29,12 +36,6 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr -= offset; size = PAGE_ALIGN(size + offset); - base = ioremap_allowed(phys_addr, size, prot); - if (IS_ERR(base)) - return NULL; - else if (base) - return base; - area = get_vm_area_caller(size, VM_IOREMAP, __builtin_return_address(0)); if (!area)
_______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel