mtd: spinand: Add support for SkyHigh S35ML-3 family
Subsystems (2)
cover mtd: spinand: Add support for SkyHigh S35ML-3 family
From: Takahiro Kuwano <[email protected]>
This series is successor of the patch submitted by KR Kim:
https://patchwork.ozlabs.org/project/linux-mtd/patch/[email protected]/
Takahiro Kuwano (2):
mtd: spinand: Introduce a way to avoid raw access
mtd: spinand: Add support for SkyHigh S35ML-3 family
drivers/mtd/nand/spi/Makefile | 2 +- drivers/mtd/nand/spi/core.c | 13 +++ drivers/mtd/nand/spi/skyhigh.c | 143 +++++++++++++++++++++++++++++++++ include/linux/mtd/spinand.h | 2 + 4 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 drivers/mtd/nand/spi/skyhigh.c
Signature · 6 lines
2.34.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 1/2 mtd: spinand: Introduce a way to avoid raw access
From: Takahiro Kuwano <[email protected]>
SkyHigh spinand device has ECC enable bit in configuration register but it must be always enabled. If ECC is disabled, read and write ops results in undetermined state. For such devices, a way to avoid raw access is needed.
Introduce SPINAND_NO_RAW_ACCESS flag to advertise the device does not support raw access. Read and write page in raw mode for the device returns error.
Checking and marking BBM need to be performed with ECC enabled to read and write the BBM correctly.
--- drivers/mtd/nand/spi/core.c | 12 ++++++++++++ include/linux/mtd/spinand.h | 1 + 2 files changed, 13 insertions(+)
drivers/mtd/nand/spi/core.c +12 -0
@@ -608,6 +608,9 @@ static int spinand_read_page(struct spinand_device *spinand,u8 status;int ret; +if (req->mode ==MTD_OPS_RAW && spinand->flags &SPINAND_NO_RAW_ACCESS ) +return -ENOTSUPP ; + ret =nand_ecc_prepare_io_req (nand, (struct nand_page_io_req *)req);if (ret)return ret;
@@ -639,6 +642,9 @@ static int spinand_write_page(struct spinand_device *spinand,u8 status;int ret; +if (req->mode ==MTD_OPS_RAW && spinand->flags &SPINAND_NO_RAW_ACCESS ) +return -ENOTSUPP ; + ret =nand_ecc_prepare_io_req (nand, (struct nand_page_io_req *)req);if (ret)return ret;
@@ -902,6 +908,9 @@ static bool spinand_isbad(struct nand_device *nand, const struct nand_pos *pos) .mode = MTD_OPS_RAW, }; +if (spinand->flags &SPINAND_NO_RAW_ACCESS ) + req.mode =MTD_OPS_PLACE_OOB ; +spinand_select_target (spinand, pos->target);spinand_read_page (spinand, &req);if (marker[0 ] !=0xff || marker[1 ] !=0xff )
@@ -938,6 +947,9 @@ static int spinand_markbad(struct nand_device *nand, const struct nand_pos *pos) };int ret; +if (spinand->flags &SPINAND_NO_RAW_ACCESS ) + req.mode =MTD_OPS_PLACE_OOB ; + ret =spinand_select_target (spinand, pos->target);if (ret)return ret;
include/linux/mtd/spinand.h +1 -0
@@ -314,6 +314,7 @@ struct spinand_ecc_info {#define SPINAND_HAS_CR_FEAT_BIT BIT(1)#define SPINAND_HAS_PROG_PLANE_SELECT_BIT BIT(2)#define SPINAND_HAS_READ_PLANE_SELECT_BIT BIT(3) +#define SPINAND_NO_RAW_ACCESS BIT(4)/** * struct spinand_ondie_ecc_conf - private SPI-NAND on-die ECC engine structure
Signature · 6 lines
2.34.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Miquel Raynal
maintainerRe: [PATCH 1/2] mtd: spinand: Introduce a way to avoid raw access
Hi,
Quoted 7 lines · On 31/10/2024 at 11:21:54 +09, [email protected] wrote:
From: Takahiro Kuwano <[email protected]>
SkyHigh spinand device has ECC enable bit in configuration register but it must be always enabled. If ECC is disabled, read and write ops results in undetermined state. For such devices, a way to avoid raw access is needed.
Quoted 6 lines
Introduce
SPINAND_NO_RAW_ACCESSflag to advertise the device does not support raw access. Read and write page in raw mode for the device returns error.Checking and marking BBM need to be performed with ECC enabled to read and write the BBM correctly.
I see your point but I'm a bit puzzled by how it's being done.
First, you disregard completely the isbad() and markbad() situations. Please have look into that because these functions are broken with your devices.
Second, what about adding this detail to the ondie ECC engine? You could simply return an error from there, so basically a single (or maybe two) changes overall.
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 1/2] mtd: spinand: Introduce a way to avoid raw access
Hi,
Quoted 15 lines · Miquel Raynal
Hi,
Quoted 11 lines · On 31/10/2024 at 11:21:54 +09, [email protected] wrote:
From: Takahiro Kuwano <[email protected]>
SkyHigh spinand device has ECC enable bit in configuration register but it must be always enabled. If ECC is disabled, read and write ops results in undetermined state. For such devices, a way to avoid raw access is needed.
Introduce
SPINAND_NO_RAW_ACCESSflag to advertise the device does not support raw access. Read and write page in raw mode for the device returns error.
Quoted 9 lines
Quoted 2 lines
Checking and marking BBM need to be performed with ECC enabled to read and write the BBM correctly.
I see your point but I'm a bit puzzled by how it's being done.
First, you disregard completely the
isbad()andmarkbad()situations. Please have look into that because these functions are broken with your devices.
Yes... now I understand how they are broken.
Quoted 4 lines
Second, what about adding this detail to the ondie ECC engine? You could simply return an error from there, so basically a single (or maybe two) changes overall.
Thank you for the suggestion.
How about change like below in prepare_finish_io_req()?
static int spinand_ondie_ecc_prepare_io_req(struct nand_device *nand,
struct nand_page_io_req *req)
{
struct spinand_device *spinand = nand_to_spinand(nand);
bool enable = (req->mode != MTD_OPS_RAW);+ /*
+ * For the devices that prohibit raw access (on-die ECC must be always
+ * enabled), return error in case of raw data access. Accessing to OOB
+ * needs to be allowed with on-die ECC enabled to support BBM checking
+ * and marking.
+ */
+ if (!enable && spinand->flags & SPINAND_NO_RAW_ACCESS) {
+ if (req->datalen)
+ return -ENOTSUPP;
+
+ enable = true;
+ }
...
Quoted 2 lines
Thanks,
Miquèl
Thanks!
Takahiro
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Miquel Raynal
maintainerRe: [PATCH 1/2] mtd: spinand: Introduce a way to avoid raw access
Quoted 42 lines · Takahiro Kuwano
Hi,
Quoted 15 lines · Miquel Raynal
Hi,
Quoted 11 lines · On 31/10/2024 at 11:21:54 +09, [email protected] wrote:
From: Takahiro Kuwano <[email protected]>
SkyHigh spinand device has ECC enable bit in configuration register but it must be always enabled. If ECC is disabled, read and write ops results in undetermined state. For such devices, a way to avoid raw access is needed.
Introduce
SPINAND_NO_RAW_ACCESSflag to advertise the device does not support raw access. Read and write page in raw mode for the device returns error.Quoted 9 lines
Quoted 2 lines
Checking and marking BBM need to be performed with ECC enabled to read and write the BBM correctly.
I see your point but I'm a bit puzzled by how it's being done.
First, you disregard completely the
isbad()andmarkbad()situations. Please have look into that because these functions are broken with your devices.Yes... now I understand how they are broken.
Quoted 4 lines
Second, what about adding this detail to the ondie ECC engine? You could simply return an error from there, so basically a single (or maybe two) changes overall.
Thank you for the suggestion.
How about change like below inprepare_finish_io_req()?static int spinand_ondie_ecc_prepare_io_req(struct
nand_device*nand,
structnand_page_io_req*req){ struct spinand_device *spinand = nand_to_spinand(nand); bool enable = (req->mode != MTD_OPS_RAW);
Review
Quoted 9 lines
(quoted diff) +9
-0+ /* + * For the devices that prohibit raw access (on-die ECC must be always + * enabled), return error in case of raw data access. Accessing to OOB + * needs to be allowed with on-die ECC enabled to support BBM checking + * and marking. + */ + if (!enable && spinand->flags & SPINAND_NO_RAW_ACCESS) { + if (req->datalen) + return -ENOTSUPP;
EOPNOTSUPP
Review
Quoted 3 lines
(quoted diff) +3
-0+ + enable = true; + }
No, this is lying, I don't like that.
What about just returnint an error here if you cannot do what the upper layer has asked you to do. And in the upper layer, you can add two specific conditions to is_bad/mark_bad() allowing to fallback to a "with ECC" operation in the EOPNOTSUPP case (with a short comment).
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 1/2] mtd: spinand: Introduce a way to avoid raw access
Quoted 62 lines · Miquel Raynal
Quoted 42 lines · Takahiro Kuwano
Hi,
Quoted 15 lines · Miquel Raynal
Hi,
Quoted 11 lines · On 31/10/2024 at 11:21:54 +09, [email protected] wrote:
From: Takahiro Kuwano <[email protected]>
SkyHigh spinand device has ECC enable bit in configuration register but it must be always enabled. If ECC is disabled, read and write ops results in undetermined state. For such devices, a way to avoid raw access is needed.
Introduce
SPINAND_NO_RAW_ACCESSflag to advertise the device does not support raw access. Read and write page in raw mode for the device returns error.Quoted 9 lines
Quoted 2 lines
Checking and marking BBM need to be performed with ECC enabled to read and write the BBM correctly.
I see your point but I'm a bit puzzled by how it's being done.
First, you disregard completely the
isbad()andmarkbad()situations. Please have look into that because these functions are broken with your devices.Yes... now I understand how they are broken.
Quoted 4 lines
Second, what about adding this detail to the ondie ECC engine? You could simply return an error from there, so basically a single (or maybe two) changes overall.
Thank you for the suggestion.
How about change like below inprepare_finish_io_req()?static int spinand_ondie_ecc_prepare_io_req(struct
nand_device*nand,
structnand_page_io_req*req){ struct spinand_device *spinand = nand_to_spinand(nand); bool enable = (req->mode != MTD_OPS_RAW);Review
Quoted 9 lines
(quoted diff) +9
-0+ /* + * For the devices that prohibit raw access (on-die ECC must be always + * enabled), return error in case of raw data access. Accessing to OOB + * needs to be allowed with on-die ECC enabled to support BBM checking + * and marking. + */ + if (!enable && spinand->flags & SPINAND_NO_RAW_ACCESS) { + if (req->datalen) + return -ENOTSUPP;EOPNOTSUPP
Review
Quoted 3 lines
(quoted diff) +3
-0+ + enable = true; + }No, this is lying, I don't like that.
Quoted 5 lines
What about just returnint an error here if you cannot do what the upper layer has asked you to do. And in the upper layer, you can add two specific conditions to is_bad/mark_bad() allowing to fallback to a "with ECC" operation in the EOPNOTSUPP case (with a short comment).
OK, I will do it in next revision.
Thanks again.
BTW, spinand_write_enable_op() in spinand_markbad() looks redundant as it is called in spinand_write_page(). Let me remove it before adding fallback.
Quoted 2 lines
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 2/2 mtd: spinand: Add support for SkyHigh S35ML-3 family
In reply to [email protected]From: Takahiro Kuwano <[email protected]>
SkyHigh S35ML01G300, S35ML01G301, S35ML02G300, and S35ML04G300 are 1Gb, 2Gb, and 4Gb SLC SPI NAND flash family. This family of devices has on-die ECC which parity bits are stored to hidden area. In this family the on-die ECC cannot be disabled so raw access needs to be prevented.
--- drivers/mtd/nand/spi/Makefile | 2 +- drivers/mtd/nand/spi/core.c | 1 + drivers/mtd/nand/spi/skyhigh.c | 143 +++++++++++++++++++++++++++++++++ include/linux/mtd/spinand.h | 1 + 4 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 drivers/mtd/nand/spi/skyhigh.c
drivers/mtd/nand/spi/Makefile +1 -1
@@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 spinand-objs := core.o alliancememory.o ato.o esmt.o foresee.o gigadevice.o macronix.o -spinand-objs += micron.o paragon.o toshiba.o winbond.o xtx.o +spinand-objs += micron.o paragon.o skyhigh.o toshiba.o winbond.o xtx.o obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
drivers/mtd/nand/spi/core.c +1 -0
@@ -1129,6 +1129,7 @@ static const struct spinand_manufacturer *spinand_manufacturers[] = { ¯onix_spinand_manufacturer, µn_spinand_manufacturer, ¶gon_spinand_manufacturer, + &skyhigh_spinand_manufacturer, &toshiba_spinand_manufacturer, &winbond_spinand_manufacturer, &xtx_spinand_manufacturer,
drivers/mtd/nand/spi/skyhigh.c new file +143 -0
143 lines not on this page · raw message
include/linux/mtd/spinand.h +1 -0
@@ -268,6 +268,7 @@ extern const struct spinand_manufacturer gigadevice_spinand_manufacturer;extern const struct spinand_manufacturer macronix_spinand_manufacturer;extern const struct spinand_manufacturer micron_spinand_manufacturer;extern const struct spinand_manufacturer paragon_spinand_manufacturer; +extern const struct spinand_manufacturer skyhigh_spinand_manufacturer;extern const struct spinand_manufacturer toshiba_spinand_manufacturer;extern const struct spinand_manufacturer winbond_spinand_manufacturer;extern const struct spinand_manufacturer xtx_spinand_manufacturer;
Signature · 6 lines
2.34.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Miquel Raynal
maintainerQuoted 10 lines · On 31/10/2024 at 11:21:55 +09, [email protected] wrote:
From: Takahiro Kuwano <[email protected]>
SkyHigh S35ML01G300, S35ML01G301, S35ML02G300, and S35ML04G300 are 1Gb, 2Gb, and 4Gb SLC SPI NAND flash family. This family of devices has on-die ECC which parity bits are stored to hidden area. In this family the on-die ECC cannot be disabled so raw access needs to be prevented.
Please have a look to the documentation regarding how to document authorship, because currently the tags are wrong.
...
drivers/mtd/nand/spi/skyhigh.c line 128
Quoted 3 lines
drivers/mtd/nand/spi/skyhigh.c new file +3
-0+static int skyhigh_spinand_init (struct spinand_device *spinand) +{ +/* A0[1] must be enabled before block unlock */
What is A0[1] ? It does not mean anything here, please be more explicit.
drivers/mtd/nand/spi/skyhigh.c line 135
Quoted 7 lines
drivers/mtd/nand/spi/skyhigh.c new file +7
-0+return spinand_write_reg_op (spinand,REG_BLOCK_LOCK , +SKYHIGH_CONFIG_PROTECT_EN ); +} + +static const struct spinand_manufacturer_ops skyhigh_spinand_manuf_ops = { + .init = skyhigh_spinand_init, +};
Otherwise this looks goot do me.
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Miquel Raynal
maintainerQuoted 4 lines · On 31/10/2024 at 11:21:53 +09, [email protected] wrote:
From: Takahiro Kuwano <[email protected]>
This series is successor of the patch submitted by KR Kim:
https://patchwork.ozlabs.org/project/linux-mtd/patch/[email protected]/
Please append a changelog next time.
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/