From fb41ff66cbe78eb11145bc311ff94ca096ebc05a Mon Sep 17 00:00:00 2001 From: Huibin Hong Date: Wed, 14 Sep 2022 10:00:45 +0000 Subject: [PATCH] fs: pstore: rename mcu log to boot log It is not only for mcu log now, includes tpl, spl, uboot, atf, optee and so on. Signed-off-by: Huibin Hong Change-Id: Ia3bb0db39edf9cfba2ef41982a6134f0f20c5d53 --- fs/pstore/Kconfig | 6 +-- fs/pstore/inode.c | 8 ++-- fs/pstore/platform.c | 4 +- fs/pstore/ram.c | 91 +++++++++++++++++++------------------- include/linux/pstore.h | 8 ++-- include/linux/pstore_ram.h | 10 ++--- 6 files changed, 63 insertions(+), 64 deletions(-) diff --git a/fs/pstore/Kconfig b/fs/pstore/Kconfig index 45e20bfa427c..d51c74600f96 100644 --- a/fs/pstore/Kconfig +++ b/fs/pstore/Kconfig @@ -264,10 +264,10 @@ config PSTORE_BLK_FTRACE_SIZE NOTE that, both Kconfig and module parameters can configure pstore/blk, but module parameters have priority over Kconfig. -config PSTORE_MCU_LOG - bool "Print mcu log by linux" +config PSTORE_BOOT_LOG + bool "Print boot log by linux" depends on PSTORE help - When your soc has several mcu, you can get their log by cat command + Collect log from loader,uboot,ATF and so on, you can get their log by cat command through linux shell If unsure, say N. diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index 32318e6d6519..29c91fda081d 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c @@ -24,7 +24,7 @@ #include #include -#ifdef CONFIG_PSTORE_MCU_LOG +#ifdef CONFIG_PSTORE_BOOT_LOG #include #include #endif @@ -135,12 +135,12 @@ static ssize_t pstore_file_read(struct file *file, char __user *userbuf, { struct seq_file *sf = file->private_data; struct pstore_private *ps = sf->private; -#ifdef CONFIG_PSTORE_MCU_LOG +#ifdef CONFIG_PSTORE_BOOT_LOG size_t size = 0; struct pstore_record *record = ps->record; - if (record->type == PSTORE_TYPE_MCU_LOG) { - size = ramoops_pstore_read_for_mcu_log(ps->record); + if (record->type == PSTORE_TYPE_BOOT_LOG) { + size = ramoops_pstore_read_for_boot_log(ps->record); size = simple_read_from_buffer(userbuf, count, ppos, record->buf, size); return size; } diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 1673f3cb23f3..417582b41757 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -58,8 +58,8 @@ static const char * const pstore_type_names[] = { "powerpc-common", "pmsg", "powerpc-opal", -#ifdef CONFIG_PSTORE_MCU_LOG - "mcu-log", +#ifdef CONFIG_PSTORE_BOOT_LOG + "boot-log", #endif }; diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 026782e95c74..143e94395987 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -81,8 +81,8 @@ struct ramoops_context { struct persistent_ram_zone *cprz; /* Console zone */ struct persistent_ram_zone **fprzs; /* Ftrace zones */ struct persistent_ram_zone *mprz; /* PMSG zone */ -#ifdef CONFIG_PSTORE_MCU_LOG - struct persistent_ram_zone **mcu_przs; /* MCU log zones */ +#ifdef CONFIG_PSTORE_BOOT_LOG + struct persistent_ram_zone **boot_przs; /* BOOT log zones */ #endif phys_addr_t phys_addr; unsigned long size; @@ -91,8 +91,8 @@ struct ramoops_context { size_t console_size; size_t ftrace_size; size_t pmsg_size; -#ifdef CONFIG_PSTORE_MCU_LOG - size_t mcu_log_size; +#ifdef CONFIG_PSTORE_BOOT_LOG + size_t boot_log_size; #endif u32 flags; struct persistent_ram_ecc_info ecc_info; @@ -104,9 +104,9 @@ struct ramoops_context { unsigned int max_ftrace_cnt; unsigned int ftrace_read_cnt; unsigned int pmsg_read_cnt; -#ifdef CONFIG_PSTORE_MCU_LOG - unsigned int mcu_log_read_cnt; - unsigned int max_mcu_log_cnt; +#ifdef CONFIG_PSTORE_BOOT_LOG + unsigned int boot_log_read_cnt; + unsigned int max_boot_log_cnt; #endif struct pstore_info pstore; }; @@ -184,8 +184,8 @@ static bool prz_ok(struct persistent_ram_zone *prz) persistent_ram_ecc_string(prz, NULL, 0)); } -#ifdef CONFIG_PSTORE_MCU_LOG -ssize_t ramoops_pstore_read_for_mcu_log(struct pstore_record *record) +#ifdef CONFIG_PSTORE_BOOT_LOG +ssize_t ramoops_pstore_read_for_boot_log(struct pstore_record *record) { struct ramoops_context *cxt = record->psi->data; struct persistent_ram_zone *prz; @@ -193,7 +193,7 @@ ssize_t ramoops_pstore_read_for_mcu_log(struct pstore_record *record) if (!cxt) return 0; - prz = cxt->mcu_przs[record->id]; + prz = cxt->boot_przs[record->id]; if (!prz) return 0; @@ -290,10 +290,10 @@ static ssize_t ramoops_pstore_read(struct pstore_record *record) } } -#ifdef CONFIG_PSTORE_MCU_LOG +#ifdef CONFIG_PSTORE_BOOT_LOG if (!prz_ok(prz)) { - while (cxt->mcu_log_read_cnt < cxt->max_mcu_log_cnt && !prz) { - prz = ramoops_get_next_prz(cxt->mcu_przs, cxt->mcu_log_read_cnt++, record); + while (cxt->boot_log_read_cnt < cxt->max_boot_log_cnt && !prz) { + prz = ramoops_get_next_prz(cxt->boot_przs, cxt->boot_log_read_cnt++, record); if (!prz_ok(prz)) continue; } @@ -305,8 +305,8 @@ static ssize_t ramoops_pstore_read(struct pstore_record *record) goto out; } -#ifdef CONFIG_PSTORE_MCU_LOG - if (record->type == PSTORE_TYPE_MCU_LOG) { +#ifdef CONFIG_PSTORE_BOOT_LOG + if (record->type == PSTORE_TYPE_BOOT_LOG) { persistent_ram_free_old(prz); persistent_ram_save_old(prz); } @@ -517,13 +517,13 @@ static void ramoops_free_przs(struct ramoops_context *cxt) kfree(cxt->fprzs); cxt->max_ftrace_cnt = 0; } -#ifdef CONFIG_PSTORE_MCU_LOG - /* Free mcu log PRZs */ - if (cxt->mcu_przs) { - for (i = 0; i < cxt->max_mcu_log_cnt; i++) - persistent_ram_free(cxt->mcu_przs[i]); - kfree(cxt->mcu_przs); - cxt->max_mcu_log_cnt = 0; +#ifdef CONFIG_PSTORE_BOOT_LOG + /* Free boot log PRZs */ + if (cxt->boot_przs) { + for (i = 0; i < cxt->max_boot_log_cnt; i++) + persistent_ram_free(cxt->boot_przs[i]); + kfree(cxt->boot_przs); + cxt->max_boot_log_cnt = 0; } #endif } @@ -745,9 +745,9 @@ static int ramoops_parse_dt(struct platform_device *pdev, parse_u32("ecc-size", pdata->ecc_info.ecc_size, 0); parse_u32("flags", pdata->flags, 0); parse_u32("max-reason", pdata->max_reason, pdata->max_reason); -#ifdef CONFIG_PSTORE_MCU_LOG - parse_u32("mcu-log-size", pdata->mcu_log_size, 0); - parse_u32("mcu-log-count", pdata->max_mcu_log_cnt, 0); +#ifdef CONFIG_PSTORE_BOOT_LOG + parse_u32("boot-log-size", pdata->boot_log_size, 0); + parse_u32("boot-log-count", pdata->max_boot_log_cnt, 0); #endif #undef parse_u32 @@ -810,9 +810,9 @@ static int ramoops_probe(struct platform_device *pdev) goto fail_out; } -#ifdef CONFIG_PSTORE_MCU_LOG +#ifdef CONFIG_PSTORE_BOOT_LOG if (!pdata->mem_size || (!pdata->record_size && !pdata->console_size && - !pdata->ftrace_size && !pdata->pmsg_size && !pdata->mcu_log_size)) { + !pdata->ftrace_size && !pdata->pmsg_size && !pdata->boot_log_size)) { pr_err("The memory size and the record/console size must be " "non-zero\n"); goto fail_out; @@ -846,18 +846,28 @@ static int ramoops_probe(struct platform_device *pdev) cxt->pmsg_size = pdata->pmsg_size; cxt->flags = pdata->flags; cxt->ecc_info = pdata->ecc_info; -#ifdef CONFIG_PSTORE_MCU_LOG - cxt->mcu_log_size = pdata->mcu_log_size; - cxt->max_mcu_log_cnt = pdata->max_mcu_log_cnt; +#ifdef CONFIG_PSTORE_BOOT_LOG + cxt->boot_log_size = pdata->boot_log_size; + cxt->max_boot_log_cnt = pdata->max_boot_log_cnt; #endif paddr = cxt->phys_addr; dump_mem_sz = cxt->size - cxt->console_size - cxt->ftrace_size - cxt->pmsg_size; +#ifdef CONFIG_PSTORE_BOOT_LOG + dump_mem_sz -= cxt->boot_log_size; +#endif -#ifdef CONFIG_PSTORE_MCU_LOG - dump_mem_sz -= cxt->mcu_log_size; +#ifdef CONFIG_PSTORE_BOOT_LOG + err = ramoops_init_przs("boot-log", dev, cxt, &cxt->boot_przs, &paddr, + cxt->boot_log_size, -1, + &cxt->max_boot_log_cnt, 0, 0); + if (err) + goto fail_clear; + if (cxt->boot_log_size > 0) + for (i = 0; i < cxt->max_boot_log_cnt; i++) + pr_info("boot-log-%d\t0x%zx@%pa\n", i, cxt->boot_przs[i]->size, &cxt->boot_przs[i]->paddr); #endif err = ramoops_init_przs("dmesg", dev, cxt, &cxt->dprzs, &paddr, @@ -897,17 +907,6 @@ static int ramoops_probe(struct platform_device *pdev) if (cxt->pmsg_size > 0) pr_info("pmsg\t0x%zx@%pa\n", cxt->mprz->size, &cxt->mprz->paddr); -#ifdef CONFIG_PSTORE_MCU_LOG - err = ramoops_init_przs("mcu-log", dev, cxt, &cxt->mcu_przs, &paddr, - cxt->mcu_log_size, -1, - &cxt->max_mcu_log_cnt, 0, 0); - if (err) - goto fail_clear; - if (cxt->mcu_log_size > 0) - for (i = 0; i < cxt->max_mcu_log_cnt; i++) - pr_info("mcu-log-%d\t0x%zx@%pa\n", i, cxt->mcu_przs[i]->size, &cxt->mcu_przs[i]->paddr); -#endif - cxt->pstore.data = cxt; /* * Prepare frontend flags based on which areas are initialized. @@ -926,9 +925,9 @@ static int ramoops_probe(struct platform_device *pdev) cxt->pstore.flags |= PSTORE_FLAGS_FTRACE; if (cxt->pmsg_size) cxt->pstore.flags |= PSTORE_FLAGS_PMSG; -#ifdef CONFIG_PSTORE_MCU_LOG - if (cxt->mcu_log_size) - cxt->pstore.flags |= PSTORE_FLAGS_MCU_LOG; +#ifdef CONFIG_PSTORE_BOOT_LOG + if (cxt->boot_log_size) + cxt->pstore.flags |= PSTORE_FLAGS_BOOT_LOG; #endif /* diff --git a/include/linux/pstore.h b/include/linux/pstore.h index 2aac7a063196..3029c7f571b8 100644 --- a/include/linux/pstore.h +++ b/include/linux/pstore.h @@ -38,8 +38,8 @@ enum pstore_type_id { PSTORE_TYPE_PPC_COMMON = 6, PSTORE_TYPE_PMSG = 7, PSTORE_TYPE_PPC_OPAL = 8, -#ifdef CONFIG_PSTORE_MCU_LOG - PSTORE_TYPE_MCU_LOG = 9, +#ifdef CONFIG_PSTORE_BOOT_LOG + PSTORE_TYPE_BOOT_LOG = 9, #endif /* End of the list */ @@ -205,8 +205,8 @@ struct pstore_info { #define PSTORE_FLAGS_CONSOLE BIT(1) #define PSTORE_FLAGS_FTRACE BIT(2) #define PSTORE_FLAGS_PMSG BIT(3) -#ifdef CONFIG_PSTORE_MCU_LOG -#define PSTORE_FLAGS_MCU_LOG BIT(4) +#ifdef CONFIG_PSTORE_BOOT_LOG +#define PSTORE_FLAGS_BOOT_LOG BIT(4) #endif extern int pstore_register(struct pstore_info *); diff --git a/include/linux/pstore_ram.h b/include/linux/pstore_ram.h index ff42d9a3fc90..ad7e88a34d60 100644 --- a/include/linux/pstore_ram.h +++ b/include/linux/pstore_ram.h @@ -116,8 +116,8 @@ void *persistent_ram_old(struct persistent_ram_zone *prz); void persistent_ram_free_old(struct persistent_ram_zone *prz); ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz, char *str, size_t len); -#ifdef CONFIG_PSTORE_MCU_LOG -ssize_t ramoops_pstore_read_for_mcu_log(struct pstore_record *record); +#ifdef CONFIG_PSTORE_BOOT_LOG +ssize_t ramoops_pstore_read_for_boot_log(struct pstore_record *record); #endif /* @@ -136,9 +136,9 @@ struct ramoops_platform_data { unsigned long console_size; unsigned long ftrace_size; unsigned long pmsg_size; -#ifdef CONFIG_PSTORE_MCU_LOG - unsigned long mcu_log_size; - unsigned long max_mcu_log_cnt; +#ifdef CONFIG_PSTORE_BOOT_LOG + unsigned long boot_log_size; + unsigned long max_boot_log_cnt; #endif int max_reason; u32 flags;