From: David Howells <dhowells@redhat.com>
To: Mike Frysinger <vapier@gentoo.org>
Cc: dhowells@redhat.com, uclinux-dev@uclinux.org,
David McCullough <davidm@snapgear.com>,
Greg Ungerer <gerg@uclinux.org>, Paul Mundt <lethal@linux-sh.org>,
linux-kernel@vger.kernel.org,
uclinux-dist-devel@blackfin.uclinux.org
Subject: Re: [PATCH v2] NOMMU: implement vmap/vunmap with kmalloc
Date: Wed, 31 Mar 2010 18:11:24 +0100 [thread overview]
Message-ID: <14998.1270055484@redhat.com> (raw)
In-Reply-To: <1268151081-28307-1-git-send-email-vapier@gentoo.org>
How about the attached patch instead? I'd rather not make vmap() generally
available in NOMMU mode since it can't be implemented in NOMMU mode. Yes,
vmap() can take a copy of the pages it is given, but you can't guarantee
that's the right thing to do. It's like a shared-writable mmap.
Instead, why not just override vmap() in firmware_class.c for the one instance
where we know we're happy with this behaviour?
David
---
From: David Howells <dhowells@redhat.com>
Subject: [PATCH] NOMMU: Work around the lack of vmap()/vunmap() in firmware_loading_store()
Work around the lack of vmap()/vunmap() in firmware_loading_store() when
operating in NOMMU mode. vmap() cannot be implemented as there's no virtual
mapping available.
Instead, in NOMMU mode, coalesce the data into one big buffer and store as the
address vmap() would've returned.
Signed-off-by: David Howells <dhowells@redhat.com>
---
drivers/base/firmware_class.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 18518ba..e33c2cb 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -59,6 +59,33 @@ static struct builtin_fw *__start_builtin_fw;
static struct builtin_fw *__end_builtin_fw;
#endif
+/*
+ * NOMMU mode can't provide vmap() as there's no MMU to do the virtual mapping.
+ * Coalesce the data into a big buffer instead.
+ */
+#ifndef CONFIG_MMU
+static void *__pretend_vmap(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;
+}
+
+#define vmap(pg, c, f, pr) __pretend_vmap(pg, c, f, pr)
+#endif /* !CONFIG_MMU */
+
static void
fw_load_abort(struct firmware_priv *fw_priv)
{
next prev parent reply other threads:[~2010-03-31 17:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-06 4:25 userspace firmware loader, vmap, and nommu Mike Frysinger
2009-10-06 4:38 ` David Woodhouse
2009-10-06 4:56 ` Mike Frysinger
2009-12-21 16:44 ` [PATCH] nommu: implement vmap/vunmap with kmalloc Mike Frysinger
2010-01-07 6:49 ` [uClinux-dev] " Mike Frysinger
2010-01-16 15:57 ` David Howells
2010-03-09 16:11 ` [PATCH v2] NOMMU: " Mike Frysinger
2010-03-31 17:11 ` David Howells [this message]
2010-03-31 19:54 ` Mike Frysinger
2010-03-31 23:06 ` David Howells
2010-03-31 23:07 ` David Howells
2010-03-31 23:10 ` 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=14998.1270055484@redhat.com \
--to=dhowells@redhat.com \
--cc=davidm@snapgear.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 \
--cc=vapier@gentoo.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