All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] mtd: spinand: add support for MX35LFxG24AD & Fix bug of BCH
@ 2020-12-10  3:22 ` YouChing Lin
  0 siblings, 0 replies; 12+ messages in thread
From: YouChing Lin @ 2020-12-10  3:22 UTC (permalink / raw)
  To: miquel.raynal, vigneshr; +Cc: juliensu, linux-mtd, linux-kernel, ycllin

Hello,

This series adds support for MX35LF1/2/4G24AD, are 3V, 1G/2G/4Gbit serial
SLC NAND flash device (without on-die ECC).

And fix a bug of BCH, the size of calc_buf/code_buf is limited to 64 bytes.
If someone uses Flash with pagesize: 4096 (for example: MX35LF4G24AD, 
eccbyte: 104 bytes), some errors will occur during the read operation.
So we correct the size of calc_buf/code_buf to mtd->oobsize.

This series has been tested on Xilinx Zynq PicoZed FPGA board.

Thanks for your time.

YouChing Lin (2):
  mtd: nand: ecc-bch: Fix the size of calc_buf/code_buf of the BCH
  mtd: spinand: macronix: Add support for MX35LFxG24AD

 drivers/mtd/nand/ecc-sw-bch.c   |  4 ++--
 drivers/mtd/nand/spi/macronix.c | 27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 2 deletions(-)

-- 
1.9.1


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

* [PATCH 0/2] mtd: spinand: add support for MX35LFxG24AD & Fix bug of BCH
@ 2020-12-10  3:22 ` YouChing Lin
  0 siblings, 0 replies; 12+ messages in thread
From: YouChing Lin @ 2020-12-10  3:22 UTC (permalink / raw)
  To: miquel.raynal, vigneshr; +Cc: juliensu, ycllin, linux-mtd, linux-kernel

Hello,

This series adds support for MX35LF1/2/4G24AD, are 3V, 1G/2G/4Gbit serial
SLC NAND flash device (without on-die ECC).

And fix a bug of BCH, the size of calc_buf/code_buf is limited to 64 bytes.
If someone uses Flash with pagesize: 4096 (for example: MX35LF4G24AD, 
eccbyte: 104 bytes), some errors will occur during the read operation.
So we correct the size of calc_buf/code_buf to mtd->oobsize.

This series has been tested on Xilinx Zynq PicoZed FPGA board.

Thanks for your time.

YouChing Lin (2):
  mtd: nand: ecc-bch: Fix the size of calc_buf/code_buf of the BCH
  mtd: spinand: macronix: Add support for MX35LFxG24AD

 drivers/mtd/nand/ecc-sw-bch.c   |  4 ++--
 drivers/mtd/nand/spi/macronix.c | 27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 2 deletions(-)

-- 
1.9.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* [PATCH 1/2] mtd: nand: ecc-bch: Fix the size of calc_buf/code_buf of the BCH
  2020-12-10  3:22 ` YouChing Lin
@ 2020-12-10  3:22   ` YouChing Lin
  -1 siblings, 0 replies; 12+ messages in thread
From: YouChing Lin @ 2020-12-10  3:22 UTC (permalink / raw)
  To: miquel.raynal, vigneshr; +Cc: juliensu, linux-mtd, linux-kernel, ycllin

If eccbyte exceeds 64 bytes, the read operation will get wrong results.
For example: Flash with a page size of 4096 bytes (eccbyte: 104 bytes).
During the read operation, after executing nand_ecc_sw_bch_calculate(),
since the calc_buf/code_buf ranges overlap each other, the last three
steps of ecc_code (read from oob) will be changed.

The root cause is that the size of calc_buf/code_buf is limited to 64
bytes, although sizeof(mtd->oobsize) returns 4, kzalloc() will allocate
64 bytes (cache size alignment).

So we correct the size of calc_buf/code_buf to mtd->oobsize.

Signed-off-by: YouChing Lin <ycllin@mxic.com.tw>
---
 drivers/mtd/nand/ecc-sw-bch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/ecc-sw-bch.c b/drivers/mtd/nand/ecc-sw-bch.c
index 4d8a979..0a0ac11 100644
--- a/drivers/mtd/nand/ecc-sw-bch.c
+++ b/drivers/mtd/nand/ecc-sw-bch.c
@@ -237,8 +237,8 @@ int nand_ecc_sw_bch_init_ctx(struct nand_device *nand)
 
 	engine_conf->code_size = code_size;
 	engine_conf->nsteps = nsteps;
-	engine_conf->calc_buf = kzalloc(sizeof(mtd->oobsize), GFP_KERNEL);
-	engine_conf->code_buf = kzalloc(sizeof(mtd->oobsize), GFP_KERNEL);
+	engine_conf->calc_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
+	engine_conf->code_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
 	if (!engine_conf->calc_buf || !engine_conf->code_buf) {
 		ret = -ENOMEM;
 		goto free_bufs;
-- 
1.9.1


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

* [PATCH 1/2] mtd: nand: ecc-bch: Fix the size of calc_buf/code_buf of the BCH
@ 2020-12-10  3:22   ` YouChing Lin
  0 siblings, 0 replies; 12+ messages in thread
From: YouChing Lin @ 2020-12-10  3:22 UTC (permalink / raw)
  To: miquel.raynal, vigneshr; +Cc: juliensu, ycllin, linux-mtd, linux-kernel

If eccbyte exceeds 64 bytes, the read operation will get wrong results.
For example: Flash with a page size of 4096 bytes (eccbyte: 104 bytes).
During the read operation, after executing nand_ecc_sw_bch_calculate(),
since the calc_buf/code_buf ranges overlap each other, the last three
steps of ecc_code (read from oob) will be changed.

The root cause is that the size of calc_buf/code_buf is limited to 64
bytes, although sizeof(mtd->oobsize) returns 4, kzalloc() will allocate
64 bytes (cache size alignment).

So we correct the size of calc_buf/code_buf to mtd->oobsize.

Signed-off-by: YouChing Lin <ycllin@mxic.com.tw>
---
 drivers/mtd/nand/ecc-sw-bch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/ecc-sw-bch.c b/drivers/mtd/nand/ecc-sw-bch.c
index 4d8a979..0a0ac11 100644
--- a/drivers/mtd/nand/ecc-sw-bch.c
+++ b/drivers/mtd/nand/ecc-sw-bch.c
@@ -237,8 +237,8 @@ int nand_ecc_sw_bch_init_ctx(struct nand_device *nand)
 
 	engine_conf->code_size = code_size;
 	engine_conf->nsteps = nsteps;
-	engine_conf->calc_buf = kzalloc(sizeof(mtd->oobsize), GFP_KERNEL);
-	engine_conf->code_buf = kzalloc(sizeof(mtd->oobsize), GFP_KERNEL);
+	engine_conf->calc_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
+	engine_conf->code_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
 	if (!engine_conf->calc_buf || !engine_conf->code_buf) {
 		ret = -ENOMEM;
 		goto free_bufs;
-- 
1.9.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* [PATCH 2/2] mtd: spinand: macronix: Add support for MX35LFxG24AD
  2020-12-10  3:22 ` YouChing Lin
@ 2020-12-10  3:22   ` YouChing Lin
  -1 siblings, 0 replies; 12+ messages in thread
From: YouChing Lin @ 2020-12-10  3:22 UTC (permalink / raw)
  To: miquel.raynal, vigneshr; +Cc: juliensu, linux-mtd, linux-kernel, ycllin

The Macronix MX35LF1G24AD(/2G24AD/4G24AD) are 3V, 1G/2G/4Gbit serial
SLC NAND flash device (without on-die ECC).

Validated by read, erase, read back, write, read back on Xilinx Zynq
PicoZed FPGA board which included Macronix SPI Host(drivers/spi/spi-mxic.c)
& S/W BCH ecc(drivers/mtd/nand/ecc-sw-bch.c) with bug fixing patch
(mtd: nand: ecc-bch: Fix the size of calc_buf/code_buf of the BCH).

Signed-off-by: YouChing Lin <ycllin@mxic.com.tw>
---
 drivers/mtd/nand/spi/macronix.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
index 3786b1b..6701aaa 100644
--- a/drivers/mtd/nand/spi/macronix.c
+++ b/drivers/mtd/nand/spi/macronix.c
@@ -139,6 +139,33 @@ static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,
 		     0,
 		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout,
 				     mx35lf1ge4ab_ecc_get_status)),
+	SPINAND_INFO("MX35LF1G24AD",
+		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x14),
+		     NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1),
+		     NAND_ECCREQ(8, 512),
+		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+					      &write_cache_variants,
+					      &update_cache_variants),
+		     0,
+		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)),
+	SPINAND_INFO("MX35LF2G24AD",
+		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x24),
+		     NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1),
+		     NAND_ECCREQ(8, 512),
+		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+					      &write_cache_variants,
+					      &update_cache_variants),
+		     0,
+		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)),
+	SPINAND_INFO("MX35LF4G24AD",
+		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x35),
+		     NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 2, 1, 1),
+		     NAND_ECCREQ(8, 512),
+		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+					      &write_cache_variants,
+					      &update_cache_variants),
+		     0,
+		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)),
 	SPINAND_INFO("MX31LF1GE4BC",
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x1e),
 		     NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
-- 
1.9.1


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

* [PATCH 2/2] mtd: spinand: macronix: Add support for MX35LFxG24AD
@ 2020-12-10  3:22   ` YouChing Lin
  0 siblings, 0 replies; 12+ messages in thread
From: YouChing Lin @ 2020-12-10  3:22 UTC (permalink / raw)
  To: miquel.raynal, vigneshr; +Cc: juliensu, ycllin, linux-mtd, linux-kernel

The Macronix MX35LF1G24AD(/2G24AD/4G24AD) are 3V, 1G/2G/4Gbit serial
SLC NAND flash device (without on-die ECC).

Validated by read, erase, read back, write, read back on Xilinx Zynq
PicoZed FPGA board which included Macronix SPI Host(drivers/spi/spi-mxic.c)
& S/W BCH ecc(drivers/mtd/nand/ecc-sw-bch.c) with bug fixing patch
(mtd: nand: ecc-bch: Fix the size of calc_buf/code_buf of the BCH).

Signed-off-by: YouChing Lin <ycllin@mxic.com.tw>
---
 drivers/mtd/nand/spi/macronix.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
index 3786b1b..6701aaa 100644
--- a/drivers/mtd/nand/spi/macronix.c
+++ b/drivers/mtd/nand/spi/macronix.c
@@ -139,6 +139,33 @@ static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,
 		     0,
 		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout,
 				     mx35lf1ge4ab_ecc_get_status)),
