Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6db0572c authored by Abdulla Anam's avatar Abdulla Anam Committed by Gerrit - the friendly Code Review server
Browse files

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: default avatarAshray Kulkarni <ashrayk@codeaurora.org>
Signed-off-by: default avatarPraveen Chavan <pchavan@codeaurora.org>
Signed-off-by: default avatarDeva Ramasubramanian <dramasub@codeaurora.org>
Signed-off-by: default avatarArun Menon <avmenon@codeaurora.org>
Signed-off-by: default avatarAbdulla Anam <abdullahanam@codeaurora.org>
parent e170b405
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
/* 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)
{
+4 −2
Original line number Diff line number Diff line
@@ -212,7 +212,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],
@@ -222,7 +224,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");
+1 −0
Original line number Diff line number Diff line
@@ -367,6 +367,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);