diff options
| -rw-r--r-- | arch/x86/mm/testmmiotrace.c | 35 |
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 | ||
| 10 | static unsigned long mmio_address; | 10 | 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 | "(or 8 MB if read_far is non-zero)."); | ||
| 14 | |||
| 15 | static unsigned long read_far = 0x400100; | ||
| 16 | module_param(read_far, ulong, 0); | ||
| 17 | MODULE_PARM_DESC(read_far, " Offset of a 32-bit read within 8 MB " | ||
| 18 | "(default: 0x400100)."); | ||
| 13 | 19 | ||
| 14 | static unsigned v16(unsigned i) | 20 | static unsigned v16(unsigned i) |
| 15 | { | 21 | { |
| @@ -24,6 +30,7 @@ static unsigned v32(unsigned i) | |||
| 24 | static void do_write_test(void __iomem *p) | 30 | static 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 | ||
| 61 | static void do_test(void) | 69 | static 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 | |||
| 77 | static 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 | ||
| 74 | static int __init init(void) | 92 | static 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 | ||
