Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Bigler <stefan.bigler@keymile.com>
To: stefan.bigler@keymile.com
Cc: linux-mtd@lists.infradead.org,
	Holger brunck <holger.brunck@keymile.com>,
	Joakim Tjernlund <joakim.tjernlund@transmode.se>,
	Michael Cashwell <mboards@prograde.net>
Subject: Re: Numonyx NOR and chip->mutex bug?
Date: Fri, 04 Feb 2011 00:18:44 +0100	[thread overview]
Message-ID: <4D4B37D4.4050204@keymile.com> (raw)
In-Reply-To: <4D4AD9ED.8060104@keymile.com>

Hi

Now I have a patch that fix my problem. I did not yet do a lot of tests 
and I did
not yet analyzed correctness in all cases.
I check in the inval_cache_and_wait_for_operation() of the status is 
status_OK
the if the chip->state and the chip_state (the current chip state and 
the chip state
when the function is called) are equal or not. If equal break and exit 
(set the
chip->state= FL_STATUS) and if not equal add the thread in the wait queue.

I think we are not finished when not equal so we have do not have to 
take the mutex.

Now why this code worked with the older Flash chips. I don't know, but 
eventually
they are slower after the write buffer command 0xe8 and they are still 
busy when
inval_cache_and_wait_for_operation() checks if status_OK.
Tomorrow I'll check if this is the case. Now I do not have access to the HW.

Regards Stefan


diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c 
b/drivers/mtd/chips/cfi_cmdset_0001.c
index 28fc5c2..723985c 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c

