LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: torvalds@osdl.org, akpm@osdl.org, dwmw2@infradead.org
Cc: linux-kernel@vger.kernel.org, uclinux-dev@uclinux.org,
linux-mtd@lists.infradead.org, dhowells@redhat.com
Subject: [PATCH 2/4] NOMMU: Add support for direct mapping through mtdconcat if possible
Date: Tue, 20 Feb 2007 19:50:55 +0000 [thread overview]
Message-ID: <20070220195055.26186.50532.stgit@warthog.cambridge.redhat.com> (raw)
In-Reply-To: <20070220195049.26186.69393.stgit@warthog.cambridge.redhat.com>
From: David Howells <dhowells@redhat.com>
Add support for direct mapping through mtdconcat, if possible, by attaching the
samebacking_dev_info structure to the master.
It has some restrictions:
(1) It won't permit direct mapping of concatenated devices that have differing
BDIs.
(2) It doesn't support maps that span the 'gap' between devices, although it
possibly could if the devices spanned across return compatible
(ie. contiguous) addresses from their get_unmapped_area() ops.
Signed-off-by: Gavin Lambert <gavinl@compacsort.com>
Signed-Off-By: David Howells <dhowells@redhat.com>
---
drivers/mtd/mtdconcat.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index 880580c..730689b 100644
--- a/drivers/mtd/mtdconcat.c
+++ b/drivers/mtd/mtdconcat.c
@@ -15,6 +15,7 @@
#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/types.h>
+#include <linux/backing-dev.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/concat.h>
@@ -686,6 +687,40 @@ static int concat_block_markbad(struct mtd_info *mtd, loff_t ofs)
}
/*
+ * try to support NOMMU mmaps on concatenated devices
+ * - we don't support subdev spanning as we can't guarantee it'll work
+ */
+static unsigned long concat_get_unmapped_area(struct mtd_info *mtd,
+ unsigned long len,
+ unsigned long offset,
+ unsigned long flags)
+{
+ struct mtd_concat *concat = CONCAT(mtd);
+ int i;
+
+ for (i = 0; i < concat->num_subdev; i++) {
+ struct mtd_info *subdev = concat->subdev[i];
+
+ if (offset >= subdev->size) {
+ offset -= subdev->size;
+ continue;
+ }
+
+ /* we've found the subdev over which the mapping will reside */
+ if (offset + len > subdev->size)
+ return (unsigned long) -EINVAL;
+
+ if (subdev->get_unmapped_area)
+ return subdev->get_unmapped_area(subdev, len, offset,
+ flags);
+
+ break;
+ }
+
+ return (unsigned long) -ENOSYS;
+}
+
+/*
* This function constructs a virtual MTD device by concatenating
* num_devs MTD devices. A pointer to the new device object is
* stored to *new_dev upon success. This function does _not_
@@ -740,6 +775,8 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
concat->mtd.ecc_stats.badblocks = subdev[0]->ecc_stats.badblocks;
+ concat->mtd.backing_dev_info = subdev[0]->backing_dev_info;
+
concat->subdev[0] = subdev[0];
for (i = 1; i < num_devs; i++) {
@@ -766,6 +803,15 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
concat->mtd.flags |=
subdev[i]->flags & MTD_WRITEABLE;
}
+
+ /* only permit direct mapping if the BDIs are all the same
+ * - copy-mapping is still permitted
+ */
+ if (concat->mtd.backing_dev_info !=
+ subdev[i]->backing_dev_info)
+ concat->mtd.backing_dev_info =
+ &default_backing_dev_info;
+
concat->mtd.size += subdev[i]->size;
concat->mtd.ecc_stats.badblocks +=
subdev[i]->ecc_stats.badblocks;
@@ -796,6 +842,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
concat->mtd.unlock = concat_unlock;
concat->mtd.suspend = concat_suspend;
concat->mtd.resume = concat_resume;
+ concat->mtd.get_unmapped_area = concat_get_unmapped_area;
/*
* Combine the erase block size info of the subdevices:
next prev parent reply other threads:[~2007-02-20 19:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-20 19:50 [PATCH 1/4] NOMMU: Present backing device capabilities for MTD chardevs David Howells
2007-02-20 19:50 ` David Howells [this message]
2007-02-20 19:51 ` [PATCH 3/4] NOMMU: Generalise the handling of MTD-specific superblocks David Howells
2007-02-20 19:51 ` [PATCH 4/4] NOMMU: Make it possible for RomFS to use MTD devices directly David Howells
2007-02-22 0:38 ` Andrew Morton
2007-02-22 11:43 ` David Howells
2007-02-21 12:56 [PATCH 1/4] NOMMU: Present backing device capabilities for MTD chardevs David Howells
2007-02-21 12:56 ` [PATCH 2/4] NOMMU: Add support for direct mapping through mtdconcat if possible David Howells
2009-02-12 10:40 [PATCH 1/4] NOMMU: Present backing device capabilities for MTD chardevs David Howells
2009-02-12 10:40 ` [PATCH 2/4] NOMMU: Add support for direct mapping through mtdconcat if possible David Howells
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=20070220195055.26186.50532.stgit@warthog.cambridge.redhat.com \
--to=dhowells@redhat.com \
--cc=akpm@osdl.org \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=torvalds@osdl.org \
--cc=uclinux-dev@uclinux.org \
--subject='Re: [PATCH 2/4] NOMMU: Add support for direct mapping through mtdconcat if possible' \
/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
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).