|
@@ -112,6 +112,7 @@ struct cam_smmu_monitor {
|
|
|
|
|
|
/* map-unmap info */
|
|
|
int ion_fd;
|
|
|
+ unsigned long i_ino;
|
|
|
dma_addr_t paddr;
|
|
|
size_t len;
|
|
|
enum cam_smmu_region_id region_id;
|
|
@@ -210,6 +211,7 @@ struct cam_dma_buff_info {
|
|
|
dma_addr_t paddr;
|
|
|
struct list_head list;
|
|
|
int ion_fd;
|
|
|
+ unsigned long i_ino;
|
|
|
size_t len;
|
|
|
size_t phys_len;
|
|
|
bool is_internal;
|
|
@@ -223,6 +225,7 @@ struct cam_sec_buff_info {
|
|
|
dma_addr_t paddr;
|
|
|
struct list_head list;
|
|
|
int ion_fd;
|
|
|
+ unsigned long i_ino;
|
|
|
size_t len;
|
|
|
};
|
|
|
|
|
@@ -241,13 +244,13 @@ static int cam_smmu_create_add_handle_in_table(char *name,
|
|
|
int *hdl);
|
|
|
|
|
|
static struct cam_dma_buff_info *cam_smmu_find_mapping_by_ion_index(int idx,
|
|
|
- int ion_fd);
|
|
|
+ int ion_fd, struct dma_buf *dma_buf);
|
|
|
|
|
|
static struct cam_dma_buff_info *cam_smmu_find_mapping_by_dma_buf(int idx,
|
|
|
struct dma_buf *buf);
|
|
|
|
|
|
static struct cam_sec_buff_info *cam_smmu_find_mapping_by_sec_buf_idx(int idx,
|
|
|
- int ion_fd);
|
|
|
+ int ion_fd, struct dma_buf *dma_buf);
|
|
|
|
|
|
static int cam_smmu_init_scratch_map(struct scratch_mapping *scratch_map,
|
|
|
dma_addr_t base, size_t size,
|
|
@@ -315,6 +318,7 @@ static void cam_smmu_update_monitor_array(
|
|
|
|
|
|
cb_info->monitor_entries[iterator].is_map = is_map;
|
|
|
cb_info->monitor_entries[iterator].ion_fd = mapping_info->ion_fd;
|
|
|
+ cb_info->monitor_entries[iterator].i_ino = mapping_info->i_ino;
|
|
|
cb_info->monitor_entries[iterator].paddr = mapping_info->paddr;
|
|
|
cb_info->monitor_entries[iterator].len = mapping_info->len;
|
|
|
cb_info->monitor_entries[iterator].region_id = mapping_info->region_id;
|
|
@@ -357,11 +361,12 @@ static void cam_smmu_dump_monitor_array(
|
|
|
hrs = do_div(tmp, 24);
|
|
|
|
|
|
CAM_INFO(CAM_SMMU,
|
|
|
- "**** %llu:%llu:%llu.%llu : Index[%d] [%s] : ion_fd=%d start=0x%llx end=0x%llx len=%zu region=%d",
|
|
|
+ "**** %llu:%llu:%llu.%llu : Index[%d] [%s] : ion_fd=%d i_ino=%lu start=0x%llx end=0x%llx len=%zu region=%d",
|
|
|
hrs, min, sec, ms,
|
|
|
index,
|
|
|
cb_info->monitor_entries[index].is_map ? "MAP" : "UNMAP",
|
|
|
cb_info->monitor_entries[index].ion_fd,
|
|
|
+ cb_info->monitor_entries[index].i_ino,
|
|
|
cb_info->monitor_entries[index].paddr,
|
|
|
cb_info->monitor_entries[index].paddr +
|
|
|
cb_info->monitor_entries[index].len,
|
|
@@ -581,8 +586,8 @@ static void cam_smmu_dump_cb_info(int idx)
|
|
|
min = do_div(tmp, 60);
|
|
|
hrs = do_div(tmp, 24);
|
|
|
CAM_ERR(CAM_SMMU,
|
|
|
- "%llu:%llu:%llu:%llu: %u ion_fd=%d start=0x%x end=0x%x len=%u region=%d",
|
|
|
- hrs, min, sec, ms, i, mapping->ion_fd,
|
|
|
+ "%llu:%llu:%llu:%llu: %u ion_fd=%d i_ino=%lu start=0x%x end=0x%x len=%u region=%d",
|
|
|
+ hrs, min, sec, ms, i, mapping->ion_fd, mapping->i_ino,
|
|
|
(void *)mapping->paddr,
|
|
|
((uint64_t)mapping->paddr +
|
|
|
(uint64_t)mapping->len),
|
|
@@ -602,8 +607,8 @@ static void cam_smmu_print_user_list(int idx)
|
|
|
list_for_each_entry(mapping,
|
|
|
&iommu_cb_set.cb_info[idx].smmu_buf_list, list) {
|
|
|
CAM_ERR(CAM_SMMU,
|
|
|
- "ion_fd = %d, paddr= 0x%pK, len = %u, region = %d",
|
|
|
- mapping->ion_fd, (void *)mapping->paddr,
|
|
|
+ "ion_fd = %d, i_ino=%lu, paddr= 0x%pK, len = %u, region = %d",
|
|
|
+ mapping->ion_fd, mapping->i_ino, (void *)mapping->paddr,
|
|
|
(unsigned int)mapping->len,
|
|
|
mapping->region_id);
|
|
|
}
|
|
@@ -617,8 +622,8 @@ static void cam_smmu_print_kernel_list(int idx)
|
|
|
list_for_each_entry(mapping,
|
|
|
&iommu_cb_set.cb_info[idx].smmu_buf_kernel_list, list) {
|
|
|
CAM_ERR(CAM_SMMU,
|
|
|
- "dma_buf = %pK, paddr= 0x%pK, len = %u, region = %d",
|
|
|
- mapping->buf, (void *)mapping->paddr,
|
|
|
+ "dma_buf = %pK, i_ino = %lu, paddr= 0x%pK, len = %u, region = %d",
|
|
|
+ mapping->buf, mapping->i_ino, (void *)mapping->paddr,
|
|
|
(unsigned int)mapping->len,
|
|
|
mapping->region_id);
|
|
|
}
|
|
@@ -657,9 +662,9 @@ static uint32_t cam_smmu_find_closest_mapping(int idx, void *vaddr)
|
|
|
if (start_addr <= current_addr && current_addr <= end_addr) {
|
|
|
closest_mapping = mapping;
|
|
|
CAM_INFO(CAM_SMMU,
|
|
|
- "Found va 0x%lx in:0x%lx-0x%lx, fd %d cb:%s",
|
|
|
+ "Found va 0x%lx in:0x%lx-0x%lx, fd %d i_ino %lu cb:%s",
|
|
|
current_addr, start_addr,
|
|
|
- end_addr, mapping->ion_fd,
|
|
|
+ end_addr, mapping->ion_fd, mapping->i_ino,
|
|
|
iommu_cb_set.cb_info[idx].name[0]);
|
|
|
goto end;
|
|
|
} else {
|
|
@@ -673,9 +678,9 @@ static uint32_t cam_smmu_find_closest_mapping(int idx, void *vaddr)
|
|
|
closest_mapping = mapping;
|
|
|
}
|
|
|
CAM_DBG(CAM_SMMU,
|
|
|
- "approx va %lx not in range: %lx-%lx fd = %0x",
|
|
|
+ "approx va %lx not in range: %lx-%lx fd = %0x i_ino %lu",
|
|
|
current_addr, start_addr,
|
|
|
- end_addr, mapping->ion_fd);
|
|
|
+ end_addr, mapping->ion_fd, mapping->i_ino);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -683,8 +688,8 @@ end:
|
|
|
if (closest_mapping) {
|
|
|
buf_handle = GET_MEM_HANDLE(idx, closest_mapping->ion_fd);
|
|
|
CAM_INFO(CAM_SMMU,
|
|
|
- "Closest map fd %d 0x%lx %llu-%llu 0x%lx-0x%lx buf=%pK mem %0x",
|
|
|
- closest_mapping->ion_fd, current_addr,
|
|
|
+ "Closest map fd %d i_ino %lu 0x%lx %llu-%llu 0x%lx-0x%lx buf=%pK mem %0x",
|
|
|
+ closest_mapping->ion_fd, closest_mapping->i_ino, current_addr,
|
|
|
mapping->len, closest_mapping->len,
|
|
|
(unsigned long)closest_mapping->paddr,
|
|
|
(unsigned long)closest_mapping->paddr + mapping->len,
|
|
@@ -1164,25 +1169,29 @@ static struct cam_dma_buff_info *cam_smmu_find_mapping_by_virt_address(int idx,
|
|
|
}
|
|
|
|
|
|
static struct cam_dma_buff_info *cam_smmu_find_mapping_by_ion_index(int idx,
|
|
|
- int ion_fd)
|
|
|
+ int ion_fd, struct dma_buf *dmabuf)
|
|
|
{
|
|
|
struct cam_dma_buff_info *mapping;
|
|
|
+ unsigned long i_ino;
|
|
|
|
|
|
if (ion_fd < 0) {
|
|
|
CAM_ERR(CAM_SMMU, "Invalid fd %d", ion_fd);
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
+ i_ino = file_inode(dmabuf->file)->i_ino;
|
|
|
+
|
|
|
list_for_each_entry(mapping,
|
|
|
&iommu_cb_set.cb_info[idx].smmu_buf_list,
|
|
|
list) {
|
|
|
- if (mapping->ion_fd == ion_fd) {
|
|
|
- CAM_DBG(CAM_SMMU, "find ion_fd %d", ion_fd);
|
|
|
+ if ((mapping->ion_fd == ion_fd) && (mapping->i_ino == i_ino)) {
|
|
|
+ CAM_DBG(CAM_SMMU, "find ion_fd %d i_ino %lu", ion_fd, i_ino);
|
|
|
return mapping;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- CAM_ERR(CAM_SMMU, "Error: Cannot find entry by index %d", idx);
|
|
|
+ CAM_ERR(CAM_SMMU, "Error: Cannot find entry by index %d, fd %d i_ino %lu",
|
|
|
+ idx, ion_fd, i_ino);
|
|
|
|
|
|
return NULL;
|
|
|
}
|
|
@@ -1212,19 +1221,22 @@ static struct cam_dma_buff_info *cam_smmu_find_mapping_by_dma_buf(int idx,
|
|
|
}
|
|
|
|
|
|
static struct cam_sec_buff_info *cam_smmu_find_mapping_by_sec_buf_idx(int idx,
|
|
|
- int ion_fd)
|
|
|
+ int ion_fd, struct dma_buf *dmabuf)
|
|
|
{
|
|
|
struct cam_sec_buff_info *mapping;
|
|
|
+ unsigned long i_ino;
|
|
|
+
|
|
|
+ i_ino = file_inode(dmabuf->file)->i_ino;
|
|
|
|
|
|
list_for_each_entry(mapping, &iommu_cb_set.cb_info[idx].smmu_buf_list,
|
|
|
list) {
|
|
|
- if (mapping->ion_fd == ion_fd) {
|
|
|
- CAM_DBG(CAM_SMMU, "find ion_fd %d", ion_fd);
|
|
|
+ if ((mapping->ion_fd == ion_fd) && (mapping->i_ino == i_ino)) {
|
|
|
+ CAM_DBG(CAM_SMMU, "find ion_fd %d, i_ino %lu", ion_fd, i_ino);
|
|
|
return mapping;
|
|
|
}
|
|
|
}
|
|
|
- CAM_ERR(CAM_SMMU, "Error: Cannot find fd %d by index %d",
|
|
|
- ion_fd, idx);
|
|
|
+ CAM_ERR(CAM_SMMU, "Error: Cannot find fd %d i_ino %lu by index %d",
|
|
|
+ ion_fd, i_ino, idx);
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
@@ -1235,9 +1247,9 @@ static void cam_smmu_clean_user_buffer_list(int idx)
|
|
|
|
|
|
list_for_each_entry_safe(mapping_info, temp,
|
|
|
&iommu_cb_set.cb_info[idx].smmu_buf_list, list) {
|
|
|
- CAM_DBG(CAM_SMMU, "Free mapping address %pK, i = %d, fd = %d",
|
|
|
+ CAM_DBG(CAM_SMMU, "Free mapping address %pK, i = %d, fd = %d, i_ino = %lu",
|
|
|
(void *)mapping_info->paddr, idx,
|
|
|
- mapping_info->ion_fd);
|
|
|
+ mapping_info->ion_fd, mapping_info->i_ino);
|
|
|
|
|
|
if (mapping_info->ion_fd == 0xDEADBEEF)
|
|
|
/* Clean up scratch buffers */
|
|
@@ -1253,9 +1265,9 @@ static void cam_smmu_clean_user_buffer_list(int idx)
|
|
|
CAM_ERR(CAM_SMMU, "Buffer delete failed: idx = %d",
|
|
|
idx);
|
|
|
CAM_ERR(CAM_SMMU,
|
|
|
- "Buffer delete failed: addr = %lx, fd = %d",
|
|
|
+ "Buffer delete failed: addr = %lx, fd = %d, i_ino = %lu",
|
|
|
(unsigned long)mapping_info->paddr,
|
|
|
- mapping_info->ion_fd);
|
|
|
+ mapping_info->ion_fd, mapping_info->i_ino);
|
|
|
/*
|
|
|
* Ignore this error and continue to delete other
|
|
|
* buffers in the list
|
|
@@ -2269,12 +2281,15 @@ static int cam_smmu_map_buffer_and_add_to_list(int idx, int ion_fd,
|
|
|
}
|
|
|
|
|
|
mapping_info->ion_fd = ion_fd;
|
|
|
+ mapping_info->i_ino = file_inode(buf->file)->i_ino;
|
|
|
mapping_info->is_internal = is_internal;
|
|
|
ktime_get_real_ts64(&mapping_info->ts);
|
|
|
/* add to the list */
|
|
|
list_add(&mapping_info->list,
|
|
|
&iommu_cb_set.cb_info[idx].smmu_buf_list);
|
|
|
|
|
|
+ CAM_DBG(CAM_SMMU, "fd %d i_ino %lu dmabuf %pK", ion_fd, mapping_info->i_ino, buf);
|
|
|
+
|
|
|
cam_smmu_update_monitor_array(&iommu_cb_set.cb_info[idx], true,
|
|
|
mapping_info);
|
|
|
|
|
@@ -2298,11 +2313,15 @@ static int cam_smmu_map_kernel_buffer_and_add_to_list(int idx,
|
|
|
}
|
|
|
|
|
|
mapping_info->ion_fd = -1;
|
|
|
+ mapping_info->i_ino = file_inode(buf->file)->i_ino;
|
|
|
ktime_get_real_ts64(&mapping_info->ts);
|
|
|
/* add to the list */
|
|
|
list_add(&mapping_info->list,
|
|
|
&iommu_cb_set.cb_info[idx].smmu_buf_kernel_list);
|
|
|
|
|
|
+ CAM_DBG(CAM_SMMU, "fd %d i_ino %lu dmabuf %pK",
|
|
|
+ mapping_info->ion_fd, mapping_info->i_ino, buf);
|
|
|
+
|
|
|
cam_smmu_update_monitor_array(&iommu_cb_set.cb_info[idx], true,
|
|
|
mapping_info);
|
|
|
|
|
@@ -2401,14 +2420,17 @@ static int cam_smmu_unmap_buf_and_remove_from_list(
|
|
|
}
|
|
|
|
|
|
static enum cam_smmu_buf_state cam_smmu_check_fd_in_list(int idx,
|
|
|
- int ion_fd, dma_addr_t *paddr_ptr, size_t *len_ptr,
|
|
|
+ int ion_fd, struct dma_buf *dmabuf, dma_addr_t *paddr_ptr, size_t *len_ptr,
|
|
|
struct timespec64 **ts_mapping)
|
|
|
{
|
|
|
struct cam_dma_buff_info *mapping;
|
|
|
+ unsigned long i_ino;
|
|
|
+
|
|
|
+ i_ino = file_inode(dmabuf->file)->i_ino;
|
|
|
|
|
|
list_for_each_entry(mapping,
|
|
|
&iommu_cb_set.cb_info[idx].smmu_buf_list, list) {
|
|
|
- if (mapping->ion_fd == ion_fd) {
|
|
|
+ if ((mapping->ion_fd == ion_fd) && (mapping->i_ino == i_ino)) {
|
|
|
*paddr_ptr = mapping->paddr;
|
|
|
*len_ptr = mapping->len;
|
|
|
*ts_mapping = &mapping->ts;
|
|
@@ -2420,14 +2442,17 @@ static enum cam_smmu_buf_state cam_smmu_check_fd_in_list(int idx,
|
|
|
}
|
|
|
|
|
|
static enum cam_smmu_buf_state cam_smmu_user_reuse_fd_in_list(int idx,
|
|
|
- int ion_fd, dma_addr_t *paddr_ptr, size_t *len_ptr,
|
|
|
+ int ion_fd, struct dma_buf *dmabuf, dma_addr_t *paddr_ptr, size_t *len_ptr,
|
|
|
struct timespec64 **ts_mapping)
|
|
|
{
|
|
|
struct cam_dma_buff_info *mapping;
|
|
|
+ unsigned long i_ino;
|
|
|
+
|
|
|
+ i_ino = file_inode(dmabuf->file)->i_ino;
|
|
|
|
|
|
list_for_each_entry(mapping,
|
|
|
&iommu_cb_set.cb_info[idx].smmu_buf_list, list) {
|
|
|
- if (mapping->ion_fd == ion_fd) {
|
|
|
+ if ((mapping->ion_fd == ion_fd) && (mapping->i_ino == i_ino)) {
|
|
|
*paddr_ptr = mapping->paddr;
|
|
|
*len_ptr = mapping->len;
|
|
|
*ts_mapping = &mapping->ts;
|
|
@@ -2457,15 +2482,17 @@ static enum cam_smmu_buf_state cam_smmu_check_dma_buf_in_list(int idx,
|
|
|
}
|
|
|
|
|
|
static enum cam_smmu_buf_state cam_smmu_check_secure_fd_in_list(int idx,
|
|
|
- int ion_fd, dma_addr_t *paddr_ptr,
|
|
|
- size_t *len_ptr)
|
|
|
+ int ion_fd, struct dma_buf *dmabuf, dma_addr_t *paddr_ptr, size_t *len_ptr)
|
|
|
{
|
|
|
struct cam_sec_buff_info *mapping;
|
|
|
+ unsigned long i_ino;
|
|
|
+
|
|
|
+ i_ino = file_inode(dmabuf->file)->i_ino;
|
|
|
|
|
|
list_for_each_entry(mapping,
|
|
|
&iommu_cb_set.cb_info[idx].smmu_buf_list,
|
|
|
list) {
|
|
|
- if (mapping->ion_fd == ion_fd) {
|
|
|
+ if ((mapping->ion_fd == ion_fd) && (mapping->i_ino == i_ino)) {
|
|
|
*paddr_ptr = mapping->paddr;
|
|
|
*len_ptr = mapping->len;
|
|
|
mapping->ref_count++;
|
|
@@ -2477,14 +2504,17 @@ static enum cam_smmu_buf_state cam_smmu_check_secure_fd_in_list(int idx,
|
|
|
}
|
|
|
|
|
|
static enum cam_smmu_buf_state cam_smmu_validate_secure_fd_in_list(int idx,
|
|
|
- int ion_fd, dma_addr_t *paddr_ptr, size_t *len_ptr)
|
|
|
+ int ion_fd, struct dma_buf *dmabuf, dma_addr_t *paddr_ptr, size_t *len_ptr)
|
|
|
{
|
|
|
struct cam_sec_buff_info *mapping;
|
|
|
+ unsigned long i_ino;
|
|
|
+
|
|
|
+ i_ino = file_inode(dmabuf->file)->i_ino;
|
|
|
|
|
|
list_for_each_entry(mapping,
|
|
|
&iommu_cb_set.cb_info[idx].smmu_buf_list,
|
|
|
list) {
|
|
|
- if (mapping->ion_fd == ion_fd) {
|
|
|
+ if ((mapping->ion_fd == ion_fd) && (mapping->i_ino == i_ino)) {
|
|
|
*paddr_ptr = mapping->paddr;
|
|
|
*len_ptr = mapping->len;
|
|
|
return CAM_SMMU_BUFF_EXIST;
|
|
@@ -2644,6 +2674,7 @@ static int cam_smmu_alloc_scratch_buffer_add_to_list(int idx,
|
|
|
}
|
|
|
|
|
|
mapping_info->ion_fd = 0xDEADBEEF;
|
|
|
+ mapping_info->i_ino = 0;
|
|
|
mapping_info->buf = NULL;
|
|
|
mapping_info->attach = NULL;
|
|
|
mapping_info->table = table;
|
|
@@ -2939,14 +2970,16 @@ static int cam_smmu_map_stage2_buffer_and_add_to_list(int idx, int ion_fd,
|
|
|
}
|
|
|
|
|
|
mapping_info->ion_fd = ion_fd;
|
|
|
+ mapping_info->i_ino = file_inode(dmabuf->file)->i_ino;
|
|
|
mapping_info->paddr = *paddr_ptr;
|
|
|
mapping_info->len = *len_ptr;
|
|
|
mapping_info->dir = dma_dir;
|
|
|
mapping_info->ref_count = 1;
|
|
|
mapping_info->buf = dmabuf;
|
|
|
|
|
|
- CAM_DBG(CAM_SMMU, "idx=%d, ion_fd=%d, dev=%pOFfp, paddr=0x%llx, len=%zu",
|
|
|
- idx, ion_fd, iommu_cb_set.cb_info[idx].dev, *paddr_ptr, *len_ptr);
|
|
|
+ CAM_DBG(CAM_SMMU, "idx=%d, ion_fd=%d, i_ino=%lu, dev=%pOFfp, paddr=0x%llx, len=%zu",
|
|
|
+ idx, ion_fd, mapping_info->i_ino, iommu_cb_set.cb_info[idx].dev,
|
|
|
+ *paddr_ptr, *len_ptr);
|
|
|
|
|
|
/* add to the list */
|
|
|
list_add(&mapping_info->list, &iommu_cb_set.cb_info[idx].smmu_buf_list);
|
|
@@ -2963,9 +2996,8 @@ err_out:
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
|
-int cam_smmu_map_stage2_iova(int handle,
|
|
|
- int ion_fd, enum cam_smmu_map_dir dir,
|
|
|
- dma_addr_t *paddr_ptr, size_t *len_ptr)
|
|
|
+int cam_smmu_map_stage2_iova(int handle, int ion_fd, struct dma_buf *dmabuf,
|
|
|
+ enum cam_smmu_map_dir dir, dma_addr_t *paddr_ptr, size_t *len_ptr)
|
|
|
{
|
|
|
int idx, rc;
|
|
|
enum dma_data_direction dma_dir;
|
|
@@ -3014,7 +3046,7 @@ int cam_smmu_map_stage2_iova(int handle,
|
|
|
goto get_addr_end;
|
|
|
}
|
|
|
|
|
|
- buf_state = cam_smmu_check_secure_fd_in_list(idx, ion_fd, paddr_ptr,
|
|
|
+ buf_state = cam_smmu_check_secure_fd_in_list(idx, ion_fd, dmabuf, paddr_ptr,
|
|
|
len_ptr);
|
|
|
if (buf_state == CAM_SMMU_BUFF_EXIST) {
|
|
|
CAM_DBG(CAM_SMMU,
|
|
@@ -3049,14 +3081,15 @@ static int cam_smmu_secure_unmap_buf_and_remove_from_list(
|
|
|
dma_buf_put(mapping_info->buf);
|
|
|
list_del_init(&mapping_info->list);
|
|
|
|
|
|
- CAM_DBG(CAM_SMMU, "unmap fd: %d, idx : %d", mapping_info->ion_fd, idx);
|
|
|
+ CAM_DBG(CAM_SMMU, "unmap fd: %d, i_ino : %lu, idx : %d",
|
|
|
+ mapping_info->ion_fd, mapping_info->i_ino, idx);
|
|
|
|
|
|
/* free one buffer */
|
|
|
kfree(mapping_info);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-int cam_smmu_unmap_stage2_iova(int handle, int ion_fd)
|
|
|
+int cam_smmu_unmap_stage2_iova(int handle, int ion_fd, struct dma_buf *dma_buf)
|
|
|
{
|
|
|
int idx, rc;
|
|
|
struct cam_sec_buff_info *mapping_info;
|
|
@@ -3088,7 +3121,7 @@ int cam_smmu_unmap_stage2_iova(int handle, int ion_fd)
|
|
|
}
|
|
|
|
|
|
/* based on ion fd and index, we can find mapping info of buffer */
|
|
|
- mapping_info = cam_smmu_find_mapping_by_sec_buf_idx(idx, ion_fd);
|
|
|
+ mapping_info = cam_smmu_find_mapping_by_sec_buf_idx(idx, ion_fd, dma_buf);
|
|
|
if (!mapping_info) {
|
|
|
CAM_ERR(CAM_SMMU,
|
|
|
"Error: Invalid params! idx = %d, fd = %d",
|
|
@@ -3159,8 +3192,8 @@ static int cam_smmu_map_iova_validate_params(int handle,
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
|
-int cam_smmu_map_user_iova(int handle, int ion_fd, bool dis_delayed_unmap,
|
|
|
- enum cam_smmu_map_dir dir, dma_addr_t *paddr_ptr,
|
|
|
+int cam_smmu_map_user_iova(int handle, int ion_fd, struct dma_buf *dmabuf,
|
|
|
+ bool dis_delayed_unmap, enum cam_smmu_map_dir dir, dma_addr_t *paddr_ptr,
|
|
|
size_t *len_ptr, enum cam_smmu_region_id region_id,
|
|
|
bool is_internal)
|
|
|
{
|
|
@@ -3203,7 +3236,7 @@ int cam_smmu_map_user_iova(int handle, int ion_fd, bool dis_delayed_unmap,
|
|
|
goto get_addr_end;
|
|
|
}
|
|
|
|
|
|
- buf_state = cam_smmu_user_reuse_fd_in_list(idx, ion_fd, paddr_ptr,
|
|
|
+ buf_state = cam_smmu_user_reuse_fd_in_list(idx, ion_fd, dmabuf, paddr_ptr,
|
|
|
len_ptr, &ts);
|
|
|
if (buf_state == CAM_SMMU_BUFF_EXIST) {
|
|
|
uint64_t ms = 0, tmp = 0, hrs = 0, min = 0, sec = 0;
|
|
@@ -3301,7 +3334,7 @@ get_addr_end:
|
|
|
}
|
|
|
EXPORT_SYMBOL(cam_smmu_map_kernel_iova);
|
|
|
|
|
|
-int cam_smmu_get_iova(int handle, int ion_fd,
|
|
|
+int cam_smmu_get_iova(int handle, int ion_fd, struct dma_buf *dma_buf,
|
|
|
dma_addr_t *paddr_ptr, size_t *len_ptr)
|
|
|
{
|
|
|
int idx, rc = 0;
|
|
@@ -3345,7 +3378,7 @@ int cam_smmu_get_iova(int handle, int ion_fd,
|
|
|
goto get_addr_end;
|
|
|
}
|
|
|
|
|
|
- buf_state = cam_smmu_check_fd_in_list(idx, ion_fd, paddr_ptr,
|
|
|
+ buf_state = cam_smmu_check_fd_in_list(idx, ion_fd, dma_buf, paddr_ptr,
|
|
|
len_ptr, &ts);
|
|
|
if (buf_state == CAM_SMMU_BUFF_NOT_EXIST) {
|
|
|
CAM_ERR(CAM_SMMU, "ion_fd:%d not in the mapped list", ion_fd);
|
|
@@ -3360,7 +3393,7 @@ get_addr_end:
|
|
|
}
|
|
|
EXPORT_SYMBOL(cam_smmu_get_iova);
|
|
|
|
|
|
-int cam_smmu_get_stage2_iova(int handle, int ion_fd,
|
|
|
+int cam_smmu_get_stage2_iova(int handle, int ion_fd, struct dma_buf *dma_buf,
|
|
|
dma_addr_t *paddr_ptr, size_t *len_ptr)
|
|
|
{
|
|
|
int idx, rc = 0;
|
|
@@ -3403,10 +3436,7 @@ int cam_smmu_get_stage2_iova(int handle, int ion_fd,
|
|
|
goto get_addr_end;
|
|
|
}
|
|
|
|
|
|
- buf_state = cam_smmu_validate_secure_fd_in_list(idx,
|
|
|
- ion_fd,
|
|
|
- paddr_ptr,
|
|
|
- len_ptr);
|
|
|
+ buf_state = cam_smmu_validate_secure_fd_in_list(idx, ion_fd, dma_buf, paddr_ptr, len_ptr);
|
|
|
|
|
|
if (buf_state == CAM_SMMU_BUFF_NOT_EXIST) {
|
|
|
CAM_ERR(CAM_SMMU, "ion_fd:%d not in the mapped list", ion_fd);
|
|
@@ -3442,7 +3472,7 @@ static int cam_smmu_unmap_validate_params(int handle)
|
|
|
}
|
|
|
|
|
|
int cam_smmu_unmap_user_iova(int handle,
|
|
|
- int ion_fd, enum cam_smmu_region_id region_id)
|
|
|
+ int ion_fd, struct dma_buf *dma_buf, enum cam_smmu_region_id region_id)
|
|
|
{
|
|
|
int idx, rc;
|
|
|
struct cam_dma_buff_info *mapping_info;
|
|
@@ -3471,7 +3501,7 @@ int cam_smmu_unmap_user_iova(int handle,
|
|
|
}
|
|
|
|
|
|
/* Based on ion_fd & index, we can find mapping info of buffer */
|
|
|
- mapping_info = cam_smmu_find_mapping_by_ion_index(idx, ion_fd);
|
|
|
+ mapping_info = cam_smmu_find_mapping_by_ion_index(idx, ion_fd, dma_buf);
|
|
|
|
|
|
if (!mapping_info) {
|
|
|
CAM_ERR(CAM_SMMU,
|
|
@@ -3556,7 +3586,7 @@ unmap_end:
|
|
|
EXPORT_SYMBOL(cam_smmu_unmap_kernel_iova);
|
|
|
|
|
|
|
|
|
-int cam_smmu_put_iova(int handle, int ion_fd)
|
|
|
+int cam_smmu_put_iova(int handle, int ion_fd, struct dma_buf *dma_buf)
|
|
|
{
|
|
|
int idx;
|
|
|
int rc = 0;
|
|
@@ -3586,7 +3616,7 @@ int cam_smmu_put_iova(int handle, int ion_fd)
|
|
|
}
|
|
|
|
|
|
/* based on ion fd and index, we can find mapping info of buffer */
|
|
|
- mapping_info = cam_smmu_find_mapping_by_ion_index(idx, ion_fd);
|
|
|
+ mapping_info = cam_smmu_find_mapping_by_ion_index(idx, ion_fd, dma_buf);
|
|
|
if (!mapping_info) {
|
|
|
CAM_ERR(CAM_SMMU, "Error: Invalid params idx = %d, fd = %d",
|
|
|
idx, ion_fd);
|