mtd: nand: tango: Update ecc_stats.corrected
According to Boris, some user-space tools expect MTD drivers to
update ecc_stats.corrected, and it's better to provide a lower
bound than to provide no information at all.
Fixes: 6956e2385a
("mtd: nand: add tango NAND flash controller support")
Cc: stable@vger.kernel.org
Reported-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
This commit is contained in:
parent
2761b4f12b
commit
60cf0ce14b
|
@ -55,10 +55,10 @@
|
||||||
* byte 1 for other packets in the page (PKT_N, for N > 0)
|
* byte 1 for other packets in the page (PKT_N, for N > 0)
|
||||||
* ERR_COUNT_PKT_N is the max error count over all but the first packet.
|
* ERR_COUNT_PKT_N is the max error count over all but the first packet.
|
||||||
*/
|
*/
|
||||||
#define DECODE_OK_PKT_0(v) ((v) & BIT(7))
|
|
||||||
#define DECODE_OK_PKT_N(v) ((v) & BIT(15))
|
|
||||||
#define ERR_COUNT_PKT_0(v) (((v) >> 0) & 0x3f)
|
#define ERR_COUNT_PKT_0(v) (((v) >> 0) & 0x3f)
|
||||||
#define ERR_COUNT_PKT_N(v) (((v) >> 8) & 0x3f)
|
#define ERR_COUNT_PKT_N(v) (((v) >> 8) & 0x3f)
|
||||||
|
#define DECODE_FAIL_PKT_0(v) (((v) & BIT(7)) == 0)
|
||||||
|
#define DECODE_FAIL_PKT_N(v) (((v) & BIT(15)) == 0)
|
||||||
|
|
||||||
/* Offsets relative to pbus_base */
|
/* Offsets relative to pbus_base */
|
||||||
#define PBUS_CS_CTRL 0x83c
|
#define PBUS_CS_CTRL 0x83c
|
||||||
|
@ -193,6 +193,8 @@ static int check_erased_page(struct nand_chip *chip, u8 *buf)
|
||||||
chip->ecc.strength);
|
chip->ecc.strength);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
mtd->ecc_stats.failed++;
|
mtd->ecc_stats.failed++;
|
||||||
|
else
|
||||||
|
mtd->ecc_stats.corrected += res;
|
||||||
|
|
||||||
bitflips = max(res, bitflips);
|
bitflips = max(res, bitflips);
|
||||||
buf += pkt_size;
|
buf += pkt_size;
|
||||||
|
@ -202,9 +204,11 @@ static int check_erased_page(struct nand_chip *chip, u8 *buf)
|
||||||
return bitflips;
|
return bitflips;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decode_error_report(struct tango_nfc *nfc)
|
static int decode_error_report(struct nand_chip *chip)
|
||||||
{
|
{
|
||||||
u32 status, res;
|
u32 status, res;
|
||||||
|
struct mtd_info *mtd = nand_to_mtd(chip);
|
||||||
|
struct tango_nfc *nfc = to_tango_nfc(chip->controller);
|
||||||
|
|
||||||
status = readl_relaxed(nfc->reg_base + NFC_XFER_STATUS);
|
status = readl_relaxed(nfc->reg_base + NFC_XFER_STATUS);
|
||||||
if (status & PAGE_IS_EMPTY)
|
if (status & PAGE_IS_EMPTY)
|
||||||
|
@ -212,10 +216,14 @@ static int decode_error_report(struct tango_nfc *nfc)
|
||||||
|
|
||||||
res = readl_relaxed(nfc->mem_base + ERROR_REPORT);
|
res = readl_relaxed(nfc->mem_base + ERROR_REPORT);
|
||||||
|
|
||||||
if (DECODE_OK_PKT_0(res) && DECODE_OK_PKT_N(res))
|
if (DECODE_FAIL_PKT_0(res) || DECODE_FAIL_PKT_N(res))
|
||||||
return max(ERR_COUNT_PKT_0(res), ERR_COUNT_PKT_N(res));
|
return -EBADMSG;
|
||||||
|
|
||||||
return -EBADMSG;
|
/* ERR_COUNT_PKT_N is max, not sum, but that's all we have */
|
||||||
|
mtd->ecc_stats.corrected +=
|
||||||
|
ERR_COUNT_PKT_0(res) + ERR_COUNT_PKT_N(res);
|
||||||
|
|
||||||
|
return max(ERR_COUNT_PKT_0(res), ERR_COUNT_PKT_N(res));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tango_dma_callback(void *arg)
|
static void tango_dma_callback(void *arg)
|
||||||
|
@ -282,7 +290,7 @@ static int tango_read_page(struct mtd_info *mtd, struct nand_chip *chip,
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
res = decode_error_report(nfc);
|
res = decode_error_report(chip);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
chip->ecc.read_oob_raw(mtd, chip, page);
|
chip->ecc.read_oob_raw(mtd, chip, page);
|
||||||
res = check_erased_page(chip, buf);
|
res = check_erased_page(chip, buf);
|
||||||
|
|
Loading…
Reference in New Issue