From: Alexander Gordeev <agordeev@linux.ibm.com>
To: Baoquan He <bhe@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
akpm@linux-foundation.org, hch@infradead.org,
wangkefeng.wang@huawei.com, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 02/11] mm: ioremap: fixup the physical address
Date: Thu, 4 Aug 2022 18:02:12 +0200 [thread overview]
Message-ID: <YuvthDzuPlAwD/LA@li-4a3a4a4c-28e5-11b2-a85c-a8d192c6f089.ibm.com> (raw)
In-Reply-To: <20220801144029.57829-3-bhe@redhat.com>
On Mon, Aug 01, 2022 at 10:40:20PM +0800, Baoquan He wrote:
> This is a preparation patch, no functionality change.
There is, please see below.
> @@ -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.
> @@ -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?
> + 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.
And now ioremap_allowed() semantics, prototype and name turn
less than obvious. Why not introduce a separate fixup callback?
> /* 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)
next prev parent reply other threads:[~2022-08-04 16:07 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-01 14:40 [PATCH 00/11] mm: ioremap: Convert architectures to take GENERIC_IOREMAP way Baoquan He
2022-08-01 14:40 ` [PATCH 01/11] mm/ioremap: change the return value of io[re|un]map_allowed Baoquan He
2022-08-04 15:42 ` Alexander Gordeev
2022-08-06 2:29 ` Kefeng Wang
2022-08-06 8:29 ` Alexander Gordeev
2022-08-07 1:42 ` Baoquan He
2022-08-07 1:51 ` Baoquan He
2022-08-07 1:58 ` Baoquan He
2022-08-01 14:40 ` [PATCH 02/11] mm: ioremap: fixup the physical address Baoquan He
2022-08-04 16:02 ` Alexander Gordeev [this message]
2022-08-07 2:11 ` Baoquan He
2022-08-20 0:49 ` Baoquan He
2022-08-01 14:40 ` [PATCH 03/11] mm: ioremap: allow ARCH to have its own ioremap definition Baoquan He
2022-08-01 14:40 ` [PATCH 04/11] arc: mm: Convert to GENERIC_IOREMAP Baoquan He
2022-08-01 14:40 ` [PATCH 05/11] hexagon: " Baoquan He
2022-08-01 14:40 ` [PATCH 06/11] ia64: " Baoquan He
2022-08-01 14:40 ` [PATCH 07/11] openrisc: " Baoquan He
2022-08-01 14:40 ` [PATCH 08/11] parisc: " Baoquan He
2022-08-01 14:40 ` [PATCH 09/11] s390: " Baoquan He
2022-08-01 14:40 ` [PATCH 10/11] sh: " Baoquan He
2022-08-01 14:40 ` [PATCH 11/11] xtensa: " Baoquan He
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YuvthDzuPlAwD/LA@li-4a3a4a4c-28e5-11b2-a85c-a8d192c6f089.ibm.com \
--to=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=hch@infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=wangkefeng.wang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox