Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1628133

[PATCH] nand_base: optimize checking of erased buffers

From Pavel Machek <pavel@ucw.cz>
Newsgroups linux.kernel
Subject [PATCH] nand_base: optimize checking of erased buffers
Date 2017-04-21 13:00 +0200
Message-ID <tyEsa-4NC-25@gated-at.bofh.it> (permalink)
References <txWKu-3m5-21@gated-at.bofh.it> <ty5b4-8qb-19@gated-at.bofh.it> <ty678-z3-15@gated-at.bofh.it> <ty6gO-DP-17@gated-at.bofh.it> <tyiL0-8qv-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

If we see ~0UL in flash, there's no need for hweight, and no need to
check number of bitflips. So this should be net win.

Signed-off-by: Pavel Machek <pavel@denx.de>

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index b0524f8..96c27ec 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1357,7 +1357,10 @@ static int nand_check_erased_buf(void *buf, int len, int bitflips_threshold)
 
 	for (; len >= sizeof(long);
 	     len -= sizeof(long), bitmap += sizeof(long)) {
-		weight = hweight_long(*((unsigned long *)bitmap));
+		unsigned long d = *((unsigned long *)bitmap);
+		if (d == ~0UL)
+			continue;
+		weight = hweight_long(d);
 		bitflips += BITS_PER_LONG - weight;
 		if (unlikely(bitflips > bitflips_threshold))
 			return -EBADMSG;

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

fsl_ifc_nand: are blank pages protected by ECC? Pavel Machek <pavel@ucw.cz> - 2017-04-19 14:20 +0200
  Re: fsl_ifc_nand: are blank pages protected by ECC? Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-04-19 23:20 +0200
    Re: fsl_ifc_nand: are blank pages protected by ECC? Pavel Machek <pavel@ucw.cz> - 2017-04-20 00:20 +0200
      Re: fsl_ifc_nand: are blank pages protected by ECC? Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-04-20 00:30 +0200
        Re: fsl_ifc_nand: are blank pages protected by ECC? Pavel Machek <pavel@ucw.cz> - 2017-04-20 13:50 +0200
          Re: fsl_ifc_nand: are blank pages protected by ECC? Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-04-20 14:20 +0200
          [PATCH] nand_base: optimize checking of erased buffers Pavel Machek <pavel@ucw.cz> - 2017-04-21 13:00 +0200
    Re: fsl_ifc_nand: are blank pages protected by ECC? Pavel Machek <pavel@ucw.cz> - 2017-04-21 12:10 +0200
      Re: fsl_ifc_nand: are blank pages protected by ECC? Richard Weinberger <richard@nod.at> - 2017-04-21 12:20 +0200
      Re: fsl_ifc_nand: are blank pages protected by ECC? Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-04-21 14:10 +0200
      Re: fsl_ifc_nand: are blank pages protected by ECC? Pavel Machek <pavel@ucw.cz> - 2017-04-21 15:40 +0200
        Re: fsl_ifc_nand: are blank pages protected by ECC? Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-04-21 15:50 +0200
          Re: fsl_ifc_nand: are blank pages protected by ECC? Pavel Machek <pavel@ucw.cz> - 2017-04-22 09:10 +0200
          [PATCH] tango_nand.c: fix ecc.stats_corrected in empty flash case Pavel Machek <pavel@ucw.cz> - 2017-04-22 12:50 +0200
          tango_nand: is logic right in error cases? (was Re: fsl_ifc_nand:  are blank pages protected by ECC?) Pavel Machek <pavel@ucw.cz> - 2017-04-23 12:00 +0200
            Re: tango_nand: is logic right in error cases? (was Re:  fsl_ifc_nand: are blank pages protected by ECC?) Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-04-24 09:20 +0200

csiph-web