+	SPINAND_INFO("MX35LF1G24AD",
+		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x14),
+		     NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1),
+		     NAND_ECCREQ(8, 512),
+		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+					      &write_cache_variants,
+					      &update_cache_variants),
+		     0,
+		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)),
+	SPINAND_INFO("MX35LF2G24AD",
+		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x24),
+		     NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1),
+		     NAND_ECCREQ(8, 512),
+		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+					      &write_cache_variants,
+					      &update_cache_variants),
+		     0,
+		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)),
+	SPINAND_INFO("MX35LF4G24AD",
+		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x35),
+		     NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 2, 1, 1),
+		     NAND_ECCREQ(8, 512),
+		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+					      &write_cache_variants,
+					      &update_cache_variants),
+		     0,
+		     SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)),
 	SPINAND_INFO("MX31LF1GE4BC",
 		     SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x1e),
 		     NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
-- 
1.9.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH 1/2] mtd: nand: ecc-bch: Fix the size of calc_buf/code_buf of the BCH
  2020-12-10  3:22   ` YouChing Lin
@ 2020-12-10 21:33     ` Miquel Raynal
  -1 siblings, 0 replies; 12+ messages in thread
From: Miquel Raynal @ 2020-12-10 21:33 UTC (permalink / raw)
  To: YouChing Lin; +Cc: vigneshr, juliensu, linux-mtd, linux-kernel

