LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] mtd: rawnand: mxc: set spare area size register explicitly
@ 2018-06-03 11:31 Martin Kaiser
  2018-06-04  6:53 ` Sascha Hauer
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Martin Kaiser @ 2018-06-03 11:31 UTC (permalink / raw)
  To: Boris Brezillon, David Woodhouse, Sascha Hauer, Fabio Estevam
  Cc: linux-mtd, linux-kernel, Martin Kaiser, stable

The v21 version of the NAND flash controller contains a Spare Area Size
Register (SPAS) at offset 0x10. Its setting defaults to the maximum
spare area size of 218 bytes. The size that is set in this register is
used by the controller when it calculates the ECC bytes internally in
hardware.

Usually, this register is updated from settings in the IIM fuses when
the system is booting from nand flash. For other boot media, however,
the SPAS register remains at the default setting, which may not work for
the particular flash chip on the board. The same goes for flash chips
whose configuration cannot be set in the IIM fuses (e.g. chips with 2k
sector size and 128 bytes spare area size can't be configured in the IIM
fuses on imx25 systems).

Set the SPAS register explicitly during the preset operation. Derive the
register value from mtd->oobsize that was detected during probe by
decoding the flash chip's ID bytes.

While at it, rename the define for the spare area register's offset to
NFC_V21_RSLTSPARE_AREA. The register at offset 0x10 on v1 controllers is
different from the register on v21 controllers.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Cc: stable@vger.kernel.org
---
 drivers/mtd/nand/raw/mxc_nand.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/mxc_nand.c b/drivers/mtd/nand/raw/mxc_nand.c
index 45786e7..c2f8572 100644
--- a/drivers/mtd/nand/raw/mxc_nand.c
+++ b/drivers/mtd/nand/raw/mxc_nand.c
@@ -48,7 +48,7 @@
 #define NFC_V1_V2_CONFIG		(host->regs + 0x0a)
 #define NFC_V1_V2_ECC_STATUS_RESULT	(host->regs + 0x0c)
 #define NFC_V1_V2_RSLTMAIN_AREA		(host->regs + 0x0e)
-#define NFC_V1_V2_RSLTSPARE_AREA	(host->regs + 0x10)
+#define NFC_V21_RSLTSPARE_AREA		(host->regs + 0x10)
 #define NFC_V1_V2_WRPROT		(host->regs + 0x12)
 #define NFC_V1_UNLOCKSTART_BLKADDR	(host->regs + 0x14)
 #define NFC_V1_UNLOCKEND_BLKADDR	(host->regs + 0x16)
@@ -1274,6 +1274,9 @@ static void preset_v2(struct mtd_info *mtd)
 	writew(config1, NFC_V1_V2_CONFIG1);
 	/* preset operation */
 
+	/* spare area size in 16bit words */
+	writew(mtd->oobsize >> 1, NFC_V21_RSLTSPARE_AREA);
+
 	/* Unlock the internal RAM Buffer */
 	writew(0x2, NFC_V1_V2_CONFIG);
 
-- 
2.1.4

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

* Re: [PATCH] mtd: rawnand: mxc: set spare area size register explicitly
  2018-06-03 11:31 [PATCH] mtd: rawnand: mxc: set spare area size register explicitly Martin Kaiser
@ 2018-06-04  6:53 ` Sascha Hauer
  2018-06-07 15:19 ` Miquel Raynal
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: Sascha Hauer @ 2018-06-04  6:53 UTC (permalink / raw)
  To: Martin Kaiser
  Cc: Boris Brezillon, David Woodhouse, Fabio Estevam, linux-mtd,
	linux-kernel, stable

On Sun, Jun 03, 2018 at 01:31:35PM +0200, Martin Kaiser wrote:
> The v21 version of the NAND flash controller contains a Spare Area Size
> Register (SPAS) at offset 0x10. Its setting defaults to the maximum
> spare area size of 218 bytes. The size that is set in this register is
> used by the controller when it calculates the ECC bytes internally in
> hardware.
> 
> Usually, this register is updated from settings in the IIM fuses when
> the system is booting from nand flash. For other boot media, however,
> the SPAS register remains at the default setting, which may not work for
> the particular flash chip on the board. The same goes for flash chips
> whose configuration cannot be set in the IIM fuses (e.g. chips with 2k
> sector size and 128 bytes spare area size can't be configured in the IIM
> fuses on imx25 systems).
> 
> Set the SPAS register explicitly during the preset operation. Derive the
> register value from mtd->oobsize that was detected during probe by
> decoding the flash chip's ID bytes.
> 
> While at it, rename the define for the spare area register's offset to
> NFC_V21_RSLTSPARE_AREA. The register at offset 0x10 on v1 controllers is
> different from the register on v21 controllers.
> 
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> Cc: stable@vger.kernel.org

Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>

Sascha

> ---
>  drivers/mtd/nand/raw/mxc_nand.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/raw/mxc_nand.c b/drivers/mtd/nand/raw/mxc_nand.c
> index 45786e7..c2f8572 100644
> --- a/drivers/mtd/nand/raw/mxc_nand.c
> +++ b/drivers/mtd/nand/raw/mxc_nand.c
> @@ -48,7 +48,7 @@
>  #define NFC_V1_V2_CONFIG		(host->regs + 0x0a)
>  #define NFC_V1_V2_ECC_STATUS_RESULT	(host->regs + 0x0c)
>  #define NFC_V1_V2_RSLTMAIN_AREA		(host->regs + 0x0e)
> -#define NFC_V1_V2_RSLTSPARE_AREA	(host->regs + 0x10)
> +#define NFC_V21_RSLTSPARE_AREA		(host->regs + 0x10)
>  #define NFC_V1_V2_WRPROT		(host->regs + 0x12)
>  #define NFC_V1_UNLOCKSTART_BLKADDR	(host->regs + 0x14)
>  #define NFC_V1_UNLOCKEND_BLKADDR	(host->regs + 0x16)
> @@ -1274,6 +1274,9 @@ static void preset_v2(struct mtd_info *mtd)
>  	writew(config1, NFC_V1_V2_CONFIG1);
>  	/* preset operation */
>  
> +	/* spare area size in 16bit words */
> +	writew(mtd->oobsize >> 1, NFC_V21_RSLTSPARE_AREA);
> +
>  	/* Unlock the internal RAM Buffer */
>  	writew(0x2, NFC_V1_V2_CONFIG);
>  
> -- 
> 2.1.4
> 
> 

-- 
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 |

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

* Re: [PATCH] mtd: rawnand: mxc: set spare area size register explicitly
  2018-06-03 11:31 [PATCH] mtd: rawnand: mxc: set spare area size register explicitly Martin Kaiser
  2018-06-04  6:53 ` Sascha Hauer
