Skip to contentSkip to conversation

Export the ecc step size to user applications

PATCH Superseded Huang Shijie 2 participants 7 messages May 3, 2013 – May 15, 2013

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#1 lore raw

PATCH 1/4 mtd: add a new field to mtd_info{}

In reply to Huang Shijie

In order to implement the NAND boot for some Freescale's chips, such as imx23/imx28/imx50/imx6, we use a tool (called kobs-ng) to burn the uboot and some metadata to nand chip. And the ROM code will use the metadata to configrate the BCH, and to find the uboot.

The ECC information(ecc step size, ecc strength) which is used to configrate the BCH is part of the metadata. The kobs-ng can gets the ecc strength from the sys node /sys/*/ecc_strength now. But it can not gets the ecc step size.

This patch adds a new field to store the ecc step size in mtd_info{}, and it makes preparation for the next patches.

---
 include/linux/mtd/mtd.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
include/linux/mtd/mtd.h +3 -0
index 183a304..b93035f 100644
@@ -173,6 +173,9 @@ struct mtd_info {
 	/* ECC layout structure pointer - read only! */
 	struct nand_ecclayout *ecclayout;
 
+	/* the ecc step size. */
+	unsigned int ecc_size;
+
 	/* max number of correctible bit errors per ecc step */
 	unsigned int ecc_strength;
 
Signature · 1 line
1.7.1
#6 lore raw

PATCH 4/4 mtd: gpmi: update the ecc step size for mtd_info{}

In reply to Huang Shijie

update the ecc step size when we have already get the right value.

---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +1 -0
index 0451a1d..b9e05df 100644
@@ -1644,6 +1644,7 @@ static int gpmi_pre_bbt_scan(struct gpmi_nand_data  *this)
 	/* Adjust the ECC strength according to the chip. */
 	this->nand.ecc.strength = this->bch_geometry.ecc_strength;
 	this->mtd.ecc_strength = this->bch_geometry.ecc_strength;
+	this->mtd.ecc_size = this->bch_geometry.ecc_chunk_size;
 	this->mtd.bitflip_threshold = this->bch_geometry.ecc_strength;
 
 	/* NAND boot init, depends on the gpmi_set_geometry(). */
Signature · 1 line
1.7.1
#0 lore raw

cover Export the ecc step size to user applications

In order to implement the NAND boot for some Freescale's chips, such as imx23/imx28/imx50/imx6, we use a tool (called kobs-ng) to burn the uboot and some metadata to nand chip. And the ROM code will use the metadata to configrate the BCH, and to find the uboot.

The ECC information(ecc step size, ecc strength) which is used to configrate the BCH is part of the metadata. The kobs-ng can gets the ecc strength from the sys node /sys/*/mtdX/ecc_strength now. But it can't gets the ecc step size.

This patch set is used to export the ecc step size to user applications. With this patch set, the kobs-ng can gets the ecc step size now.

Huang Shijie (4):
mtd: add a new field to mtd_info{}
mtd: add a new sys node to show the ecc step size
mtd: set the ecc step size for master/slave mtd_info
mtd: gpmi: update the ecc step size for mtd_info{}

 drivers/mtd/mtdcore.c                  |   11 +++++++++++
 drivers/mtd/mtdpart.c                  |    1 +
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c |    1 +
 drivers/mtd/nand/nand_base.c           |    1 +
 include/linux/mtd/mtd.h                |    3 +++
 5 files changed, 17 insertions(+), 0 deletions(-)
#5 lore raw

PATCH 3/4 mtd: set the ecc step size for master/slave mtd_info

Set the ecc step size for master/slave mtd_info{}.

---
 drivers/mtd/mtdpart.c        |    1 +
 drivers/mtd/nand/nand_base.c |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
drivers/mtd/mtdpart.c +1 -0
index 3014933..e948eb6 100644
@@ -516,6 +516,7 @@ static struct mtd_part *allocate_partition(struct mtd_info *master,
 	}
 
 	slave->mtd.ecclayout = master->ecclayout;
+	slave->mtd.ecc_size = master->ecc_size;
 	slave->mtd.ecc_strength = master->ecc_strength;
 	slave->mtd.bitflip_threshold = master->bitflip_threshold;
 
drivers/mtd/nand/nand_base.c +1 -0
index 92d0548..9de7cda 100644
@@ -3760,6 +3760,7 @@ int nand_scan_tail(struct mtd_info *mtd)
 	/* propagate ecc info to mtd_info */
 	mtd->ecclayout = chip->ecc.layout;
 	mtd->ecc_strength = chip->ecc.strength;
+	mtd->ecc_size = chip->ecc.size;
 	/*
 	 * Initialize bitflip_threshold to its default prior scan_bbt() call.
 	 * scan_bbt() might invoke mtd_read(), thus bitflip_threshold must be
Signature · 1 line
1.7.1
#4 lore raw

PATCH 2/4 mtd: add a new sys node to show the ecc step size

In reply to Huang Shijie

Add a new sys node to show the ecc step size.
The application then can uses this node to get the ecc step size.

---
 drivers/mtd/mtdcore.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
drivers/mtd/mtdcore.c +11 -0
index e513fc4..2ed2827 100644
@@ -287,6 +287,16 @@ static DEVICE_ATTR(bitflip_threshold, S_IRUGO | S_IWUSR,
 		   mtd_bitflip_threshold_show,
 		   mtd_bitflip_threshold_store);
 
+static ssize_t mtd_ecc_size_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct mtd_info *mtd = dev_get_drvdata(dev);
+
+	return snprintf(buf, PAGE_SIZE, "%lu\n", (unsigned long)mtd->ecc_size);
+
+}
+static DEVICE_ATTR(ecc_size, S_IRUGO, mtd_ecc_size_show, NULL);
+
 static struct attribute *mtd_attrs[] = {
 	&dev_attr_type.attr,
 	&dev_attr_flags.attr,
@@ -298,6 +308,7 @@ static struct attribute *mtd_attrs[] = {
 	&dev_attr_numeraseregions.attr,
 	&dev_attr_name.attr,
 	&dev_attr_ecc_strength.attr,
+	&dev_attr_ecc_size.attr,
 	&dev_attr_bitflip_threshold.attr,
 	NULL,
 };
Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH 1/4] mtd: add a new field to mtd_info{}

In reply to Huang Shijie
Quoted 22 lines · Huang Shijie

In order to implement the NAND boot for some Freescale's chips, such as imx23/imx28/imx50/imx6, we use a tool (called kobs-ng) to burn the uboot and some metadata to nand chip. And the ROM code will use the metadata to configrate the BCH, and to find the uboot.

The ECC information(ecc step size, ecc strength) which is used to configrate the BCH is part of the metadata. The kobs-ng can gets the ecc strength from the sys node /sys/*/ecc_strength now. But it can not gets the ecc step size.

This patch adds a new field to store the ecc step size in mtd_info{}, and it makes preparation for the next patches.

---
 include/linux/mtd/mtd.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
include/linux/mtd/mtd.h +0 -0
index 183a304..b93035f 100644

include/linux/mtd/mtd.h struct mtd_info { · line 177

Quoted 5 lines
include/linux/mtd/mtd.h +2 -0
@@ -173,6 +173,9 @@ struct mtd_info {
 	/* ECC layout structure pointer - read only! */
 	struct nand_ecclayout *ecclayout;
 
+	/* the ecc step size. */
+	unsigned int ecc_size;

It would really be nice to harmonize the naming and probably stick to ecc_step everywhere. To me things looks confusing, because ecc_size is actually ECC step size, and not the size of ECC codes.

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#3 lore raw

Re: [PATCH 1/4] mtd: add a new field to mtd_info{}

Quoted 26 lines · Artem Bityutskiy
Quoted 25 lines · Huang Shijie

In order to implement the NAND boot for some Freescale's chips, such as imx23/imx28/imx50/imx6, we use a tool (called kobs-ng) to burn the uboot and some metadata to nand chip. And the ROM code will use the metadata to configrate the BCH, and to find the uboot.

The ECC information(ecc step size, ecc strength) which is used to configrate the BCH is part of the metadata. The kobs-ng can gets the ecc strength from the sys node /sys/*/ecc_strength now. But it can not gets the ecc step size.

This patch adds a new field to store the ecc step size in mtd_info{}, and it makes preparation for the next patches.

---
  include/linux/mtd/mtd.h |    3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)
include/linux/mtd/mtd.h +0 -0
index 183a304..b93035f 100644
@@ -173,6 +173,9 @@ struct mtd_info {
  	/* ECC layout structure pointer - read only! */
  	struct nand_ecclayout *ecclayout;
 
Quoted 6 lines

include/linux/mtd/mtd.h struct mtd_info { · line 177

Quoted 2 lines
include/linux/mtd/mtd.h +2 -0
+	/* the ecc step size. */
+	unsigned int ecc_size;

It would really be nice to harmonize the naming and probably stick to ecc_step everywhere. To me things looks confusing, because ecc_size is actually ECC step size, and not the size of ECC codes.

ok. I will use ecc_step as the name.

thanks
Huang Shijie