[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <d05c6b9d-4b67-9fa1-88f4-9cc3a01c1a71@free.fr>
Date: Fri, 11 May 2018 07:03:31 +0200
From: Chris Moore <moore@...e.fr>
To: "Wan, Jane (Nokia - US/Sunnyvale)" <jane.wan@...ia.com>,
Boris Brezillon <boris.brezillon@...tlin.com>,
Miquel Raynal <miquel.raynal@...tlin.com>
Cc: "shreeya.patel23498@...il.com" <shreeya.patel23498@...il.com>,
"yamada.masahiro@...ionext.com" <yamada.masahiro@...ionext.com>,
"richard@....at" <richard@....at>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"marek.vasut@...il.com" <marek.vasut@...il.com>,
"Bos, Ties (Nokia - US/Sunnyvale)" <ties.bos@...ia.com>,
"prabhakar.kushwaha@....com" <prabhakar.kushwaha@....com>,
"linux-mtd@...ts.infradead.org" <linux-mtd@...ts.infradead.org>,
"jagdish.gediya@....com" <jagdish.gediya@....com>,
"computersforpeace@...il.com" <computersforpeace@...il.com>,
"shawnguo@...nel.org" <shawnguo@...nel.org>
Subject: Re: [PATCH v2 2/2] mtd: rawnand: fsl_ifc: use bit-wise majority to
Hi,
Le 04/05/2018 à 04:09, Wan, Jane (Nokia - US/Sunnyvale) a écrit
> The following is the reposting of patch with v2 version indication based on comment on "[PATCH 1/2]" (also in the attachment).
>
> Subject: [PATCH v2 2/2] mtd: rawnand: fsl_ifc: use bit-wise majority to
> recover the contents of ONFI parameter
>
> Per ONFI specification (Rev. 4.0), if all parameter pages have invalid
> CRC values, the bit-wise majority may be used to recover the contents of
> the parameter pages from the parameter page copies present.
>
> Signed-off-by: Jane Wan <Jane.Wan@...ia.com>
> ---
> drivers/mtd/nand/raw/nand_base.c | 36 ++++++++++++++++++++++++++++++------
> 1 file changed, 30 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index 72f3a89..464c4fb 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
[snip]
>
> + pr_info("Recover ONFI params with bit-wise majority\n");
> + for (j = 0; j < pagesize; j++) {
> + v = 0;
> + for (k = 0; k < 8; k++) {
> + m = 0;
> + for (l = 0; l < 3; l++)
> + m += GET_BIT(k, buf[l*pagesize + j]);
> + if (m > 1)
> + v |= BIT(k);
> + }
> + ((u8 *)p)[j] = v;
> + }
I am not familiar with the context of this but the three way bit-wise
majority can be implemented much more efficiently using the identity:
majority3(a, b, c) = (a & b) | (a & c) | (b & c)
This can be factorized slightly to (a & (b | c)) | (b & c)
This enables the operation to be performed 8, 16, 32 or even 64 bits at
a time depending on the hardware.
Cheers,
Chris
Powered by blists - more mailing lists