Skip to contentSkip to conversation

using multile partitions on one NAND chip

DISCUSSION Stephan Linke 2 participants 2 messages Nov 24, 2004 1 message not in the archive Memory technology devices (MTD)

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 85 lines

-----Original Message-----
From: Stephan Linke [mailto:[email protected]]
Sent: Mittwoch, 24. November 2004 19:13
To: [email protected]
Subject: RE: using multile partitions on one NAND chip

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(). 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.
(I'm not shure if a 3rd task could start an ERASE command - after the 2nd task has interrupted the 1st on - before the first nand_wait() returns. This could mislead the first task.)

My real problem is this one:
Our NAND-chips use to keep the buisy line active "for ever" when the RESET command is issued at the wrong point of time. A chip in that condition requires a power-on reset to reactivate the chip. Which makes it a verry critical condition to us. :)
At the moment I am fixing this problem by causing our local copy of nand_command() (in maps/) to wait for the ready bit of the NAND-chip (except for the STATUS commands).

To be more specific: If the RESET is issued when the ERASE is almost finished a deadlock of the chips state is verry likely.

As far as I know the RESET should not do any harm to the chip by definition. But unfortunately it does. :-(

Stephan

Quoted 41 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Thomas Gleixner
Sent: Mittwoch, 24. November 2004 17:29
To: Stephan Linke
Cc: Linux-Mtd
Subject: Re: using multile partitions on one NAND chip

Quoted 1 line · Stephan Linke

Hi,

Please fix your mail client, to 80 characters per line. Read http://david.woodhou.se/email.html

Quoted 1 line

anyone tried using multiple partitions on a NAND flash?

Ever looked into the various drivers in drivers/mtd/nand ?

Quoted 3 lines

I can't find the protection mechanism that protects lets say an erase on one block against a read command on the other block.

nand_get_chip() contains the protection.

Quoted 2 lines

efficient protection for this. It looks like nand_chip->chip_lock should do this job but it only protects

chip_lock is only for SMP and the lock/unlock macros contain the preemption control if CONFIG_PREEMPT=y. The lock itself is a NOOP on UP systems

tglx

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#2 lore raw
Quoted 9 lines · Stephan Linke

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.

Quoted 4 lines

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