@ 2018-06-07 15:19 ` Miquel Raynal
  2018-06-10 13:14   ` Martin Kaiser
  2018-06-10 13:31 ` [PATCH v2] " Martin Kaiser
  2018-06-18 20:41 ` [PATCH v3] " Martin Kaiser
  3 siblings, 1 reply; 12+ messages in thread
From: Miquel Raynal @ 2018-06-07 15:19 UTC (permalink / raw)
  To: Martin Kaiser
  Cc: Boris Brezillon, David Woodhouse, Sascha Hauer, Fabio Estevam,
	linux-mtd, linux-kernel, stable

Hi Martin,

On Sun,  3 Jun 2018 13:31:35 +0200, Martin Kaiser <martin@kaiser.cx>
wrote:

> The v21 version of the NAND flash controller contains a Spare Area Size
> Register (SPAS) at offset 0x10. Its setting defaults to the maximum
> spare area size of 218 bytes. The size that is set in this register is
> used by the controller when it calculates the ECC bytes internally in
> hardware.
> 
> Usually, this register is updated from settings in the IIM fuses when
> the system is booting from nand flash. For other boot media, however,

s/nand/NAND

> the SPAS register remains at the default setting, which may not work for
> the particular flash chip on the board. The same goes for flash chips
> whose configuration cannot be set in the IIM fuses (e.g. chips with 2k
> sector size and 128 bytes spare area size can't be configured in the IIM
> fuses on imx25 systems).
> 
> Set the SPAS register explicitly during the preset operation. Derive the
> register value from mtd->oobsize that was detected during probe by
> decoding the flash chip's ID bytes.
> 
> While at it, rename the define for the spare area register's offset to
> NFC_V21_RSLTSPARE_AREA. The register at offset 0x10 on v1 controllers is
> different from the register on v21 controllers.
> 
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> Cc: stable@vger.kernel.org
> ---
>  drivers/mtd/nand/raw/mxc_nand.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/raw/mxc_nand.c b/drivers/mtd/nand/raw/mxc_nand.c
> index 45786e7..c2f8572 100644
> --- a/drivers/mtd/nand/raw/mxc_nand.c
> +++ b/drivers/mtd/nand/raw/mxc_nand.c
> @@ -48,7 +48,7 @@
>  #define NFC_V1_V2_CONFIG		(host->regs + 0x0a)
>  #define NFC_V1_V2_ECC_STATUS_RESULT	(host->regs + 0x0c)
>  #define NFC_V1_V2_RSLTMAIN_AREA		(host->regs + 0x0e)
> -#define NFC_V1_V2_RSLTSPARE_AREA	(host->regs + 0x10)
> +#define NFC_V21_RSLTSPARE_AREA		(host->regs + 0x10)
>  #define NFC_V1_V2_WRPROT		(host->regs + 0x12)
>  #define NFC_V1_UNLOCKSTART_BLKADDR	(host->regs + 0x14)
>  #define NFC_V1_UNLOCKEND_BLKADDR	(host->regs + 0x16)
> @@ -1274,6 +1274,9 @@ static void preset_v2(struct mtd_info *mtd)
>  	writew(config1, NFC_V1_V2_CONFIG1);
>  	/* preset operation */
>  
> +	/* spare area size in 16bit words */