@@ static int inval_cache_and_wait_for_operation(
      for (;;) {
          status = map_read(map, cmd_adr);
-        if (map_word_andequal(map, status, status_OK, status_OK))
+        if (map_word_andequal(map, status, status_OK, status_OK)) {
+            if (chip->state != chip_state) {
+                goto unequal_states;
+            }
              break;
+        }

          if (!timeo) {

@@  static int inval_cache_and_wait_for_operation(
              cond_resched();
              timeo--;
          }
          mutex_lock(&chip->mutex);

+unequal_states:
          while (chip->state != chip_state) {


Am 02/03/2011 05:38 PM, schrieb Stefan Bigler:
> Hi
>
> I did some more anaysis of the write probem when creating a ubivolume.
> I come to the conclusion that there must be a problem in the fuction
> inval_cache_and_wait_for_operation().
>
> Why I think this. In the log below you see that in the first part the
> do_erase_oneblock() start the erasing. In the function
> inval_cache_and_wait_for_operation() this thread is interrupted.
>
> A do_write_buffer() suspends the erase by chip_ready() and runs until
> cmd 0xe8 and waits for completion in WAIT_TIMEOUT.
>
> Here again the do_erase_oneblock() continues to run and runs a
> erase resume sequence to the end of erase the block.
> --> THIS IS WRONG.
>
> Now the do_write_buffer() continue but it ends in a write error.
>
>
> When reading the inval_cache_and_wait_for_operation() there are 2
> places were the mutex is unlocked
>
> 1) while INVALIDATE_CACHED_RANGE()
> 2) if status is not status_OK
>
> My measurement shows that the mutex is taken in the first place.
>
> Now I do expect that this method should make sure that the erasing
> thread get "suspended" and the writing task can continue.
> But this is not the case.
> There is code were we compare the chip_state and chip->state.
> But we are not hitting this code.
>
> This is the summary of my analysis for today.
> I was asking me why this code is working on other chips?
>
> Regards
> Stefan
>
>
> do_erase_oneblock() begin
> [1507][0209] do_erase_oneblock start adr=0x00000000 len=0x20000
> [1507][0209] map_write 0x50 to 0x00000000
> [1507][0209] map_write 0x20 to 0x00000000
> [1507][0209] map_write 0xd0 to 0x00000000
> [1507][0209] do_erase_oneblock before INVAL_CACHE_AND_WAIT 
> adr=0x00000000 len=0x20000
> [1507][0209] inval_cache_and_wait_for_operation short unlock
>
> do_write_buffer() begin
> [1507][0465] map_write 0xb0 to 0x03fe4c00
> [1515][0465] erase suspend 1         adr=0x03fe4c00
> [1515][0465] map_write 0x70 to 0x03fe4c00
> [1515][0465] map_write 0xe8 to 0x03fe4c00
> [1515][0465] buffer write before 0xe8 WAIT_TIMEOUT
> [1515][0465] inval_cache_and_wait_for_operation short unlock
>
> do_erase_oneblock() continue & finish
> [1515][0209] inval_cache_and_wait_for_operation short lock
> [1515][0209] do_erase_oneblock after  INVAL_CACHE_AND_WAIT 
> adr=0x00000000 len=0x20000
> [1515][0209] map_write 0x70 to 0x00000000
> [1515][0209] map_write 0x50 to 0x00000000
> [1515][0209] map_write 0xd0 to 0x00000000
> [1515][0209] map_write 0x70 to 0x00000000
> [1523][0209] erase resumed 2b        adr=0x00000000
> [1527][0209] do_erase_oneblock end   adr=0x00000000 len=0x20000
>
> do_write_buffer() continue & error
> [1527][0465] inval_cache_and_wait_for_operation short lock
> [1531][0465] buffer write after  0xe8 WAIT_TIMEOUT
> [1531][0465] buffer write data to buf words=511
> [1531][0465] buffer write data buf done
> [1531][0465] map_write 0xd0 to 0x03fe4c00
> [1531][0465] 50000000.flash: buffer write before INVAL_CACHE_AND_WAIT 
> adr=0x03fe5000 len=0x400
> [1531][0465] inval_cache_and_wait_for_operation short unlock
> [1531][0465] inval_cache_and_wait_for_operation short lock
> [1531][0465] inval_cache_and_wait_for_operation long unlock
> [1543][0465] inval_cache_and_wait_for_operation long lock
>
> [2503][0465] inval_cache_and_wait_for_operation long unlock
> [2511][0465] inval_cache_and_wait_for_operation long lock
> [2511][0465] 50000000.flash: buffer write after  INVAL_CACHE_AND_WAIT 
> adr=0x03fe5000 len=0x400
> [2511][0465] map_write 0x50 to 0x03fe4c00
> [2511][0465] map_write 0x70 to 0x03fe4c00
> [2519][0465] 50000000.flash: buffer write error status 0xb0 
> adr=0x03fe5000 len=0x400
>
> Am 02/03/2011 04:24 PM, schrieb Michael Cashwell:
>> On Feb 3, 2011, at 4:50 AM, Joakim Tjernlund wrote:
>>
>>>>> My failures were caused by the erase-resume status read "seeing" a 
>>>>> non-busy WSM. Adding a 20µs delay before that read (actually after 
>>>>> the command write, but it amounts to the same thing) prevents this 
>>>>> from happening. By the time awakened "wait-for-completion" code 
>>>>> does its first status read it sees the WSM as busy as it should 
>>>>> until the erase actually finishes.
>>> Perhaps you can test for ESS(SR.6) too?
>>> something like:
>>>   if DWS&&  !ESS
>> Hmmm. So instead of a blind delay it would loop (with a timeout) 
>> while DWS&&  ESS are both set (meaning the erase resume command just 
>> written hasn't yet taken effect). It does make sense that if the 
>> resume takes time to drop SR.7 (ready) that it would also take time 
>> to drop SR.6 (ESS).
>>
>> I like that. I'll add that to the set of tests today and report back.
>>
>> -Mike
>>
>

  reply	other threads:[~2011-02-03 23:18 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-25 18:14 Numonyx NOR and chip->mutex bug? Michael Cashwell
2011-01-25 18:56 ` Joakim Tjernlund
2011-01-25 22:03   ` Michael Cashwell
2011-01-25 23:09     ` Joakim Tjernlund
2011-02-02 16:20       ` Michael Cashwell
2011-02-02 17:37         ` Stefan Bigler
2011-02-02 20:12         ` Joakim Tjernlund
2011-02-02 21:19           ` Michael Cashwell
2011-02-03  8:11             ` Joakim Tjernlund
2011-02-03  9:50               ` Joakim Tjernlund
2011-02-03 15:24                 ` Michael Cashwell
2011-02-03 16:38                   ` Stefan Bigler
2011-02-03 23:18                     ` Stefan Bigler [this message]
2011-02-04 10:47                       ` Joakim Tjernlund
2011-02-04 11:04                         ` Stefan Bigler
2011-02-04 12:26                           ` Joakim Tjernlund
2011-02-04 12:35                             ` Joakim Tjernlund
2011-02-04 12:42                               ` Joakim Tjernlund
2011-02-04 13:05                           ` Joakim Tjernlund
2011-02-04 13:25                             ` Joakim Tjernlund
2011-02-04 16:45                             ` Stefan Bigler
2011-02-04 16:55                               ` Joakim Tjernlund
2011-02-04 17:09                             ` Michael Cashwell
     [not found]                               ` <OF42EF<F66AF016-8A2B-4116-BE49-CE05B91BE50F@prograde.net>
     [not found]                               ` <OF42EF <F66AF016-8A2B-4116-BE49-CE05B91BE50F@prograde.net>
2011-02-05 10:29                               ` Joakim Tjernlund
2011-02-05 19:19                                 ` Michael Cashwell
2011-02-05 21:47                                   ` Michael Cashwell
2011-02-06  9:46                                     ` Joakim Tjernlund
2011-02-06 15:49                                       ` Michael Cashwell
2011-02-06 17:29                                         ` Joakim Tjernlund
2011-02-06 21:13                                           ` Michael Cashwell
     [not found]                                             ` <OF2C1ABD39 <4D5005E4.1040506@keymile.com>
     [not found]                                               ` <OFFF2C6D34.91E5D6C3-ONC1257 <96BD3889-E8AD-408D-8275-ED1A5FD55F1B@prograde.net>
     [not found]                                             ` <OF2C1ABD39<4D5005E4.1040506@keymile.com>
     [not found]                                               ` <OFFF2C6D34.91E5D6C3-ONC1257<96BD3889-E8AD-408D-8275-ED1A5FD55F1B@prograde.net>
     [not found]                                                 ` <OF9738D658.F46<4C117A67-5057-4ACD-8EBE-04E9C782570C@prograde.net>
     [not found]                                                   ` <OF6D40AC82.1008D3DD-ONC1 <4D53E660.4020305@users.sourceforge.net>
2011-02-06 21:20                                             ` Joakim Tjernlund
2011-02-07 14:47                                               ` Stefan Bigler
2011-02-07 15:01                                                 ` Joakim Tjernlund
2011-02-07 15:46                                                   ` Michael Cashwell
2011-02-07 15:52                                                     ` Stefan Bigler
2011-02-07 16:22                                                     ` Joakim Tjernlund
2011-02-07 16:46                                                       ` Michael Cashwell
2011-02-07 17:08                                                         ` Stefan Bigler
2011-02-07 19:04                                                           ` Michael Cashwell
2011-02-09 19:52                                                             ` Michael Cashwell
2011-02-09 20:13                                                               ` Joakim Tjernlund
2011-02-09 21:59                                                                 ` Michael Cashwell
2011-02-10 13:21                                                                   ` Anders Grafström
2011-02-10 14:04                                                                     ` Joakim Tjernlund
2011-02-10 15:04                                                                       ` Joakim Tjernlund
2011-02-10 15:59                                                                         ` Michael Cashwell
2011-02-10 16:05                                                                           ` Joakim Tjernlund
2011-02-10 16:41                                                                             ` Michael Cashwell
2011-02-10 16:46                                                                               ` Joakim Tjernlund
2011-02-10 17:02                                                                                 ` Joakim Tjernlund
2011-02-10 17:10                                                                                   ` Michael Cashwell
2011-02-10 17:20                                                                                     ` Joakim Tjernlund
2011-02-10 17:47                                                                                       ` Joakim Tjernlund
2011-02-10 18:26                                                                                         ` Joakim Tjernlund
2011-02-11 18:03                                                                                           ` Michael Cashwell
2011-02-12 10:47                                                                                             ` Joakim Tjernlund
2011-02-14 15:59                                                                                         ` Michael Cashwell
2011-02-14 15:44                                                                                       ` Michael Cashwell
2011-02-10 16:43                                                                           ` Michael Cashwell
2011-02-10 17:54                                                                             ` Anders Grafström
2011-02-11 15:05                                                                               ` Michael Cashwell
2011-02-11 15:39                                                                                 ` Joakim Tjernlund
2011-02-14 16:15                                                                                   ` Michael Cashwell
2011-02-11 17:00                                                                               ` Joakim Tjernlund
2011-02-10 15:43                                                                       ` Michael Cashwell
2011-02-10 15:51                                                                         ` Joakim Tjernlund
2011-02-24 10:50                                                                     ` Joakim Tjernlund
2011-02-24 11:36                                                                       ` Joakim Tjernlund
2011-02-24 14:28                                                                       ` Michael Cashwell
2011-02-10 14:53                                                                   ` Joakim Tjernlund
2011-02-06  9:40                                   ` Joakim Tjernlund
2011-02-06 14:55                                     ` Michael Cashwell
2011-02-07 15:10                                   ` Michael Cashwell
2011-02-07 15:48                                     ` Joakim Tjernlund
2011-02-03 13:24               ` Michael Cashwell
2011-02-03 14:01                 ` Joakim Tjernlund

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=4D4B37D4.4050204@keymile.com \
    --to=stefan.bigler@keymile.com \
    --cc=holger.brunck@keymile.com \
    --cc=joakim.tjernlund@transmode.se \
    --cc=linux-mtd@lists.infradead.org \
    --cc=mboards@prograde.net \
    /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