فهرست منبع

msm: camera: memmgr: Add error handling get slot failure

Not calling unmap_hw_va if get_slot() fails causes a stale
entry in smmu CB. since get_slot failed, memmgr table
returns error and memmgr, umd doesn't keep info about this
map entry though smmu CB still has this mapping - This
causes any further map calls on the same 'fd' as smmu
return MAP_EXISTS but CSL bookkeeping doesn't have it.

CRs-Fixed: 2788167
Change-Id: Ibb1450f089b9f175ccdbcfb4f5ecc245a5539bd1
Signed-off-by: Pavan Kumar Chilamkurthi <[email protected]>
Pavan Kumar Chilamkurthi 4 سال پیش
والد
کامیت
58588fb689
1فایلهای تغییر یافته به همراه12 افزوده شده و 7 حذف شده
  1. 12 7
      drivers/cam_req_mgr/cam_mem_mgr.c

+ 12 - 7
drivers/cam_req_mgr/cam_mem_mgr.c

@@ -830,6 +830,14 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd)
 
 
 	is_internal = cam_mem_util_is_map_internal(cmd->fd);
 	is_internal = cam_mem_util_is_map_internal(cmd->fd);
 
 
+	idx = cam_mem_get_slot();
+	if (idx < 0) {
+		CAM_ERR(CAM_MEM, "Failed in getting mem slot, idx=%d, fd=%d",
+			idx, cmd->fd);
+		rc = -ENOMEM;
+		goto slot_fail;
+	}
+
 	if ((cmd->flags & CAM_MEM_FLAG_HW_READ_WRITE) ||
 	if ((cmd->flags & CAM_MEM_FLAG_HW_READ_WRITE) ||
 		(cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE)) {
 		(cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE)) {
 		rc = cam_mem_util_map_hw_va(cmd->flags,
 		rc = cam_mem_util_map_hw_va(cmd->flags,
@@ -855,12 +863,6 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd)
 		}
 		}
 	}
 	}
 
 
-	idx = cam_mem_get_slot();
-	if (idx < 0) {
-		rc = -ENOMEM;
-		goto map_fail;
-	}
-
 	mutex_lock(&tbl.bufq[idx].q_lock);
 	mutex_lock(&tbl.bufq[idx].q_lock);
 	tbl.bufq[idx].fd = cmd->fd;
 	tbl.bufq[idx].fd = cmd->fd;
 	tbl.bufq[idx].dma_buf = NULL;
 	tbl.bufq[idx].dma_buf = NULL;
@@ -893,8 +895,9 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd)
 		tbl.bufq[idx].len);
 		tbl.bufq[idx].len);
 
 
 	return rc;
 	return rc;
-
 map_fail:
 map_fail:
+	cam_mem_put_slot(idx);
+slot_fail:
 	dma_buf_put(dmabuf);
 	dma_buf_put(dmabuf);
 	return rc;
 	return rc;
 }
 }
@@ -1266,6 +1269,7 @@ int cam_mem_mgr_request_mem(struct cam_mem_mgr_request_desc *inp,
 
 
 	idx = cam_mem_get_slot();
 	idx = cam_mem_get_slot();
 	if (idx < 0) {
 	if (idx < 0) {
+		CAM_ERR(CAM_MEM, "Failed in getting mem slot, idx=%d", idx);
 		rc = -ENOMEM;
 		rc = -ENOMEM;
 		goto slot_fail;
 		goto slot_fail;
 	}
 	}
@@ -1414,6 +1418,7 @@ int cam_mem_mgr_reserve_memory_region(struct cam_mem_mgr_request_desc *inp,
 
 
 	idx = cam_mem_get_slot();
 	idx = cam_mem_get_slot();
 	if (idx < 0) {
 	if (idx < 0) {
+		CAM_ERR(CAM_MEM, "Failed in getting mem slot, idx=%d", idx);
 		rc = -ENOMEM;
 		rc = -ENOMEM;
 		goto slot_fail;
 		goto slot_fail;
 	}
 	}