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

Commit 83174e30 authored by Gaurav Kashyap's avatar Gaurav Kashyap
Browse files

qtee_shmbridge: register bridges for CMA heaps



register shared memory bridges for CMA heaps

Change-Id: I4b80e215ea013894af27385dccec884d63d76dca
Signed-off-by: default avatarJade Xu <qxu@codeaurora.org>
Signed-off-by: default avatarGaurav Kashyap <gaurkash@codeaurora.org>
parent 7c9770b5
Loading
Loading
Loading
Loading
+35 −3
Original line number Diff line number Diff line
@@ -11,8 +11,11 @@
#include <linux/genalloc.h>
#include <linux/platform_device.h>
#include <linux/mod_devicetable.h>
#include <linux/of_platform.h>
#include <linux/of_reserved_mem.h>
#include <linux/qcom_scm.h>
#include <linux/dma-mapping.h>
#include <linux/msm_ion.h>
#include <soc/qcom/qseecomi.h>
#include <linux/qtee_shmbridge.h>
#include <linux/of_platform.h>
@@ -78,6 +81,18 @@ struct bridge_list_entry {
	uint64_t handle;
};

struct cma_heap_bridge_info {
	uint32_t heapid;
	uint64_t handle;
};

enum CMA_HEAP_TYPE {
	QSEECOM_HEAP = 0,
	QSEECOM_TA_HEAP,
	USER_CONTI_HEAP,
	HEAP_TYPE_MAX
};

static struct bridge_info default_bridge;
static struct bridge_list bridge_list_head;
static bool qtee_shmbridge_enabled;
@@ -390,11 +405,12 @@ static int qtee_shmbridge_init(struct platform_device *pdev)
	mutex_init(&bridge_list_head.lock);
	INIT_LIST_HEAD(&bridge_list_head.head);

	/* temporarily disable shm bridge mechanism */
	ret = qtee_shmbridge_enable(true);
	if (ret) {
		/* keep the mem pool and return if failed to enable bridge */
		ret = 0;
		goto exit;
		goto exit_shmbridge_enable;
	}

	/*register default bridge*/
@@ -412,7 +428,7 @@ static int qtee_shmbridge_init(struct platform_device *pdev)
	if (ret) {
		pr_err("Failed to register default bridge, size %zu\n",
			default_bridge.size);
		goto exit;
		goto exit_deregister_default_bridge;
	}

	pr_debug("qtee shmbridge registered default bridge with size %d bytes\n",
@@ -420,6 +436,10 @@ static int qtee_shmbridge_init(struct platform_device *pdev)

	return 0;

exit_deregister_default_bridge:
	qtee_shmbridge_deregister(default_bridge.handle);
exit_shmbridge_enable:
	qtee_shmbridge_enable(false);
exit_destroy_pool:
	gen_pool_destroy(default_bridge.genpool);
exit_unmap:
@@ -427,7 +447,8 @@ static int qtee_shmbridge_init(struct platform_device *pdev)
			DMA_TO_DEVICE);
exit_freebuf:
	free_pages((long)default_bridge.vaddr, get_order(default_bridge.size));
exit:
	default_bridge.vaddr = NULL;
//exit:
	return ret;
}

@@ -439,6 +460,16 @@ static int qtee_shmbridge_probe(struct platform_device *pdev)
	return qtee_shmbridge_init(pdev);
}

static int qtee_shmbridge_remove(struct platform_device *pdev)
{
	qtee_shmbridge_deregister(default_bridge.handle);
	gen_pool_destroy(default_bridge.genpool);
	dma_unmap_single(&pdev->dev, default_bridge.paddr, default_bridge.size,
			DMA_TO_DEVICE);
	free_pages((long)default_bridge.vaddr, get_order(default_bridge.size));
	return 0;
}

static const struct of_device_id qtee_shmbridge_of_match[] = {
	{ .compatible = "qcom,tee-shared-memory-bridge"},
	{}
@@ -447,6 +478,7 @@ MODULE_DEVICE_TABLE(of, qtee_shmbridge_of_match);

static struct platform_driver qtee_shmbridge_driver = {
	.probe = qtee_shmbridge_probe,
	.remove = qtee_shmbridge_remove,
	.driver = {
		.name = "shared_memory_bridge",
		.of_match_table = qtee_shmbridge_of_match,