linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Moore <moore@free.fr>
To: "Wan, Jane (Nokia - US/Sunnyvale)" <jane.wan@nokia.com>,
	Boris Brezillon <boris.brezillon@bootlin.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>
Cc: "shreeya.patel23498@gmail.com" <shreeya.patel23498@gmail.com>,
	"yamada.masahiro@socionext.com" <yamada.masahiro@socionext.com>,
	"richard@nod.at" <richard@nod.at>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"marek.vasut@gmail.com" <marek.vasut@gmail.com>,
	"Bos, Ties (Nokia - US/Sunnyvale)" <ties.bos@nokia.com>,
	"prabhakar.kushwaha@nxp.com" <prabhakar.kushwaha@nxp.com>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	"jagdish.gediya@nxp.com" <jagdish.gediya@nxp.com>,
	"computersforpeace@gmail.com" <computersforpeace@gmail.com>,
	"shawnguo@kernel.org" <shawnguo@kernel.org>
Subject: Re: [PATCH v2 2/2] mtd: rawnand: fsl_ifc: use bit-wise majority to
Date: Fri, 11 May 2018 07:03:31 +0200	[thread overview]
Message-ID: <d05c6b9d-4b67-9fa1-88f4-9cc3a01c1a71@free.fr> (raw)
In-Reply-To: <VI1PR07MB161553DA5D3EF35C9052B1CA81860@VI1PR07MB1615.eurprd07.prod.outlook.com>

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@nokia.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

      reply	other threads:[~2018-05-11  5:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-04  2:09 [PATCH v2 2/2] mtd: rawnand: fsl_ifc: use bit-wise majority to Wan, Jane (Nokia - US/Sunnyvale)
2018-05-11  5:03 ` Chris Moore [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=d05c6b9d-4b67-9fa1-88f4-9cc3a01c1a71@free.fr \
    --to=moore@free.fr \
    --cc=boris.brezillon@bootlin.com \
    --cc=computersforpeace@gmail.com \
    --cc=jagdish.gediya@nxp.com \
    --cc=jane.wan@nokia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=prabhakar.kushwaha@nxp.com \
    --cc=richard@nod.at \
    --cc=shawnguo@kernel.org \
    --cc=shreeya.patel23498@gmail.com \
    --cc=ties.bos@nokia.com \
    --cc=yamada.masahiro@socionext.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).