All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Cashwell <mboards@prograde.net>
To: Joakim Tjernlund <joakim.tjernlund@transmode.se>
Cc: Holger brunck <holger.brunck@keymile.com>,
	linux-mtd@lists.infradead.org, stefan.bigler@keymile.com
Subject: Re: Numonyx NOR and chip->mutex bug?
Date: Sat, 5 Feb 2011 14:19:59 -0500	[thread overview]
Message-ID: <76241A6C-ECA0-46B1-B8B4-F3786FCBA339@prograde.net> (raw)
In-Reply-To: <OF42EFA99A.95A8E75E-ONC125782E.00384CCF-C125782E.00399CFC@transmode.se>

On Feb 5, 2011, at 5:29 AM, Joakim Tjernlund wrote:

> Michael Cashwell <mboards@prograde.net> wrote on 2011/02/04 18:09:01:
>> 
>> That's where I get confused. It's true that another thread could do that but wouldn't it have to bracket its operation with calls to get_chip() and put_chip()? Those actually do the suspend and resume. I'm certainly seeing erases being suspended to do a buffered write and then being resumed.
> 
> buffered write do get_chip that suspends the erase, then a WAIT_TIMEOUT which drops the locks and gives the suspended erase a chance to wakeup and run but now SR is holding the status for the write so the suspended erase are testing the wrong status, do you agree?

It's not that simple. Just waking the suspended erase thread should not cause it to "run" the way you are saying.

That thread *should* wake up in inval_cache_and_wait_for_operation() inside its while (chip->state != chip_state) loop. The purpose of that loop is to see if something else is going on with the chip and if so just go back to sleep. That should prevent what you are saying is happening and if it is not then we need to figure out why.

In the case of a buffered write the erase thread should see chip->state as either FL_WRITING_TO_BUFFER (if after the 0xE8) or FL_WRITING (if after the 0xD0). Since those don't match the expected FL_ERASING state the thread should stay in the while loop and go back to sleep on the wait queue. It should keep doing that until the chip->state has come back to FL_ERASING. That should not happen until the write function is finished and does its put_chip and erase resume.

So what I'm saying is that just dropping the locks and letting other threads run is not, by itself itself, wrong. The code's supposed to do that. It's just that the other threads are supposed check the conditions when they wake up and only proceed if the conditions are correct.

But I do see something suspicious. I think it can be argued that all CFI thread wake-ups need to do the while (chip->state != chip_state) dance and go back to sleep if not.

That seems to be the case for inval_cache_and_wait_for_operation() but what about the other places where threads can be scheduled out? Won't they just wake up where they are or am I missing some wait queue magic?

IOW: We should look for other places outside of inval_cache_and_wait_for_operation() that call things like msleep, schedule, and cond_resched. (One sneaky one is cfi_udelay as it may call cond_resched.)

If any of those fail to do the chip->state != chip_state sleep loop when they awaken then we have have found our problem.

One last idea is to add more info in your logging code:

ubimkvol /dev/ubi0 -s 6MiB -N test1
[2299][209] do_erase_oneblock start adr=0x00020000 len=0x20000
[2299][209] map_write 0x50 to 0x00020000
[2299][209] map_write 0x20 to 0x00020000
[2299][209] map_write 0xd0 to 0x00020000
[2299][465] map_write 0xb0 to 0x03fe5000
[2307][465] erase suspend 1         adr=0x03fe5000
[2307][465] map_write 0x70 to 0x03fe5000
[2307][465] map_write 0xe8 to 0x03fe5000
[2307][209] map_write 0x70 to 0x00020000
[2307][209] map_write 0x50 to 0x00020000
[2307][209] map_write 0xd0 to 0x00020000
[2307][209] map_write 0x70 to 0x00020000
[2311][209] erase resumed 2b        adr=0x00020000
[2319][209] do_erase_oneblock end   adr=0x00020000 len=0x20000
[2319][465] map_write 0x1ff to 0x03fe5000
[2319][465] map_write 0xc03c0000 to 0x03fe5000
[2319][465] map_write 0xc03c0000 to 0x03fe5002
...
[2327][465] map_write 0xc03c0000 to 0x03fe53fc
[2327][465] map_write 0xc03c0000 to 0x03fe53fe
[2327][465] map_write 0xd0 to 0x03fe5000
[3387][465] map_write 0x50 to 0x03fe5000
[3387][465] map_write 0x70 to 0x03fe5000
[3395][465] 50000000.flash: buffer write error status 0xb0 adr=0x03fe5400 len=0x0 (0x400)

when "erase resumed" happens, it should be inside the put_chip() done when the write command is finished. Something to confirm.

It would be helpful if the log also showed start/end for do_buffer_write() and would print chip->state at various points since that value controls what threads do when they wake up.

> I won't worry about this until you test my patch and still have a problem :)
> Please test it.

I tested it quickly on Friday and it didn't fix my problem, but we may be fighting different problems.

I also can't be sure the .c file didn't have other changes. I was really pressed for time that day.

My plan is to retest your patch against a pristine copy of the file and report back. Unfortunately this has to wait until Monday as I don't have access to the hardware over the weekend.

-Mike

  reply	other threads:[~2011-02-05 19:20 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
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 [this message]
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=76241A6C-ECA0-46B1-B8B4-F3786FCBA339@prograde.net \
    --to=mboards@prograde.net \
    --cc=holger.brunck@keymile.com \
    --cc=joakim.tjernlund@transmode.se \
    --cc=linux-mtd@lists.infradead.org \
    --cc=stefan.bigler@keymile.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 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.