public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Miquel Raynal <miquel.raynal@free-electrons.com>,
	Robert Jarzmik <robert.jarzmik@free.fr>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Kamal Dasu <kdasu.kdev@gmail.com>,
	Richard Weinberger <richard@nod.at>,
	Antoine Tenart <antoine.tenart@free-electrons.com>,
	Stefan Agner <stefan@agner.ch>,
	Wenyou Yang <wenyou.yang@atmel.com>,
	Nadav Haklai <nadavh@marvell.com>,
	Marek Vasut <marek.vasut@gmail.com>, Han Xu <han.xu@nxp.com>,
	Rob Herring <robh+dt@kernel.org>,
	linux-mtd <linux-mtd@lists.infradead.org>,
	Ezequiel Garcia <ezequiel.garcia@free-electrons.com>,
	Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>,
	Gregory Clement <gregory.clement@free-electrons.com>,
	Josh Wu <rainyfeeling@outlook.com>,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: [RFC PATCH v2 1/6] mtd: nand: provide several helpers to do common NAND operations
Date: Thu, 30 Nov 2017 09:18:30 +0100	[thread overview]
Message-ID: <20171130091831.06781ce2@bbrezillon> (raw)
In-Reply-To: <CAK7LNATWXZci_M8EqeU-8KSEviWzAT7p1KSdkuqAkSAuj-Zj6w@mail.gmail.com>

Hi Masahiro,

On Thu, 30 Nov 2017 16:44:35 +0900
Masahiro Yamada <yamada.masahiro@socionext.com> wrote:

> 2017-11-07 23:54 GMT+09:00 Miquel Raynal <miquel.raynal@free-electrons.com>:
> 
> > diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
> > index 5124f8ae8c04..ca8d3414d252 100644
> > --- a/drivers/mtd/nand/denali.c
> > +++ b/drivers/mtd/nand/denali.c
> > @@ -645,8 +645,6 @@ static void denali_oob_xfer(struct mtd_info *mtd, struct nand_chip *chip,
> >                             int page, int write)
> >  {
> >         struct denali_nand_info *denali = mtd_to_denali(mtd);
> > -       unsigned int start_cmd = write ? NAND_CMD_SEQIN : NAND_CMD_READ0;
> > -       unsigned int rnd_cmd = write ? NAND_CMD_RNDIN : NAND_CMD_RNDOUT;
> >         int writesize = mtd->writesize;
> >         int oobsize = mtd->oobsize;
> >         uint8_t *bufpoi = chip->oob_poi;
> > @@ -658,11 +656,11 @@ static void denali_oob_xfer(struct mtd_info *mtd, struct nand_chip *chip,
> >         int i, pos, len;
> >
> >         /* BBM at the beginning of the OOB area */
> > -       chip->cmdfunc(mtd, start_cmd, writesize, page);
> >         if (write)
> > -               chip->write_buf(mtd, bufpoi, oob_skip);
> > +               nand_prog_page_begin_op(chip, page, writesize, bufpoi,
> > +                                       oob_skip);
> >         else
> > -               chip->read_buf(mtd, bufpoi, oob_skip);
> > +               nand_read_page_op(chip, page, writesize, bufpoi, oob_skip);
> >         bufpoi += oob_skip;
> >
> >         /* OOB ECC */
> > @@ -675,30 +673,35 @@ static void denali_oob_xfer(struct mtd_info *mtd, struct nand_chip *chip,
> >                 else if (pos + len > writesize)
> >                         len = writesize - pos;
> >
> > -               chip->cmdfunc(mtd, rnd_cmd, pos, -1);
> >                 if (write)
> > -                       chip->write_buf(mtd, bufpoi, len);
> > +                       nand_change_write_column_op(chip, pos, bufpoi, len,
> > +                                                   false);
> >                 else
> > -                       chip->read_buf(mtd, bufpoi, len);
> > +                       nand_change_read_column_op(chip, pos, bufpoi, len,
> > +                                                  false);
> >                 bufpoi += len;
> >                 if (len < ecc_bytes) {
> >                         len = ecc_bytes - len;
> > -                       chip->cmdfunc(mtd, rnd_cmd, writesize + oob_skip, -1);
> >                         if (write)
> > -                               chip->write_buf(mtd, bufpoi, len);
> > +                               nand_change_write_column_op(chip, writesize +
> > +                                                           oob_skip, bufpoi,
> > +                                                           len, false);
> >                         else
> > -                               chip->read_buf(mtd, bufpoi, len);
> > +                               nand_change_read_column_op(chip, writesize +
> > +                                                          oob_skip, bufpoi,
> > +                                                          len, false);
> >                         bufpoi += len;
> >                 }
> >         }
> >
> >         /* OOB free */
> >         len = oobsize - (bufpoi - chip->oob_poi);
> > -       chip->cmdfunc(mtd, rnd_cmd, size - len, -1);
> >         if (write)
> > -               chip->write_buf(mtd, bufpoi, len);
> > +               nand_change_write_column_op(chip, size - len, bufpoi, len,
> > +                                           false);
> >         else
> > -               chip->read_buf(mtd, bufpoi, len);
> > +               nand_change_read_column_op(chip, size - len, bufpoi, len,
> > +                                          false);
> >  }
> >
> >  static int denali_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
> > @@ -788,16 +791,12 @@ static int denali_write_oob(struct mtd_info *mtd, struct nand_chip *chip,
> >                             int page)
> >  {
> >         struct denali_nand_info *denali = mtd_to_denali(mtd);
> > -       int status;
> >
> >         denali_reset_irq(denali);
> >
> >         denali_oob_xfer(mtd, chip, page, 1);
> >
> > -       chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
> > -       status = chip->waitfunc(mtd, chip);
> > -
> > -       return status & NAND_STATUS_FAIL ? -EIO : 0;
> > +       return nand_prog_page_end_op(chip);
> >  }
> >
> >  static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip,
> > @@ -951,7 +950,7 @@ static int denali_erase(struct mtd_info *mtd, int page)
> >         irq_status = denali_wait_for_irq(denali,
> >                                          INTR__ERASE_COMP | INTR__ERASE_FAIL);
> >
> > -       return irq_status & INTR__ERASE_COMP ? 0 : NAND_STATUS_FAIL;
> > +       return irq_status & INTR__ERASE_FAIL ? -EIO : 0;
> >  }  
> 
> Does this change keep the equivalent behavior?

