All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] mtd: physmap: add physmap_unmapped_area() for no-mmu XIP
@ 2010-05-23  7:30 Mike Frysinger
  2010-05-23  7:30 ` [PATCH 2/2] mtd: physmap: allow maps to be read-only mapped Mike Frysinger
  2010-06-12 14:26 ` [PATCH 1/2] mtd: physmap: add physmap_unmapped_area() for no-mmu XIP Artem Bityutskiy
  0 siblings, 2 replies; 8+ messages in thread
From: Mike Frysinger @ 2010-05-23  7:30 UTC (permalink / raw)
  To: linux-mtd, David Woodhouse
  Cc: uclinux-dev, Bernd Schmidt, David Howells, Paul Mundt,
	Greg Ungerer, uclinux-dist-devel, David McCullough

From: Bernd Schmidt <bernds_cb1@t-online.de>

Currently, romfs XIP doesn't work in flash memory (the kernel crashes
with a null pointer dereference).  The problem is that the mtd physmap
driver isn't setting up a get_unmapped_area pointer for the mtd
partitions it creates.

Signed-off-by: Bernd Schmidt <bernds_cb1@t-online.de>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 drivers/mtd/maps/physmap.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 09d89ff..370da18 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -72,6 +72,20 @@ static int physmap_flash_remove(struct platform_device *dev)
 	return 0;
 }
 
+/*
+ * Allow NOMMU mmap() to directly map the device (if not NULL)
+ * - return the address to which the offset maps
+ * - return -ENOSYS to indicate refusal to do the mapping
+ */
+static unsigned long physmap_unmapped_area(struct mtd_info *mtd,
+					   unsigned long len,
+					   unsigned long offset,
+					   unsigned long flags)
+{
+	struct map_info *map = mtd->priv;
+	return (unsigned long) map->virt + offset;
+}
+
 static const char *rom_probe_types[] = {
 					"cfi_probe",
 					"jedec_probe",
@@ -149,6 +163,8 @@ static int physmap_flash_probe(struct platform_device *dev)
 		} else {
 			devices_found++;
 		}
+		if (info->mtd[i]->get_unmapped_area == NULL)
+			info->mtd[i]->get_unmapped_area = physmap_unmapped_area;
 		info->mtd[i]->owner = THIS_MODULE;
 		info->mtd[i]->dev.parent = &dev->dev;
 	}
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] mtd: physmap: allow maps to be read-only mapped
  2010-05-23  7:30 [PATCH 1/2] mtd: physmap: add physmap_unmapped_area() for no-mmu XIP Mike Frysinger
@ 2010-05-23  7:30 ` Mike Frysinger
  2010-06-12 14:26 ` [PATCH 1/2] mtd: physmap: add physmap_unmapped_area() for no-mmu XIP Artem Bityutskiy
  1 sibling, 0 replies; 8+ messages in thread
From: Mike Frysinger @ 2010-05-23  7:30 UTC (permalink / raw)
  To: linux-mtd, David Woodhouse
  Cc: uclinux-dev, Bernd Schmidt, David Howells, Paul Mundt,
	Greg Ungerer, uclinux-dist-devel, David McCullough

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3293 bytes --]

From: Bernd Schmidt <bernds_cb1@t-online.de>

Recent changes have made nommu.c more careful about checking device
capabilities before attempting to create a direct mapping.  This means
that the physmap driver has to mark its mtd devices as ro-mappable if
we want to support XIP on flash.

Signed-off-by: Bernd Schmidt <bernds_cb1@t-online.de>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
Note: this does semi-undo recent changes that punted the prototypes for
      these common mtd_bdi's ...

 drivers/mtd/maps/physmap.c |    2 ++
 drivers/mtd/mtdcore.c      |    4 ++++
 include/linux/mtd/mtdbdi.h |   17 +++++++++++++++++
 3 files changed, 23 insertions(+), 0 deletions(-)
 create mode 100644 include/linux/mtd/mtdbdi.h

diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 370da18..be2dbc2 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -19,6 +19,7 @@
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/physmap.h>
 #include <linux/mtd/concat.h>
+#include <linux/mtd/mtdbdi.h>
 #include <linux/io.h>
 
 #define MAX_RESOURCES		4
@@ -165,6 +166,7 @@ static int physmap_flash_probe(struct platform_device *dev)
 		}
 		if (info->mtd[i]->get_unmapped_area == NULL)
 			info->mtd[i]->get_unmapped_area = physmap_unmapped_area;
