public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Boris Brezillon <bbrezillon@kernel.org>
To: Emil Lenngren <emil.lenngren@gmail.com>
Cc: linux-mtd@lists.infradead.org
Subject: Re: mtd: spinand: wait on erase success in spinand_markbad?
Date: Thu, 20 Dec 2018 11:30:50 +0100	[thread overview]
Message-ID: <20181220113050.7202bc22@bbrezillon> (raw)
In-Reply-To: <CAO1O6scbGZwf_ZiG66zQuoeXHKuHLgmNHz_TjKaJi84Y7xV-ng@mail.gmail.com>

On Wed, 19 Dec 2018 20:54:33 +0100
Emil Lenngren <emil.lenngren@gmail.com> wrote:

> Den ons 19 dec. 2018 kl 19:56 skrev Boris Brezillon <bbrezillon@kernel.org>:
> >
> > On Wed, 19 Dec 2018 14:27:51 +0100
> > Emil Lenngren <emil.lenngren@gmail.com> wrote:
> >  
> > > Hi,
> > >
> > > I was just reading the spinand driver and found this piece of code:
> > > static int spinand_markbad(struct nand_device *nand, const struct nand_pos *pos)
> > > {
> > >     struct spinand_device *spinand = nand_to_spinand(nand);
> > >     struct nand_page_io_req req = {
> > >         .pos = *pos,
> > >         .ooboffs = 0,
> > >         .ooblen = 2,
> > >         .oobbuf.out = spinand->oobbuf,
> > >     };
> > >     int ret;
> > >
> > >     /* Erase block before marking it bad. */
> > >     ret = spinand_select_target(spinand, pos->target);
> > >     if (ret)
> > >         return ret;
> > >
> > >     ret = spinand_write_enable_op(spinand);
> > >     if (ret)
> > >         return ret;
> > >
> > >     spinand_erase_op(spinand, pos);
> > >
> > >     memset(spinand->oobbuf, 0, 2);
> > >     return spinand_write_page(spinand, &req);
> > > }
> > >
> > > Shouldn't there be spinand_wait call after spinand_erase_op and before
> > > spinand_write_page?
> > >  
> >
> > Absolutely. Can you send a patch to fix that?
> >  
> 
> Sure, although I'm a bit unsure how the error handling should be done.
> In the u-boot version
> (https://github.com/u-boot/u-boot/blob/9e5c2a755a6ca5f3931de548f43101d0d18ac003/drivers/mtd/nand/spi/core.c#L718),
> if the spinand_erase_op spi transfer fails, the function quits without
> writing the bad block marker, while the linux version ignores the
> error. Is the intention that the bad block marker should be written
> regardless if the erase spi transfer fails or not, or is it just a
> mistake?

To be honest, I don't think the erase operation is needed (we just
want to write 0 in the BBM), so we don't really care if it fails, which
means Linux version is correct and u-boot is probably buggy. Note that
you're unlikely to hit a failure on the erase operation anyway, so
it's more a theoretical bug than a real one.

      reply	other threads:[~2018-12-20 10:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-19 13:27 mtd: spinand: wait on erase success in spinand_markbad? Emil Lenngren
2018-12-19 18:56 ` Boris Brezillon
2018-12-19 19:54   ` Emil Lenngren
2018-12-20 10:30     ` Boris Brezillon [this message]

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=20181220113050.7202bc22@bbrezillon \
    --to=bbrezillon@kernel.org \
    --cc=emil.lenngren@gmail.com \
    --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