2013-05-03 06:35:18

by Huang Shijie

[permalink] [raw]
Subject: [PATCH 0/4] 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(-)


2013-05-03 06:35:08

by Huang Shijie

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

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.

Signed-off-by: Huang Shijie <[email protected]>
---
include/linux/mtd/mtd.h | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 183a304..b93035f 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -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;

--
1.7.1

2013-05-03 06:35:21

by Huang Shijie

[permalink] [raw]
Subject: [PATCH 3/4] mtd: set the ecc step size for master/slave mtd_info

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

Signed-off-by: Huang Shijie <[email protected]>
---
drivers/mtd/mtdpart.c | 1 +
drivers/mtd/nand/nand_base.c | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 3014933..e948eb6 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -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;

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 92d0548..9de7cda 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -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
--
1.7.1

2013-05-03 06:37:00

by Huang Shijie

[permalink] [raw]
Subject: [PATCH 2/4] mtd: add a new sys node to show the ecc step size

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

Signed-off-by: Huang Shijie <[email protected]>
---
drivers/mtd/mtdcore.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index e513fc4..2ed2827 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -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,
};
--
1.7.1

2013-05-03 06:35:16

by Huang Shijie

[permalink] [raw]
Subject: [PATCH 4/4] mtd: gpmi: update the ecc step size for mtd_info{}

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

Signed-off-by: Huang Shijie <[email protected]>
---
drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 0451a1d..b9e05df 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -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(). */
--
1.7.1

2013-05-15 07:45:26

by Artem Bityutskiy

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

On Fri, 2013-05-03 at 14:21 +0800, Huang Shijie wrote:
> 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.
>
> Signed-off-by: Huang Shijie <[email protected]>
> ---
> include/linux/mtd/mtd.h | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index 183a304..b93035f 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -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.

--
Best Regards,
Artem Bityutskiy

2013-05-15 07:57:04

by Huang Shijie

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

于 2013年05月15日 15:47, Artem Bityutskiy 写道:
> On Fri, 2013-05-03 at 14:21 +0800, Huang Shijie wrote:
>> 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.
>>
>> Signed-off-by: Huang Shijie<[email protected]>
>> ---
>> include/linux/mtd/mtd.h | 3 +++
>> 1 files changed, 3 insertions(+), 0 deletions(-)
>>
>> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
>> index 183a304..b93035f 100644
>> --- a/include/linux/mtd/mtd.h
>> +++ b/include/linux/mtd/mtd.h
>> @@ -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.
>
ok. I will use ecc_step as the name.

thanks
Huang Shijie