Loading drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.c +60 −24 Original line number Diff line number Diff line Loading @@ -386,7 +386,7 @@ static int cam_mem_util_get_dma_buf_fd(size_t len, int rc = 0; if (!buf || !fd) { CAM_ERR(CAM_MEM, "Invalid params"); CAM_ERR(CAM_MEM, "Invalid params, buf=%pK, fd=%pK", buf, fd); return -EINVAL; } Loading @@ -396,7 +396,7 @@ static int cam_mem_util_get_dma_buf_fd(size_t len, *fd = dma_buf_fd(*buf, O_CLOEXEC); if (*fd < 0) { CAM_ERR(CAM_MEM, "get fd fail"); CAM_ERR(CAM_MEM, "get fd fail, *fd=%d", *fd); rc = -EINVAL; goto get_fd_fail; } Loading Loading @@ -472,14 +472,16 @@ static int cam_mem_util_check_map_flags(struct cam_mem_mgr_map_cmd *cmd) } if (cmd->num_hdl > CAM_MEM_MMU_MAX_HANDLE) { CAM_ERR(CAM_MEM, "Num of mmu hdl exceeded maximum(%d)", CAM_MEM_MMU_MAX_HANDLE); CAM_ERR(CAM_MEM, "Num of mmu hdl %d exceeded maximum(%d)", cmd->num_hdl, CAM_MEM_MMU_MAX_HANDLE); return -EINVAL; } if (cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE && cmd->flags & CAM_MEM_FLAG_KMD_ACCESS) { CAM_ERR(CAM_MEM, "Kernel mapping in secure mode not allowed"); CAM_ERR(CAM_MEM, "Kernel mapping in secure mode not allowed, flags=0x%x", cmd->flags); return -EINVAL; } Loading @@ -505,12 +507,13 @@ static int cam_mem_util_map_hw_va(uint32_t flags, int dir = cam_mem_util_get_dma_dir(flags); if (dir < 0) { CAM_ERR(CAM_MEM, "fail to map DMA direction"); CAM_ERR(CAM_MEM, "fail to map DMA direction, dir=%d", dir); return dir; } CAM_DBG(CAM_MEM, "map_hw_va : flags = %x, dir=%d, num_hdls=%d", flags, dir, num_hdls); CAM_DBG(CAM_MEM, "map_hw_va : fd = %d, flags = 0x%x, dir=%d, num_hdls=%d", fd, flags, dir, num_hdls); if (flags & CAM_MEM_FLAG_PROTECTED_MODE) { for (i = 0; i < num_hdls; i++) { Loading @@ -522,7 +525,8 @@ static int cam_mem_util_map_hw_va(uint32_t flags, if (rc < 0) { CAM_ERR(CAM_MEM, "Failed to securely map to smmu"); "Failed to securely map to smmu, i=%d, fd=%d, dir=%d, mmu_hdl=%d, rc=%d", i, fd, dir, mmu_hdls[i], rc); goto multi_map_fail; } } Loading @@ -536,7 +540,9 @@ static int cam_mem_util_map_hw_va(uint32_t flags, region); if (rc < 0) { CAM_ERR(CAM_MEM, "Failed to map to smmu"); CAM_ERR(CAM_MEM, "Failed to map to smmu, i=%d, fd=%d, dir=%d, mmu_hdl=%d, region=%d, rc=%d", i, fd, dir, mmu_hdls[i], region, rc); goto multi_map_fail; } } Loading Loading @@ -573,7 +579,8 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd) rc = cam_mem_util_check_alloc_flags(cmd); if (rc) { CAM_ERR(CAM_MEM, "Invalid flags: flags = %X", cmd->flags); CAM_ERR(CAM_MEM, "Invalid flags: flags = 0x%X, rc=%d", cmd->flags, rc); return rc; } Loading @@ -581,12 +588,15 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd) &dmabuf, &fd); if (rc) { CAM_ERR(CAM_MEM, "Ion allocation failed"); 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); return rc; } idx = cam_mem_get_slot(); if (idx < 0) { CAM_ERR(CAM_MEM, "Failed in getting mem slot, idx=%d", idx); rc = -ENOMEM; goto slot_fail; } Loading @@ -613,7 +623,9 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd) region); if (rc) { CAM_ERR(CAM_MEM, "Failed in map_hw_va, rc=%d", rc); CAM_ERR(CAM_MEM, "Failed in map_hw_va, flags=0x%x, fd=%d, region=%d, num_hdl=%d, rc=%d", cmd->flags, fd, region, cmd->num_hdl, rc); goto map_hw_fail; } } Loading Loading @@ -644,8 +656,9 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd) cmd->out.fd = tbl.bufq[idx].fd; cmd->out.vaddr = 0; CAM_DBG(CAM_MEM, "buf handle: %x, fd: %d, len: %zu", cmd->out.buf_handle, cmd->out.fd, CAM_DBG(CAM_MEM, "fd=%d, flags=0x%x, num_hdl=%d, idx=%d, buf handle=%x, len=%zu", cmd->out.fd, cmd->flags, cmd->num_hdl, idx, cmd->out.buf_handle, tbl.bufq[idx].len); return rc; Loading @@ -670,8 +683,11 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd) return -EINVAL; } if (cmd->num_hdl > CAM_MEM_MMU_MAX_HANDLE) if (cmd->num_hdl > CAM_MEM_MMU_MAX_HANDLE) { CAM_ERR(CAM_MEM, "Num of mmu hdl %d exceeded maximum(%d)", cmd->num_hdl, CAM_MEM_MMU_MAX_HANDLE); return -EINVAL; } rc = cam_mem_util_check_map_flags(cmd); if (rc) { Loading @@ -694,9 +710,14 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd) &hw_vaddr, &len, CAM_SMMU_REGION_IO); if (rc) 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); goto map_fail; } } idx = cam_mem_get_slot(); if (idx < 0) { Loading Loading @@ -729,6 +750,11 @@ 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; 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, tbl.bufq[idx].len); return rc; map_fail: Loading Loading @@ -758,15 +784,19 @@ static int cam_mem_util_unmap_hw_va(int32_t idx, fd = tbl.bufq[idx].fd; CAM_DBG(CAM_MEM, "unmap_hw_va : fd=%x, flags=0x%x, num_hdls=%d, client=%d", fd, flags, num_hdls, client); "unmap_hw_va : idx=%d, fd=%x, flags=0x%x, num_hdls=%d, client=%d", idx, fd, flags, num_hdls, client); if (flags & CAM_MEM_FLAG_PROTECTED_MODE) { for (i = 0; i < num_hdls; i++) { rc = cam_smmu_unmap_stage2_iova(mmu_hdls[i], fd); if (rc < 0) if (rc < 0) { CAM_ERR(CAM_MEM, "Failed in secure unmap, i=%d, fd=%d, mmu_hdl=%d, rc=%d", i, fd, mmu_hdls[i], rc); goto unmap_end; } } } else { for (i = 0; i < num_hdls; i++) { if (client == CAM_SMMU_MAPPING_USER) { Loading @@ -781,10 +811,14 @@ static int cam_mem_util_unmap_hw_va(int32_t idx, client); rc = -EINVAL; } if (rc < 0) if (rc < 0) { CAM_ERR(CAM_MEM, "Failed in unmap, i=%d, fd=%d, mmu_hdl=%d, region=%d, rc=%d", i, fd, mmu_hdls[i], region, rc); goto unmap_end; } } } return rc; Loading Loading @@ -954,7 +988,8 @@ int cam_mem_mgr_release(struct cam_mem_mgr_release_cmd *cmd) idx = CAM_MEM_MGR_GET_HDL_IDX(cmd->buf_handle); if (idx >= CAM_MEM_BUFQ_MAX || idx <= 0) { CAM_ERR(CAM_MEM, "Incorrect index extracted from mem handle"); CAM_ERR(CAM_MEM, "Incorrect index %d extracted from mem handle", idx); return -EINVAL; } Loading @@ -965,11 +1000,12 @@ int cam_mem_mgr_release(struct cam_mem_mgr_release_cmd *cmd) if (tbl.bufq[idx].buf_handle != cmd->buf_handle) { CAM_ERR(CAM_MEM, "Released buf handle not matching within table"); "Released buf handle %d not matching within table %d, idx=%d", cmd->buf_handle, tbl.bufq[idx].buf_handle, idx); return -EINVAL; } CAM_DBG(CAM_MEM, "Releasing hdl = %x", cmd->buf_handle); CAM_DBG(CAM_MEM, "Releasing hdl = %x, idx = %d", cmd->buf_handle, idx); rc = cam_mem_util_unmap(idx, CAM_SMMU_MAPPING_USER); return rc; Loading drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.c +39 −21 Original line number Diff line number Diff line Loading @@ -1580,7 +1580,9 @@ static int cam_smmu_map_buffer_validate(struct dma_buf *buf, if (rc < 0) { CAM_ERR(CAM_SMMU, "IOVA alloc failed for shared memory"); "IOVA alloc failed for shared memory, size=%zu, idx=%d, handle=%d", *len_ptr, idx, iommu_cb_set.cb_info[idx].handle); goto err_unmap_sg; } Loading @@ -1596,7 +1598,9 @@ static int cam_smmu_map_buffer_validate(struct dma_buf *buf, rc = -ENOMEM; goto err_unmap_sg; } else { CAM_DBG(CAM_SMMU, "iommu_map_sg returned %zu", size); CAM_DBG(CAM_SMMU, "iommu_map_sg returned iova=%pK, size=%zu", iova, size); *paddr_ptr = iova; *len_ptr = size; } Loading @@ -1618,8 +1622,8 @@ static int cam_smmu_map_buffer_validate(struct dma_buf *buf, goto err_unmap_sg; } CAM_DBG(CAM_SMMU, "region_id=%d, paddr=%pK, len=%d", region_id, *paddr_ptr, *len_ptr); CAM_DBG(CAM_SMMU, "iova=%pK, region_id=%d, paddr=%pK, len=%d", iova, region_id, *paddr_ptr, *len_ptr); if (table->sgl) { CAM_DBG(CAM_SMMU, Loading Loading @@ -1655,11 +1659,12 @@ static int cam_smmu_map_buffer_validate(struct dma_buf *buf, if (!*paddr_ptr || !*len_ptr) { CAM_ERR(CAM_SMMU, "Error: Space Allocation failed"); kfree(*mapping_info); *mapping_info = NULL; rc = -ENOSPC; goto err_alloc; } CAM_DBG(CAM_SMMU, "dma_buf = %pK, dev = %pK, paddr= %pK, len = %u", buf, (void *)iommu_cb_set.cb_info[idx].dev, CAM_DBG(CAM_SMMU, "idx=%d, dma_buf=%pK, dev=%pK, paddr=%pK, len=%u", idx, buf, (void *)iommu_cb_set.cb_info[idx].dev, (void *)*paddr_ptr, (unsigned int)*len_ptr); return 0; Loading Loading @@ -2253,7 +2258,9 @@ static int cam_smmu_map_stage2_buffer_and_add_to_list(int idx, int ion_fd, dmabuf = dma_buf_get(ion_fd); if (IS_ERR_OR_NULL((void *)(dmabuf))) { CAM_ERR(CAM_SMMU, "Error: dma buf get failed"); CAM_ERR(CAM_SMMU, "Error: dma buf get failed, idx=%d, ion_fd=%d", idx, ion_fd); rc = PTR_ERR(dmabuf); goto err_out; } Loading @@ -2265,7 +2272,9 @@ static int cam_smmu_map_stage2_buffer_and_add_to_list(int idx, int ion_fd, */ attach = dma_buf_attach(dmabuf, iommu_cb_set.cb_info[idx].dev); if (IS_ERR_OR_NULL(attach)) { CAM_ERR(CAM_SMMU, "Error: dma buf attach failed"); CAM_ERR(CAM_SMMU, "Error: dma buf attach failed, idx=%d, ion_fd=%d", idx, ion_fd); rc = PTR_ERR(attach); goto err_put; } Loading Loading @@ -2297,8 +2306,8 @@ static int cam_smmu_map_stage2_buffer_and_add_to_list(int idx, int ion_fd, mapping_info->ref_count = 1; mapping_info->buf = dmabuf; CAM_DBG(CAM_SMMU, "ion_fd = %d, dev = %pK, paddr= %pK, len = %u", ion_fd, CAM_DBG(CAM_SMMU, "idx=%d, ion_fd=%d, dev=%pK, paddr=%pK, len=%u", idx, ion_fd, (void *)iommu_cb_set.cb_info[idx].dev, (void *)*paddr_ptr, (unsigned int)*len_ptr); Loading Loading @@ -2354,15 +2363,16 @@ int cam_smmu_map_stage2_iova(int handle, if (!iommu_cb_set.cb_info[idx].is_secure) { CAM_ERR(CAM_SMMU, "Error: can't map secure mem to non secure cb"); "Error: can't map secure mem to non secure cb, idx=%d", idx); return -EINVAL; } mutex_lock(&iommu_cb_set.cb_info[idx].lock); if (iommu_cb_set.cb_info[idx].handle != handle) { CAM_ERR(CAM_SMMU, "Error: hdl is not valid, table_hdl = %x, hdl = %x", iommu_cb_set.cb_info[idx].handle, handle); "Error: hdl is not valid, idx=%d, table_hdl=%x, hdl=%x", idx, iommu_cb_set.cb_info[idx].handle, handle); rc = -EINVAL; goto get_addr_end; } Loading @@ -2370,15 +2380,18 @@ int cam_smmu_map_stage2_iova(int handle, buf_state = cam_smmu_check_secure_fd_in_list(idx, ion_fd, paddr_ptr, len_ptr); if (buf_state == CAM_SMMU_BUFF_EXIST) { CAM_DBG(CAM_SMMU, "fd:%d already in list, give same addr back", ion_fd); CAM_DBG(CAM_SMMU, "fd:%d already in list idx:%d, handle=%d give same addr back", ion_fd, idx, handle); rc = 0; goto get_addr_end; } rc = cam_smmu_map_stage2_buffer_and_add_to_list(idx, ion_fd, dma_dir, paddr_ptr, len_ptr); if (rc < 0) { CAM_ERR(CAM_SMMU, "Error: mapping or add list fail"); CAM_ERR(CAM_SMMU, "Error: mapping or add list fail, idx=%d, handle=%d, fd=%d, rc=%d", idx, handle, ion_fd, rc); goto get_addr_end; } Loading Loading @@ -2519,14 +2532,16 @@ int cam_smmu_map_user_iova(int handle, int ion_fd, mutex_lock(&iommu_cb_set.cb_info[idx].lock); if (iommu_cb_set.cb_info[idx].is_secure) { CAM_ERR(CAM_SMMU, "Error: can't map non-secure mem to secure cb"); "Error: can't map non-secure mem to secure cb idx=%d", idx); rc = -EINVAL; goto get_addr_end; } if (iommu_cb_set.cb_info[idx].handle != handle) { CAM_ERR(CAM_SMMU, "hdl is not valid, table_hdl = %x, hdl = %x", iommu_cb_set.cb_info[idx].handle, handle); CAM_ERR(CAM_SMMU, "hdl is not valid, idx=%d, table_hdl = %x, hdl = %x", idx, iommu_cb_set.cb_info[idx].handle, handle); rc = -EINVAL; goto get_addr_end; } Loading @@ -2542,7 +2557,8 @@ int cam_smmu_map_user_iova(int handle, int ion_fd, buf_state = cam_smmu_check_fd_in_list(idx, ion_fd, paddr_ptr, len_ptr); if (buf_state == CAM_SMMU_BUFF_EXIST) { CAM_ERR(CAM_SMMU, "ion_fd: %d already in the list", ion_fd); "fd:%d already in list idx:%d, handle=%d, give same addr back", ion_fd, idx, handle); rc = -EALREADY; goto get_addr_end; } Loading @@ -2550,7 +2566,9 @@ int cam_smmu_map_user_iova(int handle, int ion_fd, rc = cam_smmu_map_buffer_and_add_to_list(idx, ion_fd, dma_dir, paddr_ptr, len_ptr, region_id); if (rc < 0) CAM_ERR(CAM_SMMU, "mapping or add list fail"); CAM_ERR(CAM_SMMU, "mapping or add list fail, idx=%d, fd=%d, region=%d, rc=%d", idx, ion_fd, region_id, rc); get_addr_end: mutex_unlock(&iommu_cb_set.cb_info[idx].lock); Loading Loading
drivers/media/platform/msm/camera/cam_req_mgr/cam_mem_mgr.c +60 −24 Original line number Diff line number Diff line Loading @@ -386,7 +386,7 @@ static int cam_mem_util_get_dma_buf_fd(size_t len, int rc = 0; if (!buf || !fd) { CAM_ERR(CAM_MEM, "Invalid params"); CAM_ERR(CAM_MEM, "Invalid params, buf=%pK, fd=%pK", buf, fd); return -EINVAL; } Loading @@ -396,7 +396,7 @@ static int cam_mem_util_get_dma_buf_fd(size_t len, *fd = dma_buf_fd(*buf, O_CLOEXEC); if (*fd < 0) { CAM_ERR(CAM_MEM, "get fd fail"); CAM_ERR(CAM_MEM, "get fd fail, *fd=%d", *fd); rc = -EINVAL; goto get_fd_fail; } Loading Loading @@ -472,14 +472,16 @@ static int cam_mem_util_check_map_flags(struct cam_mem_mgr_map_cmd *cmd) } if (cmd->num_hdl > CAM_MEM_MMU_MAX_HANDLE) { CAM_ERR(CAM_MEM, "Num of mmu hdl exceeded maximum(%d)", CAM_MEM_MMU_MAX_HANDLE); CAM_ERR(CAM_MEM, "Num of mmu hdl %d exceeded maximum(%d)", cmd->num_hdl, CAM_MEM_MMU_MAX_HANDLE); return -EINVAL; } if (cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE && cmd->flags & CAM_MEM_FLAG_KMD_ACCESS) { CAM_ERR(CAM_MEM, "Kernel mapping in secure mode not allowed"); CAM_ERR(CAM_MEM, "Kernel mapping in secure mode not allowed, flags=0x%x", cmd->flags); return -EINVAL; } Loading @@ -505,12 +507,13 @@ static int cam_mem_util_map_hw_va(uint32_t flags, int dir = cam_mem_util_get_dma_dir(flags); if (dir < 0) { CAM_ERR(CAM_MEM, "fail to map DMA direction"); CAM_ERR(CAM_MEM, "fail to map DMA direction, dir=%d", dir); return dir; } CAM_DBG(CAM_MEM, "map_hw_va : flags = %x, dir=%d, num_hdls=%d", flags, dir, num_hdls); CAM_DBG(CAM_MEM, "map_hw_va : fd = %d, flags = 0x%x, dir=%d, num_hdls=%d", fd, flags, dir, num_hdls); if (flags & CAM_MEM_FLAG_PROTECTED_MODE) { for (i = 0; i < num_hdls; i++) { Loading @@ -522,7 +525,8 @@ static int cam_mem_util_map_hw_va(uint32_t flags, if (rc < 0) { CAM_ERR(CAM_MEM, "Failed to securely map to smmu"); "Failed to securely map to smmu, i=%d, fd=%d, dir=%d, mmu_hdl=%d, rc=%d", i, fd, dir, mmu_hdls[i], rc); goto multi_map_fail; } } Loading @@ -536,7 +540,9 @@ static int cam_mem_util_map_hw_va(uint32_t flags, region); if (rc < 0) { CAM_ERR(CAM_MEM, "Failed to map to smmu"); CAM_ERR(CAM_MEM, "Failed to map to smmu, i=%d, fd=%d, dir=%d, mmu_hdl=%d, region=%d, rc=%d", i, fd, dir, mmu_hdls[i], region, rc); goto multi_map_fail; } } Loading Loading @@ -573,7 +579,8 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd) rc = cam_mem_util_check_alloc_flags(cmd); if (rc) { CAM_ERR(CAM_MEM, "Invalid flags: flags = %X", cmd->flags); CAM_ERR(CAM_MEM, "Invalid flags: flags = 0x%X, rc=%d", cmd->flags, rc); return rc; } Loading @@ -581,12 +588,15 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd) &dmabuf, &fd); if (rc) { CAM_ERR(CAM_MEM, "Ion allocation failed"); 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); return rc; } idx = cam_mem_get_slot(); if (idx < 0) { CAM_ERR(CAM_MEM, "Failed in getting mem slot, idx=%d", idx); rc = -ENOMEM; goto slot_fail; } Loading @@ -613,7 +623,9 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd) region); if (rc) { CAM_ERR(CAM_MEM, "Failed in map_hw_va, rc=%d", rc); CAM_ERR(CAM_MEM, "Failed in map_hw_va, flags=0x%x, fd=%d, region=%d, num_hdl=%d, rc=%d", cmd->flags, fd, region, cmd->num_hdl, rc); goto map_hw_fail; } } Loading Loading @@ -644,8 +656,9 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd) cmd->out.fd = tbl.bufq[idx].fd; cmd->out.vaddr = 0; CAM_DBG(CAM_MEM, "buf handle: %x, fd: %d, len: %zu", cmd->out.buf_handle, cmd->out.fd, CAM_DBG(CAM_MEM, "fd=%d, flags=0x%x, num_hdl=%d, idx=%d, buf handle=%x, len=%zu", cmd->out.fd, cmd->flags, cmd->num_hdl, idx, cmd->out.buf_handle, tbl.bufq[idx].len); return rc; Loading @@ -670,8 +683,11 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd) return -EINVAL; } if (cmd->num_hdl > CAM_MEM_MMU_MAX_HANDLE) if (cmd->num_hdl > CAM_MEM_MMU_MAX_HANDLE) { CAM_ERR(CAM_MEM, "Num of mmu hdl %d exceeded maximum(%d)", cmd->num_hdl, CAM_MEM_MMU_MAX_HANDLE); return -EINVAL; } rc = cam_mem_util_check_map_flags(cmd); if (rc) { Loading @@ -694,9 +710,14 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd) &hw_vaddr, &len, CAM_SMMU_REGION_IO); if (rc) 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); goto map_fail; } } idx = cam_mem_get_slot(); if (idx < 0) { Loading Loading @@ -729,6 +750,11 @@ 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; 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, tbl.bufq[idx].len); return rc; map_fail: Loading Loading @@ -758,15 +784,19 @@ static int cam_mem_util_unmap_hw_va(int32_t idx, fd = tbl.bufq[idx].fd; CAM_DBG(CAM_MEM, "unmap_hw_va : fd=%x, flags=0x%x, num_hdls=%d, client=%d", fd, flags, num_hdls, client); "unmap_hw_va : idx=%d, fd=%x, flags=0x%x, num_hdls=%d, client=%d", idx, fd, flags, num_hdls, client); if (flags & CAM_MEM_FLAG_PROTECTED_MODE) { for (i = 0; i < num_hdls; i++) { rc = cam_smmu_unmap_stage2_iova(mmu_hdls[i], fd); if (rc < 0) if (rc < 0) { CAM_ERR(CAM_MEM, "Failed in secure unmap, i=%d, fd=%d, mmu_hdl=%d, rc=%d", i, fd, mmu_hdls[i], rc); goto unmap_end; } } } else { for (i = 0; i < num_hdls; i++) { if (client == CAM_SMMU_MAPPING_USER) { Loading @@ -781,10 +811,14 @@ static int cam_mem_util_unmap_hw_va(int32_t idx, client); rc = -EINVAL; } if (rc < 0) if (rc < 0) { CAM_ERR(CAM_MEM, "Failed in unmap, i=%d, fd=%d, mmu_hdl=%d, region=%d, rc=%d", i, fd, mmu_hdls[i], region, rc); goto unmap_end; } } } return rc; Loading Loading @@ -954,7 +988,8 @@ int cam_mem_mgr_release(struct cam_mem_mgr_release_cmd *cmd) idx = CAM_MEM_MGR_GET_HDL_IDX(cmd->buf_handle); if (idx >= CAM_MEM_BUFQ_MAX || idx <= 0) { CAM_ERR(CAM_MEM, "Incorrect index extracted from mem handle"); CAM_ERR(CAM_MEM, "Incorrect index %d extracted from mem handle", idx); return -EINVAL; } Loading @@ -965,11 +1000,12 @@ int cam_mem_mgr_release(struct cam_mem_mgr_release_cmd *cmd) if (tbl.bufq[idx].buf_handle != cmd->buf_handle) { CAM_ERR(CAM_MEM, "Released buf handle not matching within table"); "Released buf handle %d not matching within table %d, idx=%d", cmd->buf_handle, tbl.bufq[idx].buf_handle, idx); return -EINVAL; } CAM_DBG(CAM_MEM, "Releasing hdl = %x", cmd->buf_handle); CAM_DBG(CAM_MEM, "Releasing hdl = %x, idx = %d", cmd->buf_handle, idx); rc = cam_mem_util_unmap(idx, CAM_SMMU_MAPPING_USER); return rc; Loading
drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.c +39 −21 Original line number Diff line number Diff line Loading @@ -1580,7 +1580,9 @@ static int cam_smmu_map_buffer_validate(struct dma_buf *buf, if (rc < 0) { CAM_ERR(CAM_SMMU, "IOVA alloc failed for shared memory"); "IOVA alloc failed for shared memory, size=%zu, idx=%d, handle=%d", *len_ptr, idx, iommu_cb_set.cb_info[idx].handle); goto err_unmap_sg; } Loading @@ -1596,7 +1598,9 @@ static int cam_smmu_map_buffer_validate(struct dma_buf *buf, rc = -ENOMEM; goto err_unmap_sg; } else { CAM_DBG(CAM_SMMU, "iommu_map_sg returned %zu", size); CAM_DBG(CAM_SMMU, "iommu_map_sg returned iova=%pK, size=%zu", iova, size); *paddr_ptr = iova; *len_ptr = size; } Loading @@ -1618,8 +1622,8 @@ static int cam_smmu_map_buffer_validate(struct dma_buf *buf, goto err_unmap_sg; } CAM_DBG(CAM_SMMU, "region_id=%d, paddr=%pK, len=%d", region_id, *paddr_ptr, *len_ptr); CAM_DBG(CAM_SMMU, "iova=%pK, region_id=%d, paddr=%pK, len=%d", iova, region_id, *paddr_ptr, *len_ptr); if (table->sgl) { CAM_DBG(CAM_SMMU, Loading Loading @@ -1655,11 +1659,12 @@ static int cam_smmu_map_buffer_validate(struct dma_buf *buf, if (!*paddr_ptr || !*len_ptr) { CAM_ERR(CAM_SMMU, "Error: Space Allocation failed"); kfree(*mapping_info); *mapping_info = NULL; rc = -ENOSPC; goto err_alloc; } CAM_DBG(CAM_SMMU, "dma_buf = %pK, dev = %pK, paddr= %pK, len = %u", buf, (void *)iommu_cb_set.cb_info[idx].dev, CAM_DBG(CAM_SMMU, "idx=%d, dma_buf=%pK, dev=%pK, paddr=%pK, len=%u", idx, buf, (void *)iommu_cb_set.cb_info[idx].dev, (void *)*paddr_ptr, (unsigned int)*len_ptr); return 0; Loading Loading @@ -2253,7 +2258,9 @@ static int cam_smmu_map_stage2_buffer_and_add_to_list(int idx, int ion_fd, dmabuf = dma_buf_get(ion_fd); if (IS_ERR_OR_NULL((void *)(dmabuf))) { CAM_ERR(CAM_SMMU, "Error: dma buf get failed"); CAM_ERR(CAM_SMMU, "Error: dma buf get failed, idx=%d, ion_fd=%d", idx, ion_fd); rc = PTR_ERR(dmabuf); goto err_out; } Loading @@ -2265,7 +2272,9 @@ static int cam_smmu_map_stage2_buffer_and_add_to_list(int idx, int ion_fd, */ attach = dma_buf_attach(dmabuf, iommu_cb_set.cb_info[idx].dev); if (IS_ERR_OR_NULL(attach)) { CAM_ERR(CAM_SMMU, "Error: dma buf attach failed"); CAM_ERR(CAM_SMMU, "Error: dma buf attach failed, idx=%d, ion_fd=%d", idx, ion_fd); rc = PTR_ERR(attach); goto err_put; } Loading Loading @@ -2297,8 +2306,8 @@ static int cam_smmu_map_stage2_buffer_and_add_to_list(int idx, int ion_fd, mapping_info->ref_count = 1; mapping_info->buf = dmabuf; CAM_DBG(CAM_SMMU, "ion_fd = %d, dev = %pK, paddr= %pK, len = %u", ion_fd, CAM_DBG(CAM_SMMU, "idx=%d, ion_fd=%d, dev=%pK, paddr=%pK, len=%u", idx, ion_fd, (void *)iommu_cb_set.cb_info[idx].dev, (void *)*paddr_ptr, (unsigned int)*len_ptr); Loading Loading @@ -2354,15 +2363,16 @@ int cam_smmu_map_stage2_iova(int handle, if (!iommu_cb_set.cb_info[idx].is_secure) { CAM_ERR(CAM_SMMU, "Error: can't map secure mem to non secure cb"); "Error: can't map secure mem to non secure cb, idx=%d", idx); return -EINVAL; } mutex_lock(&iommu_cb_set.cb_info[idx].lock); if (iommu_cb_set.cb_info[idx].handle != handle) { CAM_ERR(CAM_SMMU, "Error: hdl is not valid, table_hdl = %x, hdl = %x", iommu_cb_set.cb_info[idx].handle, handle); "Error: hdl is not valid, idx=%d, table_hdl=%x, hdl=%x", idx, iommu_cb_set.cb_info[idx].handle, handle); rc = -EINVAL; goto get_addr_end; } Loading @@ -2370,15 +2380,18 @@ int cam_smmu_map_stage2_iova(int handle, buf_state = cam_smmu_check_secure_fd_in_list(idx, ion_fd, paddr_ptr, len_ptr); if (buf_state == CAM_SMMU_BUFF_EXIST) { CAM_DBG(CAM_SMMU, "fd:%d already in list, give same addr back", ion_fd); CAM_DBG(CAM_SMMU, "fd:%d already in list idx:%d, handle=%d give same addr back", ion_fd, idx, handle); rc = 0; goto get_addr_end; } rc = cam_smmu_map_stage2_buffer_and_add_to_list(idx, ion_fd, dma_dir, paddr_ptr, len_ptr); if (rc < 0) { CAM_ERR(CAM_SMMU, "Error: mapping or add list fail"); CAM_ERR(CAM_SMMU, "Error: mapping or add list fail, idx=%d, handle=%d, fd=%d, rc=%d", idx, handle, ion_fd, rc); goto get_addr_end; } Loading Loading @@ -2519,14 +2532,16 @@ int cam_smmu_map_user_iova(int handle, int ion_fd, mutex_lock(&iommu_cb_set.cb_info[idx].lock); if (iommu_cb_set.cb_info[idx].is_secure) { CAM_ERR(CAM_SMMU, "Error: can't map non-secure mem to secure cb"); "Error: can't map non-secure mem to secure cb idx=%d", idx); rc = -EINVAL; goto get_addr_end; } if (iommu_cb_set.cb_info[idx].handle != handle) { CAM_ERR(CAM_SMMU, "hdl is not valid, table_hdl = %x, hdl = %x", iommu_cb_set.cb_info[idx].handle, handle); CAM_ERR(CAM_SMMU, "hdl is not valid, idx=%d, table_hdl = %x, hdl = %x", idx, iommu_cb_set.cb_info[idx].handle, handle); rc = -EINVAL; goto get_addr_end; } Loading @@ -2542,7 +2557,8 @@ int cam_smmu_map_user_iova(int handle, int ion_fd, buf_state = cam_smmu_check_fd_in_list(idx, ion_fd, paddr_ptr, len_ptr); if (buf_state == CAM_SMMU_BUFF_EXIST) { CAM_ERR(CAM_SMMU, "ion_fd: %d already in the list", ion_fd); "fd:%d already in list idx:%d, handle=%d, give same addr back", ion_fd, idx, handle); rc = -EALREADY; goto get_addr_end; } Loading @@ -2550,7 +2566,9 @@ int cam_smmu_map_user_iova(int handle, int ion_fd, rc = cam_smmu_map_buffer_and_add_to_list(idx, ion_fd, dma_dir, paddr_ptr, len_ptr, region_id); if (rc < 0) CAM_ERR(CAM_SMMU, "mapping or add list fail"); CAM_ERR(CAM_SMMU, "mapping or add list fail, idx=%d, fd=%d, region=%d, rc=%d", idx, ion_fd, region_id, rc); get_addr_end: mutex_unlock(&iommu_cb_set.cb_info[idx].lock); Loading