Commit 5ff93697 authored by Pekka Paalanen's avatar Pekka Paalanen Committed by Ingo Molnar

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: default avatarPekka Paalanen <pq@iki.fi>
Cc: Stuart Bennett <stuart@freedesktop.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent fab852aa
...@@ -9,7 +9,13 @@ ...@@ -9,7 +9,13 @@
static unsigned long mmio_address; static unsigned long mmio_address;
module_param(mmio_address, ulong, 0); module_param(mmio_address, ulong, 0);
MODULE_PARM_DESC(mmio_address, "Start address of the mapping of 16 kB."); MODULE_PARM_DESC(mmio_address, " Start address of the mapping of 16 kB "
"(or 8 MB if read_far is non-zero).");
static unsigned long read_far = 0x400100;
module_param(read_far, ulong, 0);
MODULE_PARM_DESC(read_far, " Offset of a 32-bit read within 8 MB "
"(default: 0x400100).");
static unsigned v16(unsigned i) static unsigned v16(unsigned i)
{ {
...@@ -24,6 +30,7 @@ static unsigned v32(unsigned i) ...@@ -24,6 +30,7 @@ static unsigned v32(unsigned i)
static void do_write_test(void __iomem *p) static void do_write_test(void __iomem *p)
{ {
unsigned int i; unsigned int i;
pr_info(MODULE_NAME ": write test.\n");
mmiotrace_printk("Write test.\n"); mmiotrace_printk("Write test.\n");
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
...@@ -40,6 +47,7 @@ static void do_read_test(void __iomem *p) ...@@ -40,6 +47,7 @@ static void do_read_test(void __iomem *p)
{ {
unsigned int i; unsigned int i;
unsigned errs[3] = { 0 }; unsigned errs[3] = { 0 };
pr_info(MODULE_NAME ": read test.\n");
mmiotrace_printk("Read test.\n"); mmiotrace_printk("Read test.\n");
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
...@@ -58,9 +66,17 @@ static void do_read_test(void __iomem *p) ...@@ -58,9 +66,17 @@ static void do_read_test(void __iomem *p)
errs[0], errs[1], errs[2]); errs[0], errs[1], errs[2]);
} }
static void do_test(void) static void do_read_far_test(void __iomem *p)
{
pr_info(MODULE_NAME ": read far test.\n");
mmiotrace_printk("Read far test.\n");
ioread32(p + read_far);
}
static void do_test(unsigned long size)
{ {
void __iomem *p = ioremap_nocache(mmio_address, 0x4000); void __iomem *p = ioremap_nocache(mmio_address, size);
if (!p) { if (!p) {
pr_err(MODULE_NAME ": could not ioremap, aborting.\n"); pr_err(MODULE_NAME ": could not ioremap, aborting.\n");
return; return;
...@@ -68,11 +84,15 @@ static void do_test(void) ...@@ -68,11 +84,15 @@ static void do_test(void)
mmiotrace_printk("ioremap returned %p.\n", p); mmiotrace_printk("ioremap returned %p.\n", p);
do_write_test(p); do_write_test(p);
do_read_test(p); do_read_test(p);
if (read_far && read_far < size - 4)
do_read_far_test(p);
iounmap(p); iounmap(p);
} }
static int __init init(void) static int __init init(void)
{ {
unsigned long size = (read_far) ? (8 << 20) : (16 << 10);
if (mmio_address == 0) { if (mmio_address == 0) {
pr_err(MODULE_NAME ": you have to use the module argument " pr_err(MODULE_NAME ": you have to use the module argument "
"mmio_address.\n"); "mmio_address.\n");
...@@ -81,10 +101,11 @@ static int __init init(void) ...@@ -81,10 +101,11 @@ static int __init init(void)
return -ENXIO; return -ENXIO;
} }
pr_warning(MODULE_NAME ": WARNING: mapping 16 kB @ 0x%08lx " pr_warning(MODULE_NAME ": WARNING: mapping %lu kB @ 0x%08lx in PCI "
"in PCI address space, and writing " "address space, and writing 16 kB of rubbish in there.\n",
"rubbish in there.\n", mmio_address); size >> 10, mmio_address);
do_test(); do_test(size);
pr_info(MODULE_NAME ": All done.\n");
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment