Skip to contentSkip to conversation

mtd: gpmi: make blockmark swapping optional

PATCH In review [email protected] 5 participants 32 messages Mar 19, 2014 – Mar 31, 2014

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: gpmi: make blockmark swapping optional

From: Lothar Wa?mann <[email protected]>

With a flash-based BBT there is no reason to move the Factory Bad Block Marker from the data area buffer (to where it is mapped by the GPMI NAND controller) to the OOB buffer. Thus, make this feature configurable via DT. This is required for the Ka-Ro electronics platforms.

---
 Documentation/devicetree/bindings/mtd/gpmi-nand.txt |    3 +++
 arch/arm/boot/dts/imx28-tx28.dts                    |    1 +
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c              |   10 +++++++---
 3 files changed, 11 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/mtd/gpmi-nand.txt +3 -0
index 458d596..f28949a 100644
@@ -25,6 +25,9 @@ Optional properties:
                        discoverable or this property is not enabled,
                        the software may chooses an implementation-defined
                        ECC scheme.
+  - fsl,no-blockmark-swap: Don't swap the bad block marker from the OOB
+                       area with the byte in the data area but rely on the
+                       BBT for identifying bad blocks.
 
 The device tree may optionally contain sub-nodes describing partitions of the
 address space. See partition.txt for more detail.
arch/arm/boot/dts/imx28-tx28.dts +1 -0
index e14bd86..7d2bea8 100644
@@ -247,6 +247,7 @@
 &gpmi {
 	pinctrl-0 = <&gpmi_pins_a &gpmi_status_cfg>;
 	nand-on-flash-bbt;
+	fsl,no-blockmark-swap;
 	status = "okay";
 };
 
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +7 -3
index bb77f75..98562eb 100644
@@ -1632,9 +1632,6 @@ static int gpmi_init_last(struct gpmi_nand_data *this)
 	struct bch_geometry *bch_geo = &this->bch_geometry;
 	int ret;
 
-	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
-	this->swap_block_mark = !GPMI_IS_MX23(this);
-
 	/* Set up the medium geometry */
 	ret = gpmi_set_geometry(this);
 	if (ret)
@@ -1701,6 +1698,13 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
 	if (of_get_nand_on_flash_bbt(this->dev->of_node))
 		chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
 
+	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
+	if (!of_property_read_bool(this->dev->of_node, "fsl,no-blockmark-swap"))
+		this->swap_block_mark = !GPMI_IS_MX23(this);
+
+	dev_dbg(this->dev, "Blockmark swapping %sabled\n",
+		this->swap_block_mark ? "en" : "dis");
+
 	/*
 	 * Allocate a temporary DMA buffer for reading ID in the
 	 * nand_scan_ident().
Signature · 1 line
1.7.10.4
#1 lore raw

Hi Lothar,

Quoted 6 lines · On Wednesday 19 March 2014 14:23:26 [email protected] wrote:

With a flash-based BBT there is no reason to move the Factory Bad Block Marker from the data area buffer (to where it is mapped by the GPMI NAND controller) to the OOB buffer. Thus, make this feature configurable via DT. This is required for the Ka-Ro electronics platforms.
[...]

How do you create the BBT the very first time with valuable data when the NAND already contains factory bad blocks?

jbe

Signature · 2 lines
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |
#2 lore raw

Hi,

Quoted 10 lines · Juergen Beisert

Hi Lothar,

Quoted 6 lines · On Wednesday 19 March 2014 14:23:26 y at karo-electronics.de wrote:

With a flash-based BBT there is no reason to move the Factory Bad Block Marker from the data area buffer (to where it is mapped by the GPMI NAND controller) to the OOB buffer. Thus, make this feature configurable via DT. This is required for the Ka-Ro electronics platforms.
[...]

Quoted 3 lines

How do you create the BBT the very first time with valuable data when the NAND already contains factory bad blocks?

With the flashtool that does the initial flash programming.

Lothar Wa?mann

Signature · 9 lines
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________
#3 lore raw
In reply to [email protected]
Quoted 3 lines · 于 2014年03月19日 21:23, [email protected] 写道:

configurable via DT. This is required for the Ka-Ro electronics platforms.

If you disable the swapping, you will disable the NAND boot in actually.

do you need the nand boot?

could you please tell me more detail background?

thanks
Huang Shijie

#4 lore raw

Hi,

Quoted 6 lines · Huang Shijie

? 2014?03?19? 21:23, y at karo-electronics.de ??:

Quoted 3 lines

configurable via DT. This is required for the Ka-Ro electronics platforms.

If you disable the swapping, you will disable the NAND boot in actually.

No. All our modules do boot from NAND and none of them does the swapping.

Lothar Wa?mann

Signature · 9 lines
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________
#5 lore raw
Quoted 13 lines · Lothar Waßmann

Hi,

Quoted 6 lines · Huang Shijie
Quoted 3 lines · 于 2014年03月19日 21:23, [email protected] 写道:

configurable via DT. This is required for the Ka-Ro electronics platforms.

If you disable the swapping, you will disable the NAND boot in actually.

No. All our modules do boot from NAND and none of them does the swapping.

It seems the NAND boot runs well by luck.

The ROM will do the swapping when it reads the BBT table written by the kobs-ng (or something else?).

If the BBT table is small, not bigger then a page, the NAND boot may runs well when you disable the swapping; But it the BBT table is bigger, the ROM will get a corrupted BBT table.

thanks
Huang Shijie

#6 lore raw

Hi,

Quoted 10 lines · Huang Shijie

? 2014?03?20? 17:21, Lothar Wa?mann ??:

Quoted 9 lines

Hi,

Quoted 6 lines · Huang Shijie

? 2014?03?19? 21:23, y at karo-electronics.de ??:

Quoted 3 lines

configurable via DT. This is required for the Ka-Ro electronics platforms.

If you disable the swapping, you will disable the NAND boot in actually.

Quoted 9 lines
Quoted 4 lines

No. All our modules do boot from NAND and none of them does the swapping.

It seems the NAND boot runs well by luck.

The ROM will do the swapping when it reads the BBT table written by the kobs-ng (or something else?).

This can be disabled by parameter in the FCB (at least according to the i.MX6 reference Manual):

|DISBBM 172 4 If 0 ROM will swap BadBlockMarkerByte with
|             metadata[0] after reading a page using BCH40.
|             If the value set is 1 then ROM will not do
|             swapping

Lothar Wa?mann

Signature · 9 lines
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________
#7 lore raw
Quoted 2 lines · Lothar Waßmann

This can be disabled by parameter in the FCB (at least according to the i.MX6 reference Manual):

from imx28's reference manual, there is not such bit in the FCB to disable the swapping. But you are disabling the swapping in the imx28's DTS file, isn't it?

I think it is dangerous.

Quoted 6 lines
|DISBBM 172 4 If 0 ROM will swap BadBlockMarkerByte with
|             metadata[0] after reading a page using BCH40.
|             If the value set is 1 then ROM will not do
|             swapping

I will consult with our ROM colleague about this DISBBM bit.

I am not sure if the ROM still do the swapping for the uboot when we set DISBBM bit.

thanks
Huang Shijie

#8 lore raw
In reply to [email protected]

? 2014?03?19? 21:23, y at karo-electronics.de ??:

drivers/mtd/nand/gpmi-nand/gpmi-nand.c static int gpmi_nand_init(struct gpmi_nand_data *this) · line 1703

Quoted 3 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +3 -0
+	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
+	if (!of_property_read_bool(this->dev->of_node, "fsl,no-blockmark-swap"))
+		this->swap_block_mark = !GPMI_IS_MX23(this);

Our ROM guy had confirmed that the Rom will disable the swapping if we set the DISBBM bit.
But please do not change any logic for imx23/imx28.

I really do not know what's the benefit we can get from this patch. Please send the new version about this patch if you want this feature.

thanks
Huang Shijie

#9 lore raw

PATCH v2 1/1 mtd: gpmi: make blockmark swapping optional

With a flash-based BBT there is no reason to move the Factory Bad Block Marker from the data area buffer (to where it is mapped by the GPMI NAND controller) to the OOB buffer. Thus, make this feature configurable via DT. This is required for the Ka-Ro electronics platforms.

---
 Documentation/devicetree/bindings/mtd/gpmi-nand.txt |    3 +++
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c              |   10 +++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/mtd/gpmi-nand.txt +3 -0
index 458d596..f28949a 100644
@@ -25,6 +25,9 @@ Optional properties:
                        discoverable or this property is not enabled,
                        the software may chooses an implementation-defined
                        ECC scheme.
+  - fsl,no-blockmark-swap: Don't swap the bad block marker from the OOB
+                       area with the byte in the data area but rely on the
+                       BBT for identifying bad blocks.
 
 The device tree may optionally contain sub-nodes describing partitions of the
 address space. See partition.txt for more detail.
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +7 -3
index bb77f75..98562eb 100644
@@ -1632,9 +1632,6 @@ static int gpmi_init_last(struct gpmi_nand_data *this)
 	struct bch_geometry *bch_geo = &this->bch_geometry;
 	int ret;
 
-	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
-	this->swap_block_mark = !GPMI_IS_MX23(this);
-
 	/* Set up the medium geometry */
 	ret = gpmi_set_geometry(this);
 	if (ret)
@@ -1701,6 +1698,13 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
 	if (of_get_nand_on_flash_bbt(this->dev->of_node))
 		chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
 
+	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
+	if (!of_property_read_bool(this->dev->of_node, "fsl,no-blockmark-swap"))
+		this->swap_block_mark = !GPMI_IS_MX23(this);
+
+	dev_dbg(this->dev, "Blockmark swapping %sabled\n",
+		this->swap_block_mark ? "en" : "dis");
+
 	/*
 	 * Allocate a temporary DMA buffer for reading ID in the
 	 * nand_scan_ident().
Signature · 1 line
1.7.10.4
#10 lore raw
Quoted 17 lines · Lothar Wa?mann

With a flash-based BBT there is no reason to move the Factory Bad Block Marker from the data area buffer (to where it is mapped by the GPMI NAND controller) to the OOB buffer. Thus, make this feature configurable via DT. This is required for the Ka-Ro electronics platforms.

---
 Documentation/devicetree/bindings/mtd/gpmi-nand.txt |    3 +++
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c              |   10 +++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/mtd/gpmi-nand.txt +0 -0
index 458d596..f28949a 100644

Documentation/devicetree/bindings/mtd/gpmi-nand.txt Optional properties: · line 30

Quoted 6 lines
Documentation/devicetree/bindings/mtd/gpmi-nand.txt +3 -0
@@ -25,6 +25,9 @@ Optional properties:
                        discoverable or this property is not enabled,
                        the software may chooses an implementation-defined
                        ECC scheme.
+  - fsl,no-blockmark-swap: Don't swap the bad block marker from the OOB
+                       area with the byte in the data area but rely on the
+                       BBT for identifying bad blocks.

Please add the following:
"NOTE: This property is not supported by the imx23 and imx28"

Quoted 18 lines
Documentation/devicetree/bindings/mtd/gpmi-nand.txt +0 -0
 The device tree may optionally contain sub-nodes describing partitions of the
 address space. See partition.txt for more detail.
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +0 -3
index bb77f75..98562eb 100644
@@ -1632,9 +1632,6 @@ static int gpmi_init_last(struct gpmi_nand_data *this)
 	struct bch_geometry *bch_geo = &this->bch_geometry;
 	int ret;
 
-	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
-	this->swap_block_mark = !GPMI_IS_MX23(this);
-
 	/* Set up the medium geometry */
 	ret = gpmi_set_geometry(this);
 	if (ret)

drivers/mtd/nand/gpmi-nand/gpmi-nand.c static int gpmi_nand_init(struct gpmi_nand_data *this) · line 1703

Quoted 6 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +3 -0
@@ -1701,6 +1698,13 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
 	if (of_get_nand_on_flash_bbt(this->dev->of_node))
 		chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
 
+	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
+	if (!of_property_read_bool(this->dev->of_node, "fsl,no-blockmark-swap"))
+		this->swap_block_mark = !GPMI_IS_MX23(this);

the code should like this:
----------------------------------------------

	this->swap_block_mark = !GPMI_IS_MX23(this);

	if (!GPMI_IS_IMX23(this) && !GPMI_IS_MX28(this) &&
		of_property_read_bool(this->dev->of_node, "fsl,no-blockmark-swap"))
		this->swap_block_mark = false;

----------------------------------------------

drivers/mtd/nand/gpmi-nand/gpmi-nand.c static int gpmi_nand_init(struct gpmi_nand_data *this) · line 1710

Quoted 7 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +4 -0
+
+	dev_dbg(this->dev, "Blockmark swapping %sabled\n",
+		this->swap_block_mark ? "en" : "dis");
+
 	/*
 	 * Allocate a temporary DMA buffer for reading ID in the
 	 * nand_scan_ident().

There are some bugs in the gpmi driver which is caused by the assumption that we always enable the swapping except the imx23.

So, there are some places should be changed with this patch:
[1] the subpage hook,
Please also change the gpmi_ecc_read_subpage() too.

[2] the OOB hook,
Please also change the gpmi_ecc_read_oob().

[3] the markbad hook,
Please also change the gpmi_block_markbad() .

thanks
Huang Shijie

#11 lore raw

Hi,

Quoted 13 lines · Huang Shijie
Quoted 12 lines · Lothar Wa?mann

With a flash-based BBT there is no reason to move the Factory Bad Block Marker from the data area buffer (to where it is mapped by the GPMI NAND controller) to the OOB buffer. Thus, make this feature configurable via DT. This is required for the Ka-Ro electronics platforms.

---
 Documentation/devicetree/bindings/mtd/gpmi-nand.txt |    3 +++
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c              |   10 +++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)
Quoted 15 lines

Documentation/devicetree/bindings/mtd/gpmi-nand.txt Optional properties: · line 30

Quoted 11 lines
Documentation/devicetree/bindings/mtd/gpmi-nand.txt +3 -0
index 458d596..f28949a 100644
@@ -25,6 +25,9 @@ Optional properties:
                        discoverable or this property is not enabled,
                        the software may chooses an implementation-defined
                        ECC scheme.
+  - fsl,no-blockmark-swap: Don't swap the bad block marker from the OOB
+                       area with the byte in the data area but rely on the
+                       BBT for identifying bad blocks.

Please add the following:
"NOTE: This property is not supported by the imx23 and imx28"

I don't see why this should not be supported on i.MX28 (i.MX23 doesn't do byteswapping anyway, so this wouldn't change anything for i.MX23). The partitions used by Linux need not necessarily be accessible for the Boot ROM code (and vice versa).

Quoted 26 lines
Quoted 17 lines
Documentation/devicetree/bindings/mtd/gpmi-nand.txt +0 -0
 The device tree may optionally contain sub-nodes describing partitions of the
 address space. See partition.txt for more detail.
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +0 -3
index bb77f75..98562eb 100644
@@ -1632,9 +1632,6 @@ static int gpmi_init_last(struct gpmi_nand_data *this)
 	struct bch_geometry *bch_geo = &this->bch_geometry;
 	int ret;
 
-	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
-	this->swap_block_mark = !GPMI_IS_MX23(this);
-
 	/* Set up the medium geometry */
 	ret = gpmi_set_geometry(this);
 	if (ret)

