mtd: rawnand: nandsim: Add support to disable subpage writes.
Subsystems (2)
PATCH v2 1/1 mtd: rawnand: nandsim: Add support to disable subpage writes.
This is needed if you try to use an already existing ubifs image that is created for hardware that do not support subpage write.
It is not enough that you can select what nandchip to emulate as the subpage support might not exist in the actual nand driver.
--- drivers/mtd/nand/raw/nandsim.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/mtd/nand/raw/nandsim.c +7 -0
@@ -110,6 +110,7 @@ static unsigned int overridesize = 0;static char *cache_file =NULL ;static unsigned int bbt;static unsigned int bch; +static unsigned int no_subpage;static u_char id_bytes[8 ] = { [0 ] =CONFIG_NANDSIM_FIRST_ID_BYTE , [1 ] =CONFIG_NANDSIM_SECOND_ID_BYTE ,
@@ -142,6 +143,7 @@ module_param(overridesize, uint, 0400);module_param (cache_file, charp,0400 );module_param (bbt, uint,0400 );module_param (bch, uint,0400 ); +module_param (no_subpage, uint,0400 );MODULE_PARM_DESC (id_bytes,"The ID bytes returned by NAND Flash 'read ID' command" );MODULE_PARM_DESC (first_id_byte,"The first byte returned by NAND Flash 'read ID' command (manufacturer ID) (obsolete)" );
@@ -177,6 +179,7 @@ MODULE_PARM_DESC(cache_file, "File to use to cache nand pages instead of memMODULE_PARM_DESC (bbt,"0 OOB, 1 BBT with marker in OOB, 2 BBT with marker in data area" );MODULE_PARM_DESC (bch,"Enable BCH ecc and set how many bits should " "be correctable in 512-byte blocks" ); +MODULE_PARM_DESC (no_subpage,"Disable use of subpage write" );/* The largest possible page size */ #define NS_LARGEST_PAGE_SIZE 4096
@@ -2260,6 +2263,10 @@ static int __init ns_init_module(void)/* and 'badblocks' parameters to work */ chip->options |=NAND_SKIP_BBTSCAN ; +/* turn off subpage to be able to simulate using a nand controller without subpage support */ +if (no_subpage) + chip->options |=NAND_NO_SUBPAGE_WRITE ; +switch (bbt) {case 2 : chip->bbt_options |=NAND_BBT_NO_OOB ;
Signature · 1 line
2.7.4
So there was a comment from Richard on the original patch that got mangled so it did not even have a subject line.
The original intent for this patch was to make it possible to setup the simulator with the same parameters as some real hardware. That is the command "mtdinfo /dev/mtdX" would show the same on the simulator as the real hardware.
It's true that you could change the vid offset with ubiattach but that require you know that the LEB missmatch error you get is fixed by a different vid offset and you need to understand what that value should be. This way you only need to match the basic mtd parameters and the rest will just work automatically.
Quoted 50 lines · Kenneth Johansson
This is needed if you try to use an already existing ubifs image that is created for hardware that do not support subpage write.
It is not enough that you can select what nandchip to emulate as the subpage support might not exist in the actual nand driver.
Signed-off-by Kenneth Johansson <[email protected]>--- drivers/mtd/nand/raw/nandsim.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/mtd/nand/raw/nandsim.c +7
-0@@ -110,6 +110,7 @@ static unsigned int overridesize = 0;static char *cache_file =NULL ;static unsigned int bbt;static unsigned int bch; +static unsigned int no_subpage;static u_char id_bytes[8 ] = { [0 ] =CONFIG_NANDSIM_FIRST_ID_BYTE , [1 ] =CONFIG_NANDSIM_SECOND_ID_BYTE ,@@ -142,6 +143,7 @@ module_param(overridesize, uint, 0400);module_param (cache_file, charp,0400 );module_param (bbt, uint,0400 );module_param (bch, uint,0400 ); +module_param (no_subpage, uint,0400 );MODULE_PARM_DESC (id_bytes,"The ID bytes returned by NAND Flash 'read ID' command" );MODULE_PARM_DESC (first_id_byte,"The first byte returned by NAND Flash 'read ID' command (manufacturer ID) (obsolete)" );@@ -177,6 +179,7 @@ MODULE_PARM_DESC(cache_file, "File to use to cache nand pages instead of memMODULE_PARM_DESC (bbt,"0 OOB, 1 BBT with marker in OOB, 2 BBT with marker in data area" );MODULE_PARM_DESC (bch,"Enable BCH ecc and set how many bits should " "be correctable in 512-byte blocks" ); +MODULE_PARM_DESC (no_subpage,"Disable use of subpage write" );/* The largest possible page size */ #define NS_LARGEST_PAGE_SIZE 4096@@ -2260,6 +2263,10 @@ static int __init ns_init_module(void)/* and 'badblocks' parameters to work */ chip->options |=NAND_SKIP_BBTSCAN ; +/* turn off subpage to be able to simulate using a nand controller without subpage support */ +if (no_subpage) + chip->options |=NAND_NO_SUBPAGE_WRITE ; +switch (bbt) {case 2 : chip->bbt_options |=NAND_BBT_NO_OOB ;
Richard Weinberger
maintainerKenneth,
Am Samstag, 22. Dezember 2018, 13:53:39 CET schrieb Kenneth Johansson:
Quoted 7 lines
So there was a comment from Richard on the original patch that got mangled so it did not even have a subject line.
The original intent for this patch was to make it possible to setup the simulator with the same parameters as some real hardware. That is the command "mtdinfo
/dev/mtdX" would show the same on the simulator as the real hardware.
Just to make sure: nandsim simulates a given NAND chip but the simulated NAND flash controller will always be different.
Think of ECC layout.
In this case it may be good enough to fool your userspace, but don't count on it.
Quoted 5 lines
It's true that you could change the vid offset with ubiattach but that require you know that the LEB missmatch error you get is fixed by a different vid offset and you need to understand what that value should be. This way you only need to match the basic mtd parameters and the rest will just work automatically.
I agree that adding a parameter to nandsim to control subpage behavior is nice.
But please keep in mind that nandsim will never perfectly match your hardware.
Boris, unless you have objections I'm fine to control NAND_NO_SUBPAGE_WRITE in nandsim using a module parameter.
Thanks,
//richard
Hi Richard,
Quoted 6 lines · On Thu, 03 Jan 2019 21:43:13 +0100 Richard Weinberger <[email protected]> wrote:
Quoted 5 lines
It's true that you could change the vid offset with ubiattach but that require you know that the LEB missmatch error you get is fixed by a different vid offset and you need to understand what that value should be. This way you only need to match the basic mtd parameters and the rest will just work automatically.
Quoted 6 lines
I agree that adding a parameter to nandsim to control subpage behavior is nice.
But please keep in mind that nandsim will never perfectly match your hardware.Boris, unless you have objections I'm fine to control
NAND_NO_SUBPAGE_WRITEin nandsim using a module parameter.
Hm, I'd really like to have nandsim replaced by something more generic at some point (mtdsim or MTD/NAND emulation in qemu using a virtio iface), so adding new features/option to this driver is something I'd like to avoid. This being said, this new MTD/NAND emulation infrastructure is not there yet, and I don't think I'll have time to work on it (I started working on mtdsim a while back, and someone took over this work, but it stopped at some point).
To sum-up, if you think this is absolutely necessary (given the discussion I'm not convinced it is) I'm okay to add this module param, but I'd prefer if people were working on a solution to replace all those emulation layers we have right now (mtdram, nandsim, ...).
Regards,
Boris
+Miquel
Kenneth, please Cc the NAND maintainers next time.
Quoted 34 lines · On Fri, 4 Jan 2019 09:53:02 +0100 Boris Brezillon <[email protected]> wrote:
Hi Richard,
Quoted 6 lines · On Thu, 03 Jan 2019 21:43:13 +0100 Richard Weinberger <[email protected]> wrote:
Quoted 5 lines
It's true that you could change the vid offset with ubiattach but that require you know that the LEB missmatch error you get is fixed by a different vid offset and you need to understand what that value should be. This way you only need to match the basic mtd parameters and the rest will just work automatically.
Quoted 6 lines
I agree that adding a parameter to nandsim to control subpage behavior is nice.
But please keep in mind that nandsim will never perfectly match your hardware.Boris, unless you have objections I'm fine to control
NAND_NO_SUBPAGE_WRITEin nandsim using a module parameter.Hm, I'd really like to have nandsim replaced by something more generic at some point (mtdsim or MTD/NAND emulation in qemu using a virtio iface), so adding new features/option to this driver is something I'd like to avoid. This being said, this new MTD/NAND emulation infrastructure is not there yet, and I don't think I'll have time to work on it (I started working on mtdsim a while back, and someone took over this work, but it stopped at some point).
To sum-up, if you think this is absolutely necessary (given the discussion I'm not convinced it is) I'm okay to add this module param, but I'd prefer if people were working on a solution to replace all those emulation layers we have right now (mtdram, nandsim, ...).
Regards,
Boris
Quoted 26 lines · Boris Brezillon
Hi Richard,
Quoted 6 lines · On Thu, 03 Jan 2019 21:43:13 +0100 Richard Weinberger <[email protected]> wrote:
Quoted 5 lines
It's true that you could change the vid offset with ubiattach but that require you know that the LEB missmatch error you get is fixed by a different vid offset and you need to understand what that value should be. This way you only need to match the basic mtd parameters and the rest will just work automatically.
Quoted 6 lines
I agree that adding a parameter to nandsim to control subpage behavior is nice.
But please keep in mind that nandsim will never perfectly match your hardware.Boris, unless you have objections I'm fine to control
NAND_NO_SUBPAGE_WRITEin nandsim using a module parameter.Hm, I'd really like to have nandsim replaced by something more generic at some point (mtdsim or MTD/NAND emulation in qemu using a virtio iface), so adding new features/option to this driver is something I'd like to avoid. This being said, this new MTD/NAND emulation infrastructure is not there yet, and I don't think I'll have time to work on it (I started working on mtdsim a while back, and someone took over this work, but it stopped at some point).
Quoted 4 lines
To sum-up, if you think this is absolutely necessary (given the discussion I'm not convinced it is) I'm okay to add this module param, but I'd prefer if people were working on a solution to replace all those emulation layers we have right now (mtdram, nandsim, ...).
Sorry for picking up this old thread, but is there a change to get this patch upstream? It works and solved my problem of mounting a NAND dump of an UBI/UBIFS from an imx6 (2k page size/no sub pages).
I think it doesn't apply clearly to current linus/master, but rebasing is trivial. I can send a v3.
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 6 lines · Marc Kleine-Budde
Sorry for picking up this old thread, but is there a change to get this patch upstream? It works and solved my problem of mounting a NAND dump of an UBI/UBIFS from an imx6 (2k page size/no sub pages).
I think it doesn't apply clearly to current linus/master, but rebasing is trivial. I can send a v3.
Since a nandsim replacement did not materialize yet, the chances are good to get this merged. :-)
Before we do so, can you please explain why ubiattach -O does not work for you? This is the way I deal with subpage "issues" when inspecting ubi/ubifs images on nandsim.
Signature · 6 lines
Thanks, //richard ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 11 lines · Richard Weinberger
Quoted 6 lines · Marc Kleine-Budde
Sorry for picking up this old thread, but is there a change to get this patch upstream? It works and solved my problem of mounting a NAND dump of an UBI/UBIFS from an imx6 (2k page size/no sub pages).
I think it doesn't apply clearly to current linus/master, but rebasing is trivial. I can send a v3.
Since a nandsim replacement did not materialize yet, the chances are good to get this merged. :-)
Before we do so, can you please explain why ubiattach -O does not work for you?
Doh! Thanks for the input, this is the option I needed to properly attach the UBI! \o/
Quoted 2 lines
This is the way I deal with subpage "issues" when inspecting ubi/ubifs images on nandsim.
One question (rather academic, I don't want to do that): Does the UBI/UBIFS do sub-page writes on the nandsim? Is the resulting NAND image still compatible if I write it to the original device, that doesn't do subpage writes?
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Richard Weinberger
maintainer----- Ursprüngliche Mail -----
Quoted 2 lines
Doh! Thanks for the input, this is the option I needed to properly attach the UBI! \o/
:-)
Quoted 6 lines
Quoted 2 lines
This is the way I deal with subpage "issues" when inspecting ubi/ubifs images on nandsim.
One question (rather academic, I don't want to do that): Does the UBI/UBIFS do sub-page writes on the nandsim? Is the resulting NAND image still compatible if I write it to the original device, that doesn't do subpage writes?
Since nandsim announces subpages, UBI will use them. Except you define your own VID header offset.
UBIFS does not use subpages at all and UBI only for VID headers to be more storage efficient.
So, ubiattach -O should completely fulfill your needs.
If all other parameters of the NAND match, and I guess so, otherwise ubiattach would notice, the UBI image should also work on the target. Modulo fastmap, if you have bad blocks.
Thanks,
//richard
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 7 lines · Richard Weinberger
Quoted 6 lines
Quoted 2 lines
This is the way I deal with subpage "issues" when inspecting ubi/ubifs images on nandsim.
One question (rather academic, I don't want to do that): Does the UBI/UBIFS do sub-page writes on the nandsim? Is the resulting NAND image still compatible if I write it to the original device, that doesn't do subpage writes?
Quoted 6 lines
Since nandsim announces subpages, UBI will use them. Except you define your own VID header offset.
UBIFS does not use subpages at all and UBI only for VID headers to be more storage efficient.So, ubiattach -O should completely fulfill your needs.
\o/
Quoted 3 lines
If all other parameters of the NAND match, and I guess so, otherwise ubiattach would notice, the UBI image should also work on the target. Modulo fastmap, if you have bad blocks.
Thanks for the explanation!
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 6 lines · Richard Weinberger
Kenneth,
Am Samstag, 22. Dezember 2018, 13:53:39 CET schrieb Kenneth Johansson:
Quoted 3 lines
So there was a comment from Richard on the original patch that got mangled so it did not even have a subject line.
Quoted 7 lines
Quoted 4 lines
The original intent for this patch was to make it possible to setup the simulator with the same parameters as some real hardware. That is the command "mtdinfo
/dev/mtdX" would show the same on the simulator as the real hardware.Just to make sure: nandsim simulates a given NAND chip but the simulated NAND flash controller will always be different.
Think of ECC layout.
Yes but ecc layout is generally not visible to layers on top of MTD in the same way that the smallest writeable block size(sub page) is. It just feels strange that the simulator could not simulate lack of subpage writes as it do exist on quite a few nand controllers. And in real life there is always going to be a controller in front of the nand chip so any simulator really should take that into account.