Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sergiu Iordache and committed by
Linus Torvalds
3e5c4fad 6b4d2a27

+28 -10
+27 -10
drivers/char/ramoops.c
··· 32 32 #include <linux/ramoops.h> 33 33 34 34 #define RAMOOPS_KERNMSG_HDR "====" 35 + #define MIN_MEM_SIZE 4096UL 35 36 36 - #define RECORD_SIZE 4096UL 37 + static ulong record_size = MIN_MEM_SIZE; 38 + module_param(record_size, ulong, 0400); 39 + MODULE_PARM_DESC(record_size, 40 + "size of each dump done on oops/panic"); 37 41 38 42 static ulong mem_address; 39 43 module_param(mem_address, ulong, 0400); ··· 59 55 void *virt_addr; 60 56 phys_addr_t phys_addr; 61 57 unsigned long size; 58 + unsigned long record_size; 62 59 int dump_oops; 63 60 int count; 64 61 int max_count; ··· 89 84 if (reason == KMSG_DUMP_OOPS && !cxt->dump_oops) 90 85 return; 91 86 92 - buf = cxt->virt_addr + (cxt->count * RECORD_SIZE); 87 + buf = cxt->virt_addr + (cxt->count * cxt->record_size); 93 88 buf_orig = buf; 94 89 95 - memset(buf, '\0', RECORD_SIZE); 90 + memset(buf, '\0', cxt->record_size); 96 91 res = sprintf(buf, "%s", RAMOOPS_KERNMSG_HDR); 97 92 buf += res; 98 93 do_gettimeofday(&timestamp); ··· 100 95 buf += res; 101 96 102 97 hdr_size = buf - buf_orig; 103 - l2_cpy = min(l2, RECORD_SIZE - hdr_size); 104 - l1_cpy = min(l1, RECORD_SIZE - hdr_size - l2_cpy); 98 + l2_cpy = min(l2, cxt->record_size - hdr_size); 99 + l1_cpy = min(l1, cxt->record_size - hdr_size - l2_cpy); 105 100 106 101 s2_start = l2 - l2_cpy; 107 102 s1_start = l1 - l1_cpy; ··· 118 113 struct ramoops_context *cxt = &oops_cxt; 119 114 int err = -EINVAL; 120 115 121 - if (!pdata->mem_size) { 122 - pr_err("invalid size specification\n"); 116 + if (!pdata->mem_size || !pdata->record_size) { 117 + pr_err("The memory size and the record size must be " 118 + "non-zero\n"); 123 119 goto fail3; 124 120 } 125 121 126 122 rounddown_pow_of_two(pdata->mem_size); 123 + rounddown_pow_of_two(pdata->record_size); 127 124 128 - if (pdata->mem_size < RECORD_SIZE) { 129 - pr_err("size too small\n"); 125 + /* Check for the minimum memory size */ 126 + if (pdata->mem_size < MIN_MEM_SIZE && 127 + pdata->record_size < MIN_MEM_SIZE) { 128 + pr_err("memory size too small, minium is %lu\n", MIN_MEM_SIZE); 130 129 goto fail3; 131 130 } 132 131 133 - cxt->max_count = pdata->mem_size / RECORD_SIZE; 132 + if (pdata->mem_size < pdata->record_size) { 133 + pr_err("The memory size must be larger than the " 134 + "records size\n"); 135 + goto fail3; 136 + } 137 + 138 + cxt->max_count = pdata->mem_size / pdata->record_size; 134 139 cxt->count = 0; 135 140 cxt->size = pdata->mem_size; 136 141 cxt->phys_addr = pdata->mem_address; 142 + cxt->record_size = pdata->record_size; 137 143 cxt->dump_oops = pdata->dump_oops; 138 144 139 145 if (!request_mem_region(cxt->phys_addr, cxt->size, "ramoops")) { ··· 212 196 return -ENOMEM; 213 197 dummy_data->mem_size = mem_size; 214 198 dummy_data->mem_address = mem_address; 199 + dummy_data->record_size = record_size; 215 200 dummy_data->dump_oops = dump_oops; 216 201 dummy = platform_create_bundle(&ramoops_driver, ramoops_probe, 217 202 NULL, 0, dummy_data,
+1
include/linux/ramoops.h
··· 10 10 struct ramoops_platform_data { 11 11 unsigned long mem_size; 12 12 unsigned long mem_address; 13 + unsigned long record_size; 13 14 int dump_oops; 14 15 }; 15 16