drivers/mtd/nand/gpmi-nand/gpmi-nand.c static int gpmi_nand_init(struct gpmi_nand_data *this) · line 1703

Quoted 6 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +3 -0
@@ -1701,6 +1698,13 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
 	if (of_get_nand_on_flash_bbt(this->dev->of_node))
 		chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
 
+	/* Set up swap_block_mark, must be set before the gpmi_set_geometry() */
+	if (!of_property_read_bool(this->dev->of_node, "fsl,no-blockmark-swap"))
+		this->swap_block_mark = !GPMI_IS_MX23(this);

the code should like this:
----------------------------------------------

Quoted 4 lines
	this->swap_block_mark = !GPMI_IS_MX23(this);

	if (!GPMI_IS_IMX23(this) && !GPMI_IS_MX28(this) &&

the !GPMI_IS_MX23() is redundant here as i.MX23 will always have swap_block_mark == false.
I would rather add a dependency on nand-on-flash-bbt as a prerequisite for not checking the BB marks in each block.

Quoted 15 lines

drivers/mtd/nand/gpmi-nand/gpmi-nand.c static int gpmi_nand_init(struct gpmi_nand_data *this) · line 1710

Quoted 7 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +4 -0
+
+	dev_dbg(this->dev, "Blockmark swapping %sabled\n",
+		this->swap_block_mark ? "en" : "dis");
+
 	/*
 	 * Allocate a temporary DMA buffer for reading ID in the
 	 * nand_scan_ident().

There are some bugs in the gpmi driver which is caused by the assumption that we always enable the swapping except the imx23.

So, there are some places should be changed with this patch:
[1] the subpage hook,
Please also change the gpmi_ecc_read_subpage() too.

Quoted 6 lines

[2] the OOB hook,
Please also change the gpmi_ecc_read_oob().

[3] the markbad hook,
Please also change the gpmi_block_markbad() .

OK, I'll check that.

Lothar Wa?mann

Signature · 9 lines
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________
#12 lore raw

? 2014?03?26? 16:51, Lothar Wa?mann ??:

Quoted 4 lines

I don't see why this should not be supported on i.MX28 (i.MX23 doesn't do byteswapping anyway, so this wouldn't change anything for i.MX23). The partitions used by Linux need not necessarily be accessible for the Boot ROM code (and vice versa).

But the first partition used to store the u-boot is accessible for the ROM.

Please see "Figure 12-13" in the 12.12.1.12:
"In order to preserve the BI (bad block information), flash updater
or gang programmer
applications need to swap Bad Block Information (BI) data to byte 0 of metadata area for
every page before programming NAND Flash. ROM when loading firmware, copies back
the value at metadata[0] to BI offset in page data. The following figure shows how the
factory bad block marker is preserved."

So please the imx28 should _NOT_ support this feature.

thanks
Huang Shijie

#13 lore raw

Hi,

Quoted 7 lines · Huang Shijie

? 2014?03?26? 16:51, Lothar Wa?mann ??:

Quoted 4 lines

I don't see why this should not be supported on i.MX28 (i.MX23 doesn't do byteswapping anyway, so this wouldn't change anything for i.MX23). The partitions used by Linux need not necessarily be accessible for the Boot ROM code (and vice versa).

But the first partition used to store the u-boot is accessible for the ROM.

Whether this partition is available to Linux depends on the partition table passed in the DT.

Quoted 11 lines

Please see "Figure 12-13" in the 12.12.1.12:
"In order to preserve the BI (bad block information), flash updater
or gang programmer
applications need to swap Bad Block Information (BI) data to byte 0 of metadata area for
every page before programming NAND Flash. ROM when loading firmware, copies back
the value at metadata[0] to BI offset in page data. The following figure shows how the
factory bad block marker is preserved."

The inspection of the BB markers is only a fallback for the case that there is no DBBT. From the same chapter that you quoted above:

| ROM uses DBBT to skip any bad block that falls within firmware data
| on NAND Flash device.
| If the address of DBBT Search Area in FCB is 0, ROM will rely on
| factory marked bad block markers to find out if a block is good or bad.

Thus, even the boot ROM of i.MX28 can well live without blockmark swapping.

Lothar Wa?mann

Signature · 9 lines
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________
#14 lore raw
Quoted 4 lines · Lothar Wa?mann

Hi,

Quoted 1 line · Huang Shijie

? 2014?03?26? 16:51, Lothar Wa?mann ??:

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

I don't see why this should not be supported on i.MX28 (i.MX23 doesn't do byteswapping anyway, so this wouldn't change anything for i.MX23). The partitions used by Linux need not necessarily be accessible for the Boot ROM code (and vice versa).

But the first partition used to store the u-boot is accessible for the ROM.

Whether this partition is available to Linux depends on the partition table passed in the DT.

yes, i agree.

But it is strange if we do not export this partition to Linux.

Quoted 14 lines
Quoted 12 lines

Please see "Figure 12-13" in the 12.12.1.12:
"In order to preserve the BI (bad block information), flash updater
or gang programmer
applications need to swap Bad Block Information (BI) data to byte 0 of metadata area for
every page before programming NAND Flash. ROM when loading firmware, copies back
the value at metadata[0] to BI offset in page data. The following figure shows how the
factory bad block marker is preserved."

The inspection of the BB markers is only a fallback for the case that there is no DBBT. From the same chapter that you quoted above:

Quoted 7 lines
| ROM uses DBBT to skip any bad block that falls within firmware data
| on NAND Flash device.
| If the address of DBBT Search Area in FCB is 0, ROM will rely on
| factory marked bad block markers to find out if a block is good or bad.

Thus, even the boot ROM of i.MX28 can well live without blockmark swapping.

Assume that there is a NAND block "A", and the A consist of 256 pages. the uboot is burned to the "A", can occupy 6 pages:

-----------------------------------------------------------------------------
| page 0 | page 1 | page 2 | page 3 | page 4 | page 5 | ... | ... | page 255 |
-----------------------------------------------------------------------------

\-------------------------------------- ------------------------------------/

                                         V  
                                        "A"					 

The DBBT is used to track if "A" is bad or not.
Assume we know that "A" is a good block, ROM then need to read out the uboot. When the ROM needs to read out the 6 pages one by one. And each time the ROM read the page, it should do the swapping for this page.

In this case, the ROM will do the swapping six times.

Please read the sector again, you will see the "every page" in it:
--------------------------------------------------------------------
"In order to preserve the BI (bad block information), flash updater
or gang programmer applications need to swap Bad Block Information (BI) data to byte 0 of metadata area for every page before programming NAND Flash. ROM when loading firmware, copies back
--------------------------------------------------------------------

thanks
Huang Shijie

#15 lore raw

Hi,

Quoted 39 lines · Huang Shijie
Quoted 13 lines
Quoted 11 lines

Please see "Figure 12-13" in the 12.12.1.12:
"In order to preserve the BI (bad block information), flash updater
or gang programmer
applications need to swap Bad Block Information (BI) data to byte 0 of metadata area for
every page before programming NAND Flash. ROM when loading firmware, copies back
the value at metadata[0] to BI offset in page data. The following figure shows how the
factory bad block marker is preserved."

The inspection of the BB markers is only a fallback for the case that there is no DBBT. From the same chapter that you quoted above:

Quoted 7 lines
| ROM uses DBBT to skip any bad block that falls within firmware data
| on NAND Flash device.
| If the address of DBBT Search Area in FCB is 0, ROM will rely on
| factory marked bad block markers to find out if a block is good or bad.

Thus, even the boot ROM of i.MX28 can well live without blockmark swapping.

Assume that there is a NAND block "A", and the A consist of 256 pages. the uboot is burned to the "A", can occupy 6 pages:

-----------------------------------------------------------------------------
| page 0 | page 1 | page 2 | page 3 | page 4 | page 5 | ... | ... | page 255 |
-----------------------------------------------------------------------------

\-------------------------------------- ------------------------------------/

                                         V  
                                        "A"					 

The DBBT is used to track if "A" is bad or not.
Assume we know that "A" is a good block, ROM then need to read out the uboot. When the ROM needs to read out the 6 pages one by one. And each time the ROM read the page, it should do the swapping for this page.

In this case, the ROM will do the swapping six times.

Quoted 8 lines

Please read the sector again, you will see the "every page" in it:
--------------------------------------------------------------------
"In order to preserve the BI (bad block information), flash updater
or gang programmer applications need to swap Bad Block Information (BI) data to byte 0 of metadata area for every page before programming NAND Flash. ROM when loading firmware, copies back
--------------------------------------------------------------------

I can assure you that the >100.000 i.MX28 based modules, that we sold up to now boot from NAND just fine without any block mark swapping in the U-Boot pages.

Lothar Wa?mann

Signature · 9 lines
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________
#16 lore raw
Quoted 4 lines · Lothar Waßmann

I can assure you that the>100.000 i.MX28 based modules, that we sold up to now boot from NAND just fine without any block mark swapping in the U-Boot pages.

Our driver should follow the Reference manual, not the product.

thanks
Huang Shijie

#17 lore raw

Hi,

Quoted 7 lines · Huang Shijie

? 2014?03?27? 20:21, Lothar Wa?mann ??:

Quoted 4 lines

I can assure you that the>100.000 i.MX28 based modules, that we sold up to now boot from NAND just fine without any block mark swapping in the U-Boot pages.

Our driver should follow the Reference manual, not the product.

Still there is no need for the Linux NAND driver to be able to read or write partitions in a format that the Boot ROM can understand. Thus it is perfectly legal to allow disregarding the BB marks and solely rely on a flash based BBT.

Lothar Wa?mann

Signature · 9 lines
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________
#18 lore raw
Quoted 2 lines · Lothar Waßmann

Still there is no need for the Linux NAND driver to be able to read or write partitions in a format that the Boot ROM can understand. Thus it

If you do not use the NAND boot, there really no need to do so.

Since you need the NAND boot, we should enable the swapping for imx28.

Quoted 3 lines

is perfectly legal to allow disregarding the BB marks and solely rely on a flash based BBT.

The BB mark is in the page 0 of a NAND block. But the swapping can occur in _each_ page of a NAND block, _NOT_ only the page 0.

I think you are confusing at these two things.

thanks
Huang Shijie

maintainer
#19 lore raw
Quoted 6 lines · Huang Shijie

? 2014?03?28? 16:16, Lothar Wa?mann ??:

Quoted 2 lines

Still there is no need for the Linux NAND driver to be able to read or write partitions in a format that the Boot ROM can understand. Thus it

If you do not use the NAND boot, there really no need to do so.

Since you need the NAND boot, we should enable the swapping for imx28.

Quoted 8 lines
Quoted 3 lines

is perfectly legal to allow disregarding the BB marks and solely rely on a flash based BBT.

The BB mark is in the page 0 of a NAND block. But the swapping can occur in _each_ page of
a NAND block, _NOT_ only the page 0.

I think you are confusing at these two things.

I think you are confusing two things. If Lothar:

- disables swapping of BB marks in the FCB the ROM won't swap bytes.
- writes data without swapping
- Uses a DBBT for telling the ROM code where bad blocks are
- uses a Flash BBT for mtd

Then everything should work just fine.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#20 lore raw
Quoted 1 line · Sascha Hauer

- disables swapping of BB marks in the FCB the ROM won't swap bytes.

We can not disable the swapping in the FCB in the imx28. The DISBBM bit in the FCB does _NOT_ exit in the imx28's FCB.

thanks
Huang Shijie

#21 lore raw

Hi,

Quoted 5 lines · Huang Shijie

? 2014?03?28? 17:00, Sascha Hauer ??:

Quoted 1 line

- disables swapping of BB marks in the FCB the ROM won't swap bytes.

We can not disable the swapping in the FCB in the imx28. The DISBBM bit in the FCB does _NOT_ exit in the imx28's FCB.

The Linux kernel does not have any business with the FCB, so it is completely irrelevant for Linux whether byte swapping can be disabled in the FCB or not.

Lothar Wa?mann

Signature · 9 lines
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________
#22 lore raw
Quoted 12 lines · Lothar Waßmann

Hi,

Quoted 5 lines · Huang Shijie
Quoted 1 line · Sascha Hauer

- disables swapping of BB marks in the FCB the ROM won't swap bytes.

We can not disable the swapping in the FCB in the imx28. The DISBBM bit in the FCB does _NOT_ exit in the imx28's FCB.

The Linux kernel does not have any business with the FCB, so it is completely irrelevant for Linux whether byte swapping can be disabled in the FCB or not.

But the gpmi is relevant to the ROM.
the gpmi driver should keep consistency with the ROM.

I do not object you add the swapping optional the gpmi driver(since it's ok for imx50/imx6q/imx6sx), i just object that you enable this feature for imx28.

thanks
Huang Shijie

#23 lore raw

Hi,

Quoted 13 lines · Huang Shijie

? 2014?03?28? 17:31, Lothar Wa?mann ??:

Quoted 12 lines

Hi,

Quoted 5 lines · Huang Shijie

? 2014?03?28? 17:00, Sascha Hauer ??:

Quoted 1 line

- disables swapping of BB marks in the FCB the ROM won't swap bytes.

We can not disable the swapping in the FCB in the imx28. The DISBBM bit in the FCB does _NOT_ exit in the imx28's FCB.

The Linux kernel does not have any business with the FCB, so it is completely irrelevant for Linux whether byte swapping can be disabled in the FCB or not.

Quoted 7 lines

But the gpmi is relevant to the ROM.
the gpmi driver should keep consistency with the ROM.

I do not object you add the swapping optional the gpmi driver(since it's ok for imx50/imx6q/imx6sx),
i just object that you enable this feature for imx28.

We are talking about a Linux Kernel Driver here, not about a flashtool for i.MX28.
It is a valid usecase for Linux not being able to write the bootloader, so there is no reason to disallow this feature in the driver code. Since it is a DT option it can be trivially switched on and off without having to change anything in the kernel.

Lothar Wa?mann

Signature · 9 lines
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________
#24 lore raw
In reply to Huang Shijie

Hi,

Quoted 5 lines · Huang Shijie

? 2014?03?28? 16:16, Lothar Wa?mann ??:

Quoted 2 lines

Still there is no need for the Linux NAND driver to be able to read or write partitions in a format that the Boot ROM can understand. Thus it

If you do not use the NAND boot, there really no need to do so.

There is no need for the ROM code to access any other partition than the bootloader itself. Thus Linux can perfectly well be booted from NAND without any byte swapping.

Quoted 2 lines

Since you need the NAND boot, we should enable the swapping for imx28.

Why? There is no need for Linux to do any swapping when not accessing the bootloader partition.

Quoted 9 lines
Quoted 3 lines

is perfectly legal to allow disregarding the BB marks and solely rely on a flash based BBT.

The BB mark is in the page 0 of a NAND block. But the swapping can occur in _each_ page of
a NAND block, _NOT_ only the page 0.

I think you are confusing at these two things.

No, I'm not confusing anything. The swapping in any other page than page 0 is completely useless. Thus, when there is no need to recognize the BB markers, there in no need to do any swapping too.

Lothar Wa?mann

Signature · 9 lines
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________
#25 lore raw
Quoted 2 lines · Lothar Waßmann

There is no need for the ROM code to access any other partition than the bootloader itself. Thus Linux can perfectly well be booted from

Assume the ROM only access the partition which contains the bootloader, and the ROM does the swapping for the pages(but we do not do the swapping to these pages),

what will happen?

thanks
Huang Shijie

#26 lore raw
Quoted 5 lines · Huang Shijie
Quoted 2 lines · Lothar Waßmann

There is no need for the ROM code to access any other partition than the bootloader itself. Thus Linux can perfectly well be booted from

Assume the ROM only access the partition which contains the bootloader, and the ROM does the swapping for the pages(but we do not do the swapping to these pages),

I mean the kernel do not do the swapping when we burn the uboot to the NAND.

thanks
Huang Shijie

Quoted 4 lines

what will happen?

#27 lore raw

Hi,

Quoted 10 lines · Huang Shijie

? 2014?03?28? 17:33, Huang Shijie ??:

Quoted 7 lines

? 2014?03?28? 17:01, Lothar Wa?mann ??:

Quoted 2 lines

There is no need for the ROM code to access any other partition than the bootloader itself. Thus Linux can perfectly well be booted from

Assume the ROM only access the partition which contains the bootloader, and
the ROM does the swapping for the pages(but we do not do the swapping to these pages),

I mean the kernel do not do the swapping when we burn the uboot to the NAND.

The kernel need not be able to write the bootloader to NAND. If you want a kernel that can do it, you just need to boot it with one line in the DTB removed.

Lothar Wa?mann

Signature · 9 lines
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________
#29 lore raw

PATCH v3 1/2 mtd: gpmi: make blockmark swapping optional

With a flash-based BBT there is no reason to move the Factory Bad Block Marker from the data area buffer (to where it is mapped by the GPMI NAND controller) to the OOB buffer. Thus, make this feature configurable via DT. This is required for the Ka-Ro electronics platforms.

In the original code 'this->swap_block_mark' was synonymous with '!GPMI_IS_MX23()', so use the latter at the relevant places.

---
 .../devicetree/bindings/mtd/gpmi-nand.txt          |   10 ++++
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c             |   51 ++++++++++++--------
 2 files changed, 42 insertions(+), 19 deletions(-)
Documentation/devicetree/bindings/mtd/gpmi-nand.txt +10 -0
index 458d596..a011fdf 100644
@@ -25,6 +25,16 @@ Optional properties:
                        discoverable or this property is not enabled,
                        the software may chooses an implementation-defined
                        ECC scheme.
+  - fsl,no-blockmark-swap: Don't swap the bad block marker from the OOB
+                       area with the byte in the data area but rely on the
+                       flash based BBT for identifying bad blocks.
+                       NOTE: this is only valid in conjunction with
+                             'nand-on-flash-bbt'.
+                       WARNING: on i.MX28 blockmark swapping cannot be
+                       disabled for the BootROM in the FCB. Thus,
+                       partitions written from Linux with this feature
+                       turned on may not be accessible by the BootROM
+                       code.
 
 The device tree may optionally contain sub-nodes describing partitions of the
 address space. See partition.txt for more detail.
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +32 -19

97 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#30 lore raw

PATCH v3 1/2 mtd: gpmi: make blockmark swapping optional

Documentation/devicetree/bindings/mtd/gpmi-nand.txt Optional properties: · line 37

Quoted 10 lines · Lothar Wa?mann
Documentation/devicetree/bindings/mtd/gpmi-nand.txt +10 -0
+  - fsl,no-blockmark-swap: Don't swap the bad block marker from the OOB
+                       area with the byte in the data area but rely on the
+                       flash based BBT for identifying bad blocks.
+                       NOTE: this is only valid in conjunction with
+                             'nand-on-flash-bbt'.
+                       WARNING: on i.MX28 blockmark swapping cannot be
+                       disabled for the BootROM in the FCB. Thus,
+                       partitions written from Linux with this feature
+                       turned on may not be accessible by the BootROM
+                       code.

Thanks for adding this warning.

thanks
Huang Shijie

#31 lore raw

PATCH v3 2/2 of/mtd/nand: add generic binding and helper for NAND_BBT_NO_OOB_BBM

In reply to Lothar Waßmann

add a boolean property 'nand-no-oob-bbm' and helper function to be able to set the NAND_BBT_NO_OOB_BBM flag in DT capable NAND drivers and use it for i.MX and MXS nand drivers.

---
 Documentation/devicetree/bindings/mtd/nand.txt |    1 +
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c         |    3 +++
 drivers/mtd/nand/mxc_nand.c                    |    2 ++
 drivers/of/of_mtd.c                            |   12 ++++++++++++
 include/linux/of_mtd.h                         |    6 ++++++
 5 files changed, 24 insertions(+)
Documentation/devicetree/bindings/mtd/nand.txt +1 -0
index b53f92e..e46bfbe 100644
@@ -5,6 +5,7 @@
   "soft_bch".
 - nand-bus-width : 8 or 16 bus width if not present 8
 - nand-on-flash-bbt: boolean to enable on flash bbt option if not present false
+- nand-no-oob-bbm: boolean to disable writing bad block markers to flash
 
 - nand-ecc-strength: integer representing the number of bits to correct
 		     per ECC step.
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +3 -0
index 2a489b3..c23f27b 100644
@@ -1707,6 +1707,9 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
 	if (of_get_nand_on_flash_bbt(this->dev->of_node)) {
 		chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
 
+		if (of_get_nand_no_oob_bbm(this->dev->of_node))
+			chip->bbt_options |= NAND_BBT_NO_OOB_BBM;
+
 		if (of_property_read_bool(this->dev->of_node,
 						"fsl,no-blockmark-swap"))
 			this->swap_block_mark = false;
drivers/mtd/nand/mxc_nand.c +2 -0
index dba262b..bb54a2a 100644
@@ -1496,6 +1496,8 @@ static int mxcnd_probe(struct platform_device *pdev)
 		this->bbt_md = &bbt_mirror_descr;
 		/* update flash based bbt */
 		this->bbt_options |= NAND_BBT_USE_FLASH;
+		if (of_get_nand_no_oob_bbm(pdev->dev.of_node))
+			this->bbt_options |= NAND_BBT_NO_OOB_BBM;
 	}
 
 	init_completion(&host->op_completion);
drivers/of/of_mtd.c +12 -0
index b7361ed..d947acc 100644
@@ -117,3 +117,15 @@ bool of_get_nand_on_flash_bbt(struct device_node *np)
 	return of_property_read_bool(np, "nand-on-flash-bbt");
 }
 EXPORT_SYMBOL_GPL(of_get_nand_on_flash_bbt);
+
+/**
+ * of_get_nand_no_oob_bbm - Get nand no oob bbm for given device_node
+ * @np:	Pointer to the given device_node
+ *
+ * return true if present, false otherwise
+ */
+bool of_get_nand_no_oob_bbm(struct device_node *np)
+{
+	return of_property_read_bool(np, "nand-no-oob-bbm");
+}
+EXPORT_SYMBOL_GPL(of_get_nand_no_oob_bbm);
include/linux/of_mtd.h +6 -0
index e266caa..6ece1a9 100644
@@ -17,6 +17,7 @@ int of_get_nand_ecc_step_size(struct device_node *np);
 int of_get_nand_ecc_strength(struct device_node *np);
 int of_get_nand_bus_width(struct device_node *np);
 bool of_get_nand_on_flash_bbt(struct device_node *np);
+bool of_get_nand_no_oob_bbm(struct device_node *np);
 
 #else /* CONFIG_OF_MTD */
 
@@ -45,6 +46,11 @@ static inline bool of_get_nand_on_flash_bbt(struct device_node *np)
 	return false;
 }
 
+static inline bool of_get_nand_no_oob_bbm(struct device_node *np)
+{
+	return false;
+}
+
 #endif /* CONFIG_OF_MTD */
 
 #endif /* __LINUX_OF_MTD_H */
Signature · 1 line
1.7.10.4