Преглед изворни кода

video: driver: more fw_coredump api

move fw_coredump api to firmware.c file.

Change-Id: Icbd5644244d4460bf918c1d137d19c04eb9f492a
Signed-off-by: Dikshita Agarwal <[email protected]>
Dikshita Agarwal пре 2 година
родитељ
комит
e9ebdcdbbe

+ 1 - 1
driver/vidc/inc/firmware.h

@@ -13,6 +13,6 @@ int fw_load(struct msm_vidc_core *core);
 int fw_unload(struct msm_vidc_core *core);
 int fw_suspend(struct msm_vidc_core *core);
 int fw_resume(struct msm_vidc_core *core);
-
+void fw_coredump(struct msm_vidc_core *core);
 
 #endif

+ 0 - 1
driver/vidc/inc/venus_hfi_response.h

@@ -19,7 +19,6 @@ bool is_valid_hfi_buffer_type(struct msm_vidc_inst *inst,
 	u32 buffer_type, const char *func);
 int handle_system_error(struct msm_vidc_core *core,
 	struct hfi_packet *pkt);
-void fw_coredump(struct msm_vidc_core *core);
 int handle_release_output_buffer(struct msm_vidc_inst *inst,
 	struct hfi_buffer *buffer);
 

+ 61 - 0
driver/vidc/src/firmware.c

@@ -5,6 +5,7 @@
 #include <linux/types.h>
 #include <linux/list.h>
 #include <linux/of_address.h>
+#include <linux/devcoredump.h>
 #include <linux/firmware.h>
 #include <linux/qcom_scm.h>
 #include <linux/soc/qcom/mdt_loader.h>
@@ -232,3 +233,63 @@ int fw_resume(struct msm_vidc_core *core)
 {
 	return qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_RESUME, 0);
 }
+
+void fw_coredump(struct msm_vidc_core *core)
+{
+	int rc = 0;
+	struct platform_device *pdev;
+	struct device_node *node = NULL;
+	struct resource res = {0};
+	phys_addr_t mem_phys = 0;
+	size_t res_size = 0;
+	void *mem_va = NULL;
+	char *data = NULL, *dump = NULL;
+	u64 total_size;
+
+	pdev = core->pdev;
+
+	node = of_parse_phandle(pdev->dev.of_node, "memory-region", 0);
+	if (!node) {
+		d_vpr_e("%s: DT error getting \"memory-region\" property\n",
+			__func__);
+		return;
+	}
+
+	rc = of_address_to_resource(node, 0, &res);
+	if (rc) {
+		d_vpr_e("%s: error %d while getting \"memory-region\" resource\n",
+			__func__, rc);
+		return;
+	}
+
+	mem_phys = res.start;
+	res_size = (size_t)resource_size(&res);
+
+	mem_va = memremap(mem_phys, res_size, MEMREMAP_WC);
+	if (!mem_va) {
+		d_vpr_e("%s: unable to remap firmware memory\n", __func__);
+		return;
+	}
+	total_size = res_size + TOTAL_QSIZE + ALIGNED_SFR_SIZE;
+
+	data = vmalloc(total_size);
+	if (!data) {
+		memunmap(mem_va);
+		return;
+	}
+	dump = data;
+
+	/* copy firmware dump */
+	memcpy(data, mem_va, res_size);
+	memunmap(mem_va);
+
+	/* copy queues(cmd, msg, dbg) dump(along with headers) */
+	data += res_size;
+	memcpy(data, (char *)core->iface_q_table.align_virtual_addr, TOTAL_QSIZE);
+
+	/* copy sfr dump */
+	data += TOTAL_QSIZE;
+	memcpy(data, (char *)core->sfr.align_virtual_addr, ALIGNED_SFR_SIZE);
+
+	dev_coredumpv(&pdev->dev, dump, total_size, GFP_KERNEL);
+}

+ 0 - 61
driver/vidc/src/venus_hfi_response.c

@@ -4,7 +4,6 @@
  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
-#include <linux/devcoredump.h>
 #include <linux/of_address.h>
 
 #include "hfi_packet.h"
@@ -379,66 +378,6 @@ static int handle_session_error(struct msm_vidc_inst *inst,
 	return rc;
 }
 
-void fw_coredump(struct msm_vidc_core *core)
-{
-	int rc = 0;
-	struct platform_device *pdev;
-	struct device_node *node = NULL;
-	struct resource res = {0};
-	phys_addr_t mem_phys = 0;
-	size_t res_size = 0;
-	void *mem_va = NULL;
-	char *data = NULL, *dump = NULL;
-	u64 total_size;
-
-	pdev = core->pdev;
-
-	node = of_parse_phandle(pdev->dev.of_node, "memory-region", 0);
-	if (!node) {
-		d_vpr_e("%s: DT error getting \"memory-region\" property\n",
-			__func__);
-		return;
-	}
-
-	rc = of_address_to_resource(node, 0, &res);
-	if (rc) {
-		d_vpr_e("%s: error %d while getting \"memory-region\" resource\n",
-			__func__, rc);
-		return;
-	}
-
-	mem_phys = res.start;
-	res_size = (size_t)resource_size(&res);
-
-	mem_va = memremap(mem_phys, res_size, MEMREMAP_WC);
-	if (!mem_va) {
-		d_vpr_e("%s: unable to remap firmware memory\n", __func__);
-		return;
-	}
-	total_size = res_size + TOTAL_QSIZE + ALIGNED_SFR_SIZE;
-
-	data = vmalloc(total_size);
-	if (!data) {
-		memunmap(mem_va);
-		return;
-	}
-	dump = data;
-
-	/* copy firmware dump */
-	memcpy(data, mem_va, res_size);
-	memunmap(mem_va);
-
-	/* copy queues(cmd, msg, dbg) dump(along with headers) */
-	data += res_size;
-	memcpy(data, (char *)core->iface_q_table.align_virtual_addr, TOTAL_QSIZE);
-
-	/* copy sfr dump */
-	data += TOTAL_QSIZE;
-	memcpy(data, (char *)core->sfr.align_virtual_addr, ALIGNED_SFR_SIZE);
-
-	dev_coredumpv(&pdev->dev, dump, total_size, GFP_KERNEL);
-}
-
 int handle_system_error(struct msm_vidc_core *core,
 	struct hfi_packet *pkt)
 {