diff options
author | Pekka Paalanen <pq@iki.fi> | 2009-03-01 09:09:14 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-03-02 04:20:34 -0500 |
commit | fab852aaf761a00cfe16330429b7cac15cceaeb9 (patch) | |
tree | 70ac624be9143b03fc5f8632fee437999e3f78bf /arch/x86/mm/testmmiotrace.c | |
parent | 778ef1e6cbb049c9bcbf405936ee6f2b6e451892 (diff) |
x86: count errors in testmmiotrace.ko
Check the read values against the written values in the MMIO read/write
test. This test shows if the given MMIO test area really works as
memory, which is a prerequisite for a successful mmiotrace test.
Signed-off-by: Pekka Paalanen <pq@iki.fi>
Cc: Stuart Bennett <stuart@freedesktop.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/mm/testmmiotrace.c')
-rw-r--r-- | arch/x86/mm/testmmiotrace.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/arch/x86/mm/testmmiotrace.c b/arch/x86/mm/testmmiotrace.c index ab50a8d7402c..4b29f3b0ee01 100644 --- a/arch/x86/mm/testmmiotrace.c +++ b/arch/x86/mm/testmmiotrace.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Written by Pekka Paalanen, 2008 <pq@iki.fi> | 2 | * Written by Pekka Paalanen, 2008-2009 <pq@iki.fi> |
3 | */ | 3 | */ |
4 | #include <linux/module.h> | 4 | #include <linux/module.h> |
5 | #include <linux/io.h> | 5 | #include <linux/io.h> |
@@ -11,28 +11,51 @@ static unsigned long mmio_address; | |||
11 | module_param(mmio_address, ulong, 0); | 11 | module_param(mmio_address, ulong, 0); |
12 | MODULE_PARM_DESC(mmio_address, "Start address of the mapping of 16 kB."); | 12 | MODULE_PARM_DESC(mmio_address, "Start address of the mapping of 16 kB."); |
13 | 13 | ||
14 | static unsigned v16(unsigned i) | ||
15 | { | ||
16 | return i * 12 + 7; | ||
17 | } | ||
18 | |||
19 | static unsigned v32(unsigned i) | ||
20 | { | ||
21 | return i * 212371 + 13; | ||
22 | } | ||
23 | |||
14 | static void do_write_test(void __iomem *p) | 24 | static void do_write_test(void __iomem *p) |
15 | { | 25 | { |
16 | unsigned int i; | 26 | unsigned int i; |
17 | mmiotrace_printk("Write test.\n"); | 27 | mmiotrace_printk("Write test.\n"); |
28 | |||
18 | for (i = 0; i < 256; i++) | 29 | for (i = 0; i < 256; i++) |
19 | iowrite8(i, p + i); | 30 | iowrite8(i, p + i); |
31 | |||
20 | for (i = 1024; i < (5 * 1024); i += 2) | 32 | for (i = 1024; i < (5 * 1024); i += 2) |
21 | iowrite16(i * 12 + 7, p + i); | 33 | iowrite16(v16(i), p + i); |
34 | |||
22 | for (i = (5 * 1024); i < (16 * 1024); i += 4) | 35 | for (i = (5 * 1024); i < (16 * 1024); i += 4) |
23 | iowrite32(i * 212371 + 13, p + i); | 36 | iowrite32(v32(i), p + i); |
24 | } | 37 | } |
25 | 38 | ||
26 | static void do_read_test(void __iomem *p) | 39 | static void do_read_test(void __iomem *p) |
27 | { | 40 | { |
28 | unsigned int i; | 41 | unsigned int i; |
42 | unsigned errs[3] = { 0 }; | ||
29 | mmiotrace_printk("Read test.\n"); | 43 | mmiotrace_printk("Read test.\n"); |
44 | |||
30 | for (i = 0; i < 256; i++) | 45 | for (i = 0; i < 256; i++) |
31 | ioread8(p + i); | 46 | if (ioread8(p + i) != i) |
47 | ++errs[0]; | ||
48 | |||
32 | for (i = 1024; i < (5 * 1024); i += 2) | 49 | for (i = 1024; i < (5 * 1024); i += 2) |
33 | ioread16(p + i); | 50 | if (ioread16(p + i) != v16(i)) |
51 | ++errs[1]; | ||
52 | |||
34 | for (i = (5 * 1024); i < (16 * 1024); i += 4) | 53 | for (i = (5 * 1024); i < (16 * 1024); i += 4) |
35 | ioread32(p + i); | 54 | if (ioread32(p + i) != v32(i)) |
55 | ++errs[2]; | ||
56 | |||
57 | mmiotrace_printk("Read errors: 8-bit %d, 16-bit %d, 32-bit %d.\n", | ||
58 | errs[0], errs[1], errs[2]); | ||
36 | } | 59 | } |
37 | 60 | ||
38 | static void do_test(void) | 61 | static void do_test(void) |