aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/mm/testmmiotrace.c
diff options
context:
space:
mode:
authorPekka Paalanen <pq@iki.fi>2009-03-01 09:10:08 -0500
committerIngo Molnar <mingo@elte.hu>2009-03-02 04:20:35 -0500
commit5ff93697fcfe1e2b9e61db82961d8f50d1ad5d57 (patch)
tree01d1196d6ec90a96a0fdeb41997ab7a1c0ebfdfb /arch/x86/mm/testmmiotrace.c
parentfab852aaf761a00cfe16330429b7cac15cceaeb9 (diff)
x86: add far read test to testmmiotrace
Apparently pages far into an ioremapped region might not actually be mapped during ioremap(). Add an optional read test to try to trigger a multiply faulting MMIO access. Also add more messages to the kernel log to help debugging. This patch is based on a patch suggested by Stuart Bennett <stuart@freedesktop.org> who discovered bugs in mmiotrace related to normal kernel space faults. 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.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/arch/x86/mm/testmmiotrace.c b/arch/x86/mm/testmmiotrace.c
index 4b29f3b0ee01..427fd1b56df5 100644
--- a/arch/x86/mm/testmmiotrace.c
+++ b/arch/x86/mm/testmmiotrace.c
@@ -9,7 +9,13 @@
9 9
10static unsigned long mmio_address; 10static unsigned long mmio_address;
11module_param(mmio_address, ulong, 0); 11module_param(mmio_address, ulong, 0);
12MODULE_PARM_DESC(mmio_address, "Start address of the mapping of 16 kB."); 12MODULE_PARM_DESC(mmio_address, " Start address of the mapping of 16 kB "
13 "(or 8 MB if read_far is non-zero).");
14
15static unsigned long read_far = 0x400100;
16module_param(read_far, ulong, 0);
17MODULE_PARM_DESC(read_far, " Offset of a 32-bit read within 8 MB "
18 "(default: 0x400100).");
13 19
14static unsigned v16(unsigned i) 20static unsigned v16(unsigned i)
15{ 21{
@@ -24,6 +30,7 @@ static unsigned v32(unsigned i)
24static void do_write_test(void __iomem *p) 30static void do_write_test(void __iomem *p)
25{ 31{
26 unsigned int i; 32 unsigned int i;
33 pr_info(MODULE_NAME ": write test.\n");
27 mmiotrace_printk("Write test.\n"); 34 mmiotrace_printk("Write test.\n");
28 35
29 for (i = 0; i < 256; i++) 36 for (i = 0; i < 256; i++)
@@ -40,6 +47,7 @@ static void do_read_test(void __iomem *p)
40{ 47{
41 unsigned int i; 48 unsigned int i;
42 unsigned errs[3] = { 0 }; 49 unsigned errs[3] = { 0 };
50 pr_info(MODULE_NAME ": read test.\n");
43 mmiotrace_printk("Read test.\n"); 51 mmiotrace_printk("Read test.\n");
44 52
45 for (i = 0; i < 256; i++) 53 for (i = 0; i < 256; i++)
@@ -58,9 +66,17 @@ static void do_read_test(void __iomem *p)
58 errs[0], errs[1], errs[2]); 66 errs[0], errs[1], errs[2]);
59} 67}
60 68
61static void do_test(void) 69static void do_read_far_test(void __iomem *p)
70{
71 pr_info(MODULE_NAME ": read far test.\n");
72 mmiotrace_printk("Read far test.\n");
73
74 ioread32(p + read_far);
75}
76
77static void do_test(unsigned long size)
62{ 78{
63 void __iomem *p = ioremap_nocache(mmio_address, 0x4000); 79 void __iomem *p = ioremap_nocache(mmio_address, size);
64 if (!p) { 80 if (!p) {
65 pr_err(MODULE_NAME ": could not ioremap, aborting.\n"); 81 pr_err(MODULE_NAME ": could not ioremap, aborting.\n");
66 return; 82 return;
@@ -68,11 +84,15 @@ static void do_test(void)
68 mmiotrace_printk("ioremap returned %p.\n", p); 84 mmiotrace_printk("ioremap returned %p.\n", p);
69 do_write_test(p); 85 do_write_test(p);
70 do_read_test(p); 86 do_read_test(p);
87 if (read_far && read_far < size - 4)
88 do_read_far_test(p);
71 iounmap(p); 89 iounmap(p);
72} 90}
73 91
74static int __init init(void) 92static int __init init(void)
75{ 93{
94 unsigned long size = (read_far) ? (8 << 20) : (16 << 10);
95
76 if (mmio_address == 0) { 96 if (mmio_address == 0) {
77 pr_err(MODULE_NAME ": you have to use the module argument " 97 pr_err(MODULE_NAME ": you have to use the module argument "
78 "mmio_address.\n"); 98 "mmio_address.\n");
@@ -81,10 +101,11 @@ static int __init init(void)
81 return -ENXIO; 101 return -ENXIO;
82 } 102 }
83 103
84 pr_warning(MODULE_NAME ": WARNING: mapping 16 kB @ 0x%08lx " 104 pr_warning(MODULE_NAME ": WARNING: mapping %lu kB @ 0x%08lx in PCI "
85 "in PCI address space, and writing " 105 "address space, and writing 16 kB of rubbish in there.\n",
86 "rubbish in there.\n", mmio_address); 106 size >> 10, mmio_address);
87 do_test(); 107 do_test(size);
108 pr_info(MODULE_NAME ": All done.\n");
88 return 0; 109 return 0;
89} 110}
90 111