All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Peter Pan <peterpansjtu@gmail.com>
Cc: Peter Pan <peterpandong@micron.com>,
	Richard Weinberger <richard@nod.at>,
	Brian Norris <computersforpeace@gmail.com>,
	linux-mtd@lists.infradead.org,
	"linshunquan (A)" <linshunquan1@hisilicon.com>
Subject: Re: [PATCH 04/11] nand: spi: Add read function support
Date: Tue, 21 Feb 2017 11:39:36 +0100	[thread overview]
Message-ID: <20170221113936.749b5b15@bbrezillon> (raw)
In-Reply-To: <CAAyFORKDNpkycQ-n5yg=H+fmu6v4teUhwzcXEa-SROV_8kVOBA@mail.gmail.com>

On Tue, 21 Feb 2017 18:06:03 +0800
Peter Pan <peterpansjtu@gmail.com> wrote:

[...]

> >> +static int spi_nand_get_device(struct mtd_info *mtd, int new_state)
> >> +{
> >> +     struct spi_nand_chip *this = mtd_to_spi_nand(mtd);
> >> +     DECLARE_WAITQUEUE(wait, current);
> >> +
> >> +     /*
> >> +      * Grab the lock and see if the device is available
> >> +      */
> >> +     while (1) {
> >> +             spin_lock(&this->chip_lock);
> >> +             if (this->state == FL_READY) {
> >> +                     this->state = new_state;
> >> +                     spin_unlock(&this->chip_lock);
> >> +                     break;
> >> +             }
> >> +             if (new_state == FL_PM_SUSPENDED) {
> >> +                     spin_unlock(&this->chip_lock);
> >> +                     return (this->state == FL_PM_SUSPENDED) ? 0 : -EAGAIN;
> >> +             }
> >> +             set_current_state(TASK_UNINTERRUPTIBLE);
> >> +             add_wait_queue(&this->wq, &wait);
> >> +             spin_unlock(&this->chip_lock);
> >> +             schedule();
> >> +             remove_wait_queue(&this->wq, &wait);
> >> +     }  
> >
> > Do we really need this fl_state dance? It could be replaced with a
> > simple mutex that is taken for the whole flash operation. This leaves
> > the suspended case which could be handled with:
> >
> > static void spinand_suspend(struct mtd_info *mtd)
> > {
> >         struct spi_nand_chip *this = mtd_to_spinand(mtd);
> >
> >         if (!mutex_trylock(&this->lock))
> >                 return -EAGAIN;
> >
> >         return 0;
> > }
> >
> > For other operations (read, write, lock, unlock, ...), you just have to
> > take the lock before accessing the NAND and release it when you're done.
> >
> > Again, I'm saying that because I don't want to end up with something
> > that is overly complex for no real reason, but maybe I'm missing
> > something.  
> 
> This code refers old NAND framework two years ago. I just check the latest
> nand_base.c you already remove it. Let's make it simple. Fix this in v2.

Nope, it's still here [1], but I'm pretty sure this complexity is
actually not needed, and anyway, I plan to delegate this serialization
to the NAND controller in the future (some operations can be done
in //, for example, on multi-die NANDs, you can read something on a die,
while you're programming something on the other die).

[1]http://lxr.free-electrons.com/source/drivers/mtd/nand/nand_base.c#L851

  reply	other threads:[~2017-02-21 10:40 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-21  7:59 [PATCH 00/11] Introduction to SPI NAND framework Peter Pan
2017-02-21  8:00 ` [PATCH 01/11] nand: Add SPI NAND cmd set and register definition Peter Pan
2017-02-21  8:44   ` Boris Brezillon
2017-02-21  9:16     ` Peter Pan
2017-02-21  8:00 ` [PATCH 02/11] nand: spi: create spi_nand_chip struct Peter Pan
2017-02-21  8:34   ` Boris Brezillon
2017-02-21  9:08     ` Peter Pan
2017-02-21  8:00 ` [PATCH 03/11] nand: spi: Abstract SPI NAND cmd set to functions Peter Pan
2017-02-21  9:01   ` Arnaud Mouiche
2017-02-21  9:40     ` Peter Pan
2017-02-21 10:22       ` Arnaud Mouiche
2017-02-21 10:50         ` Boris Brezillon
2017-02-21  9:06   ` Boris Brezillon
2017-02-21  9:27     ` Peter Pan
2017-02-21  8:00 ` [PATCH 04/11] nand: spi: Add read function support Peter Pan
2017-02-21  9:51   ` Boris Brezillon
2017-02-21 10:06     ` Peter Pan
2017-02-21 10:39       ` Boris Brezillon [this message]
2017-02-21 11:02       ` Boris Brezillon
2017-02-21  8:00 ` [PATCH 05/11] nand: spi: Add write " Peter Pan
2017-02-21  8:00 ` [PATCH 06/11] nand: spi: Add erase " Peter Pan
2017-02-21  8:00 ` [PATCH 07/11] nand: spi: Add init/release function Peter Pan
2017-02-21  8:00 ` [PATCH 08/11] nand: spi: Add bad block support Peter Pan
2017-02-21  8:00 ` [PATCH 09/11] nand: spi: Add BBT support Peter Pan
2017-02-21  8:00 ` [PATCH 10/11] nand: spi: Add generic SPI controller support Peter Pan
2017-02-21  8:03   ` Richard Weinberger
2017-02-21  8:17     ` Peter Pan
2017-02-21  9:25   ` Arnaud Mouiche
2017-02-21  9:37     ` Peter Pan
2017-02-21  8:00 ` [PATCH 11/11] nand: spi: Add arguments check for read/write Peter Pan
2017-02-21  8:05 ` [PATCH 00/11] Introduction to SPI NAND framework Richard Weinberger
2017-02-21  8:11   ` Peter Pan
2017-02-21  8:18     ` Peter Pan
2017-02-21  8:43 ` Boris Brezillon
2017-02-21  9:15   ` Peter Pan

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=20170221113936.749b5b15@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=linshunquan1@hisilicon.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=peterpandong@micron.com \
    --cc=peterpansjtu@gmail.com \
    --cc=richard@nod.at \
    /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.