diff options
author | Anton Vorontsov <anton.vorontsov@linaro.org> | 2012-07-09 20:03:19 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-07-17 12:46:52 -0400 |
commit | 5ca5d4e61d0cac15f36160ab48425c6e43bf2e2f (patch) | |
tree | 7e35f66cc7863798f32e96fb2062b6006352dc04 /fs/pstore | |
parent | 4a53ffae6afc94bab803087245b3b45e712c21c8 (diff) |
pstore/ram: Make ECC size configurable
This is now pretty straightforward: instead of using bool, just pass
an integer. For backwards compatibility ramoops.ecc=1 means 16 bytes
ECC (using 1 byte for ECC isn't much of use anyway).
Suggested-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/pstore')
-rw-r--r-- | fs/pstore/ram.c | 22 | ||||
-rw-r--r-- | fs/pstore/ram_core.c | 15 |
2 files changed, 22 insertions, 15 deletions
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 58b93fbd117e..b39aebbaeb89 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c | |||
@@ -63,7 +63,9 @@ MODULE_PARM_DESC(dump_oops, | |||
63 | static int ramoops_ecc; | 63 | static int ramoops_ecc; |
64 | module_param_named(ecc, ramoops_ecc, int, 0600); | 64 | module_param_named(ecc, ramoops_ecc, int, 0600); |
65 | MODULE_PARM_DESC(ramoops_ecc, | 65 | MODULE_PARM_DESC(ramoops_ecc, |
66 | "set to 1 to enable ECC support"); | 66 | "if non-zero, the option enables ECC support and specifies " |
67 | "ECC buffer size in bytes (1 is a special value, means 16 " | ||
68 | "bytes ECC)"); | ||
67 | 69 | ||
68 | struct ramoops_context { | 70 | struct ramoops_context { |
69 | struct persistent_ram_zone **przs; | 71 | struct persistent_ram_zone **przs; |
@@ -73,7 +75,7 @@ struct ramoops_context { | |||
73 | size_t record_size; | 75 | size_t record_size; |
74 | size_t console_size; | 76 | size_t console_size; |
75 | int dump_oops; | 77 | int dump_oops; |
76 | bool ecc; | 78 | int ecc_size; |
77 | unsigned int max_dump_cnt; | 79 | unsigned int max_dump_cnt; |
78 | unsigned int dump_write_cnt; | 80 | unsigned int dump_write_cnt; |
79 | unsigned int dump_read_cnt; | 81 | unsigned int dump_read_cnt; |
@@ -288,7 +290,7 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt, | |||
288 | for (i = 0; i < cxt->max_dump_cnt; i++) { | 290 | for (i = 0; i < cxt->max_dump_cnt; i++) { |
289 | size_t sz = cxt->record_size; | 291 | size_t sz = cxt->record_size; |
290 | 292 | ||
291 | cxt->przs[i] = persistent_ram_new(*paddr, sz, cxt->ecc); | 293 | cxt->przs[i] = persistent_ram_new(*paddr, sz, cxt->ecc_size); |
292 | if (IS_ERR(cxt->przs[i])) { | 294 | if (IS_ERR(cxt->przs[i])) { |
293 | err = PTR_ERR(cxt->przs[i]); | 295 | err = PTR_ERR(cxt->przs[i]); |
294 | dev_err(dev, "failed to request mem region (0x%zx@0x%llx): %d\n", | 296 | dev_err(dev, "failed to request mem region (0x%zx@0x%llx): %d\n", |
@@ -314,7 +316,7 @@ static int ramoops_init_prz(struct device *dev, struct ramoops_context *cxt, | |||
314 | if (*paddr + sz > *paddr + cxt->size) | 316 | if (*paddr + sz > *paddr + cxt->size) |
315 | return -ENOMEM; | 317 | return -ENOMEM; |
316 | 318 | ||
317 | *prz = persistent_ram_new(*paddr, sz, cxt->ecc); | 319 | *prz = persistent_ram_new(*paddr, sz, cxt->ecc_size); |
318 | if (IS_ERR(*prz)) { | 320 | if (IS_ERR(*prz)) { |
319 | int err = PTR_ERR(*prz); | 321 | int err = PTR_ERR(*prz); |
320 | 322 | ||
@@ -361,7 +363,7 @@ static int __devinit ramoops_probe(struct platform_device *pdev) | |||
361 | cxt->record_size = pdata->record_size; | 363 | cxt->record_size = pdata->record_size; |
362 | cxt->console_size = pdata->console_size; | 364 | cxt->console_size = pdata->console_size; |
363 | cxt->dump_oops = pdata->dump_oops; | 365 | cxt->dump_oops = pdata->dump_oops; |
364 | cxt->ecc = pdata->ecc; | 366 | cxt->ecc_size = pdata->ecc_size; |
365 | 367 | ||
366 | paddr = cxt->phys_addr; | 368 | paddr = cxt->phys_addr; |
367 | 369 | ||
@@ -411,9 +413,9 @@ static int __devinit ramoops_probe(struct platform_device *pdev) | |||
411 | record_size = pdata->record_size; | 413 | record_size = pdata->record_size; |
412 | dump_oops = pdata->dump_oops; | 414 | dump_oops = pdata->dump_oops; |
413 | 415 | ||
414 | pr_info("attached 0x%lx@0x%llx, ecc: %s\n", | 416 | pr_info("attached 0x%lx@0x%llx, ecc: %d\n", |
415 | cxt->size, (unsigned long long)cxt->phys_addr, | 417 | cxt->size, (unsigned long long)cxt->phys_addr, |
416 | ramoops_ecc ? "on" : "off"); | 418 | cxt->ecc_size); |
417 | 419 | ||
418 | return 0; | 420 | return 0; |
419 | 421 | ||
@@ -478,7 +480,11 @@ static void ramoops_register_dummy(void) | |||
478 | dummy_data->record_size = record_size; | 480 | dummy_data->record_size = record_size; |
479 | dummy_data->console_size = ramoops_console_size; | 481 | dummy_data->console_size = ramoops_console_size; |
480 | dummy_data->dump_oops = dump_oops; | 482 | dummy_data->dump_oops = dump_oops; |
481 | dummy_data->ecc = ramoops_ecc; | 483 | /* |
484 | * For backwards compatibility ramoops.ecc=1 means 16 bytes ECC | ||
485 | * (using 1 byte for ECC isn't much of use anyway). | ||
486 | */ | ||
487 | dummy_data->ecc_size = ramoops_ecc == 1 ? 16 : ramoops_ecc; | ||
482 | 488 | ||
483 | dummy = platform_device_register_data(NULL, "ramoops", -1, | 489 | dummy = platform_device_register_data(NULL, "ramoops", -1, |
484 | dummy_data, sizeof(struct ramoops_platform_data)); | 490 | dummy_data, sizeof(struct ramoops_platform_data)); |
diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c index 3f4d6e64f6d7..7e5a2a9154ca 100644 --- a/fs/pstore/ram_core.c +++ b/fs/pstore/ram_core.c | |||
@@ -171,7 +171,8 @@ static void persistent_ram_ecc_old(struct persistent_ram_zone *prz) | |||
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | static int persistent_ram_init_ecc(struct persistent_ram_zone *prz) | 174 | static int persistent_ram_init_ecc(struct persistent_ram_zone *prz, |
175 | int ecc_size) | ||
175 | { | 176 | { |
176 | int numerr; | 177 | int numerr; |
177 | struct persistent_ram_buffer *buffer = prz->buffer; | 178 | struct persistent_ram_buffer *buffer = prz->buffer; |
@@ -184,7 +185,7 @@ static int persistent_ram_init_ecc(struct persistent_ram_zone *prz) | |||
184 | return 0; | 185 | return 0; |
185 | 186 | ||
186 | prz->ecc_block_size = 128; | 187 | prz->ecc_block_size = 128; |
187 | prz->ecc_size = 16; | 188 | prz->ecc_size = ecc_size; |
188 | 189 | ||
189 | ecc_blocks = DIV_ROUND_UP(prz->buffer_size, prz->ecc_block_size); | 190 | ecc_blocks = DIV_ROUND_UP(prz->buffer_size, prz->ecc_block_size); |
190 | ecc_total = (ecc_blocks + 1) * prz->ecc_size; | 191 | ecc_total = (ecc_blocks + 1) * prz->ecc_size; |
@@ -390,13 +391,13 @@ static int persistent_ram_buffer_map(phys_addr_t start, phys_addr_t size, | |||
390 | } | 391 | } |
391 | 392 | ||
392 | static int __devinit persistent_ram_post_init(struct persistent_ram_zone *prz, | 393 | static int __devinit persistent_ram_post_init(struct persistent_ram_zone *prz, |
393 | bool ecc) | 394 | int ecc_size) |
394 | { | 395 | { |
395 | int ret; | 396 | int ret; |
396 | 397 | ||
397 | prz->ecc = ecc; | 398 | prz->ecc = ecc_size; |
398 | 399 | ||
399 | ret = persistent_ram_init_ecc(prz); | 400 | ret = persistent_ram_init_ecc(prz, ecc_size); |
400 | if (ret) | 401 | if (ret) |
401 | return ret; | 402 | return ret; |
402 | 403 | ||
@@ -444,7 +445,7 @@ void persistent_ram_free(struct persistent_ram_zone *prz) | |||
444 | 445 | ||
445 | struct persistent_ram_zone * __devinit persistent_ram_new(phys_addr_t start, | 446 | struct persistent_ram_zone * __devinit persistent_ram_new(phys_addr_t start, |
446 | size_t size, | 447 | size_t size, |
447 | bool ecc) | 448 | int ecc_size) |
448 | { | 449 | { |
449 | struct persistent_ram_zone *prz; | 450 | struct persistent_ram_zone *prz; |
450 | int ret = -ENOMEM; | 451 | int ret = -ENOMEM; |
@@ -459,7 +460,7 @@ struct persistent_ram_zone * __devinit persistent_ram_new(phys_addr_t start, | |||
459 | if (ret) | 460 | if (ret) |
460 | goto err; | 461 | goto err; |
461 | 462 | ||
462 | ret = persistent_ram_post_init(prz, ecc); | 463 | ret = persistent_ram_post_init(prz, ecc_size); |
463 | if (ret) | 464 | if (ret) |
464 | goto err; | 465 | goto err; |
465 | 466 | ||