From 34e86b910fbbd78e97ba799c4c8422fc30bf33c2 Mon Sep 17 00:00:00 2001 From: Praveen Chavan Date: Tue, 23 Aug 2016 13:14:22 -0700 Subject: [PATCH] msm: vidc: Compare ion_handles rather than fds fd(s) cannot uniquely identify buffers queued by cross-process clients. Use ion handles to compare and match already-mapped- buffers irrespective of data or extradata planes. CRs-Fixed: 1060416 Change-Id: I591f18aa225cc6690bf423f2ae5bc7dafd4dad78 Signed-off-by: Praveen Chavan --- drivers/media/platform/msm/vidc/msm_vidc.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/msm/vidc/msm_vidc.c b/drivers/media/platform/msm/vidc/msm_vidc.c index 84ce75c28bf8..437ad43e23e9 100644 --- a/drivers/media/platform/msm/vidc/msm_vidc.c +++ b/drivers/media/platform/msm/vidc/msm_vidc.c @@ -242,8 +242,7 @@ err_invalid_input: return ret; } -static struct msm_smem *get_same_fd_buffer(struct msm_vidc_list *buf_list, - int fd) +static struct msm_smem *get_same_fd_buffer(struct msm_vidc_inst *inst, int fd) { struct buffer_info *temp; struct msm_smem *same_fd_handle = NULL; @@ -253,16 +252,18 @@ static struct msm_smem *get_same_fd_buffer(struct msm_vidc_list *buf_list, if (!fd) return NULL; - if (!buf_list || fd < 0) { - dprintk(VIDC_ERR, "Invalid input\n"); + if (!inst || fd < 0) { + dprintk(VIDC_ERR, "%s: Invalid input\n", __func__); goto err_invalid_input; } - mutex_lock(&buf_list->lock); - list_for_each_entry(temp, &buf_list->list, list) { + mutex_lock(&inst->registeredbufs.lock); + list_for_each_entry(temp, &inst->registeredbufs.list, list) { for (i = 0; i < min(temp->num_planes, VIDEO_MAX_PLANES); i++) { - if (temp->fd[i] == fd && - temp->handle[i] && temp->mapped[i]) { + bool ion_hndl_matches = temp->handle[i] ? + msm_smem_compare_buffers(inst->mem_client, fd, + temp->handle[i]->smem_priv) : false; + if (ion_hndl_matches && temp->mapped[i]) { temp->same_fd_ref[i]++; dprintk(VIDC_INFO, "Found same fd buffer\n"); @@ -273,7 +274,7 @@ static struct msm_smem *get_same_fd_buffer(struct msm_vidc_list *buf_list, if (same_fd_handle) break; } - mutex_unlock(&buf_list->lock); + mutex_unlock(&inst->registeredbufs.lock); err_invalid_input: return same_fd_handle; @@ -487,8 +488,7 @@ int map_and_register_buf(struct msm_vidc_inst *inst, struct v4l2_buffer *b) } same_fd_handle = get_same_fd_buffer( - &inst->registeredbufs, - b->m.planes[i].reserved[0]); + inst, b->m.planes[i].reserved[0]); populate_buf_info(binfo, b, i); if (same_fd_handle) {