Yep, because the core is patched accordingly, and all implementers of
->erase() (docg4, nand_base and denali) are now returning 0 in case of
success and -EERROR in case of failure.

> 
> Changing NAND_STATUS_FAIL to -EIO is OK
> (but, not mentioned in the git-log)

You're right, we should probably move this change in a separate patch.

> 
> I am not 100% sure about
>   INTR__ERASE_COMP  ->  INTR__ERASE_FAIL.

We'll keep the old test then:

	return irq_status & INTR__ERASE_COMP ? 0 : -EIO;

> 
> 
> Theoretically, there could be three cases:
>   [1] INTR__ERASE_COMP interrupt is asserted
>   [2] INTR__ERASE_FAIL interrupt is asserted
>   [3] Nothing is asserted (bailout by timeout)

Well, ideally we should have something like:

	if (irq_status & INTR__ERASE_COMP)
		return 0;
	else if (irq_status & INTR__ERASE_FAIL)
		return -EIO;

	return -ETIMEDOUT;

But let's keep the existing behavior (return -EIO in case of timeout).

Thanks,

Boris

> 
> 
> If you change this, I must consult our hardware engineers
> whether [3] happens or not in erase operation.
> 
> 

  reply	other threads:[~2017-11-30  8:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-07 14:54 [RFC PATCH v2 0/6] Marvell NAND controller rework with ->exec_op() Miquel Raynal
2017-11-07 14:54 ` [RFC PATCH v2 1/6] mtd: nand: provide several helpers to do common NAND operations Miquel Raynal
2017-11-08 10:48   ` Boris Brezillon
2017-11-08 16:37   ` Boris Brezillon
2017-11-30  7:44   ` Masahiro Yamada
2017-11-30  8:18     ` Boris Brezillon [this message]
2017-11-30 10:38       ` Masahiro Yamada
2017-11-30 13:48         ` Miquel RAYNAL
2017-11-07 14:54 ` [RFC PATCH v2 2/6] mtd: nand: force drivers to explicitly send READ/PROG commands Miquel Raynal
2017-11-08 14:23   ` Boris Brezillon
2017-11-07 14:54 ` [RFC PATCH v2 3/6] mtd: nand: use a static data_interface in the nand_chip structure Miquel Raynal
2017-11-08 14:54   ` Boris Brezillon
2017-11-07 14:54 ` [RFC PATCH v2 4/6] mtd: nand: add ->exec_op() implementation Miquel Raynal
2017-11-08 16:31   ` Boris Brezillon
2017-11-07 14:54 ` [RFC PATCH v2 5/6] dt-bindings: mtd: add Marvell NAND controller documentation Miquel Raynal
2017-11-07 14:54 ` [RFC PATCH v2 6/6] mtd: nand: add reworked Marvell NAND controller driver Miquel Raynal

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=20171130091831.06781ce2@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=antoine.tenart@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@wedev4u.fr \
    --cc=dwmw2@infradead.org \
    --cc=ezequiel.garcia@free-electrons.com \
    --cc=gregory.clement@free-electrons.com \
    --cc=han.xu@nxp.com \
    --cc=kdasu.kdev@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=miquel.raynal@free-electrons.com \
    --cc=nadavh@marvell.com \
    --cc=rainyfeeling@outlook.com \
    --cc=richard@nod.at \
    --cc=robert.jarzmik@free.fr \
    --cc=robh+dt@kernel.org \
    --cc=stefan@agner.ch \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=wenyou.yang@atmel.com \
    --cc=yamada.masahiro@socionext.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox