mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 0/8] add new memtest command
@ 2013-01-15 13:48 Alexander Aring
  2013-01-15 13:48 ` [PATCH 1/8] remap_range: make function 'remap_range' global Alexander Aring
                   ` (7 more replies)
  0 siblings, 8 replies; 16+ messages in thread
From: Alexander Aring @ 2013-01-15 13:48 UTC (permalink / raw)
  To: barebox

The new memtest command supports to enable or disable
caching during testing(only arm architecture) and
skipping barebox regions for avoid a barebox killing,
if you want to write on barebox allocated regions.

If you run memtest without a argument, memtest will
run on all registered memory banks.

The new memtest command has these arguments:
	-s #ADDRESS [for start address]
	-e #ADDRESS [for end address]
	-i #ITER [for numbers of iterations]
	-c [don't disable caching]
	-b [do bus testing only]

v2:
	- remove adding whitespaces in linkerscript file
		and change position in of '_sdata'
		in ppc lds files.
	- remove -1 calculation in linkerscript files
		which is wrong.
	- split remap_range patch into three other patches:
		- mmu: add getters for pte cache flags
		- arm-mmu: move PAGE_ALIGN macro to common.h
		- common: add PAGE_ALIGN_DOWN macro
	- change stdout of memtest to make it more beautiful

Alexander Aring (8):
  remap_range: make function 'remap_range' global
  mmu: add getters for pte cache flags
  arm-mmu: move PAGE_ALIGN macro to common.h
  common: add PAGE_ALIGN_DOWN macro
  memory: add function address_in_sdram_regions
  barebox-data: add barebox-data sections
  memtest: remove memtest command
  memtest: add rewritten memtest command

 arch/arm/cpu/mmu.c                               |  18 +-
 arch/arm/include/asm/mmu.h                       |  17 +
 arch/arm/lib/barebox.lds.S                       |   2 +
 arch/blackfin/boards/ipe337/barebox.lds.S        |   2 +
 arch/blackfin/include/asm/mmu.h                  |  19 +
 arch/mips/include/asm/mmu.h                      |  19 +
 arch/mips/lib/barebox.lds.S                      |   2 +
 arch/nios2/cpu/barebox.lds.S                     |   1 +
 arch/nios2/include/asm/mmu.h                     |  19 +
 arch/openrisc/include/asm/mmu.h                  |  19 +
 arch/ppc/boards/freescale-p2020rdb/barebox.lds.S |   1 +
 arch/ppc/boards/pcm030/barebox.lds.S             |   1 +
 arch/ppc/include/asm/mmu.h                       |  15 +
 arch/sandbox/include/asm/mmu.h                   |  19 +
 arch/x86/include/asm/mmu.h                       |  19 +
 arch/x86/lib/barebox.lds.S                       |   2 +
 commands/Kconfig                                 |  16 +-
 commands/Makefile                                |   2 +-
 commands/memtest.c                               | 897 ++++++++++++++++-------
 common/memory.c                                  |  20 +
 include/asm-generic/sections.h                   |   1 +
 include/common.h                                 |   2 +
 include/memory.h                                 |   6 +
 23 files changed, 832 insertions(+), 287 deletions(-)
 create mode 100644 arch/blackfin/include/asm/mmu.h
 create mode 100644 arch/mips/include/asm/mmu.h
 create mode 100644 arch/nios2/include/asm/mmu.h
 create mode 100644 arch/openrisc/include/asm/mmu.h
 create mode 100644 arch/sandbox/include/asm/mmu.h
 create mode 100644 arch/x86/include/asm/mmu.h

-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/8] remap_range: make function 'remap_range' global
  2013-01-15 13:48 [PATCH v2 0/8] add new memtest command Alexander Aring
@ 2013-01-15 13:48 ` Alexander Aring
  2013-01-15 13:48 ` [PATCH 2/8] mmu: add getters for pte cache flags Alexander Aring
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Alexander Aring @ 2013-01-15 13:48 UTC (permalink / raw)
  To: barebox

Change function remap_range in arm architecture to make it
global accessable. For example command 'memtest' can change
pte flags to enable or disable cache.

Add dummy function for others architectures that doesn't
have mmu or pte support.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 arch/arm/cpu/mmu.c              | 2 +-
 arch/arm/include/asm/mmu.h      | 5 +++++
 arch/blackfin/include/asm/mmu.h | 9 +++++++++
 arch/mips/include/asm/mmu.h     | 9 +++++++++
 arch/nios2/include/asm/mmu.h    | 9 +++++++++
 arch/openrisc/include/asm/mmu.h | 9 +++++++++
 arch/ppc/include/asm/mmu.h      | 5 +++++
 arch/sandbox/include/asm/mmu.h  | 9 +++++++++
 arch/x86/include/asm/mmu.h      | 9 +++++++++
 9 files changed, 65 insertions(+), 1 deletion(-)
 create mode 100644 arch/blackfin/include/asm/mmu.h
 create mode 100644 arch/mips/include/asm/mmu.h
 create mode 100644 arch/nios2/include/asm/mmu.h
 create mode 100644 arch/openrisc/include/asm/mmu.h
 create mode 100644 arch/sandbox/include/asm/mmu.h
 create mode 100644 arch/x86/include/asm/mmu.h

diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index 40b7ec4..b5c9c60 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -93,7 +93,7 @@ static u32 *find_pte(unsigned long adr)
 	return &table[(adr >> PAGE_SHIFT) & 0xff];
 }
 
-static void remap_range(void *_start, size_t size, uint32_t flags)
+void remap_range(void *_start, size_t size, uint32_t flags)
 {
 	unsigned long start = (unsigned long)_start;
 	u32 *p;
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index a66da8c..ae1686b 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -41,6 +41,7 @@ void dma_flush_range(unsigned long, unsigned long);
 void dma_inv_range(unsigned long, unsigned long);
 unsigned long virt_to_phys(void *virt);
 void *phys_to_virt(unsigned long phys);
+void remap_range(void *_start, size_t size, uint32_t flags);
 void *map_io_sections(unsigned long physaddr, void *start, size_t size);
 
 #else
@@ -76,6 +77,10 @@ static inline void dma_inv_range(unsigned long s, unsigned long e)
 {
 }
 
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
 static inline void *map_io_sections(unsigned long phys, void *start, size_t size)
 {
 	return (void *)phys;
diff --git a/arch/blackfin/include/asm/mmu.h b/arch/blackfin/include/asm/mmu.h
new file mode 100644
index 0000000..0485a43
--- /dev/null
+++ b/arch/blackfin/include/asm/mmu.h
@@ -0,0 +1,9 @@
+#ifndef __ASM_MMU_H
+#define __ASM_MMU_H
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+#endif /* __ASM_MMU_H */
+
diff --git a/arch/mips/include/asm/mmu.h b/arch/mips/include/asm/mmu.h
new file mode 100644
index 0000000..0485a43
--- /dev/null
+++ b/arch/mips/include/asm/mmu.h
@@ -0,0 +1,9 @@
+#ifndef __ASM_MMU_H
+#define __ASM_MMU_H
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+#endif /* __ASM_MMU_H */
+
diff --git a/arch/nios2/include/asm/mmu.h b/arch/nios2/include/asm/mmu.h
new file mode 100644
index 0000000..0485a43
--- /dev/null
+++ b/arch/nios2/include/asm/mmu.h
@@ -0,0 +1,9 @@
+#ifndef __ASM_MMU_H
+#define __ASM_MMU_H
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+#endif /* __ASM_MMU_H */
+
diff --git a/arch/openrisc/include/asm/mmu.h b/arch/openrisc/include/asm/mmu.h
new file mode 100644
index 0000000..0485a43
--- /dev/null
+++ b/arch/openrisc/include/asm/mmu.h
@@ -0,0 +1,9 @@
+#ifndef __ASM_MMU_H
+#define __ASM_MMU_H
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+#endif /* __ASM_MMU_H */
+
diff --git a/arch/ppc/include/asm/mmu.h b/arch/ppc/include/asm/mmu.h
index b2dd0b7..af263ae 100644
--- a/arch/ppc/include/asm/mmu.h
+++ b/arch/ppc/include/asm/mmu.h
@@ -540,4 +540,9 @@ extern int write_bat(ppc_bat_t bat, unsigned long upper, unsigned long lower);
 					(rt<<21)|(ra<<16)|(ws<<11)|(946<<1)
 
 #endif
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
 #endif /* _PPC_MMU_H_ */
diff --git a/arch/sandbox/include/asm/mmu.h b/arch/sandbox/include/asm/mmu.h
new file mode 100644
index 0000000..0485a43
--- /dev/null
+++ b/arch/sandbox/include/asm/mmu.h
@@ -0,0 +1,9 @@
+#ifndef __ASM_MMU_H
+#define __ASM_MMU_H
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+#endif /* __ASM_MMU_H */
+
diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
new file mode 100644
index 0000000..0485a43
--- /dev/null
+++ b/arch/x86/include/asm/mmu.h
@@ -0,0 +1,9 @@
+#ifndef __ASM_MMU_H
+#define __ASM_MMU_H
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+#endif /* __ASM_MMU_H */
+
-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 2/8] mmu: add getters for pte cache flags
  2013-01-15 13:48 [PATCH v2 0/8] add new memtest command Alexander Aring
  2013-01-15 13:48 ` [PATCH 1/8] remap_range: make function 'remap_range' global Alexander Aring
@ 2013-01-15 13:48 ` Alexander Aring
  2013-01-15 13:48 ` [PATCH 3/8] arm-mmu: move PAGE_ALIGN macro to common.h Alexander Aring
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Alexander Aring @ 2013-01-15 13:48 UTC (permalink / raw)
  To: barebox

Currently only arm architecture provide to change pte flags.
Cache pte flags are configured at boottime.

Adding getters to get this pte flags at runtime. In additional
of remap_range you can disable or enable caching in commands, for
example memtest.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 arch/arm/cpu/mmu.c              | 14 ++++++++++++++
 arch/arm/include/asm/mmu.h      | 12 ++++++++++++
 arch/blackfin/include/asm/mmu.h | 10 ++++++++++
 arch/mips/include/asm/mmu.h     | 10 ++++++++++
 arch/nios2/include/asm/mmu.h    | 10 ++++++++++
 arch/openrisc/include/asm/mmu.h | 10 ++++++++++
 arch/ppc/include/asm/mmu.h      | 10 ++++++++++
 arch/sandbox/include/asm/mmu.h  | 10 ++++++++++
 arch/x86/include/asm/mmu.h      | 10 ++++++++++
 9 files changed, 96 insertions(+)

diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index b5c9c60..6e2ecca 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -52,11 +52,25 @@ extern int arm_architecture;
 #define PTE_FLAGS_CACHED_V4 (PTE_SMALL_AP_UNO_SRW | PTE_BUFFERABLE | PTE_CACHEABLE)
 #define PTE_FLAGS_UNCACHED_V4 PTE_SMALL_AP_UNO_SRW
 
+/*
+ * PTE flags to set cached and uncached areas.
+ * This will be determined at runtime.
+ */
 static uint32_t PTE_FLAGS_CACHED;
 static uint32_t PTE_FLAGS_UNCACHED;
 
 #define PTE_MASK ((1 << 12) - 1)
 
+uint32_t mmu_get_pte_cached_flags()
+{
+	return PTE_FLAGS_CACHED;
+}
+
+uint32_t mmu_get_pte_uncached_flags()
+{
+	return PTE_FLAGS_UNCACHED;
+}
+
 /*
  * Create a second level translation table for the given virtual address.
  * We initially create a flat uncached mapping on it.
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index ae1686b..f32cea6 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -43,6 +43,8 @@ unsigned long virt_to_phys(void *virt);
 void *phys_to_virt(unsigned long phys);
 void remap_range(void *_start, size_t size, uint32_t flags);
 void *map_io_sections(unsigned long physaddr, void *start, size_t size);
+uint32_t mmu_get_pte_cached_flags(void);
+uint32_t mmu_get_pte_uncached_flags(void);
 
 #else
 static inline void *dma_alloc_coherent(size_t size)
@@ -86,6 +88,16 @@ static inline void *map_io_sections(unsigned long phys, void *start, size_t size
 	return (void *)phys;
 }
 
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	return 0;
+}
+
 #endif
 
 #ifdef CONFIG_CACHE_L2X0
diff --git a/arch/blackfin/include/asm/mmu.h b/arch/blackfin/include/asm/mmu.h
index 0485a43..eed4c33 100644
--- a/arch/blackfin/include/asm/mmu.h
+++ b/arch/blackfin/include/asm/mmu.h
@@ -5,5 +5,15 @@ static inline void remap_range(void *_start, size_t size, uint32_t flags)
 {
 }
 
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	return 0;
+}
+
 #endif /* __ASM_MMU_H */
 
diff --git a/arch/mips/include/asm/mmu.h b/arch/mips/include/asm/mmu.h
index 0485a43..eed4c33 100644
--- a/arch/mips/include/asm/mmu.h
+++ b/arch/mips/include/asm/mmu.h
@@ -5,5 +5,15 @@ static inline void remap_range(void *_start, size_t size, uint32_t flags)
 {
 }
 
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	return 0;
+}
+
 #endif /* __ASM_MMU_H */
 
diff --git a/arch/nios2/include/asm/mmu.h b/arch/nios2/include/asm/mmu.h
index 0485a43..eed4c33 100644
--- a/arch/nios2/include/asm/mmu.h
+++ b/arch/nios2/include/asm/mmu.h
@@ -5,5 +5,15 @@ static inline void remap_range(void *_start, size_t size, uint32_t flags)
 {
 }
 
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	return 0;
+}
+
 #endif /* __ASM_MMU_H */
 
diff --git a/arch/openrisc/include/asm/mmu.h b/arch/openrisc/include/asm/mmu.h
index 0485a43..eed4c33 100644
--- a/arch/openrisc/include/asm/mmu.h
+++ b/arch/openrisc/include/asm/mmu.h
@@ -5,5 +5,15 @@ static inline void remap_range(void *_start, size_t size, uint32_t flags)
 {
 }
 
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	return 0;
+}
+
 #endif /* __ASM_MMU_H */
 
diff --git a/arch/ppc/include/asm/mmu.h b/arch/ppc/include/asm/mmu.h
index af263ae..050d84b 100644
--- a/arch/ppc/include/asm/mmu.h
+++ b/arch/ppc/include/asm/mmu.h
@@ -545,4 +545,14 @@ static inline void remap_range(void *_start, size_t size, uint32_t flags)
 {
 }
 
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	return 0;
+}
+
 #endif /* _PPC_MMU_H_ */
diff --git a/arch/sandbox/include/asm/mmu.h b/arch/sandbox/include/asm/mmu.h
index 0485a43..eed4c33 100644
--- a/arch/sandbox/include/asm/mmu.h
+++ b/arch/sandbox/include/asm/mmu.h
@@ -5,5 +5,15 @@ static inline void remap_range(void *_start, size_t size, uint32_t flags)
 {
 }
 
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	return 0;
+}
+
 #endif /* __ASM_MMU_H */
 
diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
index 0485a43..eed4c33 100644
--- a/arch/x86/include/asm/mmu.h
+++ b/arch/x86/include/asm/mmu.h
@@ -5,5 +5,15 @@ static inline void remap_range(void *_start, size_t size, uint32_t flags)
 {
 }
 
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	return 0;
+}
+
 #endif /* __ASM_MMU_H */
 
-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 3/8] arm-mmu: move PAGE_ALIGN macro to common.h
  2013-01-15 13:48 [PATCH v2 0/8] add new memtest command Alexander Aring
  2013-01-15 13:48 ` [PATCH 1/8] remap_range: make function 'remap_range' global Alexander Aring
  2013-01-15 13:48 ` [PATCH 2/8] mmu: add getters for pte cache flags Alexander Aring
@ 2013-01-15 13:48 ` Alexander Aring
  2013-01-15 13:48 ` [PATCH 4/8] common: add PAGE_ALIGN_DOWN macro Alexander Aring
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Alexander Aring @ 2013-01-15 13:48 UTC (permalink / raw)
  To: barebox

PAGE_ALIGN macro is needed to align addresses to page boundaries.
Move this macro to another PAGE_* defines.

Commands which uses remap_range function needs this macro.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 arch/arm/cpu/mmu.c | 2 --
 include/common.h   | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index 6e2ecca..6e24356 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -308,8 +308,6 @@ void mmu_disable(void)
 	__mmu_cache_off();
 }
 
-#define PAGE_ALIGN(s) (((s) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
-
 void *dma_alloc_coherent(size_t size)
 {
 	void *ret;
diff --git a/include/common.h b/include/common.h
index b1c96de..9533344 100644
--- a/include/common.h
+++ b/include/common.h
@@ -225,6 +225,7 @@ int run_shell(void);
 
 #define PAGE_SIZE	4096
 #define PAGE_SHIFT	12
+#define PAGE_ALIGN(s) (((s) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
 
 int memory_display(char *addr, loff_t offs, ulong nbytes, int size, int swab);
 
-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 4/8] common: add PAGE_ALIGN_DOWN macro
  2013-01-15 13:48 [PATCH v2 0/8] add new memtest command Alexander Aring
                   ` (2 preceding siblings ...)
  2013-01-15 13:48 ` [PATCH 3/8] arm-mmu: move PAGE_ALIGN macro to common.h Alexander Aring
@ 2013-01-15 13:48 ` Alexander Aring
  2013-01-15 13:48 ` [PATCH 5/8] memory: add function address_in_sdram_regions Alexander Aring
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Alexander Aring @ 2013-01-15 13:48 UTC (permalink / raw)
  To: barebox

Add PAGE_ALIGN_DOWN macro, which is like PAGE_ALIGN macro but
returns the lower page boundary of address.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 include/common.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/common.h b/include/common.h
index 9533344..3e67164 100644
--- a/include/common.h
+++ b/include/common.h
@@ -226,6 +226,7 @@ int run_shell(void);
 #define PAGE_SIZE	4096
 #define PAGE_SHIFT	12
 #define PAGE_ALIGN(s) (((s) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
+#define PAGE_ALIGN_DOWN(x) ((x) & ~(PAGE_SIZE - 1))
 
 int memory_display(char *addr, loff_t offs, ulong nbytes, int size, int swab);
 
-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 5/8] memory: add function address_in_sdram_regions
  2013-01-15 13:48 [PATCH v2 0/8] add new memtest command Alexander Aring
                   ` (3 preceding siblings ...)
  2013-01-15 13:48 ` [PATCH 4/8] common: add PAGE_ALIGN_DOWN macro Alexander Aring
@ 2013-01-15 13:48 ` Alexander Aring
  2013-01-15 13:48 ` [PATCH 6/8] barebox-data: add barebox-data sections Alexander Aring
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Alexander Aring @ 2013-01-15 13:48 UTC (permalink / raw)
  To: barebox

Add function address_in_sdram_regions to check if a address
is in any sdram region.

Also added new macro 'ADDRESS_IN_REGIONS' to check if address
is in a special boundary with start and end address.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 common/memory.c  | 16 ++++++++++++++++
 include/memory.h |  6 ++++++
 2 files changed, 22 insertions(+)

diff --git a/common/memory.c b/common/memory.c
index 7dd1384..f9192ab 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -158,6 +158,22 @@ int release_sdram_region(struct resource *res)
 	return release_region(res);
 }
 
+/*
+ * Check if specific address are in any allocated region.
+ */
+int address_in_sdram_regions(resource_size_t address)
+{
+	struct memory_bank *bank = NULL;
+	struct resource *r = NULL;
+
+	for_each_memory_bank(bank)
+		list_for_each_entry(r, &bank->res->children, sibling)
+			if (ADDRESS_IN_REGIONS(address, r->start, r->end))
+				return 1;
+
+	return 0;
+}
+
 #ifdef CONFIG_OFTREE
 
 /*
diff --git a/include/memory.h b/include/memory.h
index 165d2dc..e12a28d 100644
--- a/include/memory.h
+++ b/include/memory.h
@@ -27,4 +27,10 @@ struct resource *request_sdram_region(const char *name, resource_size_t start,
 		resource_size_t size);
 int release_sdram_region(struct resource *res);
 
+#define ADDRESS_IN_REGIONS(address, region_start, region_end) \
+	((address >= region_start) && \
+	 (address <= region_end))
+
+int address_in_sdram_regions(resource_size_t address);
+
 #endif
-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 6/8] barebox-data: add barebox-data sections
  2013-01-15 13:48 [PATCH v2 0/8] add new memtest command Alexander Aring
                   ` (4 preceding siblings ...)
  2013-01-15 13:48 ` [PATCH 5/8] memory: add function address_in_sdram_regions Alexander Aring
@ 2013-01-15 13:48 ` Alexander Aring
  2013-01-15 13:48 ` [PATCH 7/8] memtest: remove memtest command Alexander Aring
  2013-01-15 13:48 ` [PATCH 8/8] memtest: add rewritten " Alexander Aring
  7 siblings, 0 replies; 16+ messages in thread
From: Alexander Aring @ 2013-01-15 13:48 UTC (permalink / raw)
  To: barebox

Add barebox-data section in arm branch to get complete
barebox regions in sdram regions tree.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 arch/arm/lib/barebox.lds.S                       | 2 ++
 arch/blackfin/boards/ipe337/barebox.lds.S        | 2 ++
 arch/mips/lib/barebox.lds.S                      | 2 ++
 arch/nios2/cpu/barebox.lds.S                     | 1 +
 arch/ppc/boards/freescale-p2020rdb/barebox.lds.S | 1 +
 arch/ppc/boards/pcm030/barebox.lds.S             | 1 +
 arch/x86/lib/barebox.lds.S                       | 2 ++
 common/memory.c                                  | 4 ++++
 include/asm-generic/sections.h                   | 1 +
 9 files changed, 16 insertions(+)

diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/lib/barebox.lds.S
index bac1a04..e5aee8c 100644
--- a/arch/arm/lib/barebox.lds.S
+++ b/arch/arm/lib/barebox.lds.S
@@ -66,6 +66,7 @@ SECTIONS
 	}
 #endif
 	_etext = .;			/* End of text and rodata section */
+	_sdata = .;
 
 	. = ALIGN(4);
 	.data : { *(.data*) }
@@ -87,6 +88,7 @@ SECTIONS
 	__usymtab : { BAREBOX_SYMS }
 	__usymtab_end = .;
 
+	_edata = .;
 	. = ALIGN(4);
 	__bss_start = .;
 	.bss : { *(.bss*) }
diff --git a/arch/blackfin/boards/ipe337/barebox.lds.S b/arch/blackfin/boards/ipe337/barebox.lds.S
index 6a07b43..a063841 100644
--- a/arch/blackfin/boards/ipe337/barebox.lds.S
+++ b/arch/blackfin/boards/ipe337/barebox.lds.S
@@ -55,6 +55,7 @@ SECTIONS
 	.rodata : { *(.rodata) }
 
 	__etext = .;			/* End of text and rodata section */
+	_sdata = .;
 
 	. = ALIGN(4);
 	.data : { *(.data) }
@@ -79,6 +80,7 @@ SECTIONS
 	__usymtab : { BAREBOX_SYMS }
 	___usymtab_end = .;
 
+	_edata - .;
 	. = ALIGN(4);
 	___bss_start = .;
 	.bss : { *(.bss) }
diff --git a/arch/mips/lib/barebox.lds.S b/arch/mips/lib/barebox.lds.S
index 0cbf2d7..5b3d45d 100644
--- a/arch/mips/lib/barebox.lds.S
+++ b/arch/mips/lib/barebox.lds.S
@@ -44,6 +44,7 @@ SECTIONS
 	.rodata : { *(.rodata*) }
 
 	_etext = .;			/* End of text and rodata section */
+	_sdata = .;
 
 	. = ALIGN(4);
 	.data : { *(.data*) }
@@ -68,6 +69,7 @@ SECTIONS
 	__usymtab : { BAREBOX_SYMS }
 	__usymtab_end = .;
 
+	_edata = .;
 	. = ALIGN(4);
 	__bss_start = .;
 	.bss : { *(.bss*) }
diff --git a/arch/nios2/cpu/barebox.lds.S b/arch/nios2/cpu/barebox.lds.S
index af7be4d..943c507 100644
--- a/arch/nios2/cpu/barebox.lds.S
+++ b/arch/nios2/cpu/barebox.lds.S
@@ -74,6 +74,7 @@ SECTIONS
 	 * adjacent to simplify the startup code -- and provide
 	 * the global pointer for gp-relative access.
 	 */
+	_sdata = .;
 	_data = .;
 	.data :
 	{
diff --git a/arch/ppc/boards/freescale-p2020rdb/barebox.lds.S b/arch/ppc/boards/freescale-p2020rdb/barebox.lds.S
index 95033d4..85a864e 100644
--- a/arch/ppc/boards/freescale-p2020rdb/barebox.lds.S
+++ b/arch/ppc/boards/freescale-p2020rdb/barebox.lds.S
@@ -41,6 +41,7 @@ SECTIONS
 
   _etext = .;
   PROVIDE (etext = .);
+  _sdata = .;
 
   .rodata    :
   {
diff --git a/arch/ppc/boards/pcm030/barebox.lds.S b/arch/ppc/boards/pcm030/barebox.lds.S
index cc86d82..20ac0d8 100644
--- a/arch/ppc/boards/pcm030/barebox.lds.S
+++ b/arch/ppc/boards/pcm030/barebox.lds.S
@@ -69,6 +69,7 @@ SECTIONS
   . = (. + 0x0FFF) & 0xFFFFF000;
   _etext = .;
   PROVIDE (erotext = .);
+  _sdata = .;
   .reloc   :
   {
     *(.got)
diff --git a/arch/x86/lib/barebox.lds.S b/arch/x86/lib/barebox.lds.S
index 8bd2a7b..05d0f77 100644
--- a/arch/x86/lib/barebox.lds.S
+++ b/arch/x86/lib/barebox.lds.S
@@ -153,6 +153,7 @@ SECTIONS
 	} > barebox
 	BAREBOX_BARE_INIT_SIZE
 
+	_sdata = .;
 	.data : AT ( LOADADDR(.text) + SIZEOF(.text) ) {
 		*(.data*)
 		. = ALIGN(4);
@@ -191,6 +192,7 @@ SECTIONS
 		. = ALIGN(4);
 	} > barebox
 
+	_edata = .;
 	.bss : {
 		__bss_start = .;
 		*(.bss*);
diff --git a/common/memory.c b/common/memory.c
index f9192ab..d2e9164 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -75,6 +75,10 @@ static int mem_malloc_resource(void)
 			(unsigned long)&_stext,
 			(unsigned long)&_etext -
 			(unsigned long)&_stext);
+	request_sdram_region("barebox data",
+			(unsigned long)&_sdata,
+			(unsigned long)&_edata -
+			(unsigned long)&_sdata);
 	request_sdram_region("bss",
 			(unsigned long)&__bss_start,
 			(unsigned long)&__bss_stop -
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index 17d5fd1..5492aa4 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -3,6 +3,7 @@
 
 extern char _text[], _stext[], _etext[];
 extern char __bss_start[], __bss_stop[];
+extern char _sdata[], _edata[];
 extern char __bare_init_start[], __bare_init_end[];
 extern char _end[];
 extern void *_barebox_image_size;
-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 7/8] memtest: remove memtest command
  2013-01-15 13:48 [PATCH v2 0/8] add new memtest command Alexander Aring
                   ` (5 preceding siblings ...)
  2013-01-15 13:48 ` [PATCH 6/8] barebox-data: add barebox-data sections Alexander Aring
@ 2013-01-15 13:48 ` Alexander Aring
  2013-01-15 13:48 ` [PATCH 8/8] memtest: add rewritten " Alexander Aring
  7 siblings, 0 replies; 16+ messages in thread
From: Alexander Aring @ 2013-01-15 13:48 UTC (permalink / raw)
  To: barebox

Remove memtest command.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 commands/Kconfig   |   9 --
 commands/Makefile  |   1 -
 commands/memtest.c | 351 -----------------------------------------------------
 3 files changed, 361 deletions(-)
 delete mode 100644 commands/memtest.c

diff --git a/commands/Kconfig b/commands/Kconfig
index 53cee5c..fc0e448 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -496,15 +496,6 @@ config CMD_NANDTEST
 	select PARTITION_NEED_MTD
 	prompt "nandtest"
 
-config CMD_MTEST
-	tristate
-	prompt "mtest"
-
-config CMD_MTEST_ALTERNATIVE
-	bool
-	depends on CMD_MTEST
-	prompt "alternative mtest implementation"
-
 endmenu
 
 menu "video command"
diff --git a/commands/Makefile b/commands/Makefile
index 359f566..3145685 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -7,7 +7,6 @@ obj-$(CONFIG_CMD_LOADY)		+= loadxy.o
 obj-$(CONFIG_CMD_LOADS)		+= loads.o
 obj-$(CONFIG_CMD_ECHO)		+= echo.o
 obj-$(CONFIG_CMD_MEMORY)	+= mem.o
-obj-$(CONFIG_CMD_MTEST)		+= memtest.o
 obj-$(CONFIG_CMD_EDIT)		+= edit.o
 obj-$(CONFIG_CMD_EXEC)		+= exec.o
 obj-$(CONFIG_CMD_SLEEP)		+= sleep.o
diff --git a/commands/memtest.c b/commands/memtest.c
deleted file mode 100644
index 2d64d00..0000000
--- a/commands/memtest.c
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * mtest - Perform a memory test
- *
- * (C) Copyright 2000
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
-
-#include <common.h>
-#include <command.h>
-#include <types.h>
-
-/*
- * Perform a memory test. A more complete alternative test can be
- * configured using CONFIG_CMD_MTEST_ALTERNATIVE. The complete test
- * loops until interrupted by ctrl-c or by a failure of one of the
- * sub-tests.
- */
-#ifdef CONFIG_CMD_MTEST_ALTERNATIVE
-static int mem_test(ulong _start, ulong _end, ulong pattern_unused)
-{
-	vu_long *start = (vu_long *)_start;
-	vu_long *end   = (vu_long *)_end;
-	vu_long *addr;
-	ulong	val;
-	ulong	readback;
-	vu_long	addr_mask;
-	vu_long	offset;
-	vu_long	test_offset;
-	vu_long	pattern;
-	vu_long	temp;
-	vu_long	anti_pattern;
-	vu_long	num_words;
-#ifdef CFG_MEMTEST_SCRATCH
-	vu_long *dummy = (vu_long*)CFG_MEMTEST_SCRATCH;
-#else
-	vu_long *dummy = start;
-#endif
-	int	j;
-	int iterations = 1;
-
-	static const ulong bitpattern[] = {
-		0x00000001,	/* single bit */
-		0x00000003,	/* two adjacent bits */
-		0x00000007,	/* three adjacent bits */
-		0x0000000F,	/* four adjacent bits */
-		0x00000005,	/* two non-adjacent bits */
-		0x00000015,	/* three non-adjacent bits */
-		0x00000055,	/* four non-adjacent bits */
-		0xaaaaaaaa,	/* alternating 1/0 */
-	};
-
-	/* XXX: enforce alignment of start and end? */
-	for (;;) {
-		if (ctrlc()) {
-			putchar ('\n');
-			return 1;
-		}
-
-		printf("Iteration: %6d\r", iterations);
-		iterations++;
-
-		/*
-		 * Data line test: write a pattern to the first
-		 * location, write the 1's complement to a 'parking'
-		 * address (changes the state of the data bus so a
-		 * floating bus doen't give a false OK), and then
-		 * read the value back. Note that we read it back
-		 * into a variable because the next time we read it,
-		 * it might be right (been there, tough to explain to
-		 * the quality guys why it prints a failure when the
-		 * "is" and "should be" are obviously the same in the
-		 * error message).
-		 *
-		 * Rather than exhaustively testing, we test some
-		 * patterns by shifting '1' bits through a field of
-		 * '0's and '0' bits through a field of '1's (i.e.
-		 * pattern and ~pattern).
-		 */
-		addr = start;
-		/* XXX */
-		if (addr == dummy) ++addr;
-		for (j = 0; j < sizeof(bitpattern)/sizeof(bitpattern[0]); j++) {
-		    val = bitpattern[j];
-		    for(; val != 0; val <<= 1) {
-			*addr  = val;
-			*dummy  = ~val; /* clear the test data off of the bus */
-			readback = *addr;
-			if(readback != val) {
-			     printf ("FAILURE (data line): "
-				"expected 0x%08lx, actual 0x%08lx at address 0x%p\n",
-					  val, readback, addr);
-			}
-			*addr  = ~val;
-			*dummy  = val;
-			readback = *addr;
-			if(readback != ~val) {
-			    printf ("FAILURE (data line): "
-				"Is 0x%08lx, should be 0x%08lx at address 0x%p\n",
-					readback, ~val, addr);
-			}
-		    }
-		}
-
-		/*
-		 * Based on code whose Original Author and Copyright
-		 * information follows: Copyright (c) 1998 by Michael
-		 * Barr. This software is placed into the public
-		 * domain and may be used for any purpose. However,
-		 * this notice must not be changed or removed and no
-		 * warranty is either expressed or implied by its
-		 * publication or distribution.
-		 */
-
-		/*
-		 * Address line test
-		 *
-		 * Description: Test the address bus wiring in a
-		 *              memory region by performing a walking
-		 *              1's test on the relevant bits of the
-		 *              address and checking for aliasing.
-		 *              This test will find single-bit
-		 *              address failures such as stuck -high,
-		 *              stuck-low, and shorted pins. The base
-		 *              address and size of the region are
-		 *              selected by the caller.
-		 *
-		 * Notes:	For best results, the selected base
-		 *              address should have enough LSB 0's to
-		 *              guarantee single address bit changes.
-		 *              For example, to test a 64-Kbyte
-		 *              region, select a base address on a
-		 *              64-Kbyte boundary. Also, select the
-		 *              region size as a power-of-two if at
-		 *              all possible.
-		 *
-		 * Returns:     0 if the test succeeds, 1 if the test fails.
-		 *
-		 * ## NOTE ##	Be sure to specify start and end
-		 *              addresses such that addr_mask has
-		 *              lots of bits set. For example an
-		 *              address range of 01000000 02000000 is
-		 *              bad while a range of 01000000
-		 *              01ffffff is perfect.
-		 */
-		addr_mask = ((ulong)end - (ulong)start)/sizeof(vu_long);
-		pattern = (vu_long) 0xaaaaaaaa;
-		anti_pattern = (vu_long) 0x55555555;
-
-		debug("%s:%d: addr mask = 0x%.8lx\n",
-			__FUNCTION__, __LINE__,
-			addr_mask);
-		/*
-		 * Write the default pattern at each of the
-		 * power-of-two offsets.
-		 */
-		for (offset = 1; (offset & addr_mask) != 0; offset <<= 1)
-			start[offset] = pattern;
-
-		/*
-		 * Check for address bits stuck high.
-		 */
-		test_offset = 0;
-		start[test_offset] = anti_pattern;
-
-		for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) {
-		    temp = start[offset];
-		    if (temp != pattern) {
-			printf ("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
-				" expected 0x%.8lx, actual 0x%.8lx\n",
-				(ulong)&start[offset], pattern, temp);
-			return 1;
-		    }
-		}
-		start[test_offset] = pattern;
-
-		/*
-		 * Check for addr bits stuck low or shorted.
-		 */
-		for (test_offset = 1; (test_offset & addr_mask) != 0; test_offset <<= 1) {
-		    start[test_offset] = anti_pattern;
-
-		    for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) {
-			temp = start[offset];
-			if ((temp != pattern) && (offset != test_offset)) {
-			    printf ("\nFAILURE: Address bit stuck low or shorted @"
-				" 0x%.8lx: expected 0x%.8lx, actual 0x%.8lx\n",
-				(ulong)&start[offset], pattern, temp);
-			    return 1;
-			}
-		    }
-		    start[test_offset] = pattern;
-		}
-
-		/*
-		 * Description: Test the integrity of a physical
-		 *		memory device by performing an
-		 *		increment/decrement test over the
-		 *		entire region. In the process every
-		 *		storage bit in the device is tested
-		 *		as a zero and a one. The base address
-		 *		and the size of the region are
-		 *		selected by the caller.
-		 *
-		 * Returns:     0 if the test succeeds, 1 if the test fails.
-		 */
-		num_words = ((ulong)end - (ulong)start)/sizeof(vu_long) + 1;
-
-		/*
-		 * Fill memory with a known pattern.
-		 */
-		for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
-			start[offset] = pattern;
-		}
-
-		/*
-		 * Check each location and invert it for the second pass.
-		 */
-		for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
-		    temp = start[offset];
-		    if (temp != pattern) {
-			printf ("\nFAILURE (read/write) @ 0x%.8lx:"
-				" expected 0x%.8lx, actual 0x%.8lx)\n",
-				(ulong)&start[offset], pattern, temp);
-			return 1;
-		    }
-
-		    anti_pattern = ~pattern;
-		    start[offset] = anti_pattern;
-		}
-
-		/*
-		 * Check each location for the inverted pattern and zero it.
-		 */
-		for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
-		    anti_pattern = ~pattern;
-		    temp = start[offset];
-		    if (temp != anti_pattern) {
-			printf ("\nFAILURE (read/write): @ 0x%.8lx:"
-				" expected 0x%.8lx, actual 0x%.8lx)\n",
-				(ulong)&start[offset], anti_pattern, temp);
-			return 1;
-		    }
-		    start[offset] = 0;
-		}
-	}
-
-}
-#else
-static int mem_test(ulong _start, ulong _end, ulong pattern)
-{
-	vu_long	*addr;
-	vu_long *start = (vu_long *)_start;
-	vu_long *end   = (vu_long *)_end;
-	ulong	val;
-	ulong	readback;
-	ulong	incr;
-	int rcode;
-
-	incr = 1;
-	for (;;) {
-		if (ctrlc()) {
-			putchar('\n');
-			return 1;
-		}
-
-		printf ("\rPattern 0x%08lX  Writing..."
-			"%12s"
-			"\b\b\b\b\b\b\b\b\b\b",
-			pattern, "");
-
-		for (addr=start,val=pattern; addr<end; addr++) {
-			*addr = val;
-			val  += incr;
-		}
-
-		puts ("Reading...");
-
-		for (addr=start,val=pattern; addr<end; addr++) {
-			readback = *addr;
-			if (readback != val) {
-				printf ("\nMem error @ 0x%08X: "
-					"found 0x%08lX, expected 0x%08lX\n",
-					(uint)addr, readback, val);
-				rcode = 1;
-			}
-			val += incr;
-		}
-
-		/*
-		 * Flip the pattern each time to make lots of zeros and
-		 * then, the next time, lots of ones.  We decrement
-		 * the "negative" patterns and increment the "positive"
-		 * patterns to preserve this feature.
-		 */
-		if(pattern & 0x80000000) {
-			pattern = -pattern;	/* complement & increment */
-		}
-		else {
-			pattern = ~pattern;
-		}
-		incr = -incr;
-	}
-	return rcode;
-}
-#endif
-
-static int do_mem_mtest(int argc, char *argv[])
-{
-	ulong start, end, pattern = 0;
-
-	if (argc < 3)
-		return COMMAND_ERROR_USAGE;
-
-	start = simple_strtoul(argv[1], NULL, 0);
-	end = simple_strtoul(argv[2], NULL, 0);
-
-	if (argc > 3)
-		pattern = simple_strtoul(argv[3], NULL, 0);
-
-	printf ("Testing 0x%08x ... 0x%08x:\n", (uint)start, (uint)end);
-	
-	return mem_test(start, end, pattern);
-}
-
-static const __maybe_unused char cmd_mtest_help[] =
-"Usage: <start> <end> "
-#ifdef CONFIG_CMD_MTEST_ALTERNATIVE
-"[pattern]"
-#endif
-"\nsimple RAM read/write test\n";
-
-BAREBOX_CMD_START(mtest)
-	.cmd		= do_mem_mtest,
-	.usage		= "simple RAM test",
-	BAREBOX_CMD_HELP(cmd_mtest_help)
-BAREBOX_CMD_END
-
-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 8/8] memtest: add rewritten memtest command
  2013-01-15 13:48 [PATCH v2 0/8] add new memtest command Alexander Aring
                   ` (6 preceding siblings ...)
  2013-01-15 13:48 ` [PATCH 7/8] memtest: remove memtest command Alexander Aring
@ 2013-01-15 13:48 ` Alexander Aring
  2013-01-17  9:54   ` Sascha Hauer
  7 siblings, 1 reply; 16+ messages in thread
From: Alexander Aring @ 2013-01-15 13:48 UTC (permalink / raw)
  To: barebox

Rewrite memtest command:
	- Skip barebox sdram regions.
	- Uncache unused mem regions while testing.
	- Add iteration parameter.
	- Add parameter to do only bus testing.
	- Check start and end addresses.
	- Testing all banks if no start and end
	  address are given.

	- Add sha changes (thanks):
	- fix calculation of regions to test. When we use PAGE_ALIGN on
	  size, size can be to high.
	  - start address has to be aligned up
	  - end address has to be aligned down
	  - then size can be calculated as end - start + 1
	- Add ctrlc() to the longer loops
	- Add a progress bar to give some visual feedback that something
	  issues
	  still going on.

	- Change to use end element instead of size in region struct.
	- Fix some newline issues.

	- Add '-c' parameter if CONFIG_MMU enabled
	  to test with enabled cache.
	- Fix some size calculation.
	- set start address to 0xffffffff

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 commands/Kconfig   |   9 +
 commands/Makefile  |   1 +
 commands/memtest.c | 698 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 708 insertions(+)
 create mode 100644 commands/memtest.c

diff --git a/commands/Kconfig b/commands/Kconfig
index fc0e448..f027a7e 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -496,6 +496,15 @@ config CMD_NANDTEST
 	select PARTITION_NEED_MTD
 	prompt "nandtest"
 
+config CMD_MEMTEST
+    tristate
+    prompt "memtest"
+	help
+	  This command enables a memtest to test installed memory.
+	  During this test allocated iomem regions will be skipped.
+	  If tested architecture has MMU with PTE flags support,
+	  caching can be set enabled or disabled.
+
 endmenu
 
 menu "video command"
diff --git a/commands/Makefile b/commands/Makefile
index 3145685..6b4d9cb 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_CMD_LOADY)		+= loadxy.o
 obj-$(CONFIG_CMD_LOADS)		+= loads.o
 obj-$(CONFIG_CMD_ECHO)		+= echo.o
 obj-$(CONFIG_CMD_MEMORY)	+= mem.o
+obj-$(CONFIG_CMD_MEMTEST)   += memtest.o
 obj-$(CONFIG_CMD_EDIT)		+= edit.o
 obj-$(CONFIG_CMD_EXEC)		+= exec.o
 obj-$(CONFIG_CMD_SLEEP)		+= sleep.o
diff --git a/commands/memtest.c b/commands/memtest.c
new file mode 100644
index 0000000..c31e553
--- /dev/null
+++ b/commands/memtest.c
@@ -0,0 +1,698 @@
+/*
+ * memtest - Perform a memory test
+ *
+ * (C) Copyright 2013
+ * Alexander Aring <a.aring@gmail.com>
+ *
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <types.h>
+#include <getopt.h>
+#include <memory.h>
+#include <errno.h>
+#include <progress.h>
+#include <asm/mmu.h>
+
+static const vu_long bitpattern[] = {
+	0x00000001,	/* single bit */
+	0x00000003,	/* two adjacent bits */
+	0x00000007,	/* three adjacent bits */
+	0x0000000F,	/* four adjacent bits */
+	0x00000005,	/* two non-adjacent bits */
+	0x00000015,	/* three non-adjacent bits */
+	0x00000055,	/* four non-adjacent bits */
+	0xAAAAAAAA,	/* alternating 1/0 */
+};
+
+/*
+ * In CONFIG_MMU we have a special c flag.
+ */
+#ifdef CONFIG_MMU
+static char optstr[] = "s:e:i:cb";
+
+/*
+ * PTE flags variables to set cached and
+ * uncached regions.
+ */
+static uint32_t PTE_FLAGS_CACHED;
+static uint32_t PTE_FLAGS_UNCACHED;
+#else
+static char optstr[] = "s:e:i:b";
+#endif
+
+/*
+ * Perform a memory test. The complete test
+ * loops until interrupted by ctrl-c.
+ */
+static int mem_test(vu_long _start, vu_long _end,
+		int bus_only)
+{
+	vu_long *start = (vu_long *)_start;
+	/* Point the dummy to start[1] */
+	vu_long *dummy = start+1;
+
+	vu_long val;
+	vu_long readback;
+	vu_long offset;
+	vu_long pattern;
+	vu_long test_offset;
+	vu_long temp;
+	vu_long anti_pattern;
+	vu_long num_words;
+
+	int i;
+	int ret;
+
+	if (!IS_ALIGNED(_end - _start + 1, sizeof(vu_long))) {
+		printf("Testing memarea size (0x%08lx) not a multiple"
+				"of size 0x%x, please change start or end address.",
+				_end - _start + 1, sizeof(vu_long));
+		return -1;
+	}
+
+	num_words = (_end - _start + 1)/sizeof(vu_long);
+
+	printf("Starting data line test.\n");
+
+	/*
+	 * Data line test: write a pattern to the first
+	 * location, write the 1's complement to a 'parking'
+	 * address (changes the state of the data bus so a
+	 * floating bus doen't give a false OK), and then
+	 * read the value back. Note that we read it back
+	 * into a variable because the next time we read it,
+	 * it might be right (been there, tough to explain to
+	 * the quality guys why it prints a failure when the
+	 * "is" and "should be" are obviously the same in the
+	 * error message).
+	 *
+	 * Rather than exhaustively testing, we test some
+	 * patterns by shifting '1' bits through a field of
+	 * '0's and '0' bits through a field of '1's (i.e.
+	 * pattern and ~pattern).
+	 */
+	for (i = 0; i < sizeof(bitpattern)/
+			sizeof(bitpattern[0]); i++) {
+		ret = address_in_sdram_regions((vu_long)start);
+		if (ret) {
+			printf("WARNING (data line): "
+					"address 0x%08lx is in sdram regions.\n"
+					"Will skip this memory address.\n",
+					(vu_long)start);
+			break;
+		}
+
+		ret = address_in_sdram_regions((vu_long)dummy);
+		if (ret) {
+			printf("WARNING (data line): "
+					"address 0x%08lx is in sdram regions.\n"
+					"Will skip this memory address.\n",
+					(vu_long)dummy);
+			break;
+		}
+
+		val = bitpattern[i];
+
+		for (; val != 0; val <<= 1) {
+			*start = val;
+			/* clear the test data off of the bus */
+			*dummy = ~val;
+			readback = *start;
+
+			if (readback != val) {
+				printf("FAILURE (data line): "
+					"expected 0x%08lx, actual 0x%08lx at address 0x%08lx.\n",
+					val, readback, (vu_long)start);
+				return -1;
+			}
+
+			*start = ~val;
+			*dummy = val;
+			readback = *start;
+			if (readback != ~val) {
+				printf("FAILURE (data line): "
+					"Is 0x%08lx, should be 0x%08lx at address 0x%08lx.\n",
+					readback,
+					~val, (vu_long)start);
+				return -1;
+			}
+		}
+	}
+
+
+	/*
+	 * Based on code whose Original Author and Copyright
+	 * information follows: Copyright (c) 1998 by Michael
+	 * Barr. This software is placed into the public
+	 * domain and may be used for any purpose. However,
+	 * this notice must not be changed or removed and no
+	 * warranty is either expressed or implied by its
+	 * publication or distribution.
+	 */
+
+	/*
+	 * Address line test
+	 *
+	 * Description: Test the address bus wiring in a
+	 *              memory region by performing a walking
+	 *              1's test on the relevant bits of the
+	 *              address and checking for aliasing.
+	 *              This test will find single-bit
+	 *              address failures such as stuck -high,
+	 *              stuck-low, and shorted pins. The base
+	 *              address and size of the region are
+	 *              selected by the caller.
+	 *
+	 * Notes:	For best results, the selected base
+	 *              address should have enough LSB 0's to
+	 *              guarantee single address bit changes.
+	 *              For example, to test a 64-Kbyte
+	 *              region, select a base address on a
+	 *              64-Kbyte boundary. Also, select the
+	 *              region size as a power-of-two if at
+	 *              all possible.
+	 *
+	 * ## NOTE ##	Be sure to specify start and end
+	 *              addresses such that num_words has
+	 *              lots of bits set. For example an
+	 *              address range of 01000000 02000000 is
+	 *              bad while a range of 01000000
+	 *              01ffffff is perfect.
+	 */
+
+	pattern = 0xAAAAAAAA;
+	anti_pattern = 0x55555555;
+
+	/*
+	 * Write the default pattern at each of the
+	 * power-of-two offsets.
+	 */
+	for (offset = 1; (offset & num_words) != 0; offset <<= 1) {
+		ret = address_in_sdram_regions((vu_long)&start[offset]);
+		if (ret) {
+			printf("WARNING (stuck high): "
+					"address 0x%08lx is in sdram regions.\n",
+					(vu_long)&start[offset]);
+			continue;
+		}
+
+		start[offset] = pattern;
+	}
+
+	printf("Check for address bits stuck high.\n");
+
+	/*
+	 * Check for address bits stuck high.
+	 */
+	test_offset = 0;
+
+	ret = address_in_sdram_regions((vu_long)&start[test_offset]);
+	if (ret)
+		printf("WARNING (stuck high): "
+				"address 0x%08lx is in sdram regions.\n",
+				(vu_long)&start[test_offset]);
+	else
+		start[test_offset] = anti_pattern;
+
+	for (offset = 1; (offset & num_words) != 0; offset <<= 1) {
+		ret = address_in_sdram_regions((vu_long)&start[offset]);
+		if (ret) {
+			printf("WARNING (stuck high): "
+					"address 0x%08lx is in sdram regions.\n",
+					(vu_long)&start[offset]);
+			continue;
+		}
+
+		temp = start[offset];
+
+		if (temp != pattern) {
+			printf("FAILURE: Address bit "
+					"stuck high @ 0x%08lx:"
+					" expected 0x%08lx, actual 0x%08lx.\n",
+					(vu_long)&start[offset],
+					pattern, temp);
+			return -1;
+		}
+	}
+
+	ret = address_in_sdram_regions((vu_long)&start[test_offset]);
+	if (ret)
+		printf("WARNING (stuck high): "
+				"address 0x%08lx is in sdram regions.\n",
+				(vu_long)&start[test_offset]);
+	else
+		start[test_offset] = pattern;
+
+	printf("Check for address bits stuck "
+			"low or shorted.");
+
+	/*
+	 * Check for address bits stuck low or shorted.
+	 */
+	for (test_offset = 1;
+			(test_offset & num_words) != 0;
+			test_offset <<= 1) {
+		ret = address_in_sdram_regions(
+				(vu_long)&start[test_offset]);
+		if (ret) {
+			printf("\nWARNING (low high): "
+					"address 0x%08lx is in barebox regions.\n",
+					(vu_long)&start[test_offset]);
+			continue;
+		}
+
+		start[test_offset] = anti_pattern;
+
+		for (offset = 1; (offset & num_words) != 0; offset <<= 1) {
+			ret = address_in_sdram_regions(
+					(vu_long)&start[offset]);
+			if (ret) {
+				printf("\nWARNING (low high): "
+					"address 0x%08lx is in barebox regions.\n",
+					(vu_long)&start[test_offset]);
+				continue;
+			}
+
+			temp = start[offset];
+
+			if ((temp != pattern) &&
+					(offset != test_offset)) {
+				printf("\nFAILURE: Address bit stuck"
+						" low or shorted @"
+						" 0x%08lx: expected 0x%08lx, actual 0x%08lx.\n",
+						(vu_long)&start[offset],
+						pattern, temp);
+				return -1;
+			}
+		}
+		start[test_offset] = pattern;
+	}
+
+	/* We tested only the bus if != 0
+	 * leaving here */
+	if (bus_only)
+		return 0;
+
+	printf("\nStarting integrity check of physicaly ram.\n"
+			"Filling ram with patterns...\n");
+
+	/*
+	 * Description: Test the integrity of a physical
+	 *		memory device by performing an
+	 *		increment/decrement test over the
+	 *		entire region. In the process every
+	 *		storage bit in the device is tested
+	 *		as a zero and a one. The base address
+	 *		and the size of the region are
+	 *		selected by the caller.
+	 */
+
+	/*
+	 * Fill memory with a known pattern.
+	 */
+	init_progression_bar(num_words);
+	for (offset = 0; offset < num_words; offset++) {
+		if (!(offset & 0xfff)) {
+			if (ctrlc())
+				return -EINTR;
+			show_progress(offset);
+		}
+
+		ret = address_in_sdram_regions((vu_long)&start[offset]);
+		if (ret)
+			continue;
+
+		start[offset] = offset + 1;
+	}
+
+	show_progress(offset);
+
+	printf("\nCompare written patterns...\n");
+
+	/*
+	 * Check each location and invert it for the second pass.
+	 */
+	init_progression_bar(num_words - 1);
+	for (offset = 0; offset < num_words; offset++) {
+		if (!(offset & 0xfff)) {
+			if (ctrlc())
+				return -EINTR;
+			show_progress(offset);
+		}
+
+		ret = address_in_sdram_regions((vu_long)&start[offset]);
+		if (ret)
+			continue;
+
+		temp = start[offset];
+		if (temp != (offset + 1)) {
+			printf("\nFAILURE (read/write) @ 0x%08lx:"
+					" expected 0x%08lx, actual 0x%08lx.\n",
+					(vu_long)&start[offset],
+					(offset + 1), temp);
+			return -1;
+		}
+
+		anti_pattern = ~(offset + 1);
+		start[offset] = anti_pattern;
+	}
+
+	show_progress(offset);
+
+	printf("\nFilling ram with inverted pattern and compare it...\n");
+
+	/*
+	 * Check each location for the inverted pattern and zero it.
+	 */
+	init_progression_bar(num_words - 1);
+	for (offset = 0; offset < num_words; offset++) {
+		if (!(offset & 0xfff)) {
+			if (ctrlc())
+				return -EINTR;
+			show_progress(offset);
+		}
+
+		ret = address_in_sdram_regions((vu_long)&start[offset]);
+		/* Step over barebox mem usage */
+		if (ret)
+			continue;
+
+		anti_pattern = ~(offset + 1);
+		temp = start[offset];
+
+		if (temp != anti_pattern) {
+			printf("\nFAILURE (read/write): @ 0x%08lx:"
+					" expected 0x%08lx, actual 0x%08lx.\n",
+					(vu_long)&start[offset],
+					anti_pattern, temp);
+			return -1;
+		}
+
+		start[offset] = 0;
+	}
+
+	show_progress(offset);
+
+	return 0;
+}
+
+#ifdef CONFIG_MMU
+static void print_region(vu_long start, vu_long size, uint32_t flags)
+{
+	if (!size)
+		return;
+
+	printf("\t0x%08lx - "
+			"0x%08lx (size 0x%08lx)\n",
+			start, start + size - 1, size);
+}
+
+static void do_remap_range(struct memory_bank *bank, uint32_t flags)
+{
+	struct resource *r = NULL;
+	struct resource *r_prev = NULL;
+
+	vu_long size;
+	vu_long start;
+	vu_long end;
+
+	if (flags == PTE_FLAGS_UNCACHED)
+		printf("Set non caching regions:\n");
+	else if (flags == PTE_FLAGS_CACHED)
+		printf("Set caching regions:\n");
+	else
+		BUG();
+
+	/* We assume that the regions are sorted in this list */
+	list_for_each_entry(r, &bank->res->children, sibling) {
+		/* Do on head element for bank boundary */
+		if (r->sibling.prev == &bank->res->children) {
+			/* remember last used element */
+			r_prev = r;
+
+			start = PAGE_ALIGN(bank->start);
+			end = PAGE_ALIGN_DOWN(r->start) - 1;
+			if (start >= end)
+				continue;
+			size = end - start + 1;
+
+			print_region(start, size, flags);
+			remap_range((void *)start, size, flags);
+
+			continue;
+		}
+		/* Between used regions */
+		start = PAGE_ALIGN(r_prev->end);
+		end = PAGE_ALIGN_DOWN(r->start) - 1;
+		if (start < end) {
+			size = end - start + 1;
+			print_region(start, size, flags);
+			remap_range((void *)start, size, flags);
+		}
+
+		r_prev = r;
+		/* Do on head element for bank boundary */
+		if (list_is_last(&r->sibling, &bank->res->children)) {
+			start = PAGE_ALIGN(r->end);
+			end = PAGE_ALIGN_DOWN(bank->start + bank->size) - 1;
+			if (start >= end)
+				continue;
+			size = end - start + 1;
+
+			print_region(start, size, flags);
+			remap_range((void *)start, size, flags);
+		}
+	}
+}
+#endif
+
+static int do_mem_memtest(int argc, char *argv[])
+{
+	/* Set start address to 0xffffffff which
+	 * can't be. */
+	vu_long start = 0xffffffff;
+	vu_long end = 0;
+
+	uint i;
+	uint max_i = 1;
+
+#ifdef CONFIG_MMU
+	int cache = 0;
+#endif
+	int bus_only = 0;
+	int err = 0;
+	int cnt = 0;
+	int opt;
+
+	struct memory_bank *bank = NULL;
+	struct resource *r = NULL;
+
+	while ((opt = getopt(argc, argv, optstr)) > 0) {
+		switch (opt) {
+		case 's':
+			start = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'e':
+			end = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'i':
+			max_i = simple_strtoul(optarg, NULL, 0);
+			break;
+#ifdef CONFIG_MMU
+		case 'c':
+			cache = 1;
+			break;
+#endif
+		case 'b':
+			bus_only = 1;
+			break;
+		default:
+			return COMMAND_ERROR_USAGE;
+		}
+	}
+
+	if (optind > argc)
+		return COMMAND_ERROR_USAGE;
+
+	/* Error if no end address */
+	if (start != 0xffffffff && !end) {
+		printf("Please add an end address.\n");
+		return 1;
+	}
+
+	/* Error if no start address */
+	if (end && start == 0xffffffff) {
+		printf("Please add a start address.\n");
+		return 1;
+	}
+
+	/* Check parameters */
+	if (start != 0xffffffff && end) {
+		if (end <= start) {
+			printf("End address less than or"
+					" equal start address.\n");
+			return 1;
+		}
+
+		/* Check if given start and end address are in any banks */
+		for_each_memory_bank(bank) {
+			if (ADDRESS_IN_REGIONS(start, bank->start,
+						bank->start + bank->size))
+				cnt++;
+
+			if (ADDRESS_IN_REGIONS(end, bank->start,
+						bank->start + bank->size))
+				cnt++;
+		}
+
+		if (cnt != 2) {
+			printf("Start or end addresses are"
+					" not in any ram bank.\n");
+			return 1;
+		}
+	}
+
+#ifdef CONFIG_MMU
+	/*
+	 * Get pte flags. Which are configured at
+	 * runtime at booting.
+	 */
+	PTE_FLAGS_CACHED = mmu_get_pte_cached_flags();
+	PTE_FLAGS_UNCACHED = mmu_get_pte_uncached_flags();
+#endif
+
+	printf("Skipping regions:\n");
+	for_each_memory_bank(bank) {
+		list_for_each_entry(r, &bank->res->children, sibling)
+			printf("\t0x%08x - "
+					"0x%08x (size 0x%08x) %s\n",
+					r->start, r->end,
+					r->end - r->start + 1, r->name);
+#ifdef CONFIG_MMU
+		/* Disable or enable caching */
+		if (cache)
+			do_remap_range(bank, PTE_FLAGS_CACHED);
+		else
+			do_remap_range(bank, PTE_FLAGS_UNCACHED);
+#endif
+	}
+
+	/* Do test if we set a start or end address */
+	if (start != 0xffffffff && end) {
+		printf("Testing address range:\n\t0x%08lx - 0x%08lx"
+				" (size 0x%08lx)\n",
+				start, end, end - start + 1);
+
+		for (i = 1; (i <= max_i) || !max_i; i++) {
+			printf("Iteration: %u\n", i);
+
+			/* Do the memtest */
+			err = mem_test(start, end, bus_only);
+			if (err == -EINTR) {
+				printf("\nTest interrupted.\n");
+				goto err;
+			}
+
+			if (err < 0) {
+				printf("\nTest failed.\n");
+				goto err;
+			}
+			printf("\nTested %u iteration(s) without errors.\n", i);
+		}
+#ifdef CONFIG_MMU
+		/* Renable caching */
+		if (!cache)
+			for_each_memory_bank(bank)
+				do_remap_range(bank, PTE_FLAGS_CACHED);
+#endif
+		printf("Memtest done.\n");
+
+		return 0;
+	}
+
+	/* If we set no start or end address
+	 * we do the test on all ram banks */
+	for (i = 1; (i <= max_i) || !max_i; i++) {
+		for_each_memory_bank(bank) {
+			start = bank->start;
+			end = bank->start + bank->size - 1;
+
+			printf("Iteration: %u\n", i);
+
+			printf("Testing address range:\n\t0x%08lx - "
+					"0x%08lx (size 0x%08lx) on bank /dev/%s\n",
+					start, end, bank->size,
+					bank->res->name);
+
+			err = mem_test(start, end, bus_only);
+			if (err == -EINTR) {
+				printf("\nTest interrupted.\n");
+				goto err;
+			}
+
+			if (err < 0) {
+				printf("\nTest on bank /dev/%s failed.\n",
+						bank->res->name);
+				goto err;
+			}
+			printf("\nTested %u iteration(s) without errors.\n", i);
+		}
+	}
+#ifdef CONFIG_MMU
+	/* Renable caching */
+	if (!cache)
+		for_each_memory_bank(bank)
+			do_remap_range(bank, PTE_FLAGS_CACHED);
+#endif
+	printf("Memtest done.\n");
+
+	return 0;
+
+err:
+#ifdef CONFIG_MMU
+	/* Enable caching */
+	for_each_memory_bank(bank)
+		do_remap_range(bank, PTE_FLAGS_CACHED);
+#endif
+
+	return 1;
+}
+
+static const __maybe_unused char cmd_memtest_help[] =
+"Usage: memtest [OPTION]...\n"
+"memtest related commands\n"
+"	-s	<start>		start address to begin memtest.\n"
+"	-e	<end>		end address to stop memtest.\n"
+"	-i	<iterations>	iterations [default=1, endless=0].\n"
+#ifdef CONFIG_MMU
+"	-c			run test with enable cache.\n"
+#endif
+"	-b			only test bus datalines.";
+
+BAREBOX_CMD_START(memtest)
+	.cmd		= do_mem_memtest,
+	.usage		= "Memory Test",
+	BAREBOX_CMD_HELP(cmd_memtest_help)
+BAREBOX_CMD_END
-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 8/8] memtest: add rewritten memtest command
  2013-01-15 13:48 ` [PATCH 8/8] memtest: add rewritten " Alexander Aring
@ 2013-01-17  9:54   ` Sascha Hauer
  2013-01-23 20:01     ` Alexander Aring
  0 siblings, 1 reply; 16+ messages in thread
From: Sascha Hauer @ 2013-01-17  9:54 UTC (permalink / raw)
  To: Alexander Aring; +Cc: barebox

On Tue, Jan 15, 2013 at 02:48:50PM +0100, Alexander Aring wrote:
> Rewrite memtest command:
> 	- Skip barebox sdram regions.
> 	- Uncache unused mem regions while testing.
> 	- Add iteration parameter.
> 	- Add parameter to do only bus testing.
> 	- Check start and end addresses.
> 	- Testing all banks if no start and end
> 	  address are given.
> 
> 	- Add sha changes (thanks):
> 	- fix calculation of regions to test. When we use PAGE_ALIGN on
> 	  size, size can be to high.
> 	  - start address has to be aligned up
> 	  - end address has to be aligned down
> 	  - then size can be calculated as end - start + 1
> 	- Add ctrlc() to the longer loops
> 	- Add a progress bar to give some visual feedback that something
> 	  issues
> 	  still going on.
> 
> 	- Change to use end element instead of size in region struct.
> 	- Fix some newline issues.
> 
> 	- Add '-c' parameter if CONFIG_MMU enabled
> 	  to test with enabled cache.
> 	- Fix some size calculation.
> 	- set start address to 0xffffffff
> 
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
>  commands/Kconfig   |   9 +
>  commands/Makefile  |   1 +
>  commands/memtest.c | 698 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 708 insertions(+)
>  create mode 100644 commands/memtest.c
> 
> diff --git a/commands/Kconfig b/commands/Kconfig
> index fc0e448..f027a7e 100644
> --- a/commands/Kconfig
> +++ b/commands/Kconfig
> @@ -496,6 +496,15 @@ config CMD_NANDTEST
>  	select PARTITION_NEED_MTD
>  	prompt "nandtest"
>  
> +config CMD_MEMTEST
> +    tristate
> +    prompt "memtest"
> +	help
> +	  This command enables a memtest to test installed memory.
> +	  During this test allocated iomem regions will be skipped.
> +	  If tested architecture has MMU with PTE flags support,
> +	  caching can be set enabled or disabled.
> +
>  endmenu
>  
>  menu "video command"
> diff --git a/commands/Makefile b/commands/Makefile
> index 3145685..6b4d9cb 100644
> --- a/commands/Makefile
> +++ b/commands/Makefile
> @@ -7,6 +7,7 @@ obj-$(CONFIG_CMD_LOADY)		+= loadxy.o
>  obj-$(CONFIG_CMD_LOADS)		+= loads.o
>  obj-$(CONFIG_CMD_ECHO)		+= echo.o
>  obj-$(CONFIG_CMD_MEMORY)	+= mem.o
> +obj-$(CONFIG_CMD_MEMTEST)   += memtest.o
>  obj-$(CONFIG_CMD_EDIT)		+= edit.o
>  obj-$(CONFIG_CMD_EXEC)		+= exec.o
>  obj-$(CONFIG_CMD_SLEEP)		+= sleep.o
> diff --git a/commands/memtest.c b/commands/memtest.c
> new file mode 100644
> index 0000000..c31e553
> --- /dev/null
> +++ b/commands/memtest.c
> @@ -0,0 +1,698 @@
> +/*
> + * memtest - Perform a memory test
> + *
> + * (C) Copyright 2013
> + * Alexander Aring <a.aring@gmail.com>
> + *
> + * (C) Copyright 2000
> + * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> + * MA 02111-1307 USA
> + */
> +
> +#include <common.h>
> +#include <command.h>
> +#include <types.h>
> +#include <getopt.h>
> +#include <memory.h>
> +#include <errno.h>
> +#include <progress.h>
> +#include <asm/mmu.h>
> +
> +static const vu_long bitpattern[] = {
> +	0x00000001,	/* single bit */
> +	0x00000003,	/* two adjacent bits */
> +	0x00000007,	/* three adjacent bits */
> +	0x0000000F,	/* four adjacent bits */
> +	0x00000005,	/* two non-adjacent bits */
> +	0x00000015,	/* three non-adjacent bits */
> +	0x00000055,	/* four non-adjacent bits */
> +	0xAAAAAAAA,	/* alternating 1/0 */
> +};
> +
> +/*
> + * In CONFIG_MMU we have a special c flag.
> + */
> +#ifdef CONFIG_MMU
> +static char optstr[] = "s:e:i:cb";
> +
> +/*
> + * PTE flags variables to set cached and
> + * uncached regions.
> + */
> +static uint32_t PTE_FLAGS_CACHED;
> +static uint32_t PTE_FLAGS_UNCACHED;

Please no uppercase letters for variable names.

> +#else
> +static char optstr[] = "s:e:i:b";
> +#endif
> +
> +/*
> + * Perform a memory test. The complete test
> + * loops until interrupted by ctrl-c.
> + */
> +static int mem_test(vu_long _start, vu_long _end,
> +		int bus_only)

It would be good to move this function to common/memory_test.c. This way
it could be called from C. Especially testing memory might be called
from some early small (no shell) development binaries which are running from some
internal SRAM.

> +{
> +	vu_long *start = (vu_long *)_start;
> +	/* Point the dummy to start[1] */
> +	vu_long *dummy = start+1;
> +
> +	vu_long val;
> +	vu_long readback;
> +	vu_long offset;
> +	vu_long pattern;
> +	vu_long test_offset;
> +	vu_long temp;
> +	vu_long anti_pattern;
> +	vu_long num_words;
> +
> +	int i;
> +	int ret;
> +
> +	if (!IS_ALIGNED(_end - _start + 1, sizeof(vu_long))) {
> +		printf("Testing memarea size (0x%08lx) not a multiple"
> +				"of size 0x%x, please change start or end address.",
> +				_end - _start + 1, sizeof(vu_long));
> +		return -1;
> +	}

I think this is both too restrictive and not restitrictive enough. How
about quietly aligning up the start to a multiple-of-4 boundary and the
end down to a multiple-of-4 boundary?

The above requires me to enter a address containing a lot of 'f's and it
will happily crash my system if I pass 0xa0000001 as start address.

> +
> +	num_words = (_end - _start + 1)/sizeof(vu_long);
> +
> +	printf("Starting data line test.\n");
> +
> +	/*
> +	 * Data line test: write a pattern to the first
> +	 * location, write the 1's complement to a 'parking'
> +	 * address (changes the state of the data bus so a
> +	 * floating bus doen't give a false OK), and then
> +	 * read the value back. Note that we read it back
> +	 * into a variable because the next time we read it,
> +	 * it might be right (been there, tough to explain to
> +	 * the quality guys why it prints a failure when the
> +	 * "is" and "should be" are obviously the same in the
> +	 * error message).
> +	 *
> +	 * Rather than exhaustively testing, we test some
> +	 * patterns by shifting '1' bits through a field of
> +	 * '0's and '0' bits through a field of '1's (i.e.
> +	 * pattern and ~pattern).
> +	 */
> +	for (i = 0; i < sizeof(bitpattern)/
> +			sizeof(bitpattern[0]); i++) {
> +		ret = address_in_sdram_regions((vu_long)start);

Can't you just call request_sdram_region at the beginning of this
function? Then you can be sure that you exclusivly own the region and do
not have to test for it on and on again here.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 8/8] memtest: add rewritten memtest command
  2013-01-17  9:54   ` Sascha Hauer