Hi YouChing,

YouChing Lin <ycllin@mxic.com.tw> wrote on Thu, 10 Dec 2020 11:22:08
+0800:

> If eccbyte exceeds 64 bytes, the read operation will get wrong results.
> For example: Flash with a page size of 4096 bytes (eccbyte: 104 bytes).
> During the read operation, after executing nand_ecc_sw_bch_calculate(),
> since the calc_buf/code_buf ranges overlap each other, the last three
> steps of ecc_code (read from oob) will be changed.
> 
> The root cause is that the size of calc_buf/code_buf is limited to 64
> bytes, although sizeof(mtd->oobsize) returns 4, kzalloc() will allocate
> 64 bytes (cache size alignment).
> 
> So we correct the size of calc_buf/code_buf to mtd->oobsize.
> 
> Signed-off-by: YouChing Lin <ycllin@mxic.com.tw>
> ---
>  drivers/mtd/nand/ecc-sw-bch.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/ecc-sw-bch.c b/drivers/mtd/nand/ecc-sw-bch.c
> index 4d8a979..0a0ac11 100644
> --- a/drivers/mtd/nand/ecc-sw-bch.c
> +++ b/drivers/mtd/nand/ecc-sw-bch.c
> @@ -237,8 +237,8 @@ int nand_ecc_sw_bch_init_ctx(struct nand_device *nand)
>  
>  	engine_conf->code_size = code_size;
>  	engine_conf->nsteps = nsteps;
> -	engine_conf->calc_buf = kzalloc(sizeof(mtd->oobsize), GFP_KERNEL);
> -	engine_conf->code_buf = kzalloc(sizeof(mtd->oobsize), GFP_KERNEL);
> +	engine_conf->calc_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
> +	engine_conf->code_buf = kzalloc(mtd->oobsize, GFP_KERNEL);

Very nice catch! If you don't mind I will merge this fix with the
faulty commit (still in next) and I will also bring the fix to Hamming
which will suffer from the same error.

Then I will apply the second patch.

