aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorSergiu Iordache <sergiu@chromium.org>2011-07-26 19:08:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-26 19:49:46 -0400
commit3e5c4fadb9943c7539364d0c8425db071a2020e4 (patch)
tree34f1d5c4cbf2f330e9fd1210da6dabde3befa6bf /drivers/char
parent6b4d2a2733b9a17112f746d498c9f9a0427dcdd8 (diff)
ramoops: make record_size a module parameter
The size of the dump is currently set using the RECORD_SIZE macro which is set to a page size. This patch makes the record size a module parameter and allows it to be set through platform data as well to allow larger dumps if needed. Signed-off-by: Sergiu Iordache <sergiu@chromium.org> Acked-by: Marco Stornelli <marco.stornelli@gmail.com> Cc: "Ahmed S. Darwish" <darwish.07@gmail.com> Cc: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/ramoops.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/drivers/char/ramoops.c b/drivers/char/ramoops.c
index 5349d94e17da..bd9b94b518f3 100644
--- a/drivers/char/ramoops.c
+++ b/drivers/char/ramoops.c
@@ -32,8 +32,12 @@
32#include <linux/ramoops.h> 32#include <linux/ramoops.h>
33 33
34#define RAMOOPS_KERNMSG_HDR "====" 34#define RAMOOPS_KERNMSG_HDR "===="
35#define MIN_MEM_SIZE 4096UL
35 36
36#define RECORD_SIZE 4096UL 37static ulong record_size = MIN_MEM_SIZE;
38module_param(record_size, ulong, 0400);
39MODULE_PARM_DESC(record_size,
40 "size of each dump done on oops/panic");
37 41
38static ulong mem_address; 42static ulong mem_address;
39module_param(mem_address, ulong, 0400); 43module_param(mem_address, ulong, 0400);
@@ -55,6 +59,7 @@ static struct ramoops_context {
55 void *virt_addr; 59 void *virt_addr;
56 phys_addr_t phys_addr; 60 phys_addr_t phys_addr;
57 unsigned long size; 61 unsigned long size;
62 unsigned long record_size;
58 int dump_oops; 63 int dump_oops;
59 int count; 64 int count;
60 int max_count; 65 int max_count;
@@ -84,10 +89,10 @@ static void ramoops_do_dump(struct kmsg_dumper *dumper,
84 if (reason == KMSG_DUMP_OOPS && !cxt->dump_oops) 89 if (reason == KMSG_DUMP_OOPS && !cxt->dump_oops)
85 return; 90 return;
86 91
87 buf = cxt->virt_addr + (cxt->count * RECORD_SIZE); 92 buf = cxt->virt_addr + (cxt->count * cxt->record_size);
88 buf_orig = buf; 93 buf_orig = buf;
89 94
90 memset(buf, '\0', RECORD_SIZE); 95 memset(buf, '\0', cxt->record_size);
91 res = sprintf(buf, "%s", RAMOOPS_KERNMSG_HDR); 96 res = sprintf(buf, "%s", RAMOOPS_KERNMSG_HDR);
92 buf += res; 97 buf += res;
93 do_gettimeofday(&timestamp); 98 do_gettimeofday(&timestamp);
@@ -95,8 +100,8 @@ static void ramoops_do_dump(struct kmsg_dumper *dumper,
95 buf += res; 100 buf += res;
96 101
97 hdr_size = buf - buf_orig; 102 hdr_size = buf - buf_orig;
98 l2_cpy = min(l2, RECORD_SIZE - hdr_size); 103 l2_cpy = min(l2, cxt->record_size - hdr_size);
99 l1_cpy = min(l1, RECORD_SIZE - hdr_size - l2_cpy); 104 l1_cpy = min(l1, cxt->record_size - hdr_size - l2_cpy);
100 105
101 s2_start = l2 - l2_cpy; 106 s2_start = l2 - l2_cpy;
102 s1_start = l1 - l1_cpy; 107 s1_start = l1 - l1_cpy;
@@ -113,22 +118,33 @@ static int __init ramoops_probe(struct platform_device *pdev)
113 struct ramoops_context *cxt = &oops_cxt; 118 struct ramoops_context *cxt = &oops_cxt;
114 int err = -EINVAL; 119 int err = -EINVAL;
115 120
116 if (!pdata->mem_size) { 121 if (!pdata->mem_size || !pdata->record_size) {
117 pr_err("invalid size specification\n"); 122 pr_err("The memory size and the record size must be "
123 "non-zero\n");
118 goto fail3; 124 goto fail3;
119 } 125 }
120 126
121 rounddown_pow_of_two(pdata->mem_size); 127 rounddown_pow_of_two(pdata->mem_size);
128 rounddown_pow_of_two(pdata->record_size);
122 129
123 if (pdata->mem_size < RECORD_SIZE) { 130 /* Check for the minimum memory size */
124 pr_err("size too small\n"); 131 if (pdata->mem_size < MIN_MEM_SIZE &&
132 pdata->record_size < MIN_MEM_SIZE) {
133 pr_err("memory size too small, minium is %lu\n", MIN_MEM_SIZE);
125 goto fail3; 134 goto fail3;
126 } 135 }
127 136
128 cxt->max_count = pdata->mem_size / RECORD_SIZE; 137 if (pdata->mem_size < pdata->record_size) {
138 pr_err("The memory size must be larger than the "
139 "records size\n");
140 goto fail3;
141 }
142
143 cxt->max_count = pdata->mem_size / pdata->record_size;
129 cxt->count = 0; 144 cxt->count = 0;
130 cxt->size = pdata->mem_size; 145 cxt->size = pdata->mem_size;
131 cxt->phys_addr = pdata->mem_address; 146 cxt->phys_addr = pdata->mem_address;
147 cxt->record_size = pdata->record_size;
132 cxt->dump_oops = pdata->dump_oops; 148 cxt->dump_oops = pdata->dump_oops;
133 149
134 if (!request_mem_region(cxt->phys_addr, cxt->size, "ramoops")) { 150 if (!request_mem_region(cxt->phys_addr, cxt->size, "ramoops")) {
@@ -196,6 +212,7 @@ static int __init ramoops_init(void)
196 return -ENOMEM; 212 return -ENOMEM;
197 dummy_data->mem_size = mem_size; 213 dummy_data->mem_size = mem_size;
198 dummy_data->mem_address = mem_address; 214 dummy_data->mem_address = mem_address;
215 dummy_data->record_size = record_size;
199 dummy_data->dump_oops = dump_oops; 216 dummy_data->dump_oops = dump_oops;
200 dummy = platform_create_bundle(&ramoops_driver, ramoops_probe, 217 dummy = platform_create_bundle(&ramoops_driver, ramoops_probe,
201 NULL, 0, dummy_data, 218 NULL, 0, dummy_data,