switch (type) {
case PSTORE_TYPE_DMESG:
- sprintf(name, "dmesg-%s-%lld", psname, id);
+ scnprintf(name, sizeof(name), "dmesg-%s-%lld",
+ psname, id);
break;
case PSTORE_TYPE_CONSOLE:
- sprintf(name, "console-%s-%lld", psname, id);
- scnprintf(name, sizeof(name), "console-%s", psname);
++ scnprintf(name, sizeof(name), "console-%s-%lld", psname, id);
break;
case PSTORE_TYPE_FTRACE:
- sprintf(name, "ftrace-%s-%lld", psname, id);
- scnprintf(name, sizeof(name), "ftrace-%s", psname);
++ scnprintf(name, sizeof(name), "ftrace-%s-%lld", psname, id);
+ break;
+ case PSTORE_TYPE_RTRACE:
- sprintf(name, "rtrace-%s", psname);
++ scnprintf(name, sizeof(name), "rtrace-%s", psname);
break;
case PSTORE_TYPE_MCE:
- sprintf(name, "mce-%s-%lld", psname, id);
+ scnprintf(name, sizeof(name), "mce-%s-%lld", psname, id);
+ break;
+ case PSTORE_TYPE_PMSG:
+ scnprintf(name, sizeof(name), "pmsg-%s-%lld", psname, id);
break;
case PSTORE_TYPE_UNKNOWN:
- sprintf(name, "unknown-%s-%lld", psname, id);
+ scnprintf(name, sizeof(name), "unknown-%s-%lld", psname, id);
break;
default:
- sprintf(name, "type%d-%s-%lld", type, psname, id);
+ scnprintf(name, sizeof(name), "type%d-%s-%lld",
+ type, psname, id);
break;
}
module_param_named(ftrace_size, ramoops_ftrace_size, ulong, 0400);
MODULE_PARM_DESC(ftrace_size, "size of ftrace log");
+static ulong ramoops_rtrace_size = MIN_MEM_SIZE;
+module_param_named(rtrace_size, ramoops_rtrace_size, ulong, 0400);
+MODULE_PARM_DESC(rtrace_size, "size of rtrace 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,
struct persistent_ram_zone **przs;
struct persistent_ram_zone *cprz;
struct persistent_ram_zone *fprz;
+ struct persistent_ram_zone *rprz;
+ 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 rtrace_size;
+ size_t pmsg_size;
int dump_oops;
struct persistent_ram_ecc_info ecc_info;
unsigned int max_dump_cnt;
unsigned int dump_read_cnt;
unsigned int console_read_cnt;
unsigned int ftrace_read_cnt;
+ unsigned int rtrace_read_cnt;
+ unsigned int pmsg_read_cnt;
struct pstore_info pstore;
};
cxt->dump_read_cnt = 0;
cxt->console_read_cnt = 0;
cxt->ftrace_read_cnt = 0;
+ cxt->rtrace_read_cnt = 0;
+ cxt->pmsg_read_cnt = 0;
return 0;
}
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->rprz, &cxt->rtrace_read_cnt,
+ 1, id, type, PSTORE_TYPE_RTRACE, 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;
- /* TODO(kees): Bogus time for the moment. */
- time->tv_sec = 0;
- time->tv_nsec = 0;
-
size = persistent_ram_old_size(prz);
/* ECC correction notice */
return -ENOMEM;
persistent_ram_write(cxt->fprz, buf, size);
return 0;
+ } else if (type == PSTORE_TYPE_RTRACE) {
+ if (!cxt->rprz)
+ return -ENOMEM;
+ persistent_ram_write(cxt->rprz, 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)
case PSTORE_TYPE_FTRACE:
prz = cxt->fprz;
break;
+ case PSTORE_TYPE_RTRACE:
+ prz = cxt->rprz;
+ break;
+ case PSTORE_TYPE_PMSG:
+ prz = cxt->mprz;
+ break;
default:
return -EINVAL;
}
*/
if (cxt->max_dump_cnt)
goto fail_out;
-
- if (!pdata->mem_size || (!pdata->record_size && !pdata->console_size &&
- !pdata->ftrace_size && !pdata->pmsg_size)) {
- pr_err("The memory size and the record/console size must be "
- "non-zero\n");
+ if ((pdata->mem_size && pdata->record_size) == 0) {
+ pr_err("The memory size and the record size must be non-zero\n");
goto fail_out;
}
-
- if (!is_power_of_2(pdata->mem_size))
+#ifdef CONFIG_PSTORE_CONSOLE
+ if (pdata->console_size == 0) {
+ pr_err("PSTORE_CONSOLE is enabled, console size must be non-zero\n");
+ goto fail_out;
+ }
+#endif
+#ifdef CONFIG_PSTORE_FTRACE
+ if (pdata->ftrace_size == 0) {
+ pr_err("PSTORE_FTRACE is enabled, ftrace size must be non-zero\n");
+ goto fail_out;
+ }
+#endif
+#ifdef CONFIG_PSTORE_RTRACE
+ if (pdata->rtrace_size == 0) {
+ pr_err("PSTORE_RTRACE is enabled, rtrace size must be non-zero\n");
+ goto fail_out;
+ }
++#endif
++#ifdef CONFIG_PSTORE_PMSG
++ if (pdata->pmsg_size == 0) {
++ pr_err("PSTORE_PMSG is enabled, pmsg size must be non-zero\n");
++ goto fail_out;
++ }
+#endif
+ if (pdata->mem_size && !is_power_of_2(pdata->mem_size))
pdata->mem_size = rounddown_pow_of_two(pdata->mem_size);
- if (!is_power_of_2(pdata->record_size))
+ if (pdata->record_size && !is_power_of_2(pdata->record_size))
pdata->record_size = rounddown_pow_of_two(pdata->record_size);
- if (!is_power_of_2(pdata->console_size))
+ if (pdata->console_size && !is_power_of_2(pdata->console_size))
pdata->console_size = rounddown_pow_of_two(pdata->console_size);
- if (!is_power_of_2(pdata->ftrace_size))
+ if (pdata->ftrace_size && !is_power_of_2(pdata->ftrace_size))
pdata->ftrace_size = rounddown_pow_of_two(pdata->ftrace_size);
+ if (pdata->rtrace_size && !is_power_of_2(pdata->rtrace_size))
+ pdata->rtrace_size = rounddown_pow_of_two(pdata->rtrace_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;
cxt->record_size = pdata->record_size;
cxt->console_size = pdata->console_size;
cxt->ftrace_size = pdata->ftrace_size;
+ cxt->rtrace_size = pdata->rtrace_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
- - cxt->pmsg_size;
+ dump_mem_sz = cxt->size - cxt->console_size - cxt->ftrace_size -
- cxt->rtrace_size;
++ cxt->rtrace_size - cxt->pmsg_size;
err = ramoops_init_przs(dev, cxt, &paddr, dump_mem_sz);
if (err)
goto fail_out;
LINUX_VERSION_CODE);
if (err)
goto fail_init_fprz;
-
- err = ramoops_init_prz(dev, cxt, &cxt->mprz, &paddr, cxt->pmsg_size, 0);
+#endif
+#ifdef CONFIG_PSTORE_RTRACE
+ err = ramoops_init_prz(dev, cxt, &cxt->rprz, &paddr,
+ cxt->rtrace_size, 0);
+ if (err)
+ goto fail_init_rprz;
+#endif
- if (!cxt->przs && !cxt->cprz && !cxt->fprz && !cxt->rprz) {
++#ifdef CONFIG_PSTORE_PMSG
++ err = ramoops_init_prz(dev, cxt, &cxt->mprz, &paddr,
++ cxt->pmsg_size, 0);
+ if (err)
+ goto fail_init_mprz;
++#endif
++ if (!cxt->przs && !cxt->cprz && !cxt->fprz && !cxt->rprz &&
++ !cxt->mprz) {
+ pr_err("memory size too small, minimum is %zu\n",
+ cxt->console_size + cxt->record_size +
- cxt->ftrace_size + cxt->rtrace_size);
++ cxt->ftrace_size + cxt->rtrace_size + cxt->pmsg_size);
+ err = -EINVAL;
+ goto fail_cnt;
+ }
cxt->pstore.data = cxt;
/*
fail_clear:
cxt->pstore.bufsize = 0;
cxt->max_dump_cnt = 0;
+fail_cnt:
+ kfree(cxt->mprz);
+ fail_init_mprz:
+ kfree(cxt->rprz);
+fail_init_rprz:
kfree(cxt->fprz);
fail_init_fprz:
kfree(cxt->cprz);
dummy_data->record_size = record_size;
dummy_data->console_size = ramoops_console_size;
dummy_data->ftrace_size = ramoops_ftrace_size;
+ dummy_data->rtrace_size = ramoops_rtrace_size;
+ dummy_data->pmsg_size = ramoops_pmsg_size;
dummy_data->dump_oops = dump_oops;
/*
* For backwards compatibility ramoops.ecc=1 means 16 bytes ECC