+		info->mtd[i]->backing_dev_info = &mtd_bdi_ro_mappable;
 		info->mtd[i]->owner = THIS_MODULE;
 		info->mtd[i]->dev.parent = &dev->dev;
 	}
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index a1b8b70..0995819 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -24,6 +24,7 @@
 #include <linux/gfp.h>
 
 #include <linux/mtd/mtd.h>
+#include <linux/mtd/mtdbdi.h>
 
 #include "mtdcore.h"
 /*
@@ -33,6 +34,7 @@
 struct backing_dev_info mtd_bdi_unmappable = {
 	.capabilities	= BDI_CAP_MAP_COPY,
 };
+EXPORT_SYMBOL(mtd_bdi_unmappable);
 
 /*
  * backing device capabilities for R/O mappable devices (such as ROM)
@@ -43,6 +45,7 @@ struct backing_dev_info mtd_bdi_ro_mappable = {
 	.capabilities	= (BDI_CAP_MAP_COPY | BDI_CAP_MAP_DIRECT |
 			   BDI_CAP_EXEC_MAP | BDI_CAP_READ_MAP),
 };
+EXPORT_SYMBOL(mtd_bdi_ro_mappable);
 
 /*
  * backing device capabilities for writable mappable devices (such as RAM)
@@ -54,6 +57,7 @@ struct backing_dev_info mtd_bdi_rw_mappable = {
 			   BDI_CAP_EXEC_MAP | BDI_CAP_READ_MAP |
 			   BDI_CAP_WRITE_MAP),
 };
+EXPORT_SYMBOL(mtd_bdi_rw_mappable);
 
 static int mtd_cls_suspend(struct device *dev, pm_message_t state);
 static int mtd_cls_resume(struct device *dev);
diff --git a/include/linux/mtd/mtdbdi.h b/include/linux/mtd/mtdbdi.h
new file mode 100644
index 0000000..ec0dd7e
--- /dev/null
+++ b/include/linux/mtd/mtdbdi.h
@@ -0,0 +1,17 @@
+/* Internal MTD definitions
+ *
+ * Copyright © 2006 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+/*
+ * mtdcore.c
+ */
+extern struct backing_dev_info mtd_bdi_unmappable;
+extern struct backing_dev_info mtd_bdi_ro_mappable;
+extern struct backing_dev_info mtd_bdi_rw_mappable;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] mtd: physmap: add physmap_unmapped_area() for no-mmu XIP
  2010-05-23  7:30 [PATCH 1/2] mtd: physmap: add physmap_unmapped_area() for no-mmu XIP Mike Frysinger
  2010-05-23  7:30 ` [PATCH 2/2] mtd: physmap: allow maps to be read-only mapped Mike Frysinger
@ 2010-06-12 14:26 ` Artem Bityutskiy
  2010-08-04  9:33   ` David Woodhouse
  2010-08-20  6:17   ` Artem Bityutskiy
  1 sibling, 2 replies; 8+ messages in thread
From: Artem Bityutskiy @ 2010-06-12 14:26 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: uclinux-dev, Bernd Schmidt, David Howells, Paul Mundt, linux-mtd,
	Greg Ungerer, uclinux-dist-devel, David Woodhouse,
	David McCullough

On Sun, 2010-05-23 at 03:30 -0400, Mike Frysinger wrote:
> From: Bernd Schmidt <bernds_cb1@t-online.de>
> 
> Currently, romfs XIP doesn't work in flash memory (the kernel crashes
> with a null pointer dereference).  The problem is that the mtd physmap
> driver isn't setting up a get_unmapped_area pointer for the mtd
> partitions it creates.
> 
> Signed-off-by: Bernd Schmidt <bernds_cb1@t-online.de>
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>

Pushed both to my l2-mtd-2.6.git / dunno.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] mtd: physmap: add physmap_unmapped_area() for no-mmu XIP
  2010-06-12 14:26 ` [PATCH 1/2] mtd: physmap: add physmap_unmapped_area() for no-mmu XIP Artem Bityutskiy
@ 2010-08-04  9:33   ` David Woodhouse
  2010-08-07 23:26     ` [Uclinux-dist-devel] " Mike Frysinger
  2010-08-20  6:17   ` Artem Bityutskiy
  1 sibling, 1 reply; 8+ messages in thread
