Browse Source

msm: camera: common: fix map check failure for presil buffer send

Add correct way to check if buffer can be sent to hw in below cases.
1. buffer handle mapped twice, resulting into two entries in buf_q.
   One entry without smmu mapping and one with smmu mapping.
   fixed by checking if another entry with smmu map exists for i_no.
2. blob cmd buffer, packet buffer are shared only between umd and kmd.
   send_buffer_to_presil expected to be called and return success.

CRs-Fixed: 2932495
Change-Id: I2dd884b7dd16c5c45d3dfc25380d039b92199319
Signed-off-by: Suraj Dongre <[email protected]>
Suraj Dongre 3 năm trước cách đây
mục cha
commit
0fe49d5aa7
1 tập tin đã thay đổi với 23 bổ sung4 xóa
  1. 23 4
      drivers/cam_req_mgr/cam_mem_mgr.c

+ 23 - 4
drivers/cam_req_mgr/cam_mem_mgr.c

@@ -1946,12 +1946,11 @@ int cam_mem_mgr_send_buffer_to_presil(int32_t iommu_hdl, int32_t buf_handle)
 	/* Sending Presil IO Buf to PC side ( as iova start address indicates) */
 	uint64_t io_buf_addr;
 	size_t io_buf_size;
-	int i, fd = -1, idx = 0;
+	int i, j, fd = -1, idx = 0;
 	uint8_t *iova_ptr = NULL;
 	uint64_t dmabuf = 0;
 	bool is_mapped_in_cb = false;
 
-
 	CAM_DBG(CAM_PRESIL, "buf handle 0x%0x", buf_handle);
 
 	idx = CAM_MEM_MGR_GET_HDL_IDX(buf_handle);
@@ -1960,8 +1959,28 @@ int cam_mem_mgr_send_buffer_to_presil(int32_t iommu_hdl, int32_t buf_handle)
 			is_mapped_in_cb = true;
 	}
 
-	if (!is_mapped_in_cb)
-		return 0;
+	if (!is_mapped_in_cb) {
+		for (j = 0; j < CAM_MEM_BUFQ_MAX; j++) {
+			if (tbl.bufq[j].i_ino == tbl.bufq[idx].i_ino) {
+				for (i = 0; i < tbl.bufq[j].num_hdl; i++) {
+					if (tbl.bufq[j].hdls[i] == iommu_hdl)
+						is_mapped_in_cb = true;
+				}
+			}
+		}
+
+		if (!is_mapped_in_cb) {
+			CAM_DBG(CAM_PRESIL,
+				"Still Could not find idx=%d, FD %d buf_handle 0x%0x",
+				idx, GET_FD_FROM_HANDLE(buf_handle), buf_handle);
+
+			/*
+			 * Okay to return 0, since this function also gets called for buffers that
+			 * are shared only between umd/kmd, these may not be mapped with smmu
+			 */
+			return 0;
+		}
+	}
 
 	if ((tbl.bufq[idx].buf_handle != 0) && (tbl.bufq[idx].active) &&
 		(tbl.bufq[idx].buf_handle == buf_handle)) {