Skip to contentSkip to conversation

venus: core: add support to dump FW region

PATCH Applied Dikshita Agarwal 3 participants 3 messages Dec 15, 2020 – Mar 1, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 venus: core: add support to dump FW region

Add support to dump video FW region during FW crash using devcoredump helpers.

Major changes since v1:
- update the name of function (Stephen)
- store start address and size in resource structure during probe and reuse while dumping (Stephen, Stanimir)

---
 drivers/media/platform/qcom/venus/core.c     | 30 ++++++++++++++++++++++++++++
 drivers/media/platform/qcom/venus/core.h     |  2 ++
 drivers/media/platform/qcom/venus/firmware.c |  3 +++
 3 files changed, 35 insertions(+)
drivers/media/platform/qcom/venus/core.c +30 -0
index bdd293f..1cc57ee 100644
@@ -7,6 +7,7 @@
 #include <linux/interconnect.h>
 #include <linux/ioctl.h>
 #include <linux/delay.h>
+#include <linux/devcoredump.h>
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
@@ -22,6 +23,33 @@
 #include "firmware.h"
 #include "pm_helpers.h"
 
+static void venus_coredump(struct venus_core *core)
+{
+	struct device *dev;
+	phys_addr_t mem_phys;
+	size_t mem_size;
+	void *mem_va;
+	void *data;
+
+	dev = core->dev;
+	mem_phys = core->fw.mem_phys;
+	mem_size = core->fw.mem_size;
+
+	mem_va = memremap(mem_phys, mem_size, MEMREMAP_WC);
+	if (!mem_va)
+		return;
+
+	data = vmalloc(mem_size);
+	if (!data) {
+		memunmap(mem_va);
+		return;
+	}
+
+	memcpy(data, mem_va, mem_size);
+	memunmap(mem_va);
+	dev_coredumpv(dev, data, mem_size, GFP_KERNEL);
+}
+
 static void venus_event_notify(struct venus_core *core, u32 event)
 {
 	struct venus_inst *inst;
@@ -67,6 +95,8 @@ static void venus_sys_error_handler(struct work_struct *work)
 
 	venus_shutdown(core);
 
+	venus_coredump(core);
+
 	pm_runtime_put_sync(core->dev);
 
 	while (core->pmdomains[0] && pm_runtime_active(core->pmdomains[0]))
drivers/media/platform/qcom/venus/core.h +2 -0
index 3a477fc..b37de95 100644
@@ -178,6 +178,8 @@ struct venus_core {
 		struct device *dev;
 		struct iommu_domain *iommu_domain;
 		size_t mapped_mem_size;
+		phys_addr_t mem_phys;
+		size_t mem_size;
 	} fw;
 	struct mutex lock;
 	struct list_head instances;
drivers/media/platform/qcom/venus/firmware.c +3 -0
index d03e2dd..89defc2 100644
@@ -201,6 +201,9 @@ int venus_boot(struct venus_core *core)
 		return -EINVAL;
 	}
 
+	core->fw.mem_size = mem_size;
+	core->fw.mem_phys = mem_phys;
+
 	if (core->use_tz)
 		ret = qcom_scm_pas_auth_and_reset(VENUS_PAS_ID);
 	else
Signature · 1 line
2.7.4
#1 lore raw

Quoting Dikshita Agarwal (2020-12-15 10:08:36)

Quoted 7 lines

Add support to dump video FW region during FW crash using devcoredump helpers.

Quoted 5 lines

Major changes since v1:
- update the name of function (Stephen)
- store start address and size in resource structure during probe and reuse while dumping (Stephen, Stanimir)
---

Can this be picked up for the next merge window?

#2 lore raw
In reply to Dikshita Agarwal
This patch was applied to qcom/linux.git (refs/heads/for-next):

Hello:

This patch was applied to qcom/linux.git (refs/heads/for-next):

Quoted 8 lines · On Tue, 15 Dec 2020 23:38:36 +0530 you wrote:

Add support to dump video FW region during FW crash using devcoredump helpers.

[...]

Here is the summary with links:
- [v5] venus: core: add support to dump FW region

    https://git.kernel.org/qcom/c/0ca0ca980505

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html