public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Peng Fan <b51431@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH resend V2 1/3] mtd: nand: mxs support oobsize bigger than 512
Date: Sat, 1 Aug 2015 13:56:39 +0800	[thread overview]
Message-ID: <20150801055631.GA29276@shlinux2> (raw)
In-Reply-To: <1438396605.19345.122.camel@freescale.com>

On Fri, Jul 31, 2015 at 09:36:45PM -0500, Scott Wood wrote:
>On Sat, 2015-08-01 at 09:15 +0800, Peng Fan wrote:
>> On Fri, Jul 31, 2015 at 12:07:50PM -0500, Scott Wood wrote:
>> > On Tue, 2015-07-21 at 16:15 +0800, Peng Fan wrote:
>> > > If ecc chunk data size is 512 and oobsize is bigger than 512, there is
>> > > a chance that block_mark_bit_offset conflicts with bch ecc area.
>> > > 
>> > > The following graph is modified from kernel gpmi-nand.c driver with
>> > > each data block 512 bytes. We can see that Block Mark conflicts with
>> > > ecc area from bch view. We can enlarge the ecc chunk size to avoid
>> > > this problem to those oobsize which is larger than 512.
>> > 
>> > Enlarge it by how much?  What does the layout look like in that case?
>> 
>> Enlarge it to 1024 bytes.
>
>Then say so in the changelog.

You mean I need to add this in commit msg and send out a new patch version?
Or you pick this one?

>
>> In normal case the Block Mark bit should locates at the data part, but
>> not at the ECC area.
>
>It seems like either would be bad...

No. To read/write with ecc enabled, the block mark will be swapped with byte in metadata area.
This is correct way for GPMI + BCH to perform nand reading/writing with ecc enabled.
See following:
645         /* Read DMA completed, now do the mark swapping. */
646         mxs_nand_swap_block_mark(mtd, nand_info->data_buf, nand_info->oob_buf);

When GPMI + BCH used for DMA read, meta data will be stored to oob_buf. Then
swap the data at Block Mark with data at oob_buf[0](actually metadata[0]).

Before DMA write, Block Mark will be swapped with metadata[0]. Then DMA write.
Then Block Mark should not conlicts with ECC area, but ok with DATA area. Anyway
Block Mark should be aways points to bit at a data block.

>
>> You can take the following as an example.
>> 
>>    |                          P                                    |
>>    |<------------------------------------------------------------->|
>>    |                                                               |
>>    |                                          (Block Mark)         |
>>    |                      P'                         |           | |   |
>>    |<----------------------------------------------->|     D     | | O'|
>>    |                                                 |<--------->| |<->|
>>    V                                                 V           V V   V
>>    +---+---------------------------+-+---------------------------+-+---+
>>    | M |   data                    |E|   data             data   |E|   |
>>    +---+---------------------------+-+---------------------------+-+---+
>>                                                     ^                  ^
>>                                                     |         O        |
>>                                                     |<---------------->|
>> 
>> 
>> > 
>> > > 
>> > >    |                          P                                        |
>> > >    |<----------------------------------------------------------------->|
>> > >    |                                                                   |
>> > >    |                                                (Block Mark)       |
>> > >    |                      P'                             |           | |
>> > >    |
>> > >    |<--------------------------------------------------->|     D     | |
>> > > O'|
>> > >    |                                                     |<--------->| 
>> > > |<->|
>> > >    V                                                     V           V V
>> > >    V
>> > >    +---+--------------+-+--------------+-+--------------+-+----------+-+
>> > > ---+
>> > >    | M |   data       |E|   data       |E|   data       |E|   data   
>> > > |E|   |
>> > >    +---+--------------+-+--------------+-+--------------+-+----------+-+
>> > > ---+
>> > >                                                         ^               
>> > >    ^
>> > >                                                         |         O     
>> > >    |
>> > >                                                         |<--------------
>> > > -->|
>> > > 
>> > >        P : the page size for BCH module.
>> > >        E : The ECC strength.
>> > >        G : the length of Galois Field.
>> > >        N : The chunk count of per page.
>> > >        M : the metasize of per page.
>> > >        C : the ecc chunk size, aka the "data" above.
>> > >        P': the nand chip's page size.
>> > >        O : the nand chip's oob size.
>> > >        O': the free oob.
>> > 
>> > "D" is in the diagram but not the key.  "G", "N", and "C" are in the key 
>> > but 
>> > not the diagram.
>> C is ecc chunk data size, same the data area. Here it is 512 bytes. 
>> N is chunk count. for exmaple page size is 2048 bytes, ecc chunk data size 
>> is 512 bytes, then N is 2048/512.
>> G is the Galois Field, its value is 13 or 14. The should be got from 
>> reference mannual.
>> D is in the digram , but not the key. I think it is enougth to show why 
>> this patch is done.
>> 
>> I put the digram here to show that Block Mark may conflicts with ECC area,
>> and this is wrong, we need to find a way to avoid this. And the way is
>> to enlarge the ecc chunk data size from 512 to 1024 bytes.
>> 
>> I did not put the formula here. The keys is same to keys in kernel gpmi-
>> nand.c.
>> 
>>       The formula for P is :     
>> 
>>                   E * G * N
>>              P = ------------ + P' + M
>>                       8
>> 
>> The position of block mark moves forward in the ECC-based view of page, and 
>> the delta is:                                           
>> 
>>                    E * G * (N - 1)
>>              D = (---------------- + M)
>>                           8 
>> 
>> I think there is no need to put the formula in commit msg. Also, to explain 
>> D is not relevant to this patch.
>
>I'm not asking for the above to go into the commit message.  I'm asking for 
>what does go in the commit message to be less cryptic.
>
>> > What is "the metasize of per page"?
>> 
>> 10 bytes.
>
>But what does it mean?

BCH layout for data stored in nand page:
Meta + DATA + ECC + DATA + ECC + DATA + ECC + DATA + ECC

After usind DMA read, the layout in buffer is following:
DATA + DATA + DATA + DATA | META + status of each data block
   stored in data buffer  |    stored in oob buffer

Hope this is clear.

Peng.
>
>-Scott
>

-- 

  reply	other threads:[~2015-08-01  5:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-21  8:15 [U-Boot] [PATCH resend V2 1/3] mtd: nand: mxs support oobsize bigger than 512 Peng Fan
2015-07-21  8:15 ` [U-Boot] [PATCH V2 2/3] mtd: nand: mxs check maximum ecc that platfrom supports Peng Fan
2015-07-31 16:14   ` Tim Harvey
2015-08-25 21:05   ` Scott Wood
2015-08-26  0:33     ` Peng Fan
2015-08-26  2:14       ` Scott Wood
2015-08-26  1:30         ` Peng Fan
2015-08-26  7:59           ` Stefano Babic
2015-07-21  8:15 ` [U-Boot] [PATCH V2 3/3] mtd: nand: mxs invalidate dcache before DMA read Peng Fan
2015-07-21  8:41   ` Marek Vasut
2015-07-31 14:49   ` Tim Harvey
2015-07-31 15:01     ` Marek Vasut
2015-07-31 16:20 ` [U-Boot] [PATCH resend V2 1/3] mtd: nand: mxs support oobsize bigger than 512 Tim Harvey
2015-07-31 17:07 ` Scott Wood
2015-08-01  1:15   ` Peng Fan
2015-08-01  2:36     ` Scott Wood
2015-08-01  5:56       ` Peng Fan [this message]
2015-08-01 15:18         ` Marek Vasut
2015-08-01 18:32           ` Scott Wood
2015-08-01 18:38             ` Marek Vasut
2015-08-01 18:54               ` Scott Wood
2015-08-02  3:18                 ` Peng Fan
2015-08-10  1:17                   ` Peng Fan
2015-08-10 23:31                     ` Scott Wood

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=20150801055631.GA29276@shlinux2 \
    --to=b51431@freescale.com \
    --cc=u-boot@lists.denx.de \
    /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