[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZxItGw0m_w0jgtAq@pengutronix.de>
Date: Fri, 18 Oct 2024 11:40:43 +0200
From: Sascha Hauer <s.hauer@...gutronix.de>
To: Hui-Ping Chen <hpchen0nvt@...il.com>
Cc: miquel.raynal@...tlin.com, richard@....at, vigneshr@...com,
robh@...nel.org, krzk+dt@...nel.org, conor+dt@...nel.org,
nikita.shubin@...uefel.me, arnd@...db.de, vkoul@...nel.org,
esben@...nix.com, linux-arm-kernel@...ts.infradead.org,
linux-mtd@...ts.infradead.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v7 2/2] mtd: rawnand: nuvoton: add new driver for the
Nuvoton MA35 SoC
On Fri, Oct 18, 2024 at 02:25:19AM +0000, Hui-Ping Chen wrote:
> +static int ma35_nfi_ecc_check(struct nand_chip *chip, u8 *addr)
> +{
> + struct ma35_nand_info *nand = nand_get_controller_data(chip);
> + struct mtd_info *mtd = nand_to_mtd(chip);
> + int i, j, nchunks = 0;
> + int report_err = 0;
> + int err_cnt = 0;
> + u32 status;
> +
> + nchunks = mtd->writesize / chip->ecc.steps;
> + if (nchunks < 4)
> + nchunks = 1;
> + else
> + nchunks /= 4;
> +
> + for (j = 0; j < nchunks; j++) {
> + status = readl(nand->regs + MA35_NFI_REG_NANDECCES0 + j * 4);
> + if (!status)
> + continue;
> +
> + for (i = 0; i < 4; i++) {
> + if ((status & ECC_STATUS_MASK) == 0x01) {
> + /* Correctable error */
> + err_cnt = (status >> 2) & ECC_ERR_CNT_MASK;
> + ma35_nfi_correct(chip, j * 4 + i, err_cnt, addr);
> + report_err += err_cnt;
This is still wrong. This should be
report_err = max(report_err, err_cnt);
You have to search for the subpage that has the most bitflips and return
the number of bitflips on that subpage, *not* the total amount of errors
on the whole page.
That said, the statistic counter should still count the total number of
bitflips occurred.
Sascha
> + } else {
> + /* Uncorrectable error */
> + dev_warn(nand->dev, "uncorrectable error! 0x%4x\n", status);
> + return -EBADMSG;
> + }
> + status >>= 8;
> + }
> + }
> + return report_err;
> +}
> +
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Powered by blists - more mailing lists