瀏覽代碼

Merge "msm: camera: icp: Dump patching info in case of page faults" into camera-kernel.lnx.4.0

Camera Software Integration 5 年之前
父節點
當前提交
1598b6d0e8

+ 2 - 0
drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c

@@ -4690,6 +4690,8 @@ static void cam_icp_mgr_print_io_bufs(struct cam_packet *packet,
 
 		}
 	}
+	cam_packet_dump_patch_info(packet, icp_hw_mgr.iommu_hdl,
+		icp_hw_mgr.iommu_sec_hdl);
 }
 
 static int cam_icp_mgr_config_stream_settings(

+ 54 - 1
drivers/cam_utils/cam_packet_util.c

@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
  */
 
 #include <linux/types.h>
@@ -154,6 +154,59 @@ int cam_packet_util_get_kmd_buffer(struct cam_packet *packet,
 	return rc;
 }
 
+void cam_packet_dump_patch_info(struct cam_packet *packet,
+	int32_t iommu_hdl, int32_t sec_mmu_hdl)
+{
+	struct cam_patch_desc *patch_desc = NULL;
+	dma_addr_t iova_addr;
+	size_t     dst_buf_len;
+	size_t     src_buf_size;
+	int        i, rc = 0;
+	int32_t    hdl;
+	uintptr_t  cpu_addr = 0;
+	uint32_t  *dst_cpu_addr;
+	uint64_t   value = 0;
+
+	patch_desc = (struct cam_patch_desc *)
+			((uint32_t *) &packet->payload +
+			packet->patch_offset/4);
+
+	for (i = 0; i < packet->num_patches; i++) {
+		hdl = cam_mem_is_secure_buf(patch_desc[i].src_buf_hdl) ?
+			sec_mmu_hdl : iommu_hdl;
+		rc = cam_mem_get_io_buf(patch_desc[i].src_buf_hdl,
+			hdl, &iova_addr, &src_buf_size);
+		if (rc < 0) {
+			CAM_ERR(CAM_UTIL,
+				"unable to get src buf address for hdl 0x%x",
+				hdl);
+			return;
+		}
+
+		rc = cam_mem_get_cpu_buf(patch_desc[i].dst_buf_hdl,
+			&cpu_addr, &dst_buf_len);
+		if (rc < 0 || !cpu_addr || (dst_buf_len == 0)) {
+			CAM_ERR(CAM_UTIL, "unable to get dst buf address");
+			return;
+		}
+
+		dst_cpu_addr = (uint32_t *)cpu_addr;
+		dst_cpu_addr = (uint32_t *)((uint8_t *)dst_cpu_addr +
+			patch_desc[i].dst_offset);
+		value = *((uint64_t *)dst_cpu_addr);
+		CAM_INFO(CAM_UTIL,
+			"i = %d src_buf 0x%llx src_hdl 0x%x src_buf_with_offset 0x%llx size 0x%llx dst %p dst_offset %u dst_hdl 0x%x value 0x%llx",
+			i, iova_addr, patch_desc[i].src_buf_hdl,
+			(iova_addr + patch_desc[i].src_offset),
+			src_buf_size, dst_cpu_addr,
+			patch_desc[i].dst_offset,
+			patch_desc[i].dst_buf_hdl, value);
+
+		if (!(*dst_cpu_addr))
+			CAM_ERR(CAM_ICP, "Null at dst addr %p", dst_cpu_addr);
+	}
+}
+
 int cam_packet_util_process_patches(struct cam_packet *packet,
 	int32_t iommu_hdl, int32_t sec_mmu_hdl)
 {

+ 15 - 1
drivers/cam_utils/cam_packet_util.h

@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
  */
 
 #ifndef _CAM_PACKET_UTIL_H_
@@ -86,6 +86,20 @@ int cam_packet_util_validate_cmd_desc(struct cam_cmd_buf_desc *cmd_desc);
 int cam_packet_util_get_kmd_buffer(struct cam_packet *packet,
 	struct cam_kmd_buf_info *kmd_buf_info);
 
+/**
+ * cam_packet_dump_patch_info()
+ *
+ * @brief:              Dump patch info in case of page fault
+ *
+ * @packet:             Input packet containing Command Buffers and Patches
+ * @iommu_hdl:          IOMMU handle of the HW Device that received the packet
+ * @sec_iommu_hdl:      Secure IOMMU handle of the HW Device that
+ *                      received the packet
+ *
+ */
+void cam_packet_dump_patch_info(struct cam_packet *packet,
+	int32_t iommu_hdl, int32_t sec_mmu_hdl);
+
 /**
  * cam_packet_util_process_patches()
  *