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: Rename the variable ecc_chunk_size

There is only one variable ecc_chunk_size in bch_geometry data
structure but two different field in BCH registers. The data0_size in
BCH_FLASH0LAYOUT0 and datan_size in BCH_FLASH0LAYOUT1 should have
dedicate variable since they might set to different values in some
cases. For instance, if need dedicate ecc for meta area, the data0_size
should be 0 rather than datan_size, but for all other cases, data0_size
still equals to datan_size and it won't bring any function change.

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

authored by

Han Xu and committed by
Miquel Raynal
2fb038ea 10915857

+34 -27
+29 -23
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
··· 218 218 "ECC Strength : %u\n" 219 219 "Page Size in Bytes : %u\n" 220 220 "Metadata Size in Bytes : %u\n" 221 - "ECC Chunk Size in Bytes: %u\n" 221 + "ECC0 Chunk Size in Bytes: %u\n" 222 + "ECCn Chunk Size in Bytes: %u\n" 222 223 "ECC Chunk Count : %u\n" 223 224 "Payload Size in Bytes : %u\n" 224 225 "Auxiliary Size in Bytes: %u\n" ··· 230 229 geo->ecc_strength, 231 230 geo->page_size, 232 231 geo->metadata_size, 233 - geo->ecc_chunk_size, 232 + geo->ecc0_chunk_size, 233 + geo->eccn_chunk_size, 234 234 geo->ecc_chunk_count, 235 235 geo->payload_size, 236 236 geo->auxiliary_size, ··· 295 293 nanddev_get_ecc_requirements(&chip->base)->step_size); 296 294 return -EINVAL; 297 295 } 298 - geo->ecc_chunk_size = ecc_step; 296 + geo->ecc0_chunk_size = ecc_step; 297 + geo->eccn_chunk_size = ecc_step; 299 298 geo->ecc_strength = round_up(ecc_strength, 2); 300 299 if (!gpmi_check_ecc(this)) 301 300 return -EINVAL; 302 301 303 302 /* Keep the C >= O */ 304 - if (geo->ecc_chunk_size < mtd->oobsize) { 303 + if (geo->eccn_chunk_size < mtd->oobsize) { 305 304 dev_err(this->dev, 306 305 "unsupported nand chip. ecc size: %d, oob size : %d\n", 307 306 ecc_step, mtd->oobsize); ··· 312 309 /* The default value, see comment in the legacy_set_geometry(). */ 313 310 geo->metadata_size = 10; 314 311 315 - geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunk_size; 312 + geo->ecc_chunk_count = mtd->writesize / geo->eccn_chunk_size; 316 313 317 314 /* 318 315 * Now, the NAND chip with 2K page(data chunk is 512byte) shows below: ··· 434 431 geo->gf_len = 13; 435 432 436 433 /* The default for chunk size. */ 437 - geo->ecc_chunk_size = 512; 438 - while (geo->ecc_chunk_size < mtd->oobsize) { 439 - geo->ecc_chunk_size *= 2; /* keep C >= O */ 434 + geo->ecc0_chunk_size = 512; 435 + geo->eccn_chunk_size = 512; 436 + while (geo->eccn_chunk_size < mtd->oobsize) { 437 + geo->ecc0_chunk_size *= 2; /* keep C >= O */ 438 + geo->eccn_chunk_size *= 2; /* keep C >= O */ 440 439 geo->gf_len = 14; 441 440 } 442 441 443 - geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunk_size; 442 + geo->ecc_chunk_count = mtd->writesize / geo->eccn_chunk_size; 444 443 445 444 /* We use the same ECC strength for all chunks. */ 446 445 geo->ecc_strength = get_ecc_strength(this); ··· 869 864 * we are passed in exec_op. Calculate the data length from it. 870 865 */ 871 866 if (this->bch) 872 - return ALIGN_DOWN(raw_len, this->bch_geometry.ecc_chunk_size); 867 + return ALIGN_DOWN(raw_len, this->bch_geometry.eccn_chunk_size); 873 868 else 874 869 return raw_len; 875 870 } ··· 1261 1256 1262 1257 /* Read ECC bytes into our internal raw_buffer */ 1263 1258 offset = nfc_geo->metadata_size * 8; 1264 - offset += ((8 * nfc_geo->ecc_chunk_size) + eccbits) * (i + 1); 1259 + offset += ((8 * nfc_geo->eccn_chunk_size) + eccbits) * (i + 1); 1265 1260 offset -= eccbits; 1266 1261 bitoffset = offset % 8; 1267 1262 eccbytes = DIV_ROUND_UP(offset + eccbits, 8); ··· 1298 1293 if (i == 0) { 1299 1294 /* The first block includes metadata */ 1300 1295 flips = nand_check_erased_ecc_chunk( 1301 - buf + i * nfc_geo->ecc_chunk_size, 1302 - nfc_geo->ecc_chunk_size, 1296 + buf + i * nfc_geo->eccn_chunk_size, 1297 + nfc_geo->eccn_chunk_size, 1303 1298 eccbuf, eccbytes, 1304 1299 this->auxiliary_virt, 1305 1300 nfc_geo->metadata_size, 1306 1301 nfc_geo->ecc_strength); 1307 1302 } else { 1308 1303 flips = nand_check_erased_ecc_chunk( 1309 - buf + i * nfc_geo->ecc_chunk_size, 1310 - nfc_geo->ecc_chunk_size, 1304 + buf + i * nfc_geo->eccn_chunk_size, 1305 + nfc_geo->eccn_chunk_size, 1311 1306 eccbuf, eccbytes, 1312 1307 NULL, 0, 1313 1308 nfc_geo->ecc_strength); ··· 1336 1331 struct bch_geometry *geo = &this->bch_geometry; 1337 1332 unsigned int ecc_strength = geo->ecc_strength >> 1; 1338 1333 unsigned int gf_len = geo->gf_len; 1339 - unsigned int block_size = geo->ecc_chunk_size; 1334 + unsigned int block0_size = geo->ecc0_chunk_size; 1335 + unsigned int blockn_size = geo->eccn_chunk_size; 1340 1336 1341 1337 this->bch_flashlayout0 = 1342 1338 BF_BCH_FLASH0LAYOUT0_NBLOCKS(geo->ecc_chunk_count - 1) | 1343 1339 BF_BCH_FLASH0LAYOUT0_META_SIZE(geo->metadata_size) | 1344 1340 BF_BCH_FLASH0LAYOUT0_ECC0(ecc_strength, this) | 1345 1341 BF_BCH_FLASH0LAYOUT0_GF(gf_len, this) | 1346 - BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(block_size, this); 1342 + BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(block0_size, this); 1347 1343 1348 1344 this->bch_flashlayout1 = 1349 1345 BF_BCH_FLASH0LAYOUT1_PAGE_SIZE(geo->page_size) | 1350 1346 BF_BCH_FLASH0LAYOUT1_ECCN(ecc_strength, this) | 1351 1347 BF_BCH_FLASH0LAYOUT1_GF(gf_len, this) | 1352 - BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(block_size, this); 1348 + BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(blockn_size, this); 1353 1349 } 1354 1350 1355 1351 static int gpmi_ecc_read_page(struct nand_chip *chip, uint8_t *buf, ··· 1450 1444 BF_BCH_FLASH0LAYOUT0_META_SIZE(meta) | 1451 1445 BF_BCH_FLASH0LAYOUT0_ECC0(ecc_strength, this) | 1452 1446 BF_BCH_FLASH0LAYOUT0_GF(geo->gf_len, this) | 1453 - BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(geo->ecc_chunk_size, this); 1447 + BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(geo->eccn_chunk_size, this); 1454 1448 1455 1449 this->bch_flashlayout1 = BF_BCH_FLASH0LAYOUT1_PAGE_SIZE(page_size) | 1456 1450 BF_BCH_FLASH0LAYOUT1_ECCN(ecc_strength, this) | 1457 1451 BF_BCH_FLASH0LAYOUT1_GF(geo->gf_len, this) | 1458 - BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(geo->ecc_chunk_size, this); 1452 + BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(geo->eccn_chunk_size, this); 1459 1453 1460 1454 this->bch = true; 1461 1455 ··· 1624 1618 struct mtd_info *mtd = nand_to_mtd(chip); 1625 1619 struct gpmi_nand_data *this = nand_get_controller_data(chip); 1626 1620 struct bch_geometry *nfc_geo = &this->bch_geometry; 1627 - int eccsize = nfc_geo->ecc_chunk_size; 1621 + int eccsize = nfc_geo->eccn_chunk_size; 1628 1622 int eccbits = nfc_geo->ecc_strength * nfc_geo->gf_len; 1629 1623 u8 *tmp_buf = this->raw_buffer; 1630 1624 size_t src_bit_off; ··· 1709 1703 struct mtd_info *mtd = nand_to_mtd(chip); 1710 1704 struct gpmi_nand_data *this = nand_get_controller_data(chip); 1711 1705 struct bch_geometry *nfc_geo = &this->bch_geometry; 1712 - int eccsize = nfc_geo->ecc_chunk_size; 1706 + int eccsize = nfc_geo->eccn_chunk_size; 1713 1707 int eccbits = nfc_geo->ecc_strength * nfc_geo->gf_len; 1714 1708 u8 *tmp_buf = this->raw_buffer; 1715 1709 uint8_t *oob = chip->oob_poi; ··· 2083 2077 ecc->read_oob_raw = gpmi_ecc_read_oob_raw; 2084 2078 ecc->write_oob_raw = gpmi_ecc_write_oob_raw; 2085 2079 ecc->engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST; 2086 - ecc->size = bch_geo->ecc_chunk_size; 2080 + ecc->size = bch_geo->eccn_chunk_size; 2087 2081 ecc->strength = bch_geo->ecc_strength; 2088 2082 mtd_set_ooblayout(mtd, &gpmi_ooblayout_ops); 2089 2083
+5 -4
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h
··· 30 30 * @page_size: The size, in bytes, of a physical page, including 31 31 * both data and OOB. 32 32 * @metadata_size: The size, in bytes, of the metadata. 33 - * @ecc_chunk_size: The size, in bytes, of a single ECC chunk. Note 34 - * the first chunk in the page includes both data and 35 - * metadata, so it's a bit larger than this value. 33 + * @ecc0_chunk_size: The size, in bytes, of a first ECC chunk. 34 + * @eccn_chunk_size: The size, in bytes, of a single ECC chunk after 35 + * the first chunk in the page. 36 36 * @ecc_chunk_count: The number of ECC chunks in the page, 37 37 * @payload_size: The size, in bytes, of the payload buffer. 38 38 * @auxiliary_size: The size, in bytes, of the auxiliary buffer. ··· 48 48 unsigned int ecc_strength; 49 49 unsigned int page_size; 50 50 unsigned int metadata_size; 51 - unsigned int ecc_chunk_size; 51 + unsigned int ecc0_chunk_size; 52 + unsigned int eccn_chunk_size; 52 53 unsigned int ecc_chunk_count; 53 54 unsigned int payload_size; 54 55 unsigned int auxiliary_size;