@ 2013-01-23 20:01     ` Alexander Aring
  2013-01-23 20:18       ` Sascha Hauer
  0 siblings, 1 reply; 16+ messages in thread
From: Alexander Aring @ 2013-01-23 20:01 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hi,

thank you for reviewing this patch.

On Thu, Jan 17, 2013 at 10:54:31AM +0100, Sascha Hauer wrote:
> On Tue, Jan 15, 2013 at 02:48:50PM +0100, Alexander Aring wrote:
> > Rewrite memtest command:
> > 	- Skip barebox sdram regions.
> > 	- Uncache unused mem regions while testing.
> > 	- Add iteration parameter.
> > 	- Add parameter to do only bus testing.
> > 	- Check start and end addresses.
> > 	- Testing all banks if no start and end
> > 	  address are given.
> > 
> > 	- Add sha changes (thanks):
> > 	- fix calculation of regions to test. When we use PAGE_ALIGN on
> > 	  size, size can be to high.
> > 	  - start address has to be aligned up
> > 	  - end address has to be aligned down
> > 	  - then size can be calculated as end - start + 1
> > 	- Add ctrlc() to the longer loops
> > 	- Add a progress bar to give some visual feedback that something
> > 	  issues
> > 	  still going on.
> > 
> > 	- Change to use end element instead of size in region struct.
> > 	- Fix some newline issues.
> > 
> > 	- Add '-c' parameter if CONFIG_MMU enabled
> > 	  to test with enabled cache.
> > 	- Fix some size calculation.
> > 	- set start address to 0xffffffff
> > 
> > Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> > ---
> >  commands/Kconfig   |   9 +
> >  commands/Makefile  |   1 +
> >  commands/memtest.c | 698 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 708 insertions(+)
> >  create mode 100644 commands/memtest.c
> > 
> > diff --git a/commands/Kconfig b/commands/Kconfig
> > index fc0e448..f027a7e 100644
> > --- a/commands/Kconfig
> > +++ b/commands/Kconfig
> > @@ -496,6 +496,15 @@ config CMD_NANDTEST
> >  	select PARTITION_NEED_MTD
> >  	prompt "nandtest"
> >  
> > +config CMD_MEMTEST
> > +    tristate
> > +    prompt "memtest"
> > +	help
> > +	  This command enables a memtest to test installed memory.
> > +	  During this test allocated iomem regions will be skipped.
> > +	  If tested architecture has MMU with PTE flags support,
> > +	  caching can be set enabled or disabled.
> > +
> >  endmenu
> >  
> >  menu "video command"
> > diff --git a/commands/Makefile b/commands/Makefile
> > index 3145685..6b4d9cb 100644
> > --- a/commands/Makefile
> > +++ b/commands/Makefile
> > @@ -7,6 +7,7 @@ obj-$(CONFIG_CMD_LOADY)		+= loadxy.o
> >  obj-$(CONFIG_CMD_LOADS)		+= loads.o
> >  obj-$(CONFIG_CMD_ECHO)		+= echo.o
> >  obj-$(CONFIG_CMD_MEMORY)	+= mem.o
> > +obj-$(CONFIG_CMD_MEMTEST)   += memtest.o
> >  obj-$(CONFIG_CMD_EDIT)		+= edit.o
> >  obj-$(CONFIG_CMD_EXEC)		+= exec.o
> >  obj-$(CONFIG_CMD_SLEEP)		+= sleep.o
> > diff --git a/commands/memtest.c b/commands/memtest.c
> > new file mode 100644
> > index 0000000..c31e553
> > --- /dev/null
> > +++ b/commands/memtest.c
> > @@ -0,0 +1,698 @@
> > +/*
> > + * memtest - Perform a memory test
> > + *
> > + * (C) Copyright 2013
> > + * Alexander Aring <a.aring@gmail.com>
> > + *
> > + * (C) Copyright 2000
> > + * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
> > + *
> > + * See file CREDITS for list of people who contributed to this
> > + * project.
> > + *
> > + * This program is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU General Public License as
> > + * published by the Free Software Foundation; either version 2 of
> > + * the License, or (at your option) any later version.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU General Public License
> > + * along with this program; if not, write to the Free Software
> > + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> > + * MA 02111-1307 USA
> > + */
> > +
> > +#include <common.h>
> > +#include <command.h>
> > +#include <types.h>
> > +#include <getopt.h>
> > +#include <memory.h>
> > +#include <errno.h>
> > +#include <progress.h>
> > +#include <asm/mmu.h>
> > +
> > +static const vu_long bitpattern[] = {
> > +	0x00000001,	/* single bit */
> > +	0x00000003,	/* two adjacent bits */
> > +	0x00000007,	/* three adjacent bits */
> > +	0x0000000F,	/* four adjacent bits */
> > +	0x00000005,	/* two non-adjacent bits */
> > +	0x00000015,	/* three non-adjacent bits */
> > +	0x00000055,	/* four non-adjacent bits */
> > +	0xAAAAAAAA,	/* alternating 1/0 */
> > +};
> > +
> > +/*
> > + * In CONFIG_MMU we have a special c flag.
> > + */
> > +#ifdef CONFIG_MMU
> > +static char optstr[] = "s:e:i:cb";
> > +
> > +/*
> > + * PTE flags variables to set cached and
> > + * uncached regions.
> > + */
> > +static uint32_t PTE_FLAGS_CACHED;
> > +static uint32_t PTE_FLAGS_UNCACHED;
> 
> Please no uppercase letters for variable names.
>
Ok. I took it from mach/arm/cpu/mmu.c, should I create a patch which
rename it in arch/arm/cpu/mmu.c lower case, too?

