CORE: Allow kernel access to struct mtd_part and PART() for axfs
PATCH 1/1 CORE: Allow kernel access to struct mtd_part and PART() for axfs
In order to mount to mtd partitions axfs (axfs.sf.net) needs the physical address
found by using the mtd_part structure. This patch simply moves the definition of struct mtd_part and PART() from drivers/mtd/mtdpart.c to include/linux/mtd/partitions.h where other parts of the kernel, such as axfs, can use it.
This is actually in my brand new shiny users/jehulber/mtd-intel.git all ready to be pulled. If everyone is okay with it that is.
This is best way we could figure out to get access to the physical address of a given partition. We _need_ the physical address to use remap_pfn_range().
<AXFSCODE>
part = PART(mtd); map = part->master->priv; fsi->virtaddr = (void *)virtaddr; fsi->clean_up_callback = axfs_mtd_cleanup; fsi->callback_data = (u32) mtdnr; fsi->physaddr = (void *)(map->phys + part->offset);
</AXFSCODE>
<PATCH>
drivers/mtd/mtdpart.c +0 -0
@@ -24,23 +24,6 @@
/* Our partition linked list */
static LIST_HEAD(mtd_partitions);
-/* Our partition node structure */
-struct mtd_part {
- struct mtd_info mtd;
- struct mtd_info *master;
- u_int32_t offset;
- int index;
- struct list_head list;
- int registered;
-};
-
-/*
- * Given a pointer to the MTD object in the mtd_part structure, we can retrieve
- * the pointer to that structure with this macro.
- */
-#define PART(x) ((struct mtd_part *)(x))
-
-
/*
* MTD methods which simply translate the effective address and pass through
* to the _real_ device.
include/linux/mtd/partitions.h +0 -0
@@ -45,6 +45,22 @@ struct mtd_partition {
struct mtd_info **mtdp; /* pointer to store the MTD object */
};
+/* Our partition node structure */
+struct mtd_part {
+ struct mtd_info mtd;
+ struct mtd_info *master;
+ u_int32_t offset;
+ int index;
+ struct list_head list;
+ int registered;
+};
+
+/*
+ * Given a pointer to the MTD object in the mtd_part structure, we can retrieve
+ * the pointer to that structure with this macro.
+ */
+#define PART(x) ((struct mtd_part *)(x))
+
#define MTDPART_OFS_NXTBLK (-2)
#define MTDPART_OFS_APPEND (-1)
#define MTDPART_SIZ_FULL (0)
</PATCH>
Quoted 3 lines · Jared Hulbert
This is best way we could figure out to get access to the physical address of a given partition. We _need_ the physical address to use
remap_pfn_range().
If it's going to be public information I'd prefer to just add it to the struct mtd_info rather than exposing more private structures just because they happen to contain it at the moment.
But really, you need to be able to coordinate with the flash driver so that you can read from it _only_ when it's in read mode. This kind of thing is what point() is for. The whole point()/unpoint() thing is probably misdesigned, so feel free to make suggestions for changing it, if it doesn't do what you want.
How do you handle tearing down a mapping when the data moves from one place on the flash to another? Or does that not happen?
Signature · 1 line
dwmw2
Quoted 3 lines
If it's going to be public information I'd prefer to just add it to the struct
mtd_inforather than exposing more private structures just because they happen to contain it at the moment.
You're right, but I don't like putting .phys into mtd_info as it's already in map_info. Seems like redundant duplication. And besides axfs is the only customer for this data.
How about we add a new function, something like unsigned long partition_physaddr(mtd_info) in mtdpart.c to do the dirty work?
Quoted 5 lines
But really, you need to be able to coordinate with the flash driver so that you can read from it _only_ when it's in read mode. This kind of thing is what
point()is for. The whole point()/unpoint() thing is probably misdesigned, so feel free to make suggestions for changing it, if it doesn't do what you want.
As soon as I mount I point() the whole partition and unpoint() it at unmount. Works for me. Maybe someday we will include this page by page XIP into a writeable filesystem and then we'll take a more serious look at point(). But I really don't see anything wrong with point().
There is no read mode really. I assume any userspace process will have the raw flash mmap()ed directly into it's memory. So I just keep it point()ed. If the flash needs to be written to then use CONFIG_MTD_XIP or be clever with flash hardware partitions.
Quoted 2 lines
How do you handle tearing down a mapping when the data moves from one place on the flash to another? Or does that not happen?
Doesn't happen, its a static read only filesystem. Design is very simple. The mounting routines are I think twice the lines as the actual meat of the filesystem.