From 704131249234f845fc6aa2fb93b46179e40adfcd Mon Sep 17 00:00:00 2001 From: Jeya R Date: Fri, 27 Nov 2020 19:54:34 +0530 Subject: [PATCH] ADSPRPC: Enable ram dumps collection Enabled ram dump collection for CMA memory that is used for remote heap and dynamic loading memory. Change-Id: I07fe071ee90b39204822aee368b52b7e63b5600d Acked-by: Krishnaiah Tadakamalla Signed-off-by: Jeya R Signed-off-by: Vamsi krishna Gattupalli --- drivers/char/adsprpc.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/char/adsprpc.c b/drivers/char/adsprpc.c index f31e1441fd6d..b273cb3b82d6 100644 --- a/drivers/char/adsprpc.c +++ b/drivers/char/adsprpc.c @@ -500,6 +500,8 @@ struct fastrpc_apps { uint32_t duplicate_rsp_err_cnt; struct qos_cores silvercores; uint32_t max_size_limit; + void *ramdump_handle; + bool enable_ramdump; }; struct fastrpc_mmap { @@ -4270,7 +4272,7 @@ static int fastrpc_mmap_remove_ssr(struct fastrpc_file *fl) match->size, match->flags); if (err) goto bail; - if (me->channel[RH_CID].ramdumpenabled) { + if (me->ramdump_handle && me->enable_ramdump) { ramdump_segments_rh = kcalloc(1, sizeof(struct ramdump_segment), GFP_KERNEL); if (ramdump_segments_rh) { @@ -4278,8 +4280,8 @@ static int fastrpc_mmap_remove_ssr(struct fastrpc_file *fl) match->phys; ramdump_segments_rh->size = match->size; ret = do_elf_ramdump( - me->channel[RH_CID].rh_dump_dev, - ramdump_segments_rh, 1); + me->ramdump_handle, + ramdump_segments_rh, 1); if (ret < 0) pr_err("adsprpc: %s: unable to dump heap (err %d)\n", __func__, ret); @@ -4289,6 +4291,7 @@ static int fastrpc_mmap_remove_ssr(struct fastrpc_file *fl) fastrpc_mmap_free(match, 0); } } while (match); + me->enable_ramdump = false; bail: if (err && match) fastrpc_mmap_add(match); @@ -5976,13 +5979,19 @@ static int fastrpc_restart_notifier_cb(struct notifier_block *nb, mutex_unlock(&me->channel[cid].smd_mutex); } else if (code == SUBSYS_RAMDUMP_NOTIFICATION) { if (cid == RH_CID) { - if (me->channel[RH_CID].rh_dump_dev && - notifdata->enable_ramdump) { + if (me->ramdump_handle) me->channel[RH_CID].ramdumpenabled = 1; - } } pr_info("adsprpc: %s: received RAMDUMP notification for %s\n", __func__, gcinfo[cid].subsys); + } else if (code == SUBSYS_BEFORE_POWERUP) { + if (cid == RH_CID && notifdata->enable_ramdump) { + if (me->ramdump_handle && me->channel[RH_CID] + .ramdumpenabled) { + me->enable_ramdump = true; + me->channel[RH_CID].ramdumpenabled = 0; + } + } } else if (code == SUBSYS_AFTER_POWERUP) { pr_info("adsprpc: %s: %s subsystem is up\n", __func__, gcinfo[cid].subsys); @@ -6014,14 +6023,19 @@ static int fastrpc_pdr_notifier_cb(struct notifier_block *pdrnb, fastrpc_notify_pdr_drivers(me, spd->servloc_name); } else if (code == SUBSYS_RAMDUMP_NOTIFICATION) { if (spd->cid == RH_CID) { - if (me->channel[RH_CID].rh_dump_dev && - notifdata->enable_ramdump) { + if (spd->cid == RH_CID && me->ramdump_handle) me->channel[RH_CID].ramdumpenabled = 1; - } } pr_info("adsprpc: %s: received %s RAMDUMP notification for %s (%s)\n", __func__, gcinfo[spd->cid].subsys, spd->spdname, spd->servloc_name); + } else if (code == SUBSYS_BEFORE_POWERUP) { + if (spd->cid == RH_CID && notifdata->enable_ramdump) { + if (me->ramdump_handle && me->channel[RH_CID] + .ramdumpenabled) + me->enable_ramdump = true; + me->channel[RH_CID].ramdumpenabled = 0; + } } else if (code == SERVREG_NOTIF_SERVICE_STATE_UP_V01) { pr_info("adsprpc: %s: %s (%s) is up on %s\n", __func__, spd->spdname, spd->servloc_name, @@ -6422,6 +6436,7 @@ static int fastrpc_probe(struct platform_device *pdev) pr_warn("adsprpc: Error: %s: initialization of memory region adsp_mem failed with %d\n", __func__, ret); } + me->ramdump_handle = create_ramdump_device("adsp_rh", &pdev->dev); goto bail; } me->legacy_remote_heap = of_property_read_bool(dev->of_node,