Skip to contentSkip to conversation

mtd: rawnand: meson: always use OOB bytes during write

PATCH In review Arseniy Krasnov 2 participants 7 messages Dec 22, 2024 – Mar 17, 2025

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

PATCH 1/1 mtd: rawnand: meson: always use OOB bytes during write

If 'oob_required' is not set by the caller (for example 'oobbuf' is NULL), then driver doesn't copy OOB data from 'oob_poi' to special controller structures, so zeroes will be written as OOB. But, generic raw NAND logic in 'nand_base.c' already handles case when OOB is not required to write by filling 'oob_poi' with 0xFF's. So let's remove 'oob_required' check to always read 'oob_poi' data for OOB.

Kernel driver (drivers/mtd/nand/raw/meson_nand.c) works in the same way, so need to keep same behaviour here.

Fixes c2e8c4d09a7a ("mtd: rawnand: Meson NAND controller support")
---
 drivers/mtd/nand/raw/meson_nand.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mtd/nand/raw/meson_nand.c +1 -3
index 81122315f4..82a12ac061 100644
@@ -607,9 +607,7 @@ static int meson_nfc_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *ch
 		memcpy(meson_chip->data_buf, buf, mtd->writesize);
 
 	memset(meson_chip->info_buf, 0, chip->ecc.steps * PER_INFO_BYTE);
-
-	if (oob_required)
-		meson_nfc_set_user_byte(chip, chip->oob_poi);
+	meson_nfc_set_user_byte(chip, chip->oob_poi);
 
 	return meson_nfc_write_page_sub(chip, page, false);
 }
Signature · 1 line
2.30.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 22 lines · Arseniy Krasnov

If 'oob_required' is not set by the caller (for example 'oobbuf' is NULL), then driver doesn't copy OOB data from 'oob_poi' to special controller structures, so zeroes will be written as OOB. But, generic raw NAND logic in 'nand_base.c' already handles case when OOB is not required to write by filling 'oob_poi' with 0xFF's. So let's remove 'oob_required' check to always read 'oob_poi' data for OOB.

Kernel driver (drivers/mtd/nand/raw/meson_nand.c) works in the same way, so need to keep same behaviour here.

Fixes c2e8c4d09a7a ("mtd: rawnand: Meson NAND controller support")
---
 drivers/mtd/nand/raw/meson_nand.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mtd/nand/raw/meson_nand.c +0 -0
index 81122315f4..82a12ac061 100644

drivers/mtd/nand/raw/meson_nand.c static int meson_nfc_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *ch · line 611

Quoted 8 lines
drivers/mtd/nand/raw/meson_nand.c +1 -3
@@ -607,9 +607,7 @@ static int meson_nfc_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *ch
                memcpy(meson_chip->data_buf, buf, mtd->writesize);
 
        memset(meson_chip->info_buf, 0, chip->ecc.steps * PER_INFO_BYTE);
-
-       if (oob_required)
-               meson_nfc_set_user_byte(chip, chip->oob_poi);
+       meson_nfc_set_user_byte(chip, chip->oob_poi);
 

I will queue it

Quoted 4 lines
drivers/mtd/nand/raw/meson_nand.c +0 -1
        return meson_nfc_write_page_sub(chip, page, false);
 }
--

2.30.1

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#2 lore raw
Quoted 35 lines · Michael Nazzareno Trimarchi
Quoted 22 lines · Arseniy Krasnov

If 'oob_required' is not set by the caller (for example 'oobbuf' is NULL), then driver doesn't copy OOB data from 'oob_poi' to special controller structures, so zeroes will be written as OOB. But, generic raw NAND logic in 'nand_base.c' already handles case when OOB is not required to write by filling 'oob_poi' with 0xFF's. So let's remove 'oob_required' check to always read 'oob_poi' data for OOB.

Kernel driver (drivers/mtd/nand/raw/meson_nand.c) works in the same way, so need to keep same behaviour here.

Fixes c2e8c4d09a7a ("mtd: rawnand: Meson NAND controller support")
---
 drivers/mtd/nand/raw/meson_nand.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mtd/nand/raw/meson_nand.c +0 -0
index 81122315f4..82a12ac061 100644