From: David Woodhouse @ 2010-08-04  9:33 UTC (permalink / raw)
  To: dedekind1
  Cc: Mike Frysinger, uclinux-dev, Bernd Schmidt, David Howells,
	Paul Mundt, linux-mtd, Greg Ungerer, uclinux-dist-devel,
	David McCullough

On Sat, 2010-06-12 at 17:26 +0300, Artem Bityutskiy wrote:
> On Sun, 2010-05-23 at 03:30 -0400, Mike Frysinger wrote:
> > From: Bernd Schmidt <bernds_cb1@t-online.de>
> > 
> > Currently, romfs XIP doesn't work in flash memory (the kernel crashes
> > with a null pointer dereference).  The problem is that the mtd physmap
> > driver isn't setting up a get_unmapped_area pointer for the mtd
> > partitions it creates.
> > 
> > Signed-off-by: Bernd Schmidt <bernds_cb1@t-online.de>
> > Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> 
> Pushed both to my l2-mtd-2.6.git / dunno.

I'm confused by the second patch -- isn't this done in add_mtd_device()
already, according to the device type?

You're setting mtd_bdi_ro_mappable indiscriminately for all types of
devices. For flash devices, that can be an issue -- if you schedule a
userspace process while the kernel is writing to the flash, for example.

If you want to allow XIP of writable flash devices, there's more to it
than this.

-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Uclinux-dist-devel] [PATCH 1/2] mtd: physmap: add physmap_unmapped_area() for no-mmu XIP
  2010-08-04  9:33   ` David Woodhouse
@ 2010-08-07 23:26     ` Mike Frysinger
  2010-08-08 11:33       ` David Woodhouse
  0 siblings, 1 reply; 8+ messages in thread
From: Mike Frysinger @ 2010-08-07 23:26 UTC (permalink / raw)
  To: David Woodhouse
  Cc: David, uclinux-dev, dedekind1, Paul, Schmidt, David Howells,
	Mundt, linux-mtd, Greg Ungerer, uclinux-dist-devel, Bernd,
	McCullough

On Wed, Aug 4, 2010 at 05:33, David Woodhouse wrote:
> On Sat, 2010-06-12 at 17:26 +0300, Artem Bityutskiy wrote:
>> On Sun, 2010-05-23 at 03:30 -0400, Mike Frysinger wrote:
>> > Currently, romfs XIP doesn't work in flash memory (the kernel crashes
>> > with a null pointer dereference).  The problem is that the mtd physmap
>> > driver isn't setting up a get_unmapped_area pointer for the mtd
>> > partitions it creates.
>>
>> Pushed both to my l2-mtd-2.6.git / dunno.
>
> I'm confused by the second patch -- isn't this done in add_mtd_device()
> already, according to the device type?
>
> You're setting mtd_bdi_ro_mappable indiscriminately for all types of
> devices. For flash devices, that can be an issue -- if you schedule a
> userspace process while the kernel is writing to the flash, for example.
>
> If you want to allow XIP of writable flash devices, there's more to it
> than this.

can you can safely do XIP on writable flash devices ?  with nommu, you
certainly cant.  plus, it is only possible with certain filesystems
right ?  like ROMFS ?  and that's already r/o ...

if we delve a bit, what you're referring to is only possible i think
if this change is merged (we posted this back in Jan w/no feedback):
  mtd-physmap: add support users can assign the probe type in board files

otherwise, there's no way of declaring a physmap of a parallel nor
flash and having it end up with read-only capabilities ...
-mike

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Uclinux-dist-devel] [PATCH 1/2] mtd: physmap: add physmap_unmapped_area() for no-mmu XIP
  2010-08-07 23:26     ` [Uclinux-dist-devel] " Mike Frysinger
@ 2010-08-08 11:33       ` David Woodhouse
  2010-08-09  7:36         ` Mike Frysinger
  0 siblings, 1 reply; 8+ messages in thread
From: David Woodhouse @ 2010-08-08 11:33 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: David, uclinux-dev, dedekind1, Paul, Schmidt, David Howells,
	Mundt, linux-mtd, Greg Ungerer, uclinux-dist-devel, Bernd,
	McCullough

On Sat, 2010-08-07 at 19:26 -0400, Mike Frysinger wrote:
> can you can safely do XIP on writable flash devices ?  with nommu, you
> certainly cant.  plus, it is only possible with certain filesystems
> right ?  like ROMFS ?  and that's already r/o ...

As long as you don't allow any process to run that has part of the flash
chip mapped, you ought to be able to do it.

You might not want to use XIP for *everything* in that case -- but you
could imagine a situation where your critical processes are in RAM but
optional extra apps are XIP.

