From: Richard Lee <superlibj8301@gmail.com>
To: linux@arm.linux.org.uk, linux-arm-kernel@lists.infradead.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Richard Lee <superlibj8301@gmail.com>, Richard Lee <superlibj@gmail.com>
Subject: [RFC][PATCH 2/2] ARM: ioremap: Add IO mapping space reused support.
Date: Mon, 12 May 2014 10:19:55 +0800 [thread overview]
Message-ID: <1399861195-21087-3-git-send-email-superlibj8301@gmail.com> (raw)
In-Reply-To: <1399861195-21087-1-git-send-email-superlibj8301@gmail.com>
For the IO mapping, for the same physical address space maybe
mapped more than one time, for example, in some SoCs:
0x20000000 ~ 0x20001000: are global control IO physical map,
and this range space will be used by many drivers.
And then if each driver will do the same ioremap operation, we
will waste to much malloc virtual spaces.
This patch add IO mapping space reused support.
Signed-off-by: Richard Lee <superlibj@gmail.com>
---
arch/arm/mm/ioremap.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index f9c32ba..26a3744 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -260,7 +260,7 @@ void __iomem * __arm_ioremap_pfn_caller(unsigned long pfn,
{
const struct mem_type *type;
int err;
- unsigned long addr;
+ unsigned long addr, off;
struct vm_struct *area;
phys_addr_t paddr = __pfn_to_phys(pfn);
@@ -301,6 +301,12 @@ void __iomem * __arm_ioremap_pfn_caller(unsigned long pfn,
if (WARN_ON(pfn_valid(pfn)))
return NULL;
+ area = find_vm_area_paddr(paddr, size, &off, VM_IOREMAP);
+ if (area) {
+ addr = (unsigned long)area->addr;
+ return (void __iomem *)(offset + off + addr);
+ }
+
area = get_vm_area_caller(size, VM_IOREMAP, caller);
if (!area)
return NULL;
@@ -410,6 +416,9 @@ void __iounmap(volatile void __iomem *io_addr)
if (svm)
return;
+ if (!vm_area_is_aready_to_free((unsigned long)addr))
+ return;
+
#if !defined(CONFIG_SMP) && !defined(CONFIG_ARM_LPAE)
{
struct vm_struct *vm;
--
1.8.4
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2014-05-12 3:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-12 2:19 [RFC][PATCH 0/2] Add IO mapping space reused support Richard Lee
2014-05-12 2:19 ` [RFC][PATCH 1/2] mm/vmalloc: Add IO mapping space reused interface Richard Lee
2014-05-13 3:13 ` Rob Herring
2014-05-13 6:21 ` Richard Lee
2014-05-12 2:19 ` Richard Lee [this message]
2014-05-12 7:51 ` [RFC][PATCH 2/2] ARM: ioremap: Add IO mapping space reused support Arnd Bergmann
2014-05-13 1:45 ` Richard Lee
2014-05-13 8:43 ` Arnd Bergmann
2014-05-14 2:13 ` Richard Lee
2014-05-15 10:17 ` Catalin Marinas
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=1399861195-21087-3-git-send-email-superlibj8301@gmail.com \
--to=superlibj8301@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@arm.linux.org.uk \
--cc=superlibj@gmail.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;
as well as URLs for NNTP newsgroup(s).