Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mtd: rawnand: gpmi: Refactor bch geometry settings function

The code change refactor the bch geometry setting function, which
doesn't change the default behavior, while user may choose to use chips
required minimum ecc strength by DT flag "fsl,use-minimum-ecc".

The default way to set bch geometry need to set the data chunk
size(step_size) larger than oob size to make sure BBM locates in data
chunk, then set the maximum ecc strength oob can hold. It always use
unbalanced ECC layout, which ecc0 will cover both meta and data0 chunk.
But the default bch setting is deprecated for large oobsize NAND
(oobsize >1KB), so in the patch set, there is a split commit that
introduces a new way to set bch geometry for large oob size NAND.

For all other cases,set the bch geometry by chip required strength and
step size, which uses the minimum ecc strength chip required. It can be
explicitly enabled by DT flag "fsl,use-minimum-ecc", but need to be
en/disabled in both u-boot and kernel at the same time.

Signed-off-by: Han Xu <han.xu@nxp.com>
Tested-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220412025246.24269-2-han.xu@nxp.com

authored by

Han Xu and committed by
Miquel Raynal
15616c7c 3a745b51

+20 -12
+20 -12
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
··· 514 514 static int common_nfc_set_geometry(struct gpmi_nand_data *this) 515 515 { 516 516 struct nand_chip *chip = &this->nand; 517 + struct mtd_info *mtd = nand_to_mtd(&this->nand); 517 518 const struct nand_ecc_props *requirements = 518 519 nanddev_get_ecc_requirements(&chip->base); 520 + bool use_minimun_ecc; 521 + int err; 519 522 520 - if (chip->ecc.strength > 0 && chip->ecc.size > 0) 521 - return set_geometry_by_ecc_info(this, chip->ecc.strength, 522 - chip->ecc.size); 523 + use_minimun_ecc = of_property_read_bool(this->dev->of_node, 524 + "fsl,use-minimum-ecc"); 523 525 524 - if ((of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc")) 525 - || legacy_set_geometry(this)) { 526 - if (!(requirements->strength > 0 && requirements->step_size > 0)) 527 - return -EINVAL; 528 - 529 - return set_geometry_by_ecc_info(this, 530 - requirements->strength, 531 - requirements->step_size); 526 + /* use legacy bch geometry settings by default*/ 527 + if ((!use_minimun_ecc && mtd->oobsize < 1024) || 528 + !(requirements->strength > 0 && requirements->step_size > 0)) { 529 + dev_dbg(this->dev, "use legacy bch geometry\n"); 530 + err = legacy_set_geometry(this); 531 + if (!err) 532 + return 0; 532 533 } 533 534 534 - return 0; 535 + /* otherwise use the minimum ecc nand chip required */ 536 + dev_dbg(this->dev, "use minimum ecc bch geometry\n"); 537 + err = set_geometry_by_ecc_info(this, requirements->strength, 538 + requirements->step_size); 539 + if (err) 540 + dev_err(this->dev, "none of the bch geometry setting works\n"); 541 + 542 + return err; 535 543 } 536 544 537 545 /* Configures the geometry for BCH. */