|
@@ -51,6 +51,10 @@ static ulong ramoops_ftrace_size = MIN_MEM_SIZE;
|
|
|
module_param_named(ftrace_size, ramoops_ftrace_size, ulong, 0400);
|
|
|
MODULE_PARM_DESC(ftrace_size, "size of ftrace log");
|
|
|
|
|
|
+static ulong ramoops_pmsg_size = MIN_MEM_SIZE;
|
|
|
+module_param_named(pmsg_size, ramoops_pmsg_size, ulong, 0400);
|
|
|
+MODULE_PARM_DESC(pmsg_size, "size of user space message log");
|
|
|
+
|
|
|
static ulong mem_address;
|
|
|
module_param(mem_address, ulong, 0400);
|
|
|
MODULE_PARM_DESC(mem_address,
|
|
@@ -82,12 +86,14 @@ struct ramoops_context {
|
|
|
struct persistent_ram_zone **przs;
|
|
|
struct persistent_ram_zone *cprz;
|
|
|
struct persistent_ram_zone *fprz;
|
|
|
+ struct persistent_ram_zone *mprz;
|
|
|
phys_addr_t phys_addr;
|
|
|
unsigned long size;
|
|
|
unsigned int memtype;
|
|
|
size_t record_size;
|
|
|
size_t console_size;
|
|
|
size_t ftrace_size;
|
|
|
+ size_t pmsg_size;
|
|
|
int dump_oops;
|
|
|
struct persistent_ram_ecc_info ecc_info;
|
|
|
unsigned int max_dump_cnt;
|
|
@@ -96,6 +102,7 @@ struct ramoops_context {
|
|
|
unsigned int dump_read_cnt;
|
|
|
unsigned int console_read_cnt;
|
|
|
unsigned int ftrace_read_cnt;
|
|
|
+ unsigned int pmsg_read_cnt;
|
|
|
struct pstore_info pstore;
|
|
|
};
|
|
|
|
|
@@ -109,6 +116,7 @@ static int ramoops_pstore_open(struct pstore_info *psi)
|
|
|
cxt->dump_read_cnt = 0;
|
|
|
cxt->console_read_cnt = 0;
|
|
|
cxt->ftrace_read_cnt = 0;
|
|
|
+ cxt->pmsg_read_cnt = 0;
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -164,6 +172,12 @@ static int ramoops_read_kmsg_hdr(char *buffer, struct timespec *time,
|
|
|
return header_length;
|
|
|
}
|
|
|
|
|
|
+static bool prz_ok(struct persistent_ram_zone *prz)
|
|
|
+{
|
|
|
+ return !!prz && !!(persistent_ram_old_size(prz) +
|
|
|
+ persistent_ram_ecc_string(prz, NULL, 0));
|
|
|
+}
|
|
|
+
|
|
|
static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
|
|
|
int *count, struct timespec *time,
|
|
|
char **buf, bool *compressed,
|
|
@@ -178,13 +192,16 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
|
|
|
prz = ramoops_get_next_prz(cxt->przs, &cxt->dump_read_cnt,
|
|
|
cxt->max_dump_cnt, id, type,
|
|
|
PSTORE_TYPE_DMESG, 1);
|
|
|
- if (!prz)
|
|
|
+ if (!prz_ok(prz))
|
|
|
prz = ramoops_get_next_prz(&cxt->cprz, &cxt->console_read_cnt,
|
|
|
1, id, type, PSTORE_TYPE_CONSOLE, 0);
|
|
|
- if (!prz)
|
|
|
+ if (!prz_ok(prz))
|
|
|
prz = ramoops_get_next_prz(&cxt->fprz, &cxt->ftrace_read_cnt,
|
|
|
1, id, type, PSTORE_TYPE_FTRACE, 0);
|
|
|
- if (!prz)
|
|
|
+ if (!prz_ok(prz))
|
|
|
+ prz = ramoops_get_next_prz(&cxt->mprz, &cxt->pmsg_read_cnt,
|
|
|
+ 1, id, type, PSTORE_TYPE_PMSG, 0);
|
|
|
+ if (!prz_ok(prz))
|
|
|
return 0;
|
|
|
|
|
|
if (!persistent_ram_old(prz))
|
|
@@ -252,6 +269,11 @@ static int notrace ramoops_pstore_write_buf(enum pstore_type_id type,
|
|
|
return -ENOMEM;
|
|
|
persistent_ram_write(cxt->fprz, buf, size);
|
|
|
return 0;
|
|
|
+ } else if (type == PSTORE_TYPE_PMSG) {
|
|
|
+ if (!cxt->mprz)
|
|
|
+ return -ENOMEM;
|
|
|
+ persistent_ram_write(cxt->mprz, buf, size);
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
if (type != PSTORE_TYPE_DMESG)
|
|
@@ -309,6 +331,9 @@ static int ramoops_pstore_erase(enum pstore_type_id type, u64 id, int count,
|
|
|
case PSTORE_TYPE_FTRACE:
|
|
|
prz = cxt->fprz;
|
|
|
break;
|
|
|
+ case PSTORE_TYPE_PMSG:
|
|
|
+ prz = cxt->mprz;
|
|
|
+ break;
|
|
|
default:
|
|
|
return -EINVAL;
|
|
|
}
|
|
@@ -435,7 +460,7 @@ static int ramoops_probe(struct platform_device *pdev)
|
|
|
goto fail_out;
|
|
|
|
|
|
if (!pdata->mem_size || (!pdata->record_size && !pdata->console_size &&
|
|
|
- !pdata->ftrace_size)) {
|
|
|
+ !pdata->ftrace_size && !pdata->pmsg_size)) {
|
|
|
pr_err("The memory size and the record/console size must be "
|
|
|
"non-zero\n");
|
|
|
goto fail_out;
|
|
@@ -447,6 +472,8 @@ static int ramoops_probe(struct platform_device *pdev)
|
|
|
pdata->console_size = rounddown_pow_of_two(pdata->console_size);
|
|
|
if (pdata->ftrace_size && !is_power_of_2(pdata->ftrace_size))
|
|
|
pdata->ftrace_size = rounddown_pow_of_two(pdata->ftrace_size);
|
|
|
+ if (pdata->pmsg_size && !is_power_of_2(pdata->pmsg_size))
|
|
|
+ pdata->pmsg_size = rounddown_pow_of_two(pdata->pmsg_size);
|
|
|
|
|
|
cxt->size = pdata->mem_size;
|
|
|
cxt->phys_addr = pdata->mem_address;
|
|
@@ -454,12 +481,14 @@ static int ramoops_probe(struct platform_device *pdev)
|
|
|
cxt->record_size = pdata->record_size;
|
|
|
cxt->console_size = pdata->console_size;
|
|
|
cxt->ftrace_size = pdata->ftrace_size;
|
|
|
+ cxt->pmsg_size = pdata->pmsg_size;
|
|
|
cxt->dump_oops = pdata->dump_oops;
|
|
|
cxt->ecc_info = pdata->ecc_info;
|
|
|
|
|
|
paddr = cxt->phys_addr;
|
|
|
|
|
|
- dump_mem_sz = cxt->size - cxt->console_size - cxt->ftrace_size;
|
|
|
+ dump_mem_sz = cxt->size - cxt->console_size - cxt->ftrace_size
|
|
|
+ - cxt->pmsg_size;
|
|
|
err = ramoops_init_przs(dev, cxt, &paddr, dump_mem_sz);
|
|
|
if (err)
|
|
|
goto fail_out;
|
|
@@ -474,13 +503,9 @@ static int ramoops_probe(struct platform_device *pdev)
|
|
|
if (err)
|
|
|
goto fail_init_fprz;
|
|
|
|
|
|
- if (!cxt->przs && !cxt->cprz && !cxt->fprz) {
|
|
|
- pr_err("memory size too small, minimum is %zu\n",
|
|
|
- cxt->console_size + cxt->record_size +
|
|
|
- cxt->ftrace_size);
|
|
|
- err = -EINVAL;
|
|
|
- goto fail_cnt;
|
|
|
- }
|
|
|
+ err = ramoops_init_prz(dev, cxt, &cxt->mprz, &paddr, cxt->pmsg_size, 0);
|
|
|
+ if (err)
|
|
|
+ goto fail_init_mprz;
|
|
|
|
|
|
cxt->pstore.data = cxt;
|
|
|
/*
|
|
@@ -525,7 +550,8 @@ fail_buf:
|
|
|
kfree(cxt->pstore.buf);
|
|
|
fail_clear:
|
|
|
cxt->pstore.bufsize = 0;
|
|
|
-fail_cnt:
|
|
|
+ kfree(cxt->mprz);
|
|
|
+fail_init_mprz:
|
|
|
kfree(cxt->fprz);
|
|
|
fail_init_fprz:
|
|
|
kfree(cxt->cprz);
|
|
@@ -583,6 +609,7 @@ static void ramoops_register_dummy(void)
|
|
|
dummy_data->record_size = record_size;
|
|
|
dummy_data->console_size = ramoops_console_size;
|
|
|
dummy_data->ftrace_size = ramoops_ftrace_size;
|
|
|
+ dummy_data->pmsg_size = ramoops_pmsg_size;
|
|
|
dummy_data->dump_oops = dump_oops;
|
|
|
/*
|
|
|
* For backwards compatibility ramoops.ecc=1 means 16 bytes ECC
|