> > +#else
> > +static char optstr[] = "s:e:i:b";
> > +#endif
> > +
> > +/*
> > + * Perform a memory test. The complete test
> > + * loops until interrupted by ctrl-c.
> > + */
> > +static int mem_test(vu_long _start, vu_long _end,
> > +		int bus_only)
> 
> It would be good to move this function to common/memory_test.c. This way
> it could be called from C. Especially testing memory might be called
> from some early small (no shell) development binaries which are running from some
> internal SRAM.
> 
Ok.
Maybe we can do a menu entry via Kconfig or something else to run a
memtest after booting automatically.

> > +{
> > +	vu_long *start = (vu_long *)_start;
> > +	/* Point the dummy to start[1] */
> > +	vu_long *dummy = start+1;
> > +
> > +	vu_long val;
> > +	vu_long readback;
> > +	vu_long offset;
> > +	vu_long pattern;
> > +	vu_long test_offset;
> > +	vu_long temp;
> > +	vu_long anti_pattern;
> > +	vu_long num_words;
> > +
> > +	int i;
> > +	int ret;
> > +
> > +	if (!IS_ALIGNED(_end - _start + 1, sizeof(vu_long))) {
> > +		printf("Testing memarea size (0x%08lx) not a multiple"
> > +				"of size 0x%x, please change start or end address.",
> > +				_end - _start + 1, sizeof(vu_long));
> > +		return -1;
> > +	}
> 
> I think this is both too restrictive and not restitrictive enough. How
> about quietly aligning up the start to a multiple-of-4 boundary and the
> end down to a multiple-of-4 boundary?
Ok, I change it to do a align.

> 
> The above requires me to enter a address containing a lot of 'f's and it
> will happily crash my system if I pass 0xa0000001 as start address.
> 
> > +
> > +	num_words = (_end - _start + 1)/sizeof(vu_long);
> > +
> > +	printf("Starting data line test.\n");
> > +
> > +	/*
> > +	 * Data line test: write a pattern to the first
> > +	 * location, write the 1's complement to a 'parking'
> > +	 * address (changes the state of the data bus so a
> > +	 * floating bus doen't give a false OK), and then
> > +	 * read the value back. Note that we read it back
> > +	 * into a variable because the next time we read it,
> > +	 * it might be right (been there, tough to explain to
> > +	 * the quality guys why it prints a failure when the
> > +	 * "is" and "should be" are obviously the same in the
> > +	 * error message).
> > +	 *
> > +	 * Rather than exhaustively testing, we test some
> > +	 * patterns by shifting '1' bits through a field of
> > +	 * '0's and '0' bits through a field of '1's (i.e.
> > +	 * pattern and ~pattern).
> > +	 */
> > +	for (i = 0; i < sizeof(bitpattern)/
> > +			sizeof(bitpattern[0]); i++) {
> > +		ret = address_in_sdram_regions((vu_long)start);
> 
> Can't you just call request_sdram_region at the beginning of this
> function? Then you can be sure that you exclusivly own the region and do
> not have to test for it on and on again here.
Ok, sure I didn't see that.

> 
> Sascha
> 
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 8/8] memtest: add rewritten memtest command
  2013-01-23 20:01     ` Alexander Aring
@ 2013-01-23 20:18       ` Sascha Hauer
  2013-01-23 20:25         ` Alexander Aring
  0 siblings, 1 reply; 16+ messages in thread
From: Sascha Hauer @ 2013-01-23 20:18 UTC (permalink / raw)
  To: Alexander Aring; +Cc: barebox

Hi Alexander,

On Wed, Jan 23, 2013 at 09:01:36PM +0100, Alexander Aring wrote:
> > > +/*
> > > + * PTE flags variables to set cached and
> > > + * uncached regions.
> > > + */
> > > +static uint32_t PTE_FLAGS_CACHED;
> > > +static uint32_t PTE_FLAGS_UNCACHED;
> > 
> > Please no uppercase letters for variable names.
> >
> Ok. I took it from mach/arm/cpu/mmu.c, should I create a patch which
> rename it in arch/arm/cpu/mmu.c lower case, too?

Yes, that would be great. I must have forgotten reviewing my own patch
;)

> 
> > > +#else
> > > +static char optstr[] = "s:e:i:b";
> > > +#endif
> > > +
> > > +/*
> > > + * Perform a memory test. The complete test
> > > + * loops until interrupted by ctrl-c.
> > > + */
> > > +static int mem_test(vu_long _start, vu_long _end,
> > > +		int bus_only)
> > 
> > It would be good to move this function to common/memory_test.c. This way
> > it could be called from C. Especially testing memory might be called
> > from some early small (no shell) development binaries which are running from some
> > internal SRAM.
> > 
> Ok.
> Maybe we can do a menu entry via Kconfig or something else to run a
> memtest after booting automatically.

Maybe this could be added as an init script in the environment, but
personally I don't think I'll run it by default on our boards. We are
more into booting fast.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 8/8] memtest: add rewritten memtest command
  2013-01-23 20:18       ` Sascha Hauer
@ 2013-01-23 20:25         ` Alexander Aring
  2013-01-23 20:30           ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 16+ messages in thread
From: Alexander Aring @ 2013-01-23 20:25 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hi Sascha,

On Wed, Jan 23, 2013 at 09:18:44PM +0100, Sascha Hauer wrote:
> Hi Alexander,
> 
> On Wed, Jan 23, 2013 at 09:01:36PM +0100, Alexander Aring wrote:
> > > > +/*
> > > > + * PTE flags variables to set cached and
> > > > + * uncached regions.
> > > > + */
> > > > +static uint32_t PTE_FLAGS_CACHED;
> > > > +static uint32_t PTE_FLAGS_UNCACHED;
> > > 
> > > Please no uppercase letters for variable names.
> > >
> > Ok. I took it from mach/arm/cpu/mmu.c, should I create a patch which
> > rename it in arch/arm/cpu/mmu.c lower case, too?
> 
> Yes, that would be great. I must have forgotten reviewing my own patch
> ;)
> 
> > 
> > > > +#else
> > > > +static char optstr[] = "s:e:i:b";
> > > > +#endif
> > > > +
> > > > +/*
> > > > + * Perform a memory test. The complete test
> > > > + * loops until interrupted by ctrl-c.
> > > > + */
> > > > +static int mem_test(vu_long _start, vu_long _end,
> > > > +		int bus_only)
> > > 
> > > It would be good to move this function to common/memory_test.c. This way
> > > it could be called from C. Especially testing memory might be called
> > > from some early small (no shell) development binaries which are running from some
> > > internal SRAM.
> > > 
> > Ok.
> > Maybe we can do a menu entry via Kconfig or something else to run a
> > memtest after booting automatically.
> 
> Maybe this could be added as an init script in the environment, but
> personally I don't think I'll run it by default on our boards. We are
> more into booting fast.
But how will you run the memtest command in a (no shell) environment? :)

> 
> Sascha
> 
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 8/8] memtest: add rewritten memtest command
  2013-01-23 20:25         ` Alexander Aring
@ 2013-01-23 20:30           ` Jean-Christophe PLAGNIOL-VILLARD
  2013-01-23 20:43             ` Alexander Aring
  0 siblings, 1 reply; 16+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-01-23 20:30 UTC (permalink / raw)
  To: Alexander Aring; +Cc: barebox

On 21:25 Wed 23 Jan     , Alexander Aring wrote:
> Hi Sascha,
> 
> On Wed, Jan 23, 2013 at 09:18:44PM +0100, Sascha Hauer wrote:
> > Hi Alexander,
> > 
> > On Wed, Jan 23, 2013 at 09:01:36PM +0100, Alexander Aring wrote:
> > > > > +/*
> > > > > + * PTE flags variables to set cached and
> > > > > + * uncached regions.
> > > > > + */
> > > > > +static uint32_t PTE_FLAGS_CACHED;
> > > > > +static uint32_t PTE_FLAGS_UNCACHED;
> > > > 
> > > > Please no uppercase letters for variable names.
> > > >
> > > Ok. I took it from mach/arm/cpu/mmu.c, should I create a patch which
> > > rename it in arch/arm/cpu/mmu.c lower case, too?
> > 
> > Yes, that would be great. I must have forgotten reviewing my own patch
> > ;)
> > 
> > > 
> > > > > +#else
> > > > > +static char optstr[] = "s:e:i:b";
> > > > > +#endif
> > > > > +
> > > > > +/*
> > > > > + * Perform a memory test. The complete test
> > > > > + * loops until interrupted by ctrl-c.
> > > > > + */
> > > > > +static int mem_test(vu_long _start, vu_long _end,
> > > > > +		int bus_only)
> > > > 
> > > > It would be good to move this function to common/memory_test.c. This way
> > > > it could be called from C. Especially testing memory might be called
> > > > from some early small (no shell) development binaries which are running from some
> > > > internal SRAM.
> > > > 
> > > Ok.
> > > Maybe we can do a menu entry via Kconfig or something else to run a
> > > memtest after booting automatically.
> > 
> > Maybe this could be added as an init script in the environment, but
> > personally I don't think I'll run it by default on our boards. We are
> > more into booting fast.
> But how will you run the memtest command in a (no shell) environment? :)
make as an option but this will be board specific

I do not want it by default too

booting time are critical for a lost of client

Best Regards,
J.
> 
> > 
> > Sascha
> > 
> > -- 
> > Pengutronix e.K.                           |                             |
> > Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> > Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> > Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 8/8] memtest: add rewritten memtest command
  2013-01-23 20:30           ` Jean-Christophe PLAGNIOL-VILLARD
@ 2013-01-23 20:43             ` Alexander Aring
  2013-01-23 20:55               ` Sascha Hauer
  0 siblings, 1 reply; 16+ messages in thread
From: Alexander Aring @ 2013-01-23 20:43 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Wed, Jan 23, 2013 at 09:30:51PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 21:25 Wed 23 Jan     , Alexander Aring wrote:
> > Hi Sascha,
> > 
> > On Wed, Jan 23, 2013 at 09:18:44PM +0100, Sascha Hauer wrote:
> > > Hi Alexander,
> > > 
> > > On Wed, Jan 23, 2013 at 09:01:36PM +0100, Alexander Aring wrote:
> > > > > > +/*
> > > > > > + * PTE flags variables to set cached and
> > > > > > + * uncached regions.
> > > > > > + */
> > > > > > +static uint32_t PTE_FLAGS_CACHED;
> > > > > > +static uint32_t PTE_FLAGS_UNCACHED;
> > > > > 
> > > > > Please no uppercase letters for variable names.
> > > > >
> > > > Ok. I took it from mach/arm/cpu/mmu.c, should I create a patch which
> > > > rename it in arch/arm/cpu/mmu.c lower case, too?
> > > 
> > > Yes, that would be great. I must have forgotten reviewing my own patch
> > > ;)
> > > 
> > > > 
> > > > > > +#else
> > > > > > +static char optstr[] = "s:e:i:b";
> > > > > > +#endif
> > > > > > +
> > > > > > +/*
> > > > > > + * Perform a memory test. The complete test
> > > > > > + * loops until interrupted by ctrl-c.
> > > > > > + */
> > > > > > +static int mem_test(vu_long _start, vu_long _end,
> > > > > > +		int bus_only)
> > > > > 
> > > > > It would be good to move this function to common/memory_test.c. This way
> > > > > it could be called from C. Especially testing memory might be called
> > > > > from some early small (no shell) development binaries which are running from some
> > > > > internal SRAM.
> > > > > 
> > > > Ok.
> > > > Maybe we can do a menu entry via Kconfig or something else to run a
> > > > memtest after booting automatically.
> > > 
> > > Maybe this could be added as an init script in the environment, but
> > > personally I don't think I'll run it by default on our boards. We are
> > > more into booting fast.
> > But how will you run the memtest command in a (no shell) environment? :)
> make as an option but this will be board specific
> 
> I do not want it by default too
> 
> booting time are critical for a lost of client
> 
> Best Regards,
> J.
Ok, hold on.
We want this to move it in common/memory_test.c to call memtest in a
(no shell) environment for a small barebox which running in the internal
sram(like omap MLO), not in the connected "ram".

This can be useful to test the complete "connected ram" without allocated
barebox regions.

But to do this in a (no shell) environment, somebody need to modify some
code to call memtest at barebox boot. Or?

Regards
Alex
> > 
> > > 
> > > Sascha
> > > 
> > > -- 
> > > Pengutronix e.K.                           |                             |
> > > Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> > > Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> > > Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
> > 
> > _______________________________________________
> > barebox mailing list
> > barebox@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 8/8] memtest: add rewritten memtest command
  2013-01-23 20:43             ` Alexander Aring
@ 2013-01-23 20:55               ` Sascha Hauer
  0 siblings, 0 replies; 16+ messages in thread
From: Sascha Hauer @ 2013-01-23 20:55 UTC (permalink / raw)
  To: Alexander Aring; +Cc: barebox

On Wed, Jan 23, 2013 at 09:43:19PM +0100, Alexander Aring wrote:
> On Wed, Jan 23, 2013 at 09:30:51PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 21:25 Wed 23 Jan     , Alexander Aring wrote:
> > > Hi Sascha,
> > > 
> > > On Wed, Jan 23, 2013 at 09:18:44PM +0100, Sascha Hauer wrote:
> > > > Hi Alexander,
> > > > 
> > > > On Wed, Jan 23, 2013 at 09:01:36PM +0100, Alexander Aring wrote:
> > > > > > > +/*
> > > > > > > + * PTE flags variables to set cached and
> > > > > > > + * uncached regions.
> > > > > > > + */
> > > > > > > +static uint32_t PTE_FLAGS_CACHED;
> > > > > > > +static uint32_t PTE_FLAGS_UNCACHED;
> > > > > > 
> > > > > > Please no uppercase letters for variable names.
> > > > > >
> > > > > Ok. I took it from mach/arm/cpu/mmu.c, should I create a patch which
> > > > > rename it in arch/arm/cpu/mmu.c lower case, too?
> > > > 
> > > > Yes, that would be great. I must have forgotten reviewing my own patch
> > > > ;)
> > > > 
> > > > > 
> > > > > > > +#else
> > > > > > > +static char optstr[] = "s:e:i:b";
> > > > > > > +#endif
> > > > > > > +
> > > > > > > +/*
> > > > > > > + * Perform a memory test. The complete test
> > > > > > > + * loops until interrupted by ctrl-c.
> > > > > > > + */
> > > > > > > +static int mem_test(vu_long _start, vu_long _end,
> > > > > > > +		int bus_only)
> > > > > > 
> > > > > > It would be good to move this function to common/memory_test.c. This way
> > > > > > it could be called from C. Especially testing memory might be called
> > > > > > from some early small (no shell) development binaries which are running from some
> > > > > > internal SRAM.
> > > > > > 
> > > > > Ok.
> > > > > Maybe we can do a menu entry via Kconfig or something else to run a
> > > > > memtest after booting automatically.
> > > > 
> > > > Maybe this could be added as an init script in the environment, but
> > > > personally I don't think I'll run it by default on our boards. We are
> > > > more into booting fast.
> > > But how will you run the memtest command in a (no shell) environment? :)
> > make as an option but this will be board specific
> > 
> > I do not want it by default too
> > 
> > booting time are critical for a lost of client
> > 
> > Best Regards,
> > J.
> Ok, hold on.
> We want this to move it in common/memory_test.c to call memtest in a
> (no shell) environment for a small barebox which running in the internal
> sram(like omap MLO), not in the connected "ram".
> 
> This can be useful to test the complete "connected ram" without allocated
> barebox regions.
> 
> But to do this in a (no shell) environment, somebody need to modify some
> code to call memtest at barebox boot. Or?

Yes, he would have to modify code. I assumed that he is in the middle of
bootstrapping a new board, so he will be writing code anyway. If that
assumption is wrong such an option might indeed be useful.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2013-01-23 20:56 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-15 13:48 [PATCH v2 0/8] add new memtest command Alexander Aring
2013-01-15 13:48 ` [PATCH 1/8] remap_range: make function 'remap_range' global Alexander Aring
2013-01-15 13:48 ` [PATCH 2/8] mmu: add getters for pte cache flags Alexander Aring
2013-01-15 13:48 ` [PATCH 3/8] arm-mmu: move PAGE_ALIGN macro to common.h Alexander Aring
2013-01-15 13:48 ` [PATCH 4/8] common: add PAGE_ALIGN_DOWN macro Alexander Aring
2013-01-15 13:48 ` [PATCH 5/8] memory: add function address_in_sdram_regions Alexander Aring
2013-01-15 13:48 ` [PATCH 6/8] barebox-data: add barebox-data sections Alexander Aring
2013-01-15 13:48 ` [PATCH 7/8] memtest: remove memtest command Alexander Aring
2013-01-15 13:48 ` [PATCH 8/8] memtest: add rewritten " Alexander Aring
2013-01-17  9:54   ` Sascha Hauer
2013-01-23 20:01     ` Alexander Aring
2013-01-23 20:18       ` Sascha Hauer
2013-01-23 20:25         ` Alexander Aring
2013-01-23 20:30           ` Jean-Christophe PLAGNIOL-VILLARD
2013-01-23 20:43             ` Alexander Aring
2013-01-23 20:55               ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox