public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Stephan Linke <Stephan.Linke@epygi.de>
Cc: Linux-Mtd <linux-mtd@lists.infradead.org>
Subject: RE: using multile partitions on one NAND chip
Date: Wed, 24 Nov 2004 21:05:42 +0100	[thread overview]
Message-ID: <1101326743.9481.40.camel@tglx.tec.linutronix.de> (raw)
In-Reply-To: <NGENJJFPMHGLPILEKKAMAEAGCFAA.Stephan.Linke@epygi.de>

On Wed, 2004-11-24 at 19:12 +0100, Stephan Linke wrote:
> Hi Thomas,
> 
> already noticed the spinlocks; thanks anyway.
> 
> On erase the chip is locked in nand_get_chip() and stays locked
> until the ERASE2 > command has been send to the chip to wait for the 
> ready status the chip gets unlcoked since the nand_wait() also tries
> to lock the chip. Additinaly nand_wait() unlocks the chip befor
> calling yield().

retry:
        /* Hardware controller shared among independend devices */
        if (this->controller) {
                spin_lock (&this->controller->lock);
                if (this->controller->active)
                        active = this->controller->active;
                else
                        this->controller->active = this;
                spin_unlock (&this->controller->lock);
        }

        if (active == this) {
                spin_lock (&this->chip_lock);
                if (this->state == FL_READY) {
                        this->state = new_state;
                        spin_unlock (&this->chip_lock);
                        return;
                }
        }
        set_current_state (TASK_UNINTERRUPTIBLE);
        add_wait_queue (&active->wq, &wait);
        spin_unlock (&active->chip_lock);
        schedule ();
        remove_wait_queue (&active->wq, &wait);
        goto retry;

this->state is reset to FL_READY, after the active command is finished.
All waiters on the waitqueue are woken up.

> If another task tries nand_get_chip() at this verry moment the erase
> will be interrupted by sending an RESET command. Looks like this is by
> intention since the erase of the blockis restarted after the 
> nand_wait() returns.

We stopped to interrupt the erase since long, due to broken chips, which
do not handle the erase suspend correctly. 

But the locking was always safe and without race conditions.

On SMP the spinlock is protecting the state variable against concurrent
access by different tasks on different CPU's. 

In case of CONFIG_PREEMPT=y the state variable is protected by 
spin_lock() (contains preempt_disable()) on SMP and UP against
concurrent access by different tasks on the same CPU.

CONFIG_PREEMPT=n does not need further protection at this place.

Which version of nand_base.c are you using ?

tglx

  reply	other threads:[~2004-11-24 20:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <NGENJJFPMHGLPILEKKAMMEAFCFAA.Stephan.Linke@epygi.de>
2004-11-24 18:28 ` using multile partitions on one NAND chip Stephan Linke
2004-11-24 20:05   ` Thomas Gleixner [this message]
2004-11-24 14:40 Stephan Linke
2004-11-24 16:29 ` Thomas Gleixner

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=1101326743.9481.40.camel@tglx.tec.linutronix.de \
    --to=tglx@linutronix.de \
    --cc=Stephan.Linke@epygi.de \
    --cc=linux-mtd@lists.infradead.org \
    /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