Merge "msm: camera: smmu: Enhance debug capability for camera memmgr" into camera-kernel.lnx.4.0

此提交包含在:
Camera Software Integration
2020-06-18 17:19:03 -07:00
提交者 Gerrit - the friendly Code Review server
當前提交 5d4113257c
共有 4 個檔案被更改,包括 107 行新增21 行删除

查看文件

@@ -22,6 +22,39 @@
static struct cam_mem_table tbl;
static atomic_t cam_mem_mgr_state = ATOMIC_INIT(CAM_MEM_MGR_UNINITIALIZED);
static void cam_mem_mgr_print_tbl(void)
{
int i;
uint64_t ms, tmp, hrs, min, sec;
struct timespec64 *ts = NULL;
struct timespec64 current_ts;
ktime_get_real_ts64(&(current_ts));
tmp = current_ts.tv_sec;
ms = (current_ts.tv_nsec) / 1000000;
sec = do_div(tmp, 60);
min = do_div(tmp, 60);
hrs = do_div(tmp, 24);
CAM_INFO(CAM_MEM, "***%llu:%llu:%llu:%llu Mem mgr table dump***",
hrs, min, sec, ms);
for (i = 1; i < CAM_MEM_BUFQ_MAX; i++) {
if (tbl.bufq[i].active) {
ts = &tbl.bufq[i].timestamp;
tmp = ts->tv_sec;
ms = (ts->tv_nsec) / 1000000;
sec = do_div(tmp, 60);
min = do_div(tmp, 60);
hrs = do_div(tmp, 24);
CAM_INFO(CAM_MEM,
"%llu:%llu:%llu:%llu idx %d fd %d size %llu",
hrs, min, sec, ms, i, tbl.bufq[i].fd,
tbl.bufq[i].len);
}
}
}
static int cam_mem_util_get_dma_dir(uint32_t flags)
{
int rc = -EINVAL;
@@ -185,6 +218,7 @@ static int32_t cam_mem_get_slot(void)
set_bit(idx, tbl.bitmap);
tbl.bufq[idx].active = true;
ktime_get_real_ts64(&(tbl.bufq[idx].timestamp));
mutex_init(&tbl.bufq[idx].q_lock);
mutex_unlock(&tbl.m_lock);
@@ -197,6 +231,7 @@ static void cam_mem_put_slot(int32_t idx)
mutex_lock(&tbl.bufq[idx].q_lock);
tbl.bufq[idx].active = false;
tbl.bufq[idx].is_internal = false;
memset(&tbl.bufq[idx].timestamp, 0, sizeof(struct timespec64));
mutex_unlock(&tbl.bufq[idx].q_lock);
mutex_destroy(&tbl.bufq[idx].q_lock);
clear_bit(idx, tbl.bitmap);
@@ -646,6 +681,7 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd)
CAM_ERR(CAM_MEM,
"Ion Alloc failed, len=%llu, align=%llu, flags=0x%x, num_hdl=%d",
cmd->len, cmd->align, cmd->flags, cmd->num_hdl);
cam_mem_mgr_print_tbl();
return rc;
}
@@ -683,9 +719,14 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd)
if (rc) {
CAM_ERR(CAM_MEM,
"Failed in map_hw_va, len=%llu, flags=0x%x, fd=%d, region=%d, num_hdl=%d, rc=%d",
cmd->len, cmd->flags, fd, region,
cmd->num_hdl, rc);
"Failed in map_hw_va len=%llu, flags=0x%x, fd=%d, region=%d, num_hdl=%d, rc=%d",
len, cmd->flags,
fd, region, cmd->num_hdl, rc);
if (rc == -EALREADY) {
if ((size_t)dmabuf->size != len)
rc = -EBADR;
cam_mem_mgr_print_tbl();
}
goto map_hw_fail;
}
}
@@ -806,9 +847,15 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd)
is_internal);
if (rc) {
CAM_ERR(CAM_MEM,
"Failed in map_hw_va, flags=0x%x, fd=%d, region=%d, num_hdl=%d, rc=%d",
cmd->flags, cmd->fd, CAM_SMMU_REGION_IO,
cmd->num_hdl, rc);
"Failed in map_hw_va, flags=0x%x, fd=%d, len=%llu, region=%d, num_hdl=%d, rc=%d",
cmd->flags, cmd->fd, len,
CAM_SMMU_REGION_IO, cmd->num_hdl, rc);
if (rc == -EALREADY) {
if ((size_t)dmabuf->size != len) {
rc = -EBADR;
cam_mem_mgr_print_tbl();
}
}
goto map_fail;
}
}
@@ -844,7 +891,7 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd)
cmd->out.buf_handle = tbl.bufq[idx].buf_handle;
cmd->out.vaddr = 0;
cmd->out.size = (uint32_t)len;
CAM_DBG(CAM_MEM,
"fd=%d, flags=0x%x, num_hdl=%d, idx=%d, buf handle=%x, len=%zu",
cmd->fd, cmd->flags, cmd->num_hdl, idx, cmd->out.buf_handle,
@@ -1066,6 +1113,7 @@ static int cam_mem_util_unmap(int32_t idx,
tbl.bufq[idx].len = 0;
tbl.bufq[idx].num_hdl = 0;
tbl.bufq[idx].active = false;
memset(&tbl.bufq[idx].timestamp, 0, sizeof(struct timespec64));
mutex_unlock(&tbl.bufq[idx].q_lock);
mutex_destroy(&tbl.bufq[idx].q_lock);
clear_bit(idx, tbl.bitmap);

查看文件

@@ -42,6 +42,7 @@ enum cam_smmu_mapping_client {
* @active: state of the buffer
* @is_imported: Flag indicating if buffer is imported from an FD in user space
* @is_internal: Flag indicating kernel allocated buffer
* @timestamp: Timestamp at which this entry in tbl was made
*/
struct cam_mem_buf_queue {
struct dma_buf *dma_buf;
@@ -58,6 +59,7 @@ struct cam_mem_buf_queue {
bool active;
bool is_imported;
bool is_internal;
struct timespec64 timestamp;
};
/**