All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Boris Brezillon <boris.brezillon@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	linux-mtd@lists.infradead.org
Cc: David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	Marek Vasut <marek.vasut@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH] mtd: rawnand: fsmc: Fix Hamming ECC
Date: Tue, 4 Sep 2018 15:12:37 +0200	[thread overview]
Message-ID: <20180904151237.11c3c609@bbrezillon> (raw)
In-Reply-To: <20180904091438.3755-1-boris.brezillon@bootlin.com>

On Tue,  4 Sep 2018 11:14:38 +0200
Boris Brezillon <boris.brezillon@bootlin.com> wrote:

> Apparently ECC bytes are not ordered as expected by nand_correct_data()
> in the ecc_calc buffer which leads to invalid bitflip correction when
> an ECC error is detected (can be reproduced with 'nandbiterrs -i').
> 
> Re-ordering ECC bytes seems to fix the problem.
> 
> While at it, get rid of the useless u8 cast.
> 
> Fixes: 6c009ab89a21 ("mtd: generic FSMC NAND MTD driver")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> ---
>  drivers/mtd/nand/raw/fsmc_nand.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c
> index f418236fa020..c79f8e965b38 100644
> --- a/drivers/mtd/nand/raw/fsmc_nand.c
> +++ b/drivers/mtd/nand/raw/fsmc_nand.c
> @@ -440,9 +440,9 @@ static int fsmc_read_hwecc_ecc1(struct mtd_info *mtd, const uint8_t *data,
>  	uint32_t ecc_tmp;
>  
>  	ecc_tmp = readl_relaxed(host->regs_va + ECC1);
> -	ecc[0] = (uint8_t) (ecc_tmp >> 0);
> -	ecc[1] = (uint8_t) (ecc_tmp >> 8);
> -	ecc[2] = (uint8_t) (ecc_tmp >> 16);
> +	ecc[0] = ecc_tmp >> 8;
> +	ecc[1] = ecc_tmp;
> +	ecc[2] = ecc_tmp >> 16;

Hm, looks like there's a Kconfig option (CONFIG_MTD_NAND_ECC_SMC) to let
nand_ecc_correct() swap those 2 bytes for us, but it's clearly not a
good thing to take this decision based on a Kconfig option (does not
work if you want the same kernel to be used on various platforms).

I'll come up with a better solution.

      parent reply	other threads:[~2018-09-04 17:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-04  9:14 [PATCH] mtd: rawnand: fsmc: Fix Hamming ECC Boris Brezillon
2018-09-04 11:42 ` Miquel Raynal
2018-09-04 12:42 ` Linus Walleij
2018-09-04 13:12 ` Boris Brezillon [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180904151237.11c3c609@bbrezillon \
    --to=boris.brezillon@bootlin.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.