summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbdulla Anam <abdullahanam@codeaurora.org>2016-06-25 16:55:55 +0530
committerKyle Yan <kyan@codeaurora.org>2016-07-11 14:27:17 -0700
commitf55cbb338591167febfda21e07a984913190673f (patch)
tree75471aa930b7d2140be0f1b5b6c268dea666403c
parentc108070ffaa8700fea674548d37c8a385cf9ec43 (diff)
msm: vidc: add ion_handle checking before mapping buffers
Compare ion handles in driver instead of matching fds to check if a buffer is already mapped or not. Bug: 28747768 CRs-Fixed: 1026885 Change-Id: Ifd18d8689351c4a6a22c988d359fb413be19e142 Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org> Signed-off-by: Praveen Chavan <pchavan@codeaurora.org> Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org> Signed-off-by: Arun Menon <avmenon@codeaurora.org> Signed-off-by: Abdulla Anam <abdullahanam@codeaurora.org> Signed-off-by: Amit Shekhar <ashekhar@codeaurora.org>
-rw-r--r--drivers/media/platform/msm/vidc/msm_smem.c19
-rw-r--r--drivers/media/platform/msm/vidc/msm_vidc.c6
-rw-r--r--drivers/media/platform/msm/vidc/msm_vidc_internal.h1
3 files changed, 23 insertions, 3 deletions
diff --git a/drivers/media/platform/msm/vidc/msm_smem.c b/drivers/media/platform/msm/vidc/msm_smem.c
index 009d8271563d..4ae13944362a 100644
--- a/drivers/media/platform/msm/vidc/msm_smem.c
+++ b/drivers/media/platform/msm/vidc/msm_smem.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -462,6 +462,23 @@ struct msm_smem *msm_smem_user_to_kernel(void *clt, int fd, u32 offset,
return mem;
}
+bool msm_smem_compare_buffers(void *clt, int fd, void *priv)
+{
+ struct smem_client *client = clt;
+ struct ion_handle *handle = NULL;
+ bool ret = false;
+
+ if (!clt || !priv) {
+ dprintk(VIDC_ERR, "Invalid params: %p, %p\n",
+ clt, priv);
+ return false;
+ }
+ handle = ion_import_dma_buf(client->clnt, fd);
+ ret = handle == priv;
+ handle ? ion_free(client->clnt, handle) : 0;
+ return ret;
+}
+
static int ion_cache_operations(struct smem_client *client,
struct msm_smem *mem, enum smem_cache_ops cache_op)
{
diff --git a/drivers/media/platform/msm/vidc/msm_vidc.c b/drivers/media/platform/msm/vidc/msm_vidc.c
index 97add87b3ddf..8a4d5eb561c6 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc.c
+++ b/drivers/media/platform/msm/vidc/msm_vidc.c
@@ -213,7 +213,9 @@ struct buffer_info *get_registered_buf(struct msm_vidc_inst *inst,
*plane = 0;
list_for_each_entry(temp, &inst->registeredbufs.list, list) {
for (i = 0; i < min(temp->num_planes, VIDEO_MAX_PLANES); i++) {
- bool fd_matches = fd == temp->fd[i];
+ bool ion_hndl_matches = temp->handle[i] ?
+ msm_smem_compare_buffers(inst->mem_client, fd,
+ temp->handle[i]->smem_priv) : false;
bool device_addr_matches = device_addr ==
temp->device_addr[i];
bool contains_within = CONTAINS(temp->buff_off[i],
@@ -223,7 +225,7 @@ struct buffer_info *get_registered_buf(struct msm_vidc_inst *inst,
temp->buff_off[i], temp->size[i]);
if (!temp->inactive &&
- (fd_matches || device_addr_matches) &&
+ (ion_hndl_matches || device_addr_matches) &&
(contains_within || overlaps)) {
dprintk(VIDC_DBG,
"This memory region is already mapped\n");
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_internal.h b/drivers/media/platform/msm/vidc/msm_vidc_internal.h
index c127a17b6157..72c1ddcf3a70 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_internal.h
+++ b/drivers/media/platform/msm/vidc/msm_vidc_internal.h
@@ -373,6 +373,7 @@ struct msm_smem *msm_smem_user_to_kernel(void *clt, int fd, u32 offset,
struct context_bank_info *msm_smem_get_context_bank(void *clt,
bool is_secure, enum hal_buffer buffer_type);
void msm_vidc_fw_unload_handler(struct work_struct *work);
+bool msm_smem_compare_buffers(void *clt, int fd, void *priv);
/* XXX: normally should be in msm_vidc.h, but that's meant for public APIs,
* whereas this is private */
int msm_vidc_destroy(struct msm_vidc_inst *inst);