I thought I understood the problem with your commit message but
then I don't get this comment. What's the link between 16-bit buses? Is
this preset valid for both 8 and 16-bit bus width?

> +	writew(mtd->oobsize >> 1, NFC_V21_RSLTSPARE_AREA);
> +

If this is for dividing per two oobsize value, I would really prefer a
'/ 2' and let the compiler optimize things. Unless the spec is explicit
about some shifting of course.

>  	/* Unlock the internal RAM Buffer */
>  	writew(0x2, NFC_V1_V2_CONFIG);
>  

Thanks for fixing this.

Regards,
Miquèl

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

* Re: [PATCH] mtd: rawnand: mxc: set spare area size register explicitly
  2018-06-07 15:19 ` Miquel Raynal
@ 2018-06-10 13:14   ` Martin Kaiser
  0 siblings, 0 replies; 12+ messages in thread
From: Martin Kaiser @ 2018-06-10 13:14 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Boris Brezillon, David Woodhouse, Sascha Hauer, Fabio Estevam,
	linux-mtd, linux-kernel, stable

Hi Miquel,

Thus wrote Miquel Raynal (miquel.raynal@bootlin.com):

> > Usually, this register is updated from settings in the IIM fuses when
> > the system is booting from nand flash. For other boot media, however,

> s/nand/NAND

ok

> > +	/* spare area size in 16bit words */

> I thought I understood the problem with your commit message but
> then I don't get this comment. What's the link between 16-bit buses? Is
> this preset valid for both 8 and 16-bit bus width?

The register value is unrelated to the bus width.

> > +	writew(mtd->oobsize >> 1, NFC_V21_RSLTSPARE_AREA);
> > +

> If this is for dividing per two oobsize value,

