msm: camera: memmgr: Set name for dma buffer to help profiling
For dma buffer profiling,we don't konw the owner of one dma buffer. So we add it's name to show it's owner. If you use v1 struct to alloc/map dma buffer it will use default buffer name "UNKNOWN". For v2 struct you can set dma buffer name at UMD side. CRs-Fixed: 3131442 Change-Id: I24ce6aa1d97cd9fc26d9bd8796ab2367607008f6 Signed-off-by: Fengjie Chen <quic_fengjiec@quicinc.com>
这个提交包含在:

提交者
Camera Software Integration

父节点
2e6c254487
当前提交
cf223fa7b3
@@ -796,7 +796,7 @@ put_buf:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int cam_mem_util_check_alloc_flags(struct cam_mem_mgr_alloc_cmd *cmd)
|
||||
static int cam_mem_util_check_alloc_flags(struct cam_mem_mgr_alloc_cmd_v2 *cmd)
|
||||
{
|
||||
if (cmd->num_hdl > CAM_MEM_MMU_MAX_HANDLE) {
|
||||
CAM_ERR(CAM_MEM, "Num of mmu hdl exceeded maximum(%d)",
|
||||
@@ -820,7 +820,7 @@ static int cam_mem_util_check_alloc_flags(struct cam_mem_mgr_alloc_cmd *cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cam_mem_util_check_map_flags(struct cam_mem_mgr_map_cmd *cmd)
|
||||
static int cam_mem_util_check_map_flags(struct cam_mem_mgr_map_cmd_v2 *cmd)
|
||||
{
|
||||
if (!cmd->flags) {
|
||||
CAM_ERR(CAM_MEM, "Invalid flags");
|
||||
@@ -911,7 +911,7 @@ multi_map_fail:
|
||||
return rc;
|
||||
}
|
||||
|
||||
int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd)
|
||||
int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd_v2 *cmd)
|
||||
{
|
||||
int rc;
|
||||
int32_t idx;
|
||||
@@ -971,6 +971,9 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd)
|
||||
goto slot_fail;
|
||||
}
|
||||
|
||||
if (cam_dma_buf_set_name(dmabuf, cmd->buf_name))
|
||||
CAM_ERR(CAM_MEM, "set dma buffer name(%s) failed", cmd->buf_name);
|
||||
|
||||
if ((cmd->flags & CAM_MEM_FLAG_HW_READ_WRITE) ||
|
||||
(cmd->flags & CAM_MEM_FLAG_HW_SHARED_ACCESS) ||
|
||||
(cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE)) {
|
||||
@@ -1049,9 +1052,9 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd)
|
||||
cmd->out.vaddr = 0;
|
||||
|
||||
CAM_DBG(CAM_MEM,
|
||||
"fd=%d, flags=0x%x, num_hdl=%d, idx=%d, buf handle=%x, len=%zu, i_ino=%lu",
|
||||
"fd=%d, flags=0x%x, num_hdl=%d, idx=%d, buf handle=%x, len=%zu, i_ino=%lu, name:%s",
|
||||
cmd->out.fd, cmd->flags, cmd->num_hdl, idx, cmd->out.buf_handle,
|
||||
tbl.bufq[idx].len, tbl.bufq[idx].i_ino);
|
||||
tbl.bufq[idx].len, tbl.bufq[idx].i_ino, cmd->buf_name);
|
||||
|
||||
return rc;
|
||||
|
||||
@@ -1081,7 +1084,7 @@ static bool cam_mem_util_is_map_internal(int32_t fd, unsigned i_ino)
|
||||
return is_internal;
|
||||
}
|
||||
|
||||
int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd)
|
||||
int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd_v2 *cmd)
|
||||
{
|
||||
int32_t idx;
|
||||
int rc;
|
||||
@@ -1131,6 +1134,9 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd)
|
||||
goto slot_fail;
|
||||
}
|
||||
|
||||
if (cam_dma_buf_set_name(dmabuf, cmd->buf_name))
|
||||
CAM_ERR(CAM_MEM, "set dma buffer name(%s) failed", cmd->buf_name);
|
||||
|
||||
if ((cmd->flags & CAM_MEM_FLAG_HW_READ_WRITE) ||
|
||||
(cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE)) {
|
||||
rc = cam_mem_util_map_hw_va(cmd->flags,
|
||||
@@ -1185,9 +1191,9 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd)
|
||||
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, i_ino=%lu",
|
||||
"fd=%d, flags=0x%x, num_hdl=%d, idx=%d, buf handle=%x, len=%zu, i_ino=%lu, name:%s",
|
||||
cmd->fd, cmd->flags, cmd->num_hdl, idx, cmd->out.buf_handle,
|
||||
tbl.bufq[idx].len, tbl.bufq[idx].i_ino);
|
||||
tbl.bufq[idx].len, tbl.bufq[idx].i_ino, cmd->buf_name);
|
||||
|
||||
return rc;
|
||||
map_fail:
|
||||
|
@@ -139,7 +139,7 @@ struct cam_mem_table_mini_dump {
|
||||
*
|
||||
* @return Status of operation. Negative in case of error. Zero otherwise.
|
||||
*/
|
||||
int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd);
|
||||
int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd_v2 *cmd);
|
||||
|
||||
/**
|
||||
* @brief: Releases a buffer reference
|
||||
@@ -157,7 +157,7 @@ int cam_mem_mgr_release(struct cam_mem_mgr_release_cmd *cmd);
|
||||
*
|
||||
* @return Status of operation. Negative in case of error. Zero otherwise.
|
||||
*/
|
||||
int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd);
|
||||
int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd_v2 *cmd);
|
||||
|
||||
/**
|
||||
* @brief: Perform cache ops on the buffer
|
||||
|
@@ -493,6 +493,7 @@ static long cam_private_ioctl(struct file *file, void *fh,
|
||||
break;
|
||||
case CAM_REQ_MGR_ALLOC_BUF: {
|
||||
struct cam_mem_mgr_alloc_cmd cmd;
|
||||
struct cam_mem_mgr_alloc_cmd_v2 cmd_v2 = {0};
|
||||
|
||||
if (k_ioctl->size != sizeof(cmd))
|
||||
return -EINVAL;
|
||||
@@ -504,7 +505,16 @@ static long cam_private_ioctl(struct file *file, void *fh,
|
||||
break;
|
||||
}
|
||||
|
||||
rc = cam_mem_mgr_alloc_and_map(&cmd);
|
||||
strscpy(cmd_v2.buf_name, "UNKNOWN", CAM_DMA_BUF_NAME_LEN);
|
||||
memcpy(cmd_v2.mmu_hdls, cmd.mmu_hdls,
|
||||
sizeof(__s32) * CAM_MEM_MMU_MAX_HANDLE);
|
||||
cmd_v2.num_hdl = cmd.num_hdl;
|
||||
cmd_v2.flags = cmd.flags;
|
||||
cmd_v2.len = cmd.len;
|
||||
cmd_v2.align = cmd.align;
|
||||
|
||||
rc = cam_mem_mgr_alloc_and_map(&cmd_v2);
|
||||
memcpy(&cmd.out, &cmd_v2.out, sizeof(cmd.out));
|
||||
if (!rc)
|
||||
if (copy_to_user(
|
||||
u64_to_user_ptr(k_ioctl->handle),
|
||||
@@ -514,8 +524,32 @@ static long cam_private_ioctl(struct file *file, void *fh,
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CAM_REQ_MGR_ALLOC_BUF_V2: {
|
||||
struct cam_mem_mgr_alloc_cmd_v2 cmd;
|
||||
|
||||
if (k_ioctl->size != sizeof(cmd))
|
||||
return -EINVAL;
|
||||
|
||||
if (copy_from_user(&cmd,
|
||||
u64_to_user_ptr(k_ioctl->handle),
|
||||
sizeof(struct cam_mem_mgr_alloc_cmd_v2))) {
|
||||
rc = -EFAULT;
|
||||
break;
|
||||
}
|
||||
|
||||
rc = cam_mem_mgr_alloc_and_map(&cmd);
|
||||
if (!rc)
|
||||
if (copy_to_user(
|
||||
u64_to_user_ptr(k_ioctl->handle),
|
||||
&cmd, sizeof(struct cam_mem_mgr_alloc_cmd_v2))) {
|
||||
rc = -EFAULT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CAM_REQ_MGR_MAP_BUF: {
|
||||
struct cam_mem_mgr_map_cmd cmd;
|
||||
struct cam_mem_mgr_map_cmd_v2 cmd_v2 = {0};
|
||||
|
||||
if (k_ioctl->size != sizeof(cmd))
|
||||
return -EINVAL;
|
||||
@@ -527,7 +561,15 @@ static long cam_private_ioctl(struct file *file, void *fh,
|
||||
break;
|
||||
}
|
||||
|
||||
rc = cam_mem_mgr_map(&cmd);
|
||||
strscpy(cmd_v2.buf_name, "UNKNOWN", CAM_DMA_BUF_NAME_LEN);
|
||||
memcpy(cmd_v2.mmu_hdls, cmd.mmu_hdls,
|
||||
sizeof(__s32) * CAM_MEM_MMU_MAX_HANDLE);
|
||||
cmd_v2.num_hdl = cmd.num_hdl;
|
||||
cmd_v2.flags = cmd.flags;
|
||||
cmd_v2.fd = cmd.fd;
|
||||
|
||||
rc = cam_mem_mgr_map(&cmd_v2);
|
||||
memcpy(&cmd.out, &cmd_v2.out, sizeof(cmd.out));
|
||||
if (!rc)
|
||||
if (copy_to_user(
|
||||
u64_to_user_ptr(k_ioctl->handle),
|
||||
@@ -537,6 +579,29 @@ static long cam_private_ioctl(struct file *file, void *fh,
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CAM_REQ_MGR_MAP_BUF_V2: {
|
||||
struct cam_mem_mgr_map_cmd_v2 cmd;
|
||||
|
||||
if (k_ioctl->size != sizeof(cmd))
|
||||
return -EINVAL;
|
||||
|
||||
if (copy_from_user(&cmd,
|
||||
u64_to_user_ptr(k_ioctl->handle),
|
||||
sizeof(struct cam_mem_mgr_map_cmd_v2))) {
|
||||
rc = -EFAULT;
|
||||
break;
|
||||
}
|
||||
|
||||
rc = cam_mem_mgr_map(&cmd);
|
||||
if (!rc)
|
||||
if (copy_to_user(
|
||||
u64_to_user_ptr(k_ioctl->handle),
|
||||
&cmd, sizeof(struct cam_mem_mgr_map_cmd_v2))) {
|
||||
rc = -EFAULT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CAM_REQ_MGR_RELEASE_BUF: {
|
||||
struct cam_mem_mgr_release_cmd cmd;
|
||||
|
||||
|
在新工单中引用
屏蔽一个用户