Register ramoops region with APSS minidump so that these region gets captured on system crash. Signed-off-by: Mukesh Ojha <quic_mojha@xxxxxxxxxxx> --- drivers/soc/qcom/qcom_minidump.c | 62 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c index c0f76a51d0e8..9a39b68903fb 100644 --- a/drivers/soc/qcom/qcom_minidump.c +++ b/drivers/soc/qcom/qcom_minidump.c @@ -18,8 +18,10 @@ #include <linux/mutex.h> #include <linux/platform_device.h> #include <linux/printk.h> +#include <linux/pstore_ram.h> #include <linux/soc/qcom/smem.h> #include <linux/string.h> +#include <linux/workqueue.h> #include <soc/qcom/qcom_minidump.h> #include "qcom_minidump_internal.h" @@ -56,12 +58,20 @@ struct minidump_elfhdr { * @dev: Minidump backend device * @apss_data: APSS driver data * @md_lock: Lock to protect access to APSS minidump table + * @work: Minidump work for any required execution in process context. */ struct minidump { struct minidump_elfhdr elf; struct device *dev; struct minidump_ss_data *apss_data; struct mutex md_lock; + struct work_struct work; +}; + +static LIST_HEAD(apss_md_rlist); +struct md_region_list { + struct qcom_minidump_region md_region; + struct list_head list; }; /* @@ -530,6 +540,52 @@ static int qcom_apss_md_table_init(struct minidump *md, return 0; } +static int ramoops_region_md_register(const char *name, int id, void *vaddr, + phys_addr_t paddr, size_t size) +{ + struct qcom_minidump_region *md_region; + struct md_region_list *mdr_list; + int ret; + + mdr_list = kzalloc(sizeof(*mdr_list), GFP_KERNEL); + if (!mdr_list) + return -ENOMEM; + + md_region = &mdr_list->md_region; + scnprintf(md_region->name, sizeof(md_region->name), "K%s%d", name, id); + md_region->virt_addr = vaddr; + md_region->phys_addr = paddr; + md_region->size = size; + ret = qcom_minidump_region_register(md_region); + if (ret < 0) { + pr_err("failed to register region in minidump: err: %d\n", ret); + return ret; + } + + list_add(&mdr_list->list, &apss_md_rlist); + + return 0; +} + +static void ramoops_register_md_callback(struct work_struct *work) +{ + register_ramoops_ready_notifier(ramoops_region_md_register); +} + +static void qcom_ramoops_minidump_unregister(void) +{ + struct md_region_list *mdr_list; + struct md_region_list *tmp; + + list_for_each_entry_safe(mdr_list, tmp, &apss_md_rlist, list) { + struct qcom_minidump_region *region; + + region = &mdr_list->md_region; + qcom_minidump_region_unregister(region); + list_del(&mdr_list->list); + } +} + static void qcom_apss_md_table_exit(struct minidump_ss_data *mdss_data) { memset(mdss_data->md_ss_toc, cpu_to_le32(0), sizeof(*mdss_data->md_ss_toc)); @@ -575,6 +631,9 @@ static int qcom_apss_minidump_probe(struct platform_device *pdev) platform_set_drvdata(pdev, md); + INIT_WORK(&md->work, ramoops_register_md_callback); + schedule_work(&md->work); + return ret; } @@ -582,6 +641,9 @@ static void qcom_apss_minidump_remove(struct platform_device *pdev) { struct minidump *md = platform_get_drvdata(pdev); + flush_work(&md->work); + qcom_ramoops_minidump_unregister(); + unregister_ramoops_ready_notifier(ramoops_region_md_register); qcom_apss_md_table_exit(md->apss_data); } -- 2.7.4