That's exactly what I wanted to do: mtd->oobsize is in bytes, the
register value must be in 16bit words (the specification uses the term
half-words, I'll update the comment while at it).

> I would really prefer a '/ 2' and let the compiler optimize things.
> Unless the spec is explicit about some shifting of course.

Ok, I'll  use / 2 and resend the patch shortly.

Best regards,
Martin

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

* [PATCH v2] mtd: rawnand: mxc: set spare area size register explicitly
  2018-06-03 11:31 [PATCH] mtd: rawnand: mxc: set spare area size register explicitly Martin Kaiser
  2018-06-04  6:53 ` Sascha Hauer
  2018-06-07 15:19 ` Miquel Raynal
@ 2018-06-10 13:31 ` Martin Kaiser
  2018-06-18 14:06   ` Miquel Raynal
  2018-06-18 14:09   ` Boris Brezillon
  2018-06-18 20:41 ` [PATCH v3] " Martin Kaiser
  3 siblings, 2 replies; 12+ messages in thread
From: Martin Kaiser @ 2018-06-10 13:31 UTC (permalink / raw)
  To: Boris Brezillon, David Woodhouse, Sascha Hauer, Fabio Estevam,
	Miquel Raynal
  Cc: linux-mtd, linux-kernel, Martin Kaiser, stable

The v21 version of the NAND flash controller contains a Spare Area Size
Register (SPAS) at offset 0x10. Its setting defaults to the maximum
spare area size of 218 bytes. The size that is set in this register is
used by the controller when it calculates the ECC bytes internally in
hardware.

Usually, this register is updated from settings in the IIM fuses when
the system is booting from NAND flash. For other boot media, however,
the SPAS register remains at the default setting, which may not work for
the particular flash chip on the board. The same goes for flash chips
whose configuration cannot be set in the IIM fuses (e.g. chips with 2k
sector size and 128 bytes spare area size can't be configured in the IIM
fuses on imx25 systems).

Set the SPAS register explicitly during the preset operation. Derive the
register value from mtd->oobsize that was detected during probe by
decoding the flash chip's ID bytes.

While at it, rename the define for the spare area register's offset to
NFC_V21_RSLTSPARE_AREA. The register at offset 0x10 on v1 controllers is
different from the register on v21 controllers.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
Cc: stable@vger.kernel.org
---
changes in v2
   - fix the commit message
   - use '/ 2' instead of shift operator for division

BTW is it ok to keep a Reviewed-by tag when updating the patch?

 drivers/mtd/nand/raw/mxc_nand.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/mxc_nand.c b/drivers/mtd/nand/raw/mxc_nand.c
index 45786e7..26cef21 100644
--- a/drivers/mtd/nand/raw/mxc_nand.c
+++ b/drivers/mtd/nand/raw/mxc_nand.c
@@ -48,7 +48,7 @@
 #define NFC_V1_V2_CONFIG		(host->regs + 0x0a)
 #define NFC_V1_V2_ECC_STATUS_RESULT	(host->regs + 0x0c)
 #define NFC_V1_V2_RSLTMAIN_AREA		(host->regs + 0x0e)
-#define NFC_V1_V2_RSLTSPARE_AREA	(host->regs + 0x10)
+#define NFC_V21_RSLTSPARE_AREA		(host->regs + 0x10)
 #define NFC_V1_V2_WRPROT		(host->regs + 0x12)
 #define NFC_V1_UNLOCKSTART_BLKADDR	(host->regs + 0x14)
 #define NFC_V1_UNLOCKEND_BLKADDR	(host->regs + 0x16)
@@ -1274,6 +1274,9 @@ static void preset_v2(struct mtd_info *mtd)
 	writew(config1, NFC_V1_V2_CONFIG1);
 	/* preset operation */
 
+	/* spare area size in 16-bit half-words */
+	writew(mtd->oobsize / 2, NFC_V21_RSLTSPARE_AREA);
+
 	/* Unlock the internal RAM Buffer */
 	writew(0x2, NFC_V1_V2_CONFIG);
 
-- 
2.1.4

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

* Re: [PATCH v2] mtd: rawnand: mxc: set spare area size register explicitly
  2018-06-10 13:31 ` [PATCH v2] " Martin Kaiser
@ 2018-06-18 14:06   ` Miquel Raynal
  2018-06-18 14:09   ` Boris Brezillon
  1 sibling, 0 replies; 12+ messages in thread
From: Miquel Raynal @ 2018-06-18 14:06 UTC (permalink / raw)
  To: Martin Kaiser
  Cc: Boris Brezillon, David Woodhouse, Sascha Hauer, Fabio Estevam,
	linux-mtd, linux-kernel, stable

Hi Martin,

On Sun, 10 Jun 2018 15:31:27 +0200, Martin Kaiser <martin@kaiser.cx>
wrote:

> The v21 version of the NAND flash controller contains a Spare Area Size
> Register (SPAS) at offset 0x10. Its setting defaults to the maximum
> spare area size of 218 bytes. The size that is set in this register is
> used by the controller when it calculates the ECC bytes internally in
> hardware.
> 
> Usually, this register is updated from settings in the IIM fuses when
> the system is booting from NAND flash. For other boot media, however,
> the SPAS register remains at the default setting, which may not work for
> the particular flash chip on the board. The same goes for flash chips
> whose configuration cannot be set in the IIM fuses (e.g. chips with 2k
> sector size and 128 bytes spare area size can't be configured in the IIM
> fuses on imx25 systems).
> 
> Set the SPAS register explicitly during the preset operation. Derive the
> register value from mtd->oobsize that was detected during probe by
> decoding the flash chip's ID bytes.
> 
> While at it, rename the define for the spare area register's offset to
> NFC_V21_RSLTSPARE_AREA. The register at offset 0x10 on v1 controllers is
> different from the register on v21 controllers.
> 
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: stable@vger.kernel.org
> ---

Thanks, I'm ok with the patch, I'll queue it to nand/next.

> changes in v2
>    - fix the commit message
>    - use '/ 2' instead of shift operator for division
> 
> BTW is it ok to keep a Reviewed-by tag when updating the patch?

I think so, at least for such minor updates it is okay :)

Regards,
Miquèl

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

* Re: [PATCH v2] mtd: rawnand: mxc: set spare area size register explicitly
  2018-06-10 13:31 ` [PATCH v2] " Martin Kaiser
  2018-06-18 14:06   ` Miquel Raynal
@ 2018-06-18 14:09   ` Boris Brezillon
  2018-06-18 20:36     ` Martin Kaiser
  1 sibling, 1 reply; 12+ messages in thread
From: Boris Brezillon @ 2018-06-18 14:09 UTC (permalink / raw)
  To: Martin Kaiser
  Cc: David Woodhouse, Sascha Hauer, Fabio Estevam, Miquel Raynal,
	linux-mtd, linux-kernel, stable

Hi Martin,

On Sun, 10 Jun 2018 15:31:27 +0200
Martin Kaiser <martin@kaiser.cx> wrote:

> The v21 version of the NAND flash controller contains a Spare Area Size
> Register (SPAS) at offset 0x10. Its setting defaults to the maximum
> spare area size of 218 bytes. The size that is set in this register is
> used by the controller when it calculates the ECC bytes internally in
> hardware.
> 
> Usually, this register is updated from settings in the IIM fuses when
> the system is booting from NAND flash. For other boot media, however,
> the SPAS register remains at the default setting, which may not work for
> the particular flash chip on the board. The same goes for flash chips
> whose configuration cannot be set in the IIM fuses (e.g. chips with 2k
> sector size and 128 bytes spare area size can't be configured in the IIM
> fuses on imx25 systems).
> 
> Set the SPAS register explicitly during the preset operation. Derive the
> register value from mtd->oobsize that was detected during probe by
> decoding the flash chip's ID bytes.
> 
> While at it, rename the define for the spare area register's offset to
> NFC_V21_RSLTSPARE_AREA. The register at offset 0x10 on v1 controllers is
> different from the register on v21 controllers.
> 
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: stable@vger.kernel.org

Hm, a Cc-stable tag without its associated Fixes tag, I don't like that.
Can you find which commit introduced this bug?

Thanks,

Boris

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

* Re: [PATCH v2] mtd: rawnand: mxc: set spare area size register explicitly
  2018-06-18 14:09   ` Boris Brezillon
@ 2018-06-18 20:36     ` Martin Kaiser
  0 siblings, 0 replies; 12+ messages in thread
From: Martin Kaiser @ 2018-06-18 20:36 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: David Woodhouse, Sascha Hauer, Fabio Estevam, Miquel Raynal,
	linux-mtd, linux-kernel, stable

Hi Boris,

Thus wrote Boris Brezillon (boris.brezillon@bootlin.com):

> > Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> > Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
> > Cc: stable@vger.kernel.org

> Hm, a Cc-stable tag without its associated Fixes tag, I don't like that.
> Can you find which commit introduced this bug?

the particular corner case that I fixed has never really worked. As my
fix updates the preset operation, I'd suggest adding a Fixes tag pointing
at the first commit that introduced the preset operation.

I'll resend my patch with this tag added.

Best regards,

   Martin

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

* [PATCH v3] mtd: rawnand: mxc: set spare area size register explicitly
  2018-06-03 11:31 [PATCH] mtd: rawnand: mxc: set spare area size register explicitly Martin Kaiser
                   ` (2 preceding siblings ...)
  2018-06-10 13:31 ` [PATCH v2] " Martin Kaiser
@ 2018-06-18 20:41 ` Martin Kaiser
  2018-06-19  5:52   ` Boris Brezillon
  2018-06-19  9:07   ` Miquel Raynal
  3 siblings, 2 replies; 12+ messages in thread
From: Martin Kaiser @ 2018-06-18 20:41 UTC (permalink / raw)
  To: Boris Brezillon, David Woodhouse, Sascha Hauer, Fabio Estevam,
	Miquel Raynal
  Cc: linux-mtd, linux-kernel, Martin Kaiser, stable

The v21 version of the NAND flash controller contains a Spare Area Size
Register (SPAS) at offset 0x10. Its setting defaults to the maximum
spare area size of 218 bytes. The size that is set in this register is
used by the controller when it calculates the ECC bytes internally in
hardware.

Usually, this register is updated from settings in the IIM fuses when
the system is booting from NAND flash. For other boot media, however,
the SPAS register remains at the default setting, which may not work for
the particular flash chip on the board. The same goes for flash chips
whose configuration cannot be set in the IIM fuses (e.g. chips with 2k
sector size and 128 bytes spare area size can't be configured in the IIM
fuses on imx25 systems).

Set the SPAS register explicitly during the preset operation. Derive the
register value from mtd->oobsize that was detected during probe by
decoding the flash chip's ID bytes.

While at it, rename the define for the spare area register's offset to
NFC_V21_RSLTSPARE_AREA. The register at offset 0x10 on v1 controllers is
different from the register on v21 controllers.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Cc: stable@vger.kernel.org
Fixes: d484018 ("mtd: mxc_nand: set NFC registers after reset")
---
changes in v3
   - add a Fixes tag pointing to the commit that introduced the
     preset() operation

changes in v2
   - fix the commit message
   - use '/ 2' instead of shift operator for division

 drivers/mtd/nand/raw/mxc_nand.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/mxc_nand.c b/drivers/mtd/nand/raw/mxc_nand.c
index 45786e7..26cef21 100644
--- a/drivers/mtd/nand/raw/mxc_nand.c
+++ b/drivers/mtd/nand/raw/mxc_nand.c
@@ -48,7 +48,7 @@
 #define NFC_V1_V2_CONFIG		(host->regs + 0x0a)
 #define NFC_V1_V2_ECC_STATUS_RESULT	(host->regs + 0x0c)
 #define NFC_V1_V2_RSLTMAIN_AREA		(host->regs + 0x0e)
-#define NFC_V1_V2_RSLTSPARE_AREA	(host->regs + 0x10)
+#define NFC_V21_RSLTSPARE_AREA		(host->regs + 0x10)
 #define NFC_V1_V2_WRPROT		(host->regs + 0x12)
 #define NFC_V1_UNLOCKSTART_BLKADDR	(host->regs + 0x14)
 #define NFC_V1_UNLOCKEND_BLKADDR	(host->regs + 0x16)
@@ -1274,6 +1274,9 @@ static void preset_v2(struct mtd_info *mtd)
 	writew(config1, NFC_V1_V2_CONFIG1);
 	/* preset operation */
 
+	/* spare area size in 16-bit half-words */
+	writew(mtd->oobsize / 2, NFC_V21_RSLTSPARE_AREA);
+
 	/* Unlock the internal RAM Buffer */
 	writew(0x2, NFC_V1_V2_CONFIG);
 
-- 
2.1.4


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

* Re: [PATCH v3] mtd: rawnand: mxc: set spare area size register explicitly
  2018-06-18 20:41 ` [PATCH v3] " Martin Kaiser
@ 2018-06-19  5:52   ` Boris Brezillon
  2018-06-19  9:07   ` Miquel Raynal
  1 sibling, 0 replies; 12+ messages in thread
From: Boris Brezillon @ 2018-06-19  5:52 UTC (permalink / raw)
  To: Martin Kaiser
  Cc: David Woodhouse, Sascha Hauer, Fabio Estevam, Miquel Raynal,
	linux-mtd, linux-kernel, stable

On Mon, 18 Jun 2018 22:41:03 +0200
Martin Kaiser <martin@kaiser.cx> wrote:

> The v21 version of the NAND flash controller contains a Spare Area Size
> Register (SPAS) at offset 0x10. Its setting defaults to the maximum
> spare area size of 218 bytes. The size that is set in this register is
> used by the controller when it calculates the ECC bytes internally in
> hardware.
> 
> Usually, this register is updated from settings in the IIM fuses when
> the system is booting from NAND flash. For other boot media, however,
> the SPAS register remains at the default setting, which may not work for
> the particular flash chip on the board. The same goes for flash chips
> whose configuration cannot be set in the IIM fuses (e.g. chips with 2k
> sector size and 128 bytes spare area size can't be configured in the IIM
> fuses on imx25 systems).
> 
> Set the SPAS register explicitly during the preset operation. Derive the
> register value from mtd->oobsize that was detected during probe by
> decoding the flash chip's ID bytes.
> 
> While at it, rename the define for the spare area register's offset to
> NFC_V21_RSLTSPARE_AREA. The register at offset 0x10 on v1 controllers is
> different from the register on v21 controllers.
> 
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> Cc: stable@vger.kernel.org
> Fixes: d484018 ("mtd: mxc_nand: set NFC registers after reset")

You could have kept Sacha's R-b, it's not like the patch completely
changed between v1 and v3. Also, just nitpicking, but I prefer when
Fixes and Cc-stable tags are placed before author's SoB. No need
to send a new version for that, I'll fix it when applying.

Thanks,

Boris

> ---
> changes in v3
>    - add a Fixes tag pointing to the commit that introduced the
>      preset() operation
> 
> changes in v2
>    - fix the commit message
>    - use '/ 2' instead of shift operator for division
> 
>  drivers/mtd/nand/raw/mxc_nand.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/raw/mxc_nand.c b/drivers/mtd/nand/raw/mxc_nand.c
> index 45786e7..26cef21 100644
> --- a/drivers/mtd/nand/raw/mxc_nand.c
> +++ b/drivers/mtd/nand/raw/mxc_nand.c
> @@ -48,7 +48,7 @@
>  #define NFC_V1_V2_CONFIG		(host->regs + 0x0a)
>  #define NFC_V1_V2_ECC_STATUS_RESULT	(host->regs + 0x0c)
>  #define NFC_V1_V2_RSLTMAIN_AREA		(host->regs + 0x0e)
> -#define NFC_V1_V2_RSLTSPARE_AREA	(host->regs + 0x10)
> +#define NFC_V21_RSLTSPARE_AREA		(host->regs + 0x10)
>  #define NFC_V1_V2_WRPROT		(host->regs + 0x12)
>  #define NFC_V1_UNLOCKSTART_BLKADDR	(host->regs + 0x14)
>  #define NFC_V1_UNLOCKEND_BLKADDR	(host->regs + 0x16)
> @@ -1274,6 +1274,9 @@ static void preset_v2(struct mtd_info *mtd)
>  	writew(config1, NFC_V1_V2_CONFIG1);
>  	/* preset operation */
>  
> +	/* spare area size in 16-bit half-words */
> +	writew(mtd->oobsize / 2, NFC_V21_RSLTSPARE_AREA);
> +
>  	/* Unlock the internal RAM Buffer */
>  	writew(0x2, NFC_V1_V2_CONFIG);
>  


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

* Re: [PATCH v3] mtd: rawnand: mxc: set spare area size register explicitly
  2018-06-18 20:41 ` [PATCH v3] " Martin Kaiser
  2018-06-19  5:52   ` Boris Brezillon
@ 2018-06-19  9:07   ` Miquel Raynal
  2018-06-20  9:41     ` Boris Brezillon
  1 sibling, 1 reply; 12+ messages in thread
From: Miquel Raynal @ 2018-06-19  9:07 UTC (permalink / raw)
  To: Martin Kaiser
  Cc: Boris Brezillon, David Woodhouse, Sascha Hauer, Fabio Estevam,
	linux-mtd, linux-kernel, stable

On Mon, 18 Jun 2018 22:41:03 +0200, Martin Kaiser <martin@kaiser.cx>
wrote:

> The v21 version of the NAND flash controller contains a Spare Area Size
> Register (SPAS) at offset 0x10. Its setting defaults to the maximum
> spare area size of 218 bytes. The size that is set in this register is
> used by the controller when it calculates the ECC bytes internally in
> hardware.
> 
> Usually, this register is updated from settings in the IIM fuses when
> the system is booting from NAND flash. For other boot media, however,
> the SPAS register remains at the default setting, which may not work for
> the particular flash chip on the board. The same goes for flash chips
> whose configuration cannot be set in the IIM fuses (e.g. chips with 2k
> sector size and 128 bytes spare area size can't be configured in the IIM
> fuses on imx25 systems).
> 
> Set the SPAS register explicitly during the preset operation. Derive the
> register value from mtd->oobsize that was detected during probe by
> decoding the flash chip's ID bytes.
> 
> While at it, rename the define for the spare area register's offset to
> NFC_V21_RSLTSPARE_AREA. The register at offset 0x10 on v1 controllers is
> different from the register on v21 controllers.
> 
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> Cc: stable@vger.kernel.org
> Fixes: d484018 ("mtd: mxc_nand: set NFC registers after reset")

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl

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

* Re: [PATCH v3] mtd: rawnand: mxc: set spare area size register explicitly
  2018-06-19  9:07   ` Miquel Raynal
@ 2018-06-20  9:41     ` Boris Brezillon
  0 siblings, 0 replies; 12+ messages in thread
From: Boris Brezillon @ 2018-06-20  9:41 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Martin Kaiser, David Woodhouse, Sascha Hauer, Fabio Estevam,
	linux-mtd, linux-kernel, stable

On Tue, 19 Jun 2018 11:07:41 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> On Mon, 18 Jun 2018 22:41:03 +0200, Martin Kaiser <martin@kaiser.cx>
> wrote:
> 
> > The v21 version of the NAND flash controller contains a Spare Area Size
> > Register (SPAS) at offset 0x10. Its setting defaults to the maximum
> > spare area size of 218 bytes. The size that is set in this register is
> > used by the controller when it calculates the ECC bytes internally in
> > hardware.
> > 
> > Usually, this register is updated from settings in the IIM fuses when
> > the system is booting from NAND flash. For other boot media, however,
> > the SPAS register remains at the default setting, which may not work for
> > the particular flash chip on the board. The same goes for flash chips
> > whose configuration cannot be set in the IIM fuses (e.g. chips with 2k
> > sector size and 128 bytes spare area size can't be configured in the IIM
> > fuses on imx25 systems).
> > 
> > Set the SPAS register explicitly during the preset operation. Derive the
> > register value from mtd->oobsize that was detected during probe by
> > decoding the flash chip's ID bytes.
> > 
> > While at it, rename the define for the spare area register's offset to
> > NFC_V21_RSLTSPARE_AREA. The register at offset 0x10 on v1 controllers is
> > different from the register on v21 controllers.
> > 
> > Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> > Cc: stable@vger.kernel.org
> > Fixes: d484018 ("mtd: mxc_nand: set NFC registers after reset")  
> 
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Applied.

Thanks,

Boris


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

end of thread, other threads:[~2018-06-20  9:41 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-03 11:31 [PATCH] mtd: rawnand: mxc: set spare area size register explicitly Martin Kaiser
2018-06-04  6:53 ` Sascha Hauer
2018-06-07 15:19 ` Miquel Raynal
2018-06-10 13:14   ` Martin Kaiser
2018-06-10 13:31 ` [PATCH v2] " Martin Kaiser
2018-06-18 14:06   ` Miquel Raynal
2018-06-18 14:09   ` Boris Brezillon
2018-06-18 20:36     ` Martin Kaiser
2018-06-18 20:41 ` [PATCH v3] " Martin Kaiser
2018-06-19  5:52   ` Boris Brezillon
2018-06-19  9:07   ` Miquel Raynal
2018-06-20  9:41     ` Boris Brezillon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).