It's hard to implement though, because you'd have to keep track of which
processes need to be blocked and have some way to ensure it happens.

> if we delve a bit, what you're referring to is only possible i think
> if this change is merged (we posted this back in Jan w/no feedback):
>   mtd-physmap: add support users can assign the probe type in board files
> 
> otherwise, there's no way of declaring a physmap of a parallel nor
> flash and having it end up with read-only capabilities ...

Hm, yeah -- that one looks sane enough. I can merge that, although part
1 of that 2-part series I still object to because I don't *want*
different architectures to use different config symbols for the same
thing. Driver code shouldn't have to cope with that.

-- 
dwmw2

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Uclinux-dist-devel] [PATCH 1/2] mtd: physmap: add physmap_unmapped_area() for no-mmu XIP
  2010-08-08 11:33       ` David Woodhouse
@ 2010-08-09  7:36         ` Mike Frysinger
  0 siblings, 0 replies; 8+ messages in thread
From: Mike Frysinger @ 2010-08-09  7:36 UTC (permalink / raw)
  To: David Woodhouse
  Cc: David, uclinux-dev, dedekind1, Paul, Schmidt, David Howells,
	Mundt, linux-mtd, Greg Ungerer, uclinux-dist-devel, Bernd,
	McCullough

On Sun, Aug 8, 2010 at 07:33, David Woodhouse wrote:
> On Sat, 2010-08-07 at 19:26 -0400, Mike Frysinger wrote:
>> if we delve a bit, what you're referring to is only possible i think
>> if this change is merged (we posted this back in Jan w/no feedback):
>>   mtd-physmap: add support users can assign the probe type in board files
>>
>> otherwise, there's no way of declaring a physmap of a parallel nor
>> flash and having it end up with read-only capabilities ...
>
> Hm, yeah -- that one looks sane enough. I can merge that, although part
> 1 of that 2-part series I still object to because I don't *want*
> different architectures to use different config symbols for the same
> thing. Driver code shouldn't have to cope with that.

the two arent really dependent on each other.  i'll probably just
change the Blackfin code to also enable the XIP_KERNEL symbol and
forget about the whole damned mess.
-mike

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] mtd: physmap: add physmap_unmapped_area() for no-mmu XIP
  2010-06-12 14:26 ` [PATCH 1/2] mtd: physmap: add physmap_unmapped_area() for no-mmu XIP Artem Bityutskiy
  2010-08-04  9:33   ` David Woodhouse
@ 2010-08-20  6:17   ` Artem Bityutskiy
  1 sibling, 0 replies; 8+ messages in thread
From: Artem Bityutskiy @ 2010-08-20  6:17 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: uclinux-dev, Bernd Schmidt, David Howells, Paul Mundt, linux-mtd,
	Greg Ungerer, uclinux-dist-devel, David Woodhouse,
	David McCullough

On Sat, 2010-06-12 at 17:26 +0300, Artem Bityutskiy wrote:
> On Sun, 2010-05-23 at 03:30 -0400, Mike Frysinger wrote:
> > From: Bernd Schmidt <bernds_cb1@t-online.de>
> > 
> > Currently, romfs XIP doesn't work in flash memory (the kernel crashes
> > with a null pointer dereference).  The problem is that the mtd physmap
> > driver isn't setting up a get_unmapped_area pointer for the mtd
> > partitions it creates.
> > 
> > Signed-off-by: Bernd Schmidt <bernds_cb1@t-online.de>
> > Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> 
> Pushed both to my l2-mtd-2.6.git / dunno.

dwmw2 did not take these 2 patches, so I'm dropping them from my l2 tree
as well.

Artem.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-08-20  6:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-23  7:30 [PATCH 1/2] mtd: physmap: add physmap_unmapped_area() for no-mmu XIP Mike Frysinger
2010-05-23  7:30 ` [PATCH 2/2] mtd: physmap: allow maps to be read-only mapped Mike Frysinger
2010-06-12 14:26 ` [PATCH 1/2] mtd: physmap: add physmap_unmapped_area() for no-mmu XIP Artem Bityutskiy
2010-08-04  9:33   ` David Woodhouse
2010-08-07 23:26     ` [Uclinux-dist-devel] " Mike Frysinger
2010-08-08 11:33       ` David Woodhouse
2010-08-09  7:36         ` Mike Frysinger
2010-08-20  6:17   ` Artem Bityutskiy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.