All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Dunn <mikedunn@newsguy.com>
To: Ivan Djelic <ivan.djelic@parrot.com>
Cc: Marek Vasut <marek.vasut@gmail.com>,
	"robert.jarzmik@free.fr" <robert.jarzmik@free.fr>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>
Subject: Re: [PATCH] Add driver for M-sys / Sandisk diskonchip G4 nand flash
Date: Mon, 10 Oct 2011 14:02:21 -0700	[thread overview]
Message-ID: <4E935D5D.4050504@newsguy.com> (raw)
In-Reply-To: <20111010181210.GA23655@parrot.com>

On 10/10/2011 11:12 AM, Ivan Djelic wrote:
>
> Hello Mike,

Hi Ivan.  Boy, I wish I had dropped you a line sooner!

> I had a quick look at how you handle BCH ecc correction. If I understood
> correctly:
> - hw generates a 56-bit polynomial remainder (56 = 14*4, m=14, t=4)

Well, m=14 and t=4, yes.  But honestly, I'm not sure what the hardware
generates, except that it is the same size as the syndrome, given m and t.

> - hw-generated polynomial terms are mapped to bits in a way not compatible with
> the BCH library

Well yes, the bit order is backwards.  But again, I'mnot sure what the hardware
gives me.  The key to my success was having a look at some other code that does
the same thing (but using static remainder tables, and preserving the reversed
bit order throughout the whole decoding).  Then I got a basic understanding of
the mechanics of the steps, and for the driver I re-wrote (using generated
remainder tables and reversing the bit order along the way) the first two steps
of the decoding (up to the syndrome calculation), then let your code handle the
rest (error locator polynomial and root-finding).

If you can enlighted me, I'd be grateful!  From what I've been able to
understand from the textbook, it looks to me that the processing normally done
on the entire code polynomial - as described in the text - is done only on the
56 bit hw ecc.  In my simplistic interpretation, it seems that the 56 bits are
some kind of distillation of the entire code vector.  The steps are all the same.

> Still, I do not understand why you go to great lengths computing syndromes in
> your code, using a mix of generated remainder tables and Galois field tables.
>
> Why don't you just reformat the hw-generated polynomial (cheap, only 56 bits
> to shuffle) and let the BCH library do the whole computation ?

Could you elaborate?  What are the 56 bits that the hardware gives me?  It's not
the syndrome, right?  (BTW, I did verify that the results are correct).

>>> +
>>> +     /* undo last step in BCH alg; currently this is a mystery to me */
> Maybe I can help here :)
> This last step exists because the BCH library represents nand data as a large
> polynomial with high order terms first (this is consistent with several hw
> generators). If N is the total bit length of array data[], then byte data[0]
> will contain polynomial terms X^(N-1) (in bit 7), X^(N-2), ... X^(N-8) (in bit
> 0). Byte data[1] will contain X^(N-9) (bit 7) ... X^(N-16) (bit 0) and so on.
>
> Thus, term X^i is located in byte data[(N-1-i)/8], in bit position
> 7-(N-1-i)%8. The last step:
>
>    errloc[i] = (errloc[i] & ~7)|(7-(errloc[i] & 7));
>
> was added just so that users can correct bit errors with byte access:
>
>    data[errloc[i]/8] ^= 1 << (errloc[i] & 7);
>
> instead of (the slightly more complicated):
>
>    data[errloc[i]/8] ^= 1 << (7-(errloc[i] & 7));
>
> And that's all there is to it, really.
>
> Looking at your code, it seems that your hw generator represents nand data[] as
> a 32-bit words array with high order terms in lower bits (assuming your machine
> is little-endian):
>
> data[0] = X^(N-32) (bit 31) ... X^(N-1) (bit 0),
> data[1] = X^(N-64) (bit 31) ... X^(N-33) (bit 0)
>
> .. and so on. In your case you don't need the modulo mirroring step.

Thanks much, Ivan!  I'll need some time to digest that.  All I knew was that the
last three bits were screwy, and by chance discovered that undoing that last
step generted the correct result.

Thanks again,
Mike

  reply	other threads:[~2011-10-10 21:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-10 14:48 [PATCH] Add driver for M-sys / Sandisk diskonchip G4 nand flash Mike Dunn
2011-10-10 15:51 ` Marek Vasut
2011-10-10 18:12   ` Ivan Djelic
2011-10-10 21:02     ` Mike Dunn [this message]
2011-10-11 11:50       ` Ivan Djelic
2011-10-11 19:17         ` Mike Dunn
2011-10-12 18:49           ` Ivan Djelic
2011-10-13  1:18             ` Mike Dunn
2011-10-13  6:58             ` Robert Jarzmik
2011-10-13  8:37               ` Ivan Djelic
2011-10-13 15:52                 ` Mike Dunn
2011-10-10 20:20   ` Mike Dunn
2011-10-12 21:28 ` Robert Jarzmik
2011-10-13  0:26   ` Marek Vasut
2011-10-13  2:25     ` Mike Dunn
2011-10-13  1:53   ` Mike Dunn
2011-10-17 21:45   ` Mike Dunn
2011-10-20 16:31     ` Artem Bityutskiy
2011-10-20 19:57       ` Mike Dunn

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=4E935D5D.4050504@newsguy.com \
    --to=mikedunn@newsguy.com \
    --cc=ivan.djelic@parrot.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=robert.jarzmik@free.fr \
    /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.