linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Richard Weinberger <richard.weinberger@gmail.com>
Cc: Boris Brezillon <boris.brezillon@collabora.com>,
	linux-mtd@lists.infradead.org, kernel@pengutronix.de,
	Miquel Raynal <miquel.raynal@bootlin.com>
Subject: Re: Prevent Nand page writes on Power failure
Date: Thu, 21 Feb 2019 09:39:14 +0100	[thread overview]
Message-ID: <20190221083914.dq4kzyx4t4fgoo46@pengutronix.de> (raw)
In-Reply-To: <CAFLxGvxJ=sRRKMVJHCh6S--NtEjJ7eUXD=VK3a5DXkWqi4Y1fQ@mail.gmail.com>

On Thu, Feb 21, 2019 at 01:05:04AM +0100, Richard Weinberger wrote:
> On Wed, Feb 20, 2019 at 2:58 PM Sascha Hauer <s.hauer@pengutronix.de> wrote:
> >
> >
> > Hi All,
> >
> > I have hardware here for which the normal way to turn off is just to cut
> > the power. When the powercut happens during a NAND page write then we
> > get more or less completely written pages during next boot. Very rarely
> > it seems to happen that such a half written page with only very few
> > flipped bits is erroneously detected as empty and written again which
> > then results in ECC errors when reading the data.
> >
> > The Nand in question is a Micron MT29F4G08ABADAH4 and in TN2917 Micron
> > clearly states:
> >
> > | Power loss during NAND array operations (especially Program/Erase) is a
> > | violation of the NAND voltage specifications, which is not supported and
> > | should be avoided
> >
> > Micron suggests to make the capacitors on the Nand chips supply input
> > big enough that every started operation will be finished before the
> > power goes down. Now we don't have that situation here, what I have
> > though is a power good status GPIO, so my job is to wire that up to the
> > Nand write operations.
> >
> > Now my question is how could that be done? I assume for some people a
> > power good failure means that we should write all important data away,
> > rather than preventing any Nand access. Given it's a policy decision I
> > assume user space should be involved, right?  An option might be to
> > introcude some sysfs entry to switch mtd devices to readonly mode. Would
> > that be fine? Other suggestions?
> 
> Well, we need to make sure that no new write/erase command is issued and
> the running one can complete. So, in nand_base.c you can (ab)use a lock
> to ensure that.

Nice idea.

> Regarding important data, users that care need to use fsync() anyway, so
> there is no need to trigger whatever writeback upon power failure.
> Or what else important data do you have in mind?

What you want to do on a power failure probably depends on the time
you have left. When you have a second left then you get other ideas than
when you have just a few milliseconds. If you have enough time then you
maybe even want to do an ordered shutdown which would include writing to
the nand.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

  reply	other threads:[~2019-02-21  8:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-20 13:58 Prevent Nand page writes on Power failure Sascha Hauer
2019-02-21  0:05 ` Richard Weinberger
2019-02-21  8:39   ` Sascha Hauer [this message]
2019-02-21  9:28     ` Richard Weinberger
2019-02-21  8:10 ` Boris Brezillon
2019-02-21 10:17   ` Sascha Hauer
2019-02-21 10:36     ` Boris Brezillon
2019-02-21 11:21       ` Sascha Hauer
2019-02-21 11:37         ` Boris Brezillon
2019-02-21 12:17           ` Richard Weinberger
2019-02-21 13:27           ` Sascha Hauer
2019-02-25  8:56 ` Sascha Hauer
2019-02-25 11:28   ` Richard Weinberger
2019-02-26  9:10     ` Sascha Hauer

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=20190221083914.dq4kzyx4t4fgoo46@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=boris.brezillon@collabora.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard.weinberger@gmail.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;
as well as URLs for NNTP newsgroup(s).