* [PATCH 1/2] nand_base: SOFT_BCH: Request strength over bytes [not found] <2021171878.109755.1421108768347.JavaMail.zimbra@xes-inc.com> @ 2015-01-13 0:35 ` Aaron Sierra 2015-01-14 9:34 ` Boris Brezillon 0 siblings, 1 reply; 6+ messages in thread From: Aaron Sierra @ 2015-01-13 0:35 UTC (permalink / raw) To: Brian Norris, David Woodhouse, Boris Brezillon, Ezequiel Garcia; +Cc: linux-mtd Previously, we requested that drivers pass ecc.size and ecc.bytes when using NAND_ECC_SOFT_BCH. However, a driver is likely to only know the ECC strength required for its NAND, so each driver would need to perform a strength-to-bytes calculation. Avoid duplicating this calculation in each driver by asking drivers to pass ecc.size and ecc.strength so that the strength-to-bytes calculation need only be implemented once. This reverts/generalizes this commit: mtd: nand: Base BCH ECC bytes on required strength Signed-off-by: Aaron Sierra <asierra@xes-inc.com> --- drivers/mtd/nand/nand_base.c | 21 +++++++++++++++------ drivers/mtd/nand/sunxi_nand.c | 2 -- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 41585df..993612c 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -4028,22 +4028,31 @@ int nand_scan_tail(struct mtd_info *mtd) ecc->read_oob = nand_read_oob_std; ecc->write_oob = nand_write_oob_std; /* - * Board driver should supply ecc.size and ecc.bytes values to - * select how many bits are correctable; see nand_bch_init() - * for details. Otherwise, default to 4 bits for large page - * devices. + * Board driver should supply ecc.size and ecc.strength values + * to select how many bits are correctable. Otherwise, default + * to 4 bits for large page devices. */ if (!ecc->size && (mtd->oobsize >= 64)) { ecc->size = 512; - ecc->bytes = DIV_ROUND_UP(13 * ecc->strength, 8); + ecc->strength = 4; } + + /* + * We previously recommended drivers pass ecc.size and + * ecc.bytes. Continue to support drivers that do. + * See nand_bch_init() for details. + */ + if (ecc->bytes && !ecc->strength) + ecc->strength = ecc->bytes * 8 / fls(8 * ecc->size); + + ecc->bytes = DIV_ROUND_UP( + ecc->strength * fls(8 * ecc->size), 8); ecc->priv = nand_bch_init(mtd, ecc->size, ecc->bytes, &ecc->layout); if (!ecc->priv) { pr_warn("BCH ECC initialization failed!\n"); BUG(); } - ecc->strength = ecc->bytes * 8 / fls(8 * ecc->size); break; case NAND_ECC_NONE: diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c index ccaa8e2..6f93b29 100644 --- a/drivers/mtd/nand/sunxi_nand.c +++ b/drivers/mtd/nand/sunxi_nand.c @@ -1110,8 +1110,6 @@ static int sunxi_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc, switch (ecc->mode) { case NAND_ECC_SOFT_BCH: - ecc->bytes = DIV_ROUND_UP(ecc->strength * fls(8 * ecc->size), - 8); break; case NAND_ECC_HW: ret = sunxi_nand_hw_ecc_ctrl_init(mtd, ecc, np); -- 1.9.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] nand_base: SOFT_BCH: Request strength over bytes 2015-01-13 0:35 ` [PATCH 1/2] nand_base: SOFT_BCH: Request strength over bytes Aaron Sierra @ 2015-01-14 9:34 ` Boris Brezillon 2015-01-14 19:08 ` Aaron Sierra 2015-01-14 23:41 ` [PATCH 1/2 v2] " Aaron Sierra 0 siblings, 2 replies; 6+ messages in thread From: Boris Brezillon @ 2015-01-14 9:34 UTC (permalink / raw) To: Aaron Sierra; +Cc: linux-mtd, Brian Norris, David Woodhouse, Ezequiel Garcia Hi Aaron, On Mon, 12 Jan 2015 18:35:55 -0600 (CST) Aaron Sierra <asierra@xes-inc.com> wrote: > Previously, we requested that drivers pass ecc.size and ecc.bytes when > using NAND_ECC_SOFT_BCH. However, a driver is likely to only know the ECC > strength required for its NAND, so each driver would need to perform a > strength-to-bytes calculation. > > Avoid duplicating this calculation in each driver by asking drivers to > pass ecc.size and ecc.strength so that the strength-to-bytes calculation > need only be implemented once. > > This reverts/generalizes this commit: > mtd: nand: Base BCH ECC bytes on required strength Apart from the nit below, you can add my: Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com> > > Signed-off-by: Aaron Sierra <asierra@xes-inc.com> > --- > drivers/mtd/nand/nand_base.c | 21 +++++++++++++++------ > drivers/mtd/nand/sunxi_nand.c | 2 -- > 2 files changed, 15 insertions(+), 8 deletions(-) > > diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c > index 41585df..993612c 100644 > --- a/drivers/mtd/nand/nand_base.c > +++ b/drivers/mtd/nand/nand_base.c > @@ -4028,22 +4028,31 @@ int nand_scan_tail(struct mtd_info *mtd) > ecc->read_oob = nand_read_oob_std; > ecc->write_oob = nand_write_oob_std; > /* > - * Board driver should supply ecc.size and ecc.bytes values to > - * select how many bits are correctable; see nand_bch_init() > - * for details. Otherwise, default to 4 bits for large page > - * devices. > + * Board driver should supply ecc.size and ecc.strength values > + * to select how many bits are correctable. Otherwise, default > + * to 4 bits for large page devices. > */ > if (!ecc->size && (mtd->oobsize >= 64)) { > ecc->size = 512; > - ecc->bytes = DIV_ROUND_UP(13 * ecc->strength, 8); > + ecc->strength = 4; > } > + > + /* > + * We previously recommended drivers pass ecc.size and > + * ecc.bytes. Continue to support drivers that do. > + * See nand_bch_init() for details. > + */ > + if (ecc->bytes && !ecc->strength) > + ecc->strength = ecc->bytes * 8 / fls(8 * ecc->size); How about fixing all NAND_ECC_SOFT_BCH users (AFAICT the only remaining one is nandsim, since you fixed sunxi_nand) instead of keeping this backward compat code. Best Regards, Boris -- Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] nand_base: SOFT_BCH: Request strength over bytes 2015-01-14 9:34 ` Boris Brezillon @ 2015-01-14 19:08 ` Aaron Sierra 2015-01-14 23:41 ` [PATCH 1/2 v2] " Aaron Sierra 1 sibling, 0 replies; 6+ messages in thread From: Aaron Sierra @ 2015-01-14 19:08 UTC (permalink / raw) To: Boris Brezillon; +Cc: linux-mtd, Brian Norris, David Woodhouse, Ezequiel Garcia ----- Original Message ----- > From: "Boris Brezillon" <boris.brezillon@free-electrons.com> > Sent: Wednesday, January 14, 2015 3:34:49 AM > > Hi Aaron, > > On Mon, 12 Jan 2015 18:35:55 -0600 (CST) > Aaron Sierra <asierra@xes-inc.com> wrote: > > > Previously, we requested that drivers pass ecc.size and ecc.bytes when > > using NAND_ECC_SOFT_BCH. However, a driver is likely to only know the ECC > > strength required for its NAND, so each driver would need to perform a > > strength-to-bytes calculation. > > > > Avoid duplicating this calculation in each driver by asking drivers to > > pass ecc.size and ecc.strength so that the strength-to-bytes calculation > > need only be implemented once. > > > > This reverts/generalizes this commit: > > mtd: nand: Base BCH ECC bytes on required strength > > Apart from the nit below, you can add my: > > Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com> > > > > > Signed-off-by: Aaron Sierra <asierra@xes-inc.com> > > --- > > drivers/mtd/nand/nand_base.c | 21 +++++++++++++++------ > > drivers/mtd/nand/sunxi_nand.c | 2 -- > > 2 files changed, 15 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c > > index 41585df..993612c 100644 > > --- a/drivers/mtd/nand/nand_base.c > > +++ b/drivers/mtd/nand/nand_base.c > > @@ -4028,22 +4028,31 @@ int nand_scan_tail(struct mtd_info *mtd) > > ecc->read_oob = nand_read_oob_std; > > ecc->write_oob = nand_write_oob_std; > > /* > > - * Board driver should supply ecc.size and ecc.bytes values to > > - * select how many bits are correctable; see nand_bch_init() > > - * for details. Otherwise, default to 4 bits for large page > > - * devices. > > + * Board driver should supply ecc.size and ecc.strength values > > + * to select how many bits are correctable. Otherwise, default > > + * to 4 bits for large page devices. > > */ > > if (!ecc->size && (mtd->oobsize >= 64)) { > > ecc->size = 512; > > - ecc->bytes = DIV_ROUND_UP(13 * ecc->strength, 8); > > + ecc->strength = 4; > > } > > + > > + /* > > + * We previously recommended drivers pass ecc.size and > > + * ecc.bytes. Continue to support drivers that do. > > + * See nand_bch_init() for details. > > + */ > > + if (ecc->bytes && !ecc->strength) > > + ecc->strength = ecc->bytes * 8 / fls(8 * ecc->size); > > How about fixing all NAND_ECC_SOFT_BCH users (AFAICT the only remaining > one is nandsim, since you fixed sunxi_nand) instead of keeping this > backward compat code. Boris, Yes, nandsim was the only other that I found. I will submit an update that does not include this backward compatibility code, thanks. -Aaron > > Best Regards, > > Boris ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2 v2] nand_base: SOFT_BCH: Request strength over bytes 2015-01-14 9:34 ` Boris Brezillon 2015-01-14 19:08 ` Aaron Sierra @ 2015-01-14 23:41 ` Aaron Sierra 2015-01-29 16:46 ` Aaron Sierra 1 sibling, 1 reply; 6+ messages in thread From: Aaron Sierra @ 2015-01-14 23:41 UTC (permalink / raw) To: Brian Norris, David Woodhouse, Ezequiel Garcia, Boris Brezillon; +Cc: linux-mtd Previously, we requested that drivers pass ecc.size and ecc.bytes when using NAND_ECC_SOFT_BCH. However, a driver is likely to only know the ECC strength required for its NAND, so each driver would need to perform a strength-to-bytes calculation. Avoid duplicating this calculation in each driver by asking drivers to pass ecc.size and ecc.strength so that the strength-to-bytes calculation need only be implemented once. This reverts/generalizes this commit: mtd: nand: Base BCH ECC bytes on required strength Signed-off-by: Aaron Sierra <asierra@xes-inc.com> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com> --- v2: * nandsim: Set ECC strength to chip->ecc.strength * nand_base: Don't provide ECC bytes-to-strength backward compat drivers/mtd/nand/nand_base.c | 14 ++++++++------ drivers/mtd/nand/nandsim.c | 1 + drivers/mtd/nand/sunxi_nand.c | 2 -- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 41585df..2f9c0bf 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -4028,22 +4028,24 @@ int nand_scan_tail(struct mtd_info *mtd) ecc->read_oob = nand_read_oob_std; ecc->write_oob = nand_write_oob_std; /* - * Board driver should supply ecc.size and ecc.bytes values to - * select how many bits are correctable; see nand_bch_init() - * for details. Otherwise, default to 4 bits for large page - * devices. + * Board driver should supply ecc.size and ecc.strength values + * to select how many bits are correctable. Otherwise, default + * to 4 bits for large page devices. */ if (!ecc->size && (mtd->oobsize >= 64)) { ecc->size = 512; - ecc->bytes = DIV_ROUND_UP(13 * ecc->strength, 8); + ecc->strength = 4; } + + /* See nand_bch_init() for details. */ + ecc->bytes = DIV_ROUND_UP( + ecc->strength * fls(8 * ecc->size), 8); ecc->priv = nand_bch_init(mtd, ecc->size, ecc->bytes, &ecc->layout); if (!ecc->priv) { pr_warn("BCH ECC initialization failed!\n"); BUG(); } - ecc->strength = ecc->bytes * 8 / fls(8 * ecc->size); break; case NAND_ECC_NONE: diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c index ab5bbf5..0ed1464 100644 --- a/drivers/mtd/nand/nandsim.c +++ b/drivers/mtd/nand/nandsim.c @@ -2343,6 +2343,7 @@ static int __init ns_init_module(void) } chip->ecc.mode = NAND_ECC_SOFT_BCH; chip->ecc.size = 512; + chip->ecc.strength = bch; chip->ecc.bytes = eccbytes; NS_INFO("using %u-bit/%u bytes BCH ECC\n", bch, chip->ecc.size); } diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c index ccaa8e2..6f93b29 100644 --- a/drivers/mtd/nand/sunxi_nand.c +++ b/drivers/mtd/nand/sunxi_nand.c @@ -1110,8 +1110,6 @@ static int sunxi_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc, switch (ecc->mode) { case NAND_ECC_SOFT_BCH: - ecc->bytes = DIV_ROUND_UP(ecc->strength * fls(8 * ecc->size), - 8); break; case NAND_ECC_HW: ret = sunxi_nand_hw_ecc_ctrl_init(mtd, ecc, np); -- 1.9.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2 v2] nand_base: SOFT_BCH: Request strength over bytes 2015-01-14 23:41 ` [PATCH 1/2 v2] " Aaron Sierra @ 2015-01-29 16:46 ` Aaron Sierra 2015-02-02 5:12 ` Brian Norris 0 siblings, 1 reply; 6+ messages in thread From: Aaron Sierra @ 2015-01-29 16:46 UTC (permalink / raw) To: Brian Norris, David Woodhouse, Ezequiel Garcia, Boris Brezillon; +Cc: linux-mtd ----- Original Message ----- > From: "Aaron Sierra" <asierra@xes-inc.com> > Sent: Wednesday, January 14, 2015 5:41:31 PM > > Previously, we requested that drivers pass ecc.size and ecc.bytes when > using NAND_ECC_SOFT_BCH. However, a driver is likely to only know the ECC > strength required for its NAND, so each driver would need to perform a > strength-to-bytes calculation. > > Avoid duplicating this calculation in each driver by asking drivers to > pass ecc.size and ecc.strength so that the strength-to-bytes calculation > need only be implemented once. > > This reverts/generalizes this commit: > mtd: nand: Base BCH ECC bytes on required strength > > Signed-off-by: Aaron Sierra <asierra@xes-inc.com> > Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com> > --- > v2: > * nandsim: Set ECC strength to chip->ecc.strength > * nand_base: Don't provide ECC bytes-to-strength backward compat > > drivers/mtd/nand/nand_base.c | 14 ++++++++------ > drivers/mtd/nand/nandsim.c | 1 + > drivers/mtd/nand/sunxi_nand.c | 2 -- > 3 files changed, 9 insertions(+), 8 deletions(-) > Is this patch still being considered despite the changes requested for the 2nd patch in this series? -Aaron ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2 v2] nand_base: SOFT_BCH: Request strength over bytes 2015-01-29 16:46 ` Aaron Sierra @ 2015-02-02 5:12 ` Brian Norris 0 siblings, 0 replies; 6+ messages in thread From: Brian Norris @ 2015-02-02 5:12 UTC (permalink / raw) To: Aaron Sierra; +Cc: Boris Brezillon, David Woodhouse, Ezequiel Garcia, linux-mtd On Thu, Jan 29, 2015 at 10:46:08AM -0600, Aaron Sierra wrote: > ----- Original Message ----- > > From: "Aaron Sierra" <asierra@xes-inc.com> > > Sent: Wednesday, January 14, 2015 5:41:31 PM > > > > Previously, we requested that drivers pass ecc.size and ecc.bytes when > > using NAND_ECC_SOFT_BCH. However, a driver is likely to only know the ECC > > strength required for its NAND, so each driver would need to perform a > > strength-to-bytes calculation. > > > > Avoid duplicating this calculation in each driver by asking drivers to > > pass ecc.size and ecc.strength so that the strength-to-bytes calculation > > need only be implemented once. > > > > This reverts/generalizes this commit: > > mtd: nand: Base BCH ECC bytes on required strength > > > > Signed-off-by: Aaron Sierra <asierra@xes-inc.com> > > Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com> > > --- > > v2: > > * nandsim: Set ECC strength to chip->ecc.strength > > * nand_base: Don't provide ECC bytes-to-strength backward compat > > > > drivers/mtd/nand/nand_base.c | 14 ++++++++------ > > drivers/mtd/nand/nandsim.c | 1 + > > drivers/mtd/nand/sunxi_nand.c | 2 -- > > 3 files changed, 9 insertions(+), 8 deletions(-) > > > > Is this patch still being considered despite the changes requested for > the 2nd patch in this series? Sorry, I thought I had queued it up. Pushed this patch to l2-mtd.git now. Thanks. Brian ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-02-02 5:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <2021171878.109755.1421108768347.JavaMail.zimbra@xes-inc.com>
2015-01-13 0:35 ` [PATCH 1/2] nand_base: SOFT_BCH: Request strength over bytes Aaron Sierra
2015-01-14 9:34 ` Boris Brezillon
2015-01-14 19:08 ` Aaron Sierra
2015-01-14 23:41 ` [PATCH 1/2 v2] " Aaron Sierra
2015-01-29 16:46 ` Aaron Sierra
2015-02-02 5:12 ` Brian Norris
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox