linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Anyone can help me about do_write_buffer at cfi_cmdset_0002
@ 2010-09-08  1:18 Qi Zhang
  2010-09-09 12:38 ` Gernot Hoyler
  0 siblings, 1 reply; 2+ messages in thread
From: Qi Zhang @ 2010-09-08  1:18 UTC (permalink / raw)
  To: linux-mtd

Hello:

    In functions
    do_write_buffer @ drivers/mtd/chips/cfi_cmdset_0002.c.
    ...
    map_write(map, CMD(0x29), cmd_adr);
    /* send buffer program command */
    chip->state = FL_WRITING;
    /* change chip state */
    INVALIDATE_CACHE_UDELAY(map, chip, adr, map_bankwidth(map),
                                                   chip->word_write_time);
    /* why word_write_time? */
    ...

    Struct flchip already have "buffer_write_time",
    seems it should replace the "word_write_time".
    Both of thems come from the cfi_ident's
    "WordWriteTimeoutTyp" and "BufWriteTimeoutTyp",
    which indicate the real flash performance on word program
    and buffer program and usually they are quite different.

    Further more, the cfi_ident also have
    "WordWriteTimeoutMax", "BufWriteTimeoutMax",
    but the real implementation igore them as below

    ......
    unsigned long uWriteTimeout = ( HZ / 1000 ) + 1;
    ....
    INVALIDATE_CACHE_UDELAY(map, chip, adr, map_bankwidth(map),
                                                   chip->word_write_time);
    timeo = jiffies + uWriteTimeout;
    for (;;) {
       ......
       if (time_after(jiffies, timeo) && !chip_ready(map, adr))
       break;
       ......
   }

   The max time out will be "word_write_time" + "uWriteTimeOut"

   Let's look at Intel M29EW flash's CFI spec.

   WordWriteTimeoutTyp : 512us
   BufWriteTimeoutTyp    : 1024us
   WordWriteTimeoutMax: 1024us
   BufWriteTimeoutMax:    4096us

   for HZ = 100, that will be ok since 1 tick 10ms
   But for HZ = 1000, we got only 2.5ms ( 512us + 2 ticks),
   and 3ms (1024us + 2 ticks)
  (when replaced word_write_time with buf_write_time).
   Both are not met 4096us spec.

   Does anybody can help on that?

Thanks
Zhang Qi

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Re: Anyone can help me about do_write_buffer at cfi_cmdset_0002
  2010-09-08  1:18 Anyone can help me about do_write_buffer at cfi_cmdset_0002 Qi Zhang
@ 2010-09-09 12:38 ` Gernot Hoyler
  0 siblings, 0 replies; 2+ messages in thread
From: Gernot Hoyler @ 2010-09-09 12:38 UTC (permalink / raw)
  To: qzhan2009; +Cc: linux-mtd

 >    In functions
 >    do_write_buffer @ drivers/mtd/chips/cfi_cmdset_0002.c.
 >    /* why word_write_time? */

I assume this is because the write times as given by CFI are typical times and 
is most cases the device is faster than that. In other words, if we waited 
"buffer_write_time" before starting to poll then the device would already have 
finished the operation and we would waste time in most cases.

Actually, newer devices would work without any delay after sending the command 
cycles and before polling. However, first generation MirrorBit devices (-A and 
-M families) required a 4us delay to give stable status information. So 
waiting the typical word program time is a good compromise. It gives you 
maximum performance while still keeping compatiblility with older devices.

--Gernot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-09-09 12:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-08  1:18 Anyone can help me about do_write_buffer at cfi_cmdset_0002 Qi Zhang
2010-09-09 12:38 ` Gernot Hoyler

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).