From: Mike Frysinger <vapier@gentoo.org>
To: uclinux-dev@uclinux.org, David Howells <dhowells@redhat.com>,
David McCullough <davidm@snapgear.com>,
Greg Ungerer <gerg@uclinux.org>, Paul Mundt <lethal@linux-sh.org>
Cc: uclinux-dist-devel@blackfin.uclinux.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] NOMMU: new vcoalesce helper function
Date: Wed, 12 Jan 2011 00:08:08 -0500 [thread overview]
Message-ID: <1294808889-11453-1-git-send-email-vapier@gentoo.org> (raw)
We can't support vmap on NOMMU systems, so add a new vcoalesce function
which combines maps via kmalloc. A bit more overhead, but at least it
works. For MMU systems, vcoalesce simply redirects to vmap.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
include/linux/vmalloc.h | 3 +++
mm/nommu.c | 22 +++++++++++++++++++++-
2 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index 44b54f6..1dec450 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -44,10 +44,13 @@ extern void vm_unmap_aliases(void);
#ifdef CONFIG_MMU
extern void __init vmalloc_init(void);
+#define vcoalesce(...) vmap(...)
#else
static inline void vmalloc_init(void)
{
}
+extern void *vcoalesce(struct page **pages, unsigned int count,
+ unsigned long flags, pgprot_t prot);
#endif
extern void *vmalloc(unsigned long size);
diff --git a/mm/nommu.c b/mm/nommu.c
index ef4045d..c1b8e39 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -402,6 +402,26 @@ void *vmalloc_32_user(unsigned long size)
}
EXPORT_SYMBOL(vmalloc_32_user);
+void *vcoalesce(struct page **pages, unsigned int count,
+ unsigned long flags, pgprot_t prot)
+{
+ unsigned int i;
+ void *new_map, *page_data;
+
+ new_map = kmalloc(count << PAGE_SHIFT, GFP_KERNEL);
+ if (!new_map)
+ return NULL;
+
+ for (i = 0; i < count; ++i) {
+ page_data = kmap(pages[i]);
+ memcpy(new_map + (i << PAGE_SHIFT), page_data, PAGE_SIZE);
+ kunmap(page_data);
+ }
+
+ return new_map;
+}
+EXPORT_SYMBOL(vcoalesce);
+
void *vmap(struct page **pages, unsigned int count, unsigned long flags, pgprot_t prot)
{
BUG();
@@ -411,7 +431,7 @@ EXPORT_SYMBOL(vmap);
void vunmap(const void *addr)
{
- BUG();
+ kfree(addr);
}
EXPORT_SYMBOL(vunmap);
--
1.7.4.rc1
next reply other threads:[~2011-01-12 5:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-12 5:08 Mike Frysinger [this message]
2011-01-12 5:08 ` [PATCH 2/2] firmware loader: use vcoalesce for NOMMU Mike Frysinger
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=1294808889-11453-1-git-send-email-vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=davidm@snapgear.com \
--cc=dhowells@redhat.com \
--cc=gerg@uclinux.org \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=uclinux-dev@uclinux.org \
--cc=uclinux-dist-devel@blackfin.uclinux.org \
/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
all inboxes | Powered by JetHome®