From patchwork Fri Aug 10 19:16:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Beno=C3=AEt_Th=C3=A9baudeau?= X-Patchwork-Id: 176608 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 330932C0093 for ; Sat, 11 Aug 2012 05:11:09 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B00482808C; Fri, 10 Aug 2012 21:11:07 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id erL015h0Dn7p; Fri, 10 Aug 2012 21:11:07 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4A9C52808D; Fri, 10 Aug 2012 21:11:05 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BABDE2808D for ; Fri, 10 Aug 2012 21:11:02 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id y1bjT7iAOGU8 for ; Fri, 10 Aug 2012 21:11:01 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from zose-mta15.web4all.fr (zose-mta15.web4all.fr [176.31.217.11]) by theia.denx.de (Postfix) with ESMTP id 0C66C2808C for ; Fri, 10 Aug 2012 21:10:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zose-mta15.web4all.fr (Postfix) with ESMTP id 69A663211E; Fri, 10 Aug 2012 21:13:38 +0200 (CEST) X-Virus-Scanned: amavisd-new at zose1.web4all.fr Received: from zose-mta15.web4all.fr ([127.0.0.1]) by localhost (zose-mta15.web4all.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3kMG-f+NfX89; Fri, 10 Aug 2012 21:13:37 +0200 (CEST) Received: from zose-store12.web4all.fr (zose-store-12.w4a.fr [178.33.204.48]) by zose-mta15.web4all.fr (Postfix) with ESMTP id 97A582C373; Fri, 10 Aug 2012 21:13:37 +0200 (CEST) Date: Fri, 10 Aug 2012 21:16:15 +0200 (CEST) From: =?utf-8?Q?Beno=C3=AEt_Th=C3=A9baudeau?= To: u-boot@lists.denx.de Message-ID: <1902435786.2282282.1344626175261.JavaMail.root@advansee.com> MIME-Version: 1.0 X-Originating-IP: [88.188.188.98] X-Mailer: Zimbra 7.2.0_GA_2669 (ZimbraWebClient - FF3.0 (Win)/7.2.0_GA_2669) Subject: [U-Boot] [PATCH] mtest: Disable dcache during test X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de mtest is supposed to test many types of memory accesses in many different conditions. If dcache is enabled, memory accesses are likely bursts, and some memory accesses are simply skipped. Hence, dcache should be disabled during mtest operation so that what mtest actually tests is not masked by dcache. Signed-off-by: Benoît Thébaudeau Cc: Wolfgang Denk --- .../common/cmd_mem.c | 39 ++++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git u-boot-4d3c95f.orig/common/cmd_mem.c u-boot-4d3c95f/common/cmd_mem.c index 18f0a3f..5d2b735 100644 --- u-boot-4d3c95f.orig/common/cmd_mem.c +++ u-boot-4d3c95f/common/cmd_mem.c @@ -600,6 +600,8 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ulong errs = 0; int iterations = 1; int iteration_limit; + int dcache; + int ret = 1; #if defined(CONFIG_SYS_ALT_MEMTEST) vu_long len; @@ -651,6 +653,13 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) else iteration_limit = 0; + /* Perform tests on the underlying memory rather than on the D-cache. */ + dcache = dcache_status(); + if (dcache) { + dcache_disable(); + invalidate_dcache_all(); + } + #if defined(CONFIG_SYS_ALT_MEMTEST) printf ("Testing %08x ... %08x:\n", (uint)start, (uint)end); debug("%s:%d: start 0x%p end 0x%p\n", @@ -659,14 +668,15 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) for (;;) { if (ctrlc()) { putc ('\n'); - return 1; + goto end; } if (iteration_limit && iterations > iteration_limit) { printf("Tested %d iteration(s) with %lu errors.\n", iterations-1, errs); - return errs != 0; + ret = errs != 0; + goto end; } printf("Iteration: %6d\r", iterations); @@ -704,7 +714,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) errs++; if (ctrlc()) { putc ('\n'); - return 1; + goto end; } } *addr = ~val; @@ -717,7 +727,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) errs++; if (ctrlc()) { putc ('\n'); - return 1; + goto end; } } } @@ -787,7 +797,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) errs++; if (ctrlc()) { putc ('\n'); - return 1; + goto end; } } } @@ -809,7 +819,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) errs++; if (ctrlc()) { putc ('\n'); - return 1; + goto end; } } } @@ -851,7 +861,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) errs++; if (ctrlc()) { putc ('\n'); - return 1; + goto end; } } @@ -873,7 +883,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) errs++; if (ctrlc()) { putc ('\n'); - return 1; + goto end; } } start[offset] = 0; @@ -885,13 +895,14 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) for (;;) { if (ctrlc()) { putc ('\n'); - return 1; + goto end; } if (iteration_limit && iterations > iteration_limit) { printf("Tested %d iteration(s) with %lu errors.\n", iterations-1, errs); - return errs != 0; + ret = errs != 0; + goto end; } ++iterations; @@ -918,7 +929,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) errs++; if (ctrlc()) { putc ('\n'); - return 1; + goto end; } } val += incr; @@ -939,7 +950,11 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) incr = -incr; } #endif - return 0; /* not reached */ + +end: + if (dcache) + dcache_enable(); + return ret; }