All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Gardiner <bengardiner@nanometrics.ca>
To: linux-mtd@lists.infradead.org
Cc: Ben Gardiner <bengardiner@nanometrics.ca>
Subject: [PATCH 3/3] nandtest: report estimated BER
Date: Tue,  9 Aug 2011 16:57:29 -0400	[thread overview]
Message-ID: <c1dd282881d83603b3f9d7ccc8f51ebe98e7d294.1312922073.git.bengardiner@nanometrics.ca> (raw)
In-Reply-To: <e51a260aa56112648b5413c66d4036e489ae09f7.1312922073.git.bengardiner@nanometrics.ca>
In-Reply-To: <cover.1312922073.git.bengardiner@nanometrics.ca>

The nandtest program will excercise every block on a given mtd device by
writing to it and monitoring the ECC corrections and failures.

Augment this utility to report an estimate of the program-disturb raw BER
based on the writesize, eccsize, number of passes and ecc corrections stat.

Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca>

---

This estimate relies on the eccbytes field of the now deprecated struct
nand_ecclayout_user. Since I found it useful I thought I should propose
the change anyways. I'm open to modifications to retrieve 'eccbytes' the
right way.
---
 nandtest.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/nandtest.c b/nandtest.c
index dc28d09..35e3e94 100644
--- a/nandtest.c
+++ b/nandtest.c
@@ -4,6 +4,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -32,7 +33,8 @@ void usage(void)
 }
 
 struct mtd_info_user meminfo;
-struct mtd_ecc_stats oldstats, newstats;
+struct mtd_ecc_stats origstats, oldstats, newstats;
+struct nand_ecclayout_user ecclayout;
 int fd;
 int markbad=0;
 int seed;
@@ -126,6 +128,16 @@ int erase_and_write(loff_t ofs, unsigned char *data, unsigned char *rbuf)
 	return 0;
 }
 
+void report_raw_ber(unsigned long len)
+{
+	unsigned long corrections = newstats.corrected - origstats.corrected;
+	long double rate = (long double) corrections;
+	rate /= (long double) len;
+	rate /= CHAR_BIT;
+
+	printf("%lu bit corrections in %lu bytes. Estimated program-disturb raw BER: %Lg\n",
+			corrections, len, rate);
+}
 
 /*
  * Main program
@@ -204,6 +216,12 @@ int main(int argc, char **argv)
 		exit(1);
 	}
 
+	if (ioctl(fd, ECCGETLAYOUT, &ecclayout)) {
+		perror("ECCGETLAYOUT");
+		close(fd);
+		exit(1);
+	}
+
 	if (length == -1)
 		length = meminfo.size;
 
@@ -243,6 +261,8 @@ int main(int argc, char **argv)
 	printf("Bad blocks     : %d\n", oldstats.badblocks);
 	printf("BBT blocks     : %d\n", oldstats.bbtblocks);
 
+	origstats = oldstats;
+
 	for (pass = 0; pass < nr_passes; pass++) {
 		loff_t test_ofs;
 
@@ -281,6 +301,9 @@ int main(int argc, char **argv)
 		}
 		printf("\nFinished pass %d successfully\n", pass+1);
 	}
+
+	report_raw_ber(length * (meminfo.erasesize + meminfo.erasesize/meminfo.writesize * ecclayout.eccbytes) *(unsigned long)nr_passes);
+
 	/* Return happy */
 	return 0;
 }
-- 
1.7.3.5

      parent reply	other threads:[~2011-08-09 20:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-09 20:38 [PATCH 0/3] mtd-utils: bit errors in nandtest Ben Gardiner
2011-08-09 20:57 ` [PATCH 1/3] mtd_debug: report ecc layout Ben Gardiner
2011-08-10 17:07   ` Brian Norris
2011-08-10 17:52     ` Ben Gardiner
2011-08-17  8:32     ` Artem Bityutskiy
2011-08-17  8:03   ` Artem Bityutskiy
2011-08-18 14:01     ` Ben Gardiner
2011-08-22 11:00       ` Artem Bityutskiy
2011-08-22 13:11         ` Ben Gardiner
2011-08-09 20:57 ` [PATCH 2/3] nandtest: print number of bits corrected during test Ben Gardiner
2011-08-25 11:00   ` Artem Bityutskiy
2011-08-09 20:57 ` Ben Gardiner [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=c1dd282881d83603b3f9d7ccc8f51ebe98e7d294.1312922073.git.bengardiner@nanometrics.ca \
    --to=bengardiner@nanometrics.ca \
    --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 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.