drivers/mtd/nand/raw/meson_nand.c static int meson_nfc_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *ch · line 611

Quoted 8 lines
drivers/mtd/nand/raw/meson_nand.c +1 -3
@@ -607,9 +607,7 @@ static int meson_nfc_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *ch
                memcpy(meson_chip->data_buf, buf, mtd->writesize);
 
        memset(meson_chip->info_buf, 0, chip->ecc.steps * PER_INFO_BYTE);
-
-       if (oob_required)
-               meson_nfc_set_user_byte(chip, chip->oob_poi);
+       meson_nfc_set_user_byte(chip, chip->oob_poi);
 
Quoted 1 line

I will queue it

Thanks. You mean it will be merged to https://source.denx.de/u-boot/custodians/u-boot-nand-flash ?

Quoted 8 lines
Quoted 5 lines
drivers/mtd/nand/raw/meson_nand.c +0 -1
        return meson_nfc_write_page_sub(chip, page, false);
 }
--

2.30.1

#3 lore raw

Hi

Yes

Michael

Quoted 52 lines · Arseniy Krasnov
Quoted 35 lines · Michael Nazzareno Trimarchi
Quoted 22 lines · Arseniy Krasnov

If 'oob_required' is not set by the caller (for example 'oobbuf' is NULL), then driver doesn't copy OOB data from 'oob_poi' to special controller structures, so zeroes will be written as OOB. But, generic raw NAND logic in 'nand_base.c' already handles case when OOB is not required to write by filling 'oob_poi' with 0xFF's. So let's remove 'oob_required' check to always read 'oob_poi' data for OOB.

Kernel driver (drivers/mtd/nand/raw/meson_nand.c) works in the same way, so need to keep same behaviour here.

Fixes c2e8c4d09a7a ("mtd: rawnand: Meson NAND controller support")
---
 drivers/mtd/nand/raw/meson_nand.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mtd/nand/raw/meson_nand.c +0 -0
index 81122315f4..82a12ac061 100644

drivers/mtd/nand/raw/meson_nand.c static int meson_nfc_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *ch · line 611

Quoted 8 lines
drivers/mtd/nand/raw/meson_nand.c +1 -3
@@ -607,9 +607,7 @@ static int meson_nfc_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *ch
                memcpy(meson_chip->data_buf, buf, mtd->writesize);
 
        memset(meson_chip->info_buf, 0, chip->ecc.steps * PER_INFO_BYTE);
-
-       if (oob_required)
-               meson_nfc_set_user_byte(chip, chip->oob_poi);
+       meson_nfc_set_user_byte(chip, chip->oob_poi);
 
Quoted 1 line

I will queue it

Thanks. You mean it will be merged to https://source.denx.de/u-boot/custodians/u-boot-nand-flash ?

Quoted 8 lines
Quoted 5 lines
drivers/mtd/nand/raw/meson_nand.c +0 -1
        return meson_nfc_write_page_sub(chip, page, false);
 }
--

2.30.1

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#4 lore raw

Hi, sorry, but i don't see it merged. Is it ok?

Thanks

Quoted 63 lines · Michael Nazzareno Trimarchi

Hi

Yes

Michael

Quoted 52 lines · Arseniy Krasnov
Quoted 35 lines · Michael Nazzareno Trimarchi
Quoted 22 lines · Arseniy Krasnov

If 'oob_required' is not set by the caller (for example 'oobbuf' is NULL), then driver doesn't copy OOB data from 'oob_poi' to special controller structures, so zeroes will be written as OOB. But, generic raw NAND logic in 'nand_base.c' already handles case when OOB is not required to write by filling 'oob_poi' with 0xFF's. So let's remove 'oob_required' check to always read 'oob_poi' data for OOB.

Kernel driver (drivers/mtd/nand/raw/meson_nand.c) works in the same way, so need to keep same behaviour here.

Fixes c2e8c4d09a7a ("mtd: rawnand: Meson NAND controller support")
---
 drivers/mtd/nand/raw/meson_nand.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mtd/nand/raw/meson_nand.c +0 -0
index 81122315f4..82a12ac061 100644

drivers/mtd/nand/raw/meson_nand.c static int meson_nfc_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *ch · line 611

Quoted 8 lines
drivers/mtd/nand/raw/meson_nand.c +1 -3
@@ -607,9 +607,7 @@ static int meson_nfc_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *ch
                memcpy(meson_chip->data_buf, buf, mtd->writesize);
 
        memset(meson_chip->info_buf, 0, chip->ecc.steps * PER_INFO_BYTE);
-
-       if (oob_required)
-               meson_nfc_set_user_byte(chip, chip->oob_poi);
+       meson_nfc_set_user_byte(chip, chip->oob_poi);
 
Quoted 1 line

I will queue it

Thanks. You mean it will be merged to https://source.denx.de/u-boot/custodians/u-boot-nand-flash ?

Quoted 8 lines
Quoted 5 lines
drivers/mtd/nand/raw/meson_nand.c +0 -1
        return meson_nfc_write_page_sub(chip, page, false);
 }
--

2.30.1

#5 lore raw
In reply to Arseniy Krasnov

Hi Arseniy

Quoted 32 lines · Arseniy Krasnov

If 'oob_required' is not set by the caller (for example 'oobbuf' is NULL), then driver doesn't copy OOB data from 'oob_poi' to special controller structures, so zeroes will be written as OOB. But, generic raw NAND logic in 'nand_base.c' already handles case when OOB is not required to write by filling 'oob_poi' with 0xFF's. So let's remove 'oob_required' check to always read 'oob_poi' data for OOB.

Kernel driver (drivers/mtd/nand/raw/meson_nand.c) works in the same way, so need to keep same behaviour here.

Fixes c2e8c4d09a7a ("mtd: rawnand: Meson NAND controller support")
---
 drivers/mtd/nand/raw/meson_nand.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mtd/nand/raw/meson_nand.c +1 -3
index 81122315f4..82a12ac061 100644
@@ -607,9 +607,7 @@ static int meson_nfc_write_page_hwecc(struct mtd_info
 *mtd, struct nand_chip *ch
                memcpy(meson_chip->data_buf, buf, mtd->writesize);
 
        memset(meson_chip->info_buf, 0, chip->ecc.steps * PER_INFO_BYTE);
-
-       if (oob_required)
-               meson_nfc_set_user_byte(chip, chip->oob_poi);
+       meson_nfc_set_user_byte(chip, chip->oob_poi);
 
        return meson_nfc_write_page_sub(chip, page, false);
Quoted 2 lines

}

Applied and sent already the pull request

Michael

Quoted 3 lines

--
2.30.1

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#6 lore raw

Hi, thanks!

Quoted 50 lines · Michael Nazzareno Trimarchi

Hi Arseniy

Quoted 32 lines · Arseniy Krasnov

If 'oob_required' is not set by the caller (for example 'oobbuf' is NULL), then driver doesn't copy OOB data from 'oob_poi' to special controller structures, so zeroes will be written as OOB. But, generic raw NAND logic in 'nand_base.c' already handles case when OOB is not required to write by filling 'oob_poi' with 0xFF's. So let's remove 'oob_required' check to always read 'oob_poi' data for OOB.

Kernel driver (drivers/mtd/nand/raw/meson_nand.c) works in the same way, so need to keep same behaviour here.

Fixes c2e8c4d09a7a ("mtd: rawnand: Meson NAND controller support")
---
 drivers/mtd/nand/raw/meson_nand.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mtd/nand/raw/meson_nand.c +1 -3
index 81122315f4..82a12ac061 100644
@@ -607,9 +607,7 @@ static int meson_nfc_write_page_hwecc(struct mtd_info
 *mtd, struct nand_chip *ch
                memcpy(meson_chip->data_buf, buf, mtd->writesize);
 
        memset(meson_chip->info_buf, 0, chip->ecc.steps * PER_INFO_BYTE);
-
-       if (oob_required)
-               meson_nfc_set_user_byte(chip, chip->oob_poi);
+       meson_nfc_set_user_byte(chip, chip->oob_poi);
 
        return meson_nfc_write_page_sub(chip, page, false);
Quoted 2 lines

}

Applied and sent already the pull request

Michael

Quoted 3 lines

--
2.30.1