>  	if (!engine_conf->calc_buf || !engine_conf->code_buf) {
>  		ret = -ENOMEM;
>  		goto free_bufs;

Thanks,
Miquèl

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

* Re: [PATCH 1/2] mtd: nand: ecc-bch: Fix the size of calc_buf/code_buf of the BCH
@ 2020-12-10 21:33     ` Miquel Raynal
  0 siblings, 0 replies; 12+ messages in thread
From: Miquel Raynal @ 2020-12-10 21:33 UTC (permalink / raw)
  To: YouChing Lin; +Cc: juliensu, linux-mtd, vigneshr, linux-kernel

Hi YouChing,

YouChing Lin <ycllin@mxic.com.tw> wrote on Thu, 10 Dec 2020 11:22:08
+0800:

> If eccbyte exceeds 64 bytes, the read operation will get wrong results.
> For example: Flash with a page size of 4096 bytes (eccbyte: 104 bytes).
> During the read operation, after executing nand_ecc_sw_bch_calculate(),
> since the calc_buf/code_buf ranges overlap each other, the last three
> steps of ecc_code (read from oob) will be changed.
> 
> The root cause is that the size of calc_buf/code_buf is limited to 64
> bytes, although sizeof(mtd->oobsize) returns 4, kzalloc() will allocate
> 64 bytes (cache size alignment).
> 
> So we correct the size of calc_buf/code_buf to mtd->oobsize.
> 
> Signed-off-by: YouChing Lin <ycllin@mxic.com.tw>
> ---
>  drivers/mtd/nand/ecc-sw-bch.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/ecc-sw-bch.c b/drivers/mtd/nand/ecc-sw-bch.c
> index 4d8a979..0a0ac11 100644
> --- a/drivers/mtd/nand/ecc-sw-bch.c
> +++ b/drivers/mtd/nand/ecc-sw-bch.c
> @@ -237,8 +237,8 @@ int nand_ecc_sw_bch_init_ctx(struct nand_device *nand)
>  
>  	engine_conf->code_size = code_size;
>  	engine_conf->nsteps = nsteps;
> -	engine_conf->calc_buf = kzalloc(sizeof(mtd->oobsize), GFP_KERNEL);
> -	engine_conf->code_buf = kzalloc(sizeof(mtd->oobsize), GFP_KERNEL);
> +	engine_conf->calc_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
> +	engine_conf->code_buf = kzalloc(mtd->oobsize, GFP_KERNEL);

Very nice catch! If you don't mind I will merge this fix with the
faulty commit (still in next) and I will also bring the fix to Hamming
which will suffer from the same error.

Then I will apply the second patch.

>  	if (!engine_conf->calc_buf || !engine_conf->code_buf) {
>  		ret = -ENOMEM;
>  		goto free_bufs;

Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH 2/2] mtd: spinand: macronix: Add support for MX35LFxG24AD
  2020-12-10  3:22   ` YouChing Lin
@ 2020-12-10 21:38     ` Miquel Raynal
  -1 siblings, 0 replies; 12+ messages in thread
From: Miquel Raynal @ 2020-12-10 21:38 UTC (permalink / raw)
  To: YouChing Lin, miquel.raynal, vigneshr; +Cc: juliensu, linux-mtd, linux-kernel

On Thu, 2020-12-10 at 03:22:09 UTC, YouChing Lin wrote:
> The Macronix MX35LF1G24AD(/2G24AD/4G24AD) are 3V, 1G/2G/4Gbit serial
> SLC NAND flash device (without on-die ECC).
> 
> Validated by read, erase, read back, write, read back on Xilinx Zynq
> PicoZed FPGA board which included Macronix SPI Host(drivers/spi/spi-mxic.c)
> & S/W BCH ecc(drivers/mtd/nand/ecc-sw-bch.c) with bug fixing patch
> (mtd: nand: ecc-bch: Fix the size of calc_buf/code_buf of the BCH).
> 
> Signed-off-by: YouChing Lin <ycllin@mxic.com.tw>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

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

* Re: [PATCH 2/2] mtd: spinand: macronix: Add support for MX35LFxG24AD
@ 2020-12-10 21:38     ` Miquel Raynal
  0 siblings, 0 replies; 12+ messages in thread
From: Miquel Raynal @ 2020-12-10 21:38 UTC (permalink / raw)
  To: YouChing Lin, miquel.raynal, vigneshr; +Cc: juliensu, linux-mtd, linux-kernel

On Thu, 2020-12-10 at 03:22:09 UTC, YouChing Lin wrote:
> The Macronix MX35LF1G24AD(/2G24AD/4G24AD) are 3V, 1G/2G/4Gbit serial
> SLC NAND flash device (without on-die ECC).
> 
> Validated by read, erase, read back, write, read back on Xilinx Zynq
> PicoZed FPGA board which included Macronix SPI Host(drivers/spi/spi-mxic.c)
> & S/W BCH ecc(drivers/mtd/nand/ecc-sw-bch.c) with bug fixing patch
> (mtd: nand: ecc-bch: Fix the size of calc_buf/code_buf of the BCH).
> 
> Signed-off-by: YouChing Lin <ycllin@mxic.com.tw>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH 1/2] mtd: nand: ecc-bch: Fix the size of calc_buf/code_buf of the BCH
  2020-12-10 21:33     ` Miquel Raynal
@ 2020-12-11  1:20       ` ycllin
  -1 siblings, 0 replies; 12+ messages in thread
