|
@@ -1,6 +1,6 @@
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
|
// 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>
|
|
#include <linux/types.h>
|
|
@@ -154,6 +154,59 @@ int cam_packet_util_get_kmd_buffer(struct cam_packet *packet,
|
|
return rc;
|
|
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,
|
|
int cam_packet_util_process_patches(struct cam_packet *packet,
|
|
int32_t iommu_hdl, int32_t sec_mmu_hdl)
|
|
int32_t iommu_hdl, int32_t sec_mmu_hdl)
|
|
{
|
|
{
|