From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 8/9] memtest: By default only test biggest region
Date: Tue, 27 Oct 2015 09:30:01 +0100 [thread overview]
Message-ID: <1445934602-25903-9-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1445934602-25903-1-git-send-email-s.hauer@pengutronix.de>
Often enough the biggest free region spans most free RAM, so
it doesn't add much value to test the remaining free regions. This
patch changes the default behaviour to only test the biggest free
region and adds the -t option to test all regions.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/memtest.c | 82 ++++++++++++++++++++++++++++++++++++------------------
common/memtest.c | 16 +++++++++++
include/memtest.h | 1 +
3 files changed, 72 insertions(+), 27 deletions(-)
diff --git a/commands/memtest.c b/commands/memtest.c
index ccccc9c..7853cc5 100644
--- a/commands/memtest.c
+++ b/commands/memtest.c
@@ -28,42 +28,70 @@
#include <memtest.h>
#include <mmu.h>
-static int __do_memtest(struct list_head *memtest_regions,
+static int do_test_one_area(struct mem_test_resource *r, int bus_only,
+ unsigned cache_flag)
+{
+ int ret;
+
+ printf("Testing memory space: "
+ "0x%08x -> 0x%08x:\n",
+ r->r->start, r->r->end);
+
+ remap_range((void *)r->r->start, r->r->end -
+ r->r->start + 1, cache_flag);
+
+ ret = mem_test_bus_integrity(r->r->start, r->r->end);
+ if (ret < 0)
+ return ret;
+
+ if (bus_only)
+ return 0;
+
+ ret = mem_test_moving_inversions_pattern(r->r->start, r->r->end, 0xdeadbeef);
+ if (ret < 0)
+ return ret;
+ printf("done.\n\n");
+
+ return 0;
+}
+
+static int do_memtest_thorough(struct list_head *memtest_regions,
int bus_only, unsigned cache_flag)
{
struct mem_test_resource *r;
int ret;
list_for_each_entry(r, memtest_regions, list) {
- printf("Testing memory space: "
- "0x%08x -> 0x%08x:\n",
- r->r->start, r->r->end);
- remap_range((void *)r->r->start, r->r->end -
- r->r->start + 1, cache_flag);
-
- ret = mem_test_bus_integrity(r->r->start, r->r->end);
- if (ret < 0)
+ ret = do_test_one_area(r, bus_only, cache_flag);
+ if (ret)
return ret;
-
- if (bus_only)
- continue;
-
- ret = mem_test_moving_inversions(r->r->start, r->r->end);
- if (ret < 0)
- return ret;
- printf("done.\n\n");
}
return 0;
}
+static int do_memtest_biggest(struct list_head *memtest_regions,
+ int bus_only, unsigned cache_flag)
+{
+ struct mem_test_resource *r;
+
+ r = mem_test_biggest_region(memtest_regions);
+ if (!r)
+ return -EINVAL;
+
+ return do_test_one_area(r, bus_only, cache_flag);
+}
+
static int do_memtest(int argc, char *argv[])
{
int bus_only = 0, ret, opt;
uint32_t i, max_i = 1;
struct list_head memtest_used_regions;
+ int (*memtest)(struct list_head *, int, unsigned);
+
+ memtest = do_memtest_biggest;
- while ((opt = getopt(argc, argv, "i:b")) > 0) {
+ while ((opt = getopt(argc, argv, "i:bt")) > 0) {
switch (opt) {
case 'i':
max_i = simple_strtoul(optarg, NULL, 0);
@@ -71,6 +99,9 @@ static int do_memtest(int argc, char *argv[])
case 'b':
bus_only = 1;
break;
+ case 't':
+ memtest = do_memtest_thorough;
+ break;
default:
return COMMAND_ERROR_USAGE;
}
@@ -90,25 +121,21 @@ static int do_memtest(int argc, char *argv[])
printf("Start iteration %u of %u.\n", i, max_i);
if (arch_can_remap()) {
- /*
- * First try a memtest with caching enabled.
- */
+ /* First do a memtest with caching enabled. */
printf("Do memtest with caching enabled.\n");
- ret = __do_memtest(&memtest_used_regions,
+ ret = memtest(&memtest_used_regions,
bus_only, MAP_CACHED);
if (ret < 0)
goto out;
- /*
- * Second try a memtest with caching disabled.
- */
+ /* Second do a memtest with caching disabled. */
printf("Do memtest with caching disabled.\n");
- ret = __do_memtest(&memtest_used_regions,
+ ret = memtest(&memtest_used_regions,
bus_only, MAP_UNCACHED);
if (ret < 0)
goto out;
} else {
- ret = __do_memtest(&memtest_used_regions,
+ ret = memtest(&memtest_used_regions,
bus_only, MAP_DEFAULT);
if (ret < 0)
goto out;
@@ -139,6 +166,7 @@ BAREBOX_CMD_HELP_START(memtest)
BAREBOX_CMD_HELP_TEXT("Options:")
BAREBOX_CMD_HELP_OPT("-i ITERATIONS", "perform number of iterations (default 1, 0 is endless)")
BAREBOX_CMD_HELP_OPT("-b", "perform only a test on bus lines")
+BAREBOX_CMD_HELP_OPT("-t", "thorough. test all free areas. If unset, only test biggest free area")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(memtest)
diff --git a/common/memtest.c b/common/memtest.c
index 026fd0d..401b902 100644
--- a/common/memtest.c
+++ b/common/memtest.c
@@ -139,6 +139,22 @@ void mem_test_release_regions(struct list_head *list)
}
}
+struct mem_test_resource *mem_test_biggest_region(struct list_head *list)
+{
+ struct mem_test_resource *r, *best = NULL;
+ resource_size_t size = 0;
+
+ list_for_each_entry(r, list, list) {
+ resource_size_t now = resource_size(r->r);
+ if (now > size) {
+ size = now;
+ best = r;
+ }
+ }
+
+ return best;
+}
+
static void mem_test_report_failure(const char *failure_description,
resource_size_t expected_value,
resource_size_t actual_value,
diff --git a/include/memtest.h b/include/memtest.h
index 3979d65..0100a6c 100644
--- a/include/memtest.h
+++ b/include/memtest.h
@@ -10,6 +10,7 @@ struct mem_test_resource {
int mem_test_request_regions(struct list_head *list);
void mem_test_release_regions(struct list_head *list);
+struct mem_test_resource *mem_test_biggest_region(struct list_head *list);
int mem_test_bus_integrity(resource_size_t _start, resource_size_t _end);
int mem_test_moving_inversions(resource_size_t _start, resource_size_t _end);
--
2.6.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2015-10-27 8:30 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-27 8:29 memtest updates Sascha Hauer
2015-10-27 8:29 ` [PATCH 1/9] memtest: move request/release regions to common/ Sascha Hauer
2015-10-27 8:29 ` [PATCH 2/9] rework remap_range Sascha Hauer
2015-10-27 8:29 ` [PATCH 3/9] memtest: split tests in separate functions Sascha Hauer
2015-10-27 8:29 ` [PATCH 4/9] memtest: Make output more compact Sascha Hauer
2015-10-27 8:29 ` [PATCH 5/9] memtest: Make comments single line when appropriate Sascha Hauer
2015-10-27 8:29 ` [PATCH 6/9] memtest: move ctrlc check / progress showing into separate function Sascha Hauer
2015-10-27 8:30 ` [PATCH 7/9] memtest: move error handling to end of function Sascha Hauer
2015-10-27 8:30 ` Sascha Hauer [this message]
2015-10-27 8:30 ` [PATCH 9/9] memtest: Make cached/uncached test configurable Sascha Hauer
2015-10-27 16:55 ` memtest updates Alexander Aring
2015-10-27 17:27 ` Alexander Aring
2015-10-27 17:35 ` Alexander Aring
2015-10-28 6:17 ` Sascha Hauer
2015-10-28 9:11 ` Alexander Aring
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=1445934602-25903-9-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@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