From: ycllin @ 2020-12-11  1:20 UTC (permalink / raw)
  To: Miquel Raynal; +Cc: juliensu, linux-kernel, linux-mtd, vigneshr


Hi Miquel,
> "Miquel Raynal" <miquel.raynal@bootlin.com> 
> 
> Re: [PATCH 1/2] mtd: nand: ecc-bch: Fix the size of calc_buf/code_buf of 
the BCH
> 
> Hi YouChing,
> 
> YouChing Lin <ycllin@mxic.com.tw> wrote on Thu, 10 Dec 2020 11:22:08
> +0800:
> 
(deleted)
> > The root cause is that the size of calc_buf/code_buf is limited to 64
> > bytes, although sizeof(mtd->oobsize) returns 4, kzalloc() will 
allocate
> > 64 bytes (cache size alignment).
> > 
> > So we correct the size of calc_buf/code_buf to mtd->oobsize.
> > 
> > Signed-off-by: YouChing Lin <ycllin@mxic.com.tw>
> > ---
> >  drivers/mtd/nand/ecc-sw-bch.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/mtd/nand/ecc-sw-bch.c 
b/drivers/mtd/nand/ecc-sw-bch.c
> > index 4d8a979..0a0ac11 100644
> > --- a/drivers/mtd/nand/ecc-sw-bch.c
> > +++ b/drivers/mtd/nand/ecc-sw-bch.c
> > @@ -237,8 +237,8 @@ int nand_ecc_sw_bch_init_ctx(struct nand_device 
*nand)
> > 
> >     engine_conf->code_size = code_size;
> >     engine_conf->nsteps = nsteps;
> > -   engine_conf->calc_buf = kzalloc(sizeof(mtd->oobsize), GFP_KERNEL);
> > -   engine_conf->code_buf = kzalloc(sizeof(mtd->oobsize), GFP_KERNEL);
> > +   engine_conf->calc_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
> > +   engine_conf->code_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
> 
> Very nice catch! If you don't mind I will merge this fix with the
> faulty commit (still in next) and I will also bring the fix to Hamming
> which will suffer from the same error.
> 
> Then I will apply the second patch.
 
No problem, thank you for your help.


Thanks,
Youching.


CONFIDENTIALITY NOTE:

This e-mail and any attachments may contain confidential information 
and/or personal data, which is protected by applicable laws. Please be 
reminded that duplication, disclosure, distribution, or use of this e-mail 
(and/or its attachments) or any part thereof is prohibited. If you receive 
this e-mail in error, please notify us immediately and delete this mail as 
well as its attachment(s) from your system. In addition, please be 
informed that collection, processing, and/or use of personal data is 
prohibited unless expressly permitted by personal data protection laws. 
Thank you for your attention and cooperation.

Macronix International Co., Ltd.

=====================================================================



============================================================================

CONFIDENTIALITY NOTE:

This e-mail and any attachments may contain confidential information and/or personal data, which is protected by applicable laws. Please be reminded that duplication, disclosure, distribution, or use of this e-mail (and/or its attachments) or any part thereof is prohibited. If you receive this e-mail in error, please notify us immediately and delete this mail as well as its attachment(s) from your system. In addition, please be informed that collection, processing, and/or use of personal data is prohibited unless expressly permitted by personal data protection laws. Thank you for your attention and cooperation.

Macronix International Co., Ltd.

=====================================================================


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

