* [PATCH v2 1/2] mtd: rawnand: marvell: document a bit more the driver
@ 2018-07-25 14:27 Miquel Raynal
2018-07-25 14:27 ` [PATCH v2 2/2] Documentation: mtd: remove stale pxa3xx NAND controller documentation Miquel Raynal
2018-07-26 13:28 ` [PATCH v2 1/2] mtd: rawnand: marvell: document a bit more the driver Boris Brezillon
0 siblings, 2 replies; 4+ messages in thread
From: Miquel Raynal @ 2018-07-25 14:27 UTC (permalink / raw)
To: Boris Brezillon, Richard Weinberger, David Woodhouse,
Brian Norris, Marek Vasut
Cc: linux-mtd, Miquel Raynal
A stale document about the old pxa3cc_nand.c driver is available in
Documentation/mtd/nand/. Rewrite the parts that explain the IP itself
and some non-trivial choices made in the driver directly in
marvell_nand.c to then be able to remove this file.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
Changes since v1:
=================
* Corrected mistakes pointed by Boris.
* Enlarged the documentation as suggested by Thomas to mention the
layouts as seen per the controller.
* Added a mention about the maximum ECC size which is 2kiB.
drivers/mtd/nand/raw/marvell_nand.c | 66 +++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
index 218e09431d3d..de74ea18c539 100644
--- a/drivers/mtd/nand/raw/marvell_nand.c
+++ b/drivers/mtd/nand/raw/marvell_nand.c
@@ -5,6 +5,72 @@
* Copyright (C) 2017 Marvell
* Author: Miquel RAYNAL <miquel.raynal@free-electrons.com>
*
+ *
+ * This NAND controller driver handles two versions of the hardware,
+ * one is called NFCv1 and is available on PXA SoCs and the other is
+ * called NFCv2 and is available on almost all the Armada SoCs.
+ *
+ * The main visible difference is that the NFCv1 only has Hamming ECC
+ * capabilities, while NFCv2 also embeds a BCH ECC engine. Also, DMA
+ * is not used with NFCv2.
+ *
+ * The internal ECC operations are depicted in details in Marvell
+ * AN-379.
+ *
+ * When using the Hamming engine, the data is cut in 512B chunks
+ * (either 0, 1 or 2) and each chunk will have its own ECC "digest" of
+ * 6B at the beginning of the OOB area and eventually the remaining
+ * free OOB bytes. This engine corrects up to 1 bit per chunk and
+ * detects reliably an error if there are at most 2 bitflips. Here is
+ * the controller view:
+ *
+ * +-------------------------------------------------------------+
+ * | Data 1 | ... | Data N | ECC 1 | ... | ECCN | Free OOB bytes |
+ * +-------------------------------------------------------------+
+ *
+ * When using the BCH engine, the generic pattern is that the
+ * controller sees only up to 2kiB chunks of data, followed by free
+ * OOB bytes (if any) and then ECC bytes. This pattern is repeated as
+ * much as needed with the same length for each section, until arrives
+ * the last patter which has the same organization but each section
+ * may be of different length. The layout presented to the user in the
+ * raw accessors is always: all the data, then in the OOB all the
+ * free OOB bytes and all the ECC digests. Here is the controller
+ * view:
+ *
+ * +-----------------------------------------
+ * | Data 1 | Free OOB bytes 1 | ECC 1 | ...
+ * +-----------------------------------------
+ *
+ * -------------------------------------------
+ * ... | Data N | Free OOB bytes N | ECC N |
+ * -------------------------------------------
+ *
+ * --------------------------------------------+
+ * Last Data | Last Free OOB bytes | Last ECC |
+ * --------------------------------------------+
+ *
+ * The controller has certain limitations that are handled by the
+ * driver:
+ * - It can only read 2k at a time. To overcome this limitation, the
+ * driver makes use of 'naked' operations.
+ * - The ECC strength in BCH mode cannot be tuned easily. It is a
+ * fixed 16 bits. What can be tuned is the area on which this
+ * correction occurs which is something between 512B and 2kiB based
+ * on the chip's requirements. Hence, using 2kiB ECC chunks leads
+ * to use a strength of 4b/512B.
+ * - The controller will always treat data bytes, free OOB bytes
+ * (also referred as "spare bytes") and ECC bytes in that order,
+ * no matter the real factory layout (which is usually all data
+ * then all OOB bytes). But depending on the chosen layout, the
+ * areas of each section may vary or be absent. The same
+ * data/spare/ecc layout is repeated until the last chunk, were
+ * the data, spare and ECC sections may be different again. The
+ * marvell_nfc_layouts array below contains the currently
+ * supported layouts.
+ * - Because of these weird layouts, the Bad Block Markers can be
+ * located in data. In this case, the NAND_BBT_NO_OOB_BBM option
+ * must be set.
*/
#include <linux/module.h>
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] Documentation: mtd: remove stale pxa3xx NAND controller documentation
2018-07-25 14:27 [PATCH v2 1/2] mtd: rawnand: marvell: document a bit more the driver Miquel Raynal
@ 2018-07-25 14:27 ` Miquel Raynal
2018-07-26 13:32 ` Boris Brezillon
2018-07-26 13:28 ` [PATCH v2 1/2] mtd: rawnand: marvell: document a bit more the driver Boris Brezillon
1 sibling, 1 reply; 4+ messages in thread
From: Miquel Raynal @ 2018-07-25 14:27 UTC (permalink / raw)
To: Boris Brezillon, Richard Weinberger, David Woodhouse,
Brian Norris, Marek Vasut
Cc: linux-mtd, Miquel Raynal
It is preferred to have the documentation about the drivers directly
embedded in the driver itself. Remove this file now that the most
important information from this file have been re-written in
marvell_nand.c.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
Changes since v1:
=================
* None.
Documentation/mtd/nand/pxa3xx-nand.txt | 113 ---------------------------------
1 file changed, 113 deletions(-)
delete mode 100644 Documentation/mtd/nand/pxa3xx-nand.txt
diff --git a/Documentation/mtd/nand/pxa3xx-nand.txt b/Documentation/mtd/nand/pxa3xx-nand.txt
deleted file mode 100644
index 1074cbc67ec6..000000000000
--- a/Documentation/mtd/nand/pxa3xx-nand.txt
+++ /dev/null
@@ -1,113 +0,0 @@
-
-About this document
-===================
-
-Some notes about Marvell's NAND controller available in PXA and Armada 370/XP
-SoC (aka NFCv1 and NFCv2), with an emphasis on the latter.
-
-NFCv2 controller background
-===========================
-
-The controller has a 2176 bytes FIFO buffer. Therefore, in order to support
-larger pages, I/O operations on 4 KiB and 8 KiB pages is done with a set of
-chunked transfers.
-
-For instance, if we choose a 2048 data chunk and set "BCH" ECC (see below)
-we'll have this layout in the pages:
-
- ------------------------------------------------------------------------------
- | 2048B data | 32B spare | 30B ECC || 2048B data | 32B spare | 30B ECC | ... |
- ------------------------------------------------------------------------------
-
-The driver reads the data and spare portions independently and builds an internal
-buffer with this layout (in the 4 KiB page case):
-
- ------------------------------------------
- | 4096B data | 64B spare |
- ------------------------------------------
-
-Also, for the READOOB command the driver disables the ECC and reads a 'spare + ECC'
-OOB, one per chunk read.
-
- -------------------------------------------------------------------
- | 4096B data | 32B spare | 30B ECC | 32B spare | 30B ECC |
- -------------------------------------------------------------------
-
-So, in order to achieve reading (for instance), we issue several READ0 commands
-(with some additional controller-specific magic) and read two chunks of 2080B
-(2048 data + 32 spare) each.
-The driver accommodates this data to expose the NAND core a contiguous buffer
-(4096 data + spare) or (4096 + spare + ECC + spare + ECC).
-
-ECC
-===
-
-The controller has built-in hardware ECC capabilities. In addition it is
-configurable between two modes: 1) Hamming, 2) BCH.
-
-Note that the actual BCH mode: BCH-4 or BCH-8 will depend on the way
-the controller is configured to transfer the data.
-
-In the BCH mode the ECC code will be calculated for each transferred chunk
-and expected to be located (when reading/programming) right after the spare
-bytes as the figure above shows.
-
-So, repeating the above scheme, a 2048B data chunk will be followed by 32B
-spare, and then the ECC controller will read/write the ECC code (30B in
-this case):
-
- ------------------------------------
- | 2048B data | 32B spare | 30B ECC |
- ------------------------------------
-
-If the ECC mode is 'BCH' then the ECC is *always* 30 bytes long.
-If the ECC mode is 'Hamming' the ECC is 6 bytes long, for each 512B block.
-So in Hamming mode, a 2048B page will have a 24B ECC.
-
-Despite all of the above, the controller requires the driver to only read or
-write in multiples of 8-bytes, because the data buffer is 64-bits.
-
-OOB
-===
-
-Because of the above scheme, and because the "spare" OOB is really located in
-the middle of a page, spare OOB cannot be read or write independently of the
-data area. In other words, in order to read the OOB (aka READOOB), the entire
-page (aka READ0) has to be read.
-
-In the same sense, in order to write to the spare OOB the driver has to write
-an *entire* page.
-
-Factory bad blocks handling
-===========================
-
-Given the ECC BCH requires to layout the device's pages in a split
-data/OOB/data/OOB way, the controller has a view of the flash page that's
-different from the specified (aka the manufacturer's) view. In other words,
-
-Factory view:
-
- -----------------------------------------------
- | Data |x OOB |
- -----------------------------------------------
-
-Driver's view:
-
- -----------------------------------------------
- | Data | OOB | Data x | OOB |
- -----------------------------------------------
-
-It can be seen from the above, that the factory bad block marker must be
-searched within the 'data' region, and not in the usual OOB region.
-
-In addition, this means under regular usage the driver will write such
-position (since it belongs to the data region) and every used block is
-likely to be marked as bad.
-
-For this reason, marking the block as bad in the OOB is explicitly
-disabled by using the NAND_BBT_NO_OOB_BBM option in the driver. The rationale
-for this is that there's no point in marking a block as bad, because good
-blocks are also 'marked as bad' (in the OOB BBM sense) under normal usage.
-
-Instead, the driver relies on the bad block table alone, and should only perform
-the bad block scan on the very first time (when the device hasn't been used).
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] mtd: rawnand: marvell: document a bit more the driver
2018-07-25 14:27 [PATCH v2 1/2] mtd: rawnand: marvell: document a bit more the driver Miquel Raynal
2018-07-25 14:27 ` [PATCH v2 2/2] Documentation: mtd: remove stale pxa3xx NAND controller documentation Miquel Raynal
@ 2018-07-26 13:28 ` Boris Brezillon
1 sibling, 0 replies; 4+ messages in thread
From: Boris Brezillon @ 2018-07-26 13:28 UTC (permalink / raw)
To: Miquel Raynal
Cc: Richard Weinberger, David Woodhouse, Brian Norris, Marek Vasut,
linux-mtd
Hi Miquel,
On Wed, 25 Jul 2018 16:27:53 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> A stale document about the old pxa3cc_nand.c driver is available in
> Documentation/mtd/nand/. Rewrite the parts that explain the IP itself
> and some non-trivial choices made in the driver directly in
> marvell_nand.c to then be able to remove this file.
>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>
> Changes since v1:
> =================
> * Corrected mistakes pointed by Boris.
> * Enlarged the documentation as suggested by Thomas to mention the
> layouts as seen per the controller.
> * Added a mention about the maximum ECC size which is 2kiB.
>
> drivers/mtd/nand/raw/marvell_nand.c | 66 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 66 insertions(+)
>
> diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
> index 218e09431d3d..de74ea18c539 100644
> --- a/drivers/mtd/nand/raw/marvell_nand.c
> +++ b/drivers/mtd/nand/raw/marvell_nand.c
> @@ -5,6 +5,72 @@
> * Copyright (C) 2017 Marvell
> * Author: Miquel RAYNAL <miquel.raynal@free-electrons.com>
> *
> + *
> + * This NAND controller driver handles two versions of the hardware,
> + * one is called NFCv1 and is available on PXA SoCs and the other is
> + * called NFCv2 and is available on almost all the Armada SoCs.
^ s/all//
> + *
> + * The main visible difference is that the NFCv1 only has Hamming ECC
^ s/the//
> + * capabilities, while NFCv2 also embeds a BCH ECC engine. Also, DMA
> + * is not used with NFCv2.
> + *
> + * The internal ECC operations are depicted in details in Marvell
> + * AN-379.
Actually, I'm not sure AN-379 describes how the ECC engines works, just
the different page layouts.
> + *
> + * When using the Hamming engine, the data is cut in 512B chunks
^ s/the Hamming engine/Hamming/ ^ s/cut/split/
> + * (either 0, 1 or 2) and each chunk will have its own ECC "digest" of
> + * 6B at the beginning of the OOB area and eventually the remaining
> + * free OOB bytes. This engine corrects up to 1 bit per chunk and
> + * detects reliably an error if there are at most 2 bitflips. Here is
> + * the controller view:
"
Here the page layout used by the controller when Hamming is chosen:
"
> + *
> + * +-------------------------------------------------------------+
> + * | Data 1 | ... | Data N | ECC 1 | ... | ECCN | Free OOB bytes |
> + * +-------------------------------------------------------------+
> + *
> + * When using the BCH engine, the generic pattern is that the
> + * controller sees only up to 2kiB chunks of data, followed by free
> + * OOB bytes (if any) and then ECC bytes. This pattern is repeated as
> + * much as needed with the same length for each section, until arrives
> + * the last patter which has the same organization but each section
^ pattern?
> + * may be of different length.
Hm, this paragraph is not clear.
> The layout presented to the user in the
> + * raw accessors is always: all the data, then in the OOB all the
> + * free OOB bytes and all the ECC digests.
Isn't that true for both algorithms?
> Here is the controller
> + * view:
Here the page layout used by the controller when BCH is chosen:
> + *
> + * +-----------------------------------------
> + * | Data 1 | Free OOB bytes 1 | ECC 1 | ...
> + * +-----------------------------------------
> + *
> + * -------------------------------------------
> + * ... | Data N | Free OOB bytes N | ECC N |
> + * -------------------------------------------
> + *
> + * --------------------------------------------+
> + * Last Data | Last Free OOB bytes | Last ECC |
> + * --------------------------------------------+
> + *
> + * The controller has certain limitations that are handled by the
> + * driver:
> + * - It can only read 2k at a time. To overcome this limitation, the
> + * driver makes use of 'naked' operations.
> + * - The ECC strength in BCH mode cannot be tuned easily. It is a
^ s/a//
> + * fixed 16 bits. What can be tuned is the area on which this
> + * correction occurs which is something between 512B and 2kiB based
What can be tuned in the ECC block size as long as it stays
between 512B and 2kiB. It's usually chosen based on the chip
ECC requirements.
> + * on the chip's requirements. Hence, using 2kiB ECC chunks leads
> + * to use a strength of 4b/512B.
For instance, using 2kiB ECC chunks provides 5b/512B
correctability.
> + * - The controller will always treat data bytes, free OOB bytes
> + * (also referred as "spare bytes") and ECC bytes in that order,
> + * no matter the real factory layout (which is usually all data
> + * then all OOB bytes).
The term "factory layout" is unfortunate. I guess you're talking about
"standard" layouts that place all data bytes at the beginning of a page
and all free-OOB/ECC bytes at the enf of the page (in the OOB section).
> But depending on the chosen layout, the
> + * areas of each section may vary or be absent. The same
> + * data/spare/ecc layout is repeated until the last chunk, were
^ where
> + * the data, spare and ECC sections may be different again. The
> + * marvell_nfc_layouts array below contains the currently
> + * supported layouts.
Again, it's not clear. How about saying you have N identical
data+spare+ecc sections and potentially an extra one to deal with
configurations where the chosen data+spare+ecc sizes do not align with
the page (data+oob) size.
> + * - Because of these weird layouts, the Bad Block Markers can be
> + * located in data. In this case, the NAND_BBT_NO_OOB_BBM option
^ data section.
> + * must be set.
to prevent scanning/writing bad block markers.
> */
>
> #include <linux/module.h>
Regards,
Boris
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 2/2] Documentation: mtd: remove stale pxa3xx NAND controller documentation
2018-07-25 14:27 ` [PATCH v2 2/2] Documentation: mtd: remove stale pxa3xx NAND controller documentation Miquel Raynal
@ 2018-07-26 13:32 ` Boris Brezillon
0 siblings, 0 replies; 4+ messages in thread
From: Boris Brezillon @ 2018-07-26 13:32 UTC (permalink / raw)
To: Miquel Raynal
Cc: Richard Weinberger, David Woodhouse, Brian Norris, Marek Vasut,
linux-mtd
On Wed, 25 Jul 2018 16:27:54 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> It is preferred to have the documentation about the drivers directly
> embedded in the driver itself. Remove this file now that the most
> important information from this file have been re-written in
> marvell_nand.c.
>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Boris Brezillon <boris.brezillon@bootlin.com>
> ---
>
> Changes since v1:
> =================
> * None.
>
> Documentation/mtd/nand/pxa3xx-nand.txt | 113 ---------------------------------
> 1 file changed, 113 deletions(-)
> delete mode 100644 Documentation/mtd/nand/pxa3xx-nand.txt
>
> diff --git a/Documentation/mtd/nand/pxa3xx-nand.txt b/Documentation/mtd/nand/pxa3xx-nand.txt
> deleted file mode 100644
> index 1074cbc67ec6..000000000000
> --- a/Documentation/mtd/nand/pxa3xx-nand.txt
> +++ /dev/null
> @@ -1,113 +0,0 @@
> -
> -About this document
> -===================
> -
> -Some notes about Marvell's NAND controller available in PXA and Armada 370/XP
> -SoC (aka NFCv1 and NFCv2), with an emphasis on the latter.
> -
> -NFCv2 controller background
> -===========================
> -
> -The controller has a 2176 bytes FIFO buffer. Therefore, in order to support
> -larger pages, I/O operations on 4 KiB and 8 KiB pages is done with a set of
> -chunked transfers.
> -
> -For instance, if we choose a 2048 data chunk and set "BCH" ECC (see below)
> -we'll have this layout in the pages:
> -
> - ------------------------------------------------------------------------------
> - | 2048B data | 32B spare | 30B ECC || 2048B data | 32B spare | 30B ECC | ... |
> - ------------------------------------------------------------------------------
> -
> -The driver reads the data and spare portions independently and builds an internal
> -buffer with this layout (in the 4 KiB page case):
> -
> - ------------------------------------------
> - | 4096B data | 64B spare |
> - ------------------------------------------
> -
> -Also, for the READOOB command the driver disables the ECC and reads a 'spare + ECC'
> -OOB, one per chunk read.
> -
> - -------------------------------------------------------------------
> - | 4096B data | 32B spare | 30B ECC | 32B spare | 30B ECC |
> - -------------------------------------------------------------------
> -
> -So, in order to achieve reading (for instance), we issue several READ0 commands
> -(with some additional controller-specific magic) and read two chunks of 2080B
> -(2048 data + 32 spare) each.
> -The driver accommodates this data to expose the NAND core a contiguous buffer
> -(4096 data + spare) or (4096 + spare + ECC + spare + ECC).
> -
> -ECC
> -===
> -
> -The controller has built-in hardware ECC capabilities. In addition it is
> -configurable between two modes: 1) Hamming, 2) BCH.
> -
> -Note that the actual BCH mode: BCH-4 or BCH-8 will depend on the way
> -the controller is configured to transfer the data.
> -
> -In the BCH mode the ECC code will be calculated for each transferred chunk
> -and expected to be located (when reading/programming) right after the spare
> -bytes as the figure above shows.
> -
> -So, repeating the above scheme, a 2048B data chunk will be followed by 32B
> -spare, and then the ECC controller will read/write the ECC code (30B in
> -this case):
> -
> - ------------------------------------
> - | 2048B data | 32B spare | 30B ECC |
> - ------------------------------------
> -
> -If the ECC mode is 'BCH' then the ECC is *always* 30 bytes long.
> -If the ECC mode is 'Hamming' the ECC is 6 bytes long, for each 512B block.
> -So in Hamming mode, a 2048B page will have a 24B ECC.
> -
> -Despite all of the above, the controller requires the driver to only read or
> -write in multiples of 8-bytes, because the data buffer is 64-bits.
> -
> -OOB
> -===
> -
> -Because of the above scheme, and because the "spare" OOB is really located in
> -the middle of a page, spare OOB cannot be read or write independently of the
> -data area. In other words, in order to read the OOB (aka READOOB), the entire
> -page (aka READ0) has to be read.
> -
> -In the same sense, in order to write to the spare OOB the driver has to write
> -an *entire* page.
> -
> -Factory bad blocks handling
> -===========================
> -
> -Given the ECC BCH requires to layout the device's pages in a split
> -data/OOB/data/OOB way, the controller has a view of the flash page that's
> -different from the specified (aka the manufacturer's) view. In other words,
> -
> -Factory view:
> -
> - -----------------------------------------------
> - | Data |x OOB |
> - -----------------------------------------------
> -
> -Driver's view:
> -
> - -----------------------------------------------
> - | Data | OOB | Data x | OOB |
> - -----------------------------------------------
> -
> -It can be seen from the above, that the factory bad block marker must be
> -searched within the 'data' region, and not in the usual OOB region.
> -
> -In addition, this means under regular usage the driver will write such
> -position (since it belongs to the data region) and every used block is
> -likely to be marked as bad.
> -
> -For this reason, marking the block as bad in the OOB is explicitly
> -disabled by using the NAND_BBT_NO_OOB_BBM option in the driver. The rationale
> -for this is that there's no point in marking a block as bad, because good
> -blocks are also 'marked as bad' (in the OOB BBM sense) under normal usage.
> -
> -Instead, the driver relies on the bad block table alone, and should only perform
> -the bad block scan on the very first time (when the device hasn't been used).
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-26 13:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-25 14:27 [PATCH v2 1/2] mtd: rawnand: marvell: document a bit more the driver Miquel Raynal
2018-07-25 14:27 ` [PATCH v2 2/2] Documentation: mtd: remove stale pxa3xx NAND controller documentation Miquel Raynal
2018-07-26 13:32 ` Boris Brezillon
2018-07-26 13:28 ` [PATCH v2 1/2] mtd: rawnand: marvell: document a bit more the driver Boris Brezillon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox