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

Commit b6b130b0 authored by Monika Singh's avatar Monika Singh
Browse files

qseecom: Add shmbrdige to allocate memory



In case of send_modfd_cmd we are using older allocation
methods, which are using more time and causing performace
degradation, hence updating it to use shmbridge instead.

Change-Id: I01afa0ac36d584fcc1a84570dc159b3af99f48c8
Signed-off-by: default avatarMonika Singh <monising@codeaurora.org>
parent 1c2af547
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -4319,8 +4319,10 @@ static int __qseecom_send_modfd_cmd(struct qseecom_dev_handle *data,
	struct qseecom_send_modfd_cmd_req req;
	struct qseecom_send_cmd_req send_cmd_req;
	void *origin_req_buf_kvirt, *origin_rsp_buf_kvirt;
	u32 tzbuflen;
	phys_addr_t pa;
	u8 *va = NULL;
	struct qtee_shm shm = {0};

	ret = copy_from_user(&req, argp, sizeof(req));
	if (ret) {
@@ -4352,11 +4354,11 @@ static int __qseecom_send_modfd_cmd(struct qseecom_dev_handle *data,
				(uintptr_t)req.resp_buf);

	/* Allocate kernel buffer for request and response*/
	ret = __qseecom_alloc_coherent_buf(req.cmd_req_len + req.resp_len,
					&va, &pa);
	if (ret) {
		pr_err("Failed to allocate coherent buf, ret %d\n", ret);
		return ret;
	tzbuflen = PAGE_ALIGN(req.cmd_req_len + req.resp_len);
	va = __qseecom_alloc_tzbuf(tzbuflen, &pa, &shm);
	if (!va) {
		pr_err("error allocating in buffer\n");
		return -ENOMEM;
	}

	req.cmd_req_buf = va;
@@ -4373,7 +4375,11 @@ static int __qseecom_send_modfd_cmd(struct qseecom_dev_handle *data,
		ret = __qseecom_update_cmd_buf(&req, false, data);
		if (ret)
			goto out;

		dmac_flush_range(req.cmd_req_buf, req.cmd_req_buf + tzbuflen);
		ret = __qseecom_send_cmd(data, &send_cmd_req, true);
		dmac_flush_range(req.cmd_req_buf, req.cmd_req_buf + tzbuflen);

		if (ret)
			goto out;
		ret = __qseecom_update_cmd_buf(&req, true, data);
@@ -4383,7 +4389,11 @@ static int __qseecom_send_modfd_cmd(struct qseecom_dev_handle *data,
		ret = __qseecom_update_cmd_buf_64(&req, false, data);
		if (ret)
			goto out;

		dmac_flush_range(req.cmd_req_buf, req.cmd_req_buf + tzbuflen);
		ret = __qseecom_send_cmd(data, &send_cmd_req, true);
		dmac_flush_range(req.cmd_req_buf, req.cmd_req_buf + tzbuflen);

		if (ret)
			goto out;
		ret = __qseecom_update_cmd_buf_64(&req, true, data);
@@ -4397,8 +4407,7 @@ static int __qseecom_send_modfd_cmd(struct qseecom_dev_handle *data,

out:
	if (req.cmd_req_buf)
		__qseecom_free_coherent_buf(req.cmd_req_len + req.resp_len,
			req.cmd_req_buf, (phys_addr_t)send_cmd_req.cmd_req_buf);
		__qseecom_free_tzbuf(&shm);

	return ret;
}