* Re: [PATCH 1/2] mtd: nand: ecc-bch: Fix the size of calc_buf/code_buf of the BCH
@ 2020-12-11  1:20       ` ycllin
  0 siblings, 0 replies; 12+ messages in thread
From: ycllin @ 2020-12-11  1:20 UTC (permalink / raw)
  To: Miquel Raynal; +Cc: juliensu, linux-mtd, linux-kernel, vigneshr


Hi Miquel,
> "Miquel Raynal" <miquel.raynal@bootlin.com> 
> 
> Re: [PATCH 1/2] mtd: nand: ecc-bch: Fix the size of calc_buf/code_buf of 
the BCH
> 
> Hi YouChing,
> 
> YouChing Lin <ycllin@mxic.com.tw> wrote on Thu, 10 Dec 2020 11:22:08
> +0800:
> 
(deleted)
> > The root cause is that the size of calc_buf/code_buf is limited to 64
> > bytes, although sizeof(mtd->oobsize) returns 4, kzalloc() will 
allocate
> > 64 bytes (cache size alignment).
> > 
> > So we correct the size of calc_buf/code_buf to mtd->oobsize.
> > 
> > Signed-off-by: YouChing Lin <ycllin@mxic.com.tw>
> > ---
> >  drivers/mtd/nand/ecc-sw-bch.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/mtd/nand/ecc-sw-bch.c 
b/drivers/mtd/nand/ecc-sw-bch.c
> > index 4d8a979..0a0ac11 100644
> > --- a/drivers/mtd/nand/ecc-sw-bch.c
> > +++ b/drivers/mtd/nand/ecc-sw-bch.c
> > @@ -237,8 +237,8 @@ int nand_ecc_sw_bch_init_ctx(struct nand_device 
*nand)
> > 
> >     engine_conf->code_size = code_size;
> >     engine_conf->nsteps = nsteps;
> > -   engine_conf->calc_buf = kzalloc(sizeof(mtd->oobsize), GFP_KERNEL);
> > -   engine_conf->code_buf = kzalloc(sizeof(mtd->oobsize), GFP_KERNEL);
> > +   engine_conf->calc_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
> > +   engine_conf->code_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
> 
> Very nice catch! If you don't mind I will merge this fix with the
> faulty commit (still in next) and I will also bring the fix to Hamming
> which will suffer from the same error.
> 
> Then I will apply the second patch.
 
No problem, thank you for your help.


Thanks,
Youching.


CONFIDENTIALITY NOTE:

This e-mail and any attachments may contain confidential information 
and/or personal data, which is protected by applicable laws. Please be 
reminded that duplication, disclosure, distribution, or use of this e-mail 
(and/or its attachments) or any part thereof is prohibited. If you receive 
this e-mail in error, please notify us immediately and delete this mail as 
well as its attachment(s) from your system. In addition, please be 
informed that collection, processing, and/or use of personal data is 
prohibited unless expressly permitted by personal data protection laws. 
Thank you for your attention and cooperation.

Macronix International Co., Ltd.

=====================================================================



============================================================================

CONFIDENTIALITY NOTE:

This e-mail and any attachments may contain confidential information and/or personal data, which is protected by applicable laws. Please be reminded that duplication, disclosure, distribution, or use of this e-mail (and/or its attachments) or any part thereof is prohibited. If you receive this e-mail in error, please notify us immediately and delete this mail as well as its attachment(s) from your system. In addition, please be informed that collection, processing, and/or use of personal data is prohibited unless expressly permitted by personal data protection laws. Thank you for your attention and cooperation.

Macronix International Co., Ltd.

=====================================================================


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, other threads:[~2020-12-11  1:26 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-10  3:22 [PATCH 0/2] mtd: spinand: add support for MX35LFxG24AD & Fix bug of BCH YouChing Lin
2020-12-10  3:22 ` YouChing Lin
2020-12-10  3:22 ` [PATCH 1/2] mtd: nand: ecc-bch: Fix the size of calc_buf/code_buf of the BCH YouChing Lin
2020-12-10  3:22   ` YouChing Lin
2020-12-10 21:33   ` Miquel Raynal
2020-12-10 21:33     ` Miquel Raynal
2020-12-11  1:20     ` ycllin
2020-12-11  1:20       ` ycllin
2020-12-10  3:22 ` [PATCH 2/2] mtd: spinand: macronix: Add support for MX35LFxG24AD YouChing Lin
2020-12-10  3:22   ` YouChing Lin
2020-12-10 21:38   ` Miquel Raynal
2020-12-10 21:38     ` Miquel Raynal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.