diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-10-23 11:06:56 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-11-03 07:27:44 +0100 |
commit | b792124a7dd30f03b9ad0e06589b5b58ed930d3b (patch) | |
tree | 9811bbbc0b5bb5baade7d32309ced5b3c59046df /commands/memtest.c | |
parent | 6b127d4f189c03f4417f6185de1aeb55b1706f94 (diff) | |
download | barebox-b792124a7dd30f03b9ad0e06589b5b58ed930d3b.tar.gz barebox-b792124a7dd30f03b9ad0e06589b5b58ed930d3b.tar.xz |
rework remap_range
remap_range is for remapping regions with different cache attributes.
It is implemented for ARM and PowerPC only, the other architectures only
provide stubs.
Currently the new cache attributes are passed in an architecture specific
way and the attributes have to be retrieved by calls to
mmu_get_pte_cached_flags() and mmu_get_pte_uncached_flags().
Make this simpler by providing architecture independent flags which can
be directly passed to remap_range()
Also provide a MAP_ARCH_DEFAULT flag and a arch_can_remap() function.
The MAP_ARCH_DEFAULT defaults to whatever caching type the architecture
has as default. the arch_can_remap() function returns true if the
architecture can change the cache attributes, false otherwise. This
allows the memtest code to better find out what it has to do.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/memtest.c')
-rw-r--r-- | commands/memtest.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/commands/memtest.c b/commands/memtest.c index 531b8e0ea7..db9e3dbb01 100644 --- a/commands/memtest.c +++ b/commands/memtest.c @@ -21,15 +21,15 @@ #include <command.h> #include <getopt.h> -#include <asm/mmu.h> #include <memory.h> #include <malloc.h> #include <common.h> #include <errno.h> #include <memtest.h> +#include <mmu.h> static int __do_memtest(struct list_head *memtest_regions, - int bus_only, uint32_t cache_flag) + int bus_only, unsigned cache_flag) { struct mem_test_resource *r; int ret; @@ -53,7 +53,7 @@ static int __do_memtest(struct list_head *memtest_regions, static int do_memtest(int argc, char *argv[]) { int bus_only = 0, ret, opt; - uint32_t i, max_i = 1, pte_flags_cached, pte_flags_uncached; + uint32_t i, max_i = 1; struct list_head memtest_used_regions; while ((opt = getopt(argc, argv, "i:b")) > 0) { @@ -72,12 +72,6 @@ static int do_memtest(int argc, char *argv[]) if (optind > argc) return COMMAND_ERROR_USAGE; - /* - * Get pte flags for enable and disable cache support on page. - */ - pte_flags_cached = mmu_get_pte_cached_flags(); - pte_flags_uncached = mmu_get_pte_uncached_flags(); - INIT_LIST_HEAD(&memtest_used_regions); ret = mem_test_request_regions(&memtest_used_regions); @@ -87,24 +81,31 @@ static int do_memtest(int argc, char *argv[]) for (i = 1; (i <= max_i) || !max_i; i++) { if (max_i) printf("Start iteration %u of %u.\n", i, max_i); - /* - * First try a memtest with caching enabled. - */ - if (IS_ENABLED(CONFIG_MMU)) { + + if (arch_can_remap()) { + /* + * First try a memtest with caching enabled. + */ printf("Do memtest with caching enabled.\n"); ret = __do_memtest(&memtest_used_regions, - bus_only, pte_flags_cached); + bus_only, MAP_CACHED); + if (ret < 0) + goto out; + + /* + * Second try a memtest with caching disabled. + */ + printf("Do memtest with caching disabled.\n"); + ret = __do_memtest(&memtest_used_regions, + bus_only, MAP_UNCACHED); + if (ret < 0) + goto out; + } else { + ret = __do_memtest(&memtest_used_regions, + bus_only, MAP_DEFAULT); if (ret < 0) goto out; } - /* - * Second try a memtest with caching disabled. - */ - printf("Do memtest with caching disabled.\n"); - ret = __do_memtest(&memtest_used_regions, - bus_only, pte_flags_uncached); - if (ret < 0) - goto out; } out: |