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

Commit b5e7ea5c authored by Anmolpreet Kaur's avatar Anmolpreet Kaur
Browse files

shmbridge: Change the bridge size according to dtsi entry



For MDMs, LEVMs and targets other than MSMs, we might not
need to register memory as large as 4M for shmbridge.
This change helps to decide the shmbridge pool size according
to the dtsi entry of the target.

Change-Id: I8f6905b5793f2dbe69f269a05cbbe74855eab708
Signed-off-by: default avatarAnmolpreet Kaur <anmolpre@codeaurora.org>
parent c1c7f2ef
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include "qtee_shmbridge_internal.h"

#define DEFAULT_BRIDGE_SIZE	SZ_4M	/*4M*/
#define MIN_BRIDGE_SIZE	SZ_4K	/*4K*/

#define MAXSHMVMS 4
#define PERM_BITS 3
@@ -280,18 +281,19 @@ int32_t qtee_shmbridge_allocate_shm(size_t size, struct qtee_shm *shm)
	int32_t ret = 0;
	unsigned long va;

	if (size > DEFAULT_BRIDGE_SIZE) {
		pr_err("requestd size %zu is larger than bridge size %d\n",
			size, DEFAULT_BRIDGE_SIZE);
	if (IS_ERR_OR_NULL(shm)) {
		pr_err("qtee_shm is NULL\n");
		ret = -EINVAL;
		goto exit;
	}

	if (IS_ERR_OR_NULL(shm)) {
		pr_err("qtee_shm is NULL\n");
	if (size > default_bridge.size) {
		pr_err("requestd size %zu is larger than bridge size %d\n",
			size, default_bridge.size);
		ret = -EINVAL;
		goto exit;
	}

	size = roundup(size, 1 << default_bridge.min_alloc_order);

	va = gen_pool_alloc(default_bridge.genpool, size);
@@ -350,6 +352,7 @@ EXPORT_SYMBOL(qtee_shmbridge_inv_shm_buf);
static int qtee_shmbridge_init(struct platform_device *pdev)
{
	int ret = 0;
	uint32_t custom_bridge_size;
	uint32_t *ns_vm_ids;
	uint32_t ns_vm_ids_hlos[] = {VMID_HLOS};
	uint32_t ns_vm_ids_hyp[] = {};
@@ -367,8 +370,16 @@ static int qtee_shmbridge_init(struct platform_device *pdev)
		return 0;
	}

	/* allocate a contiguous page aligned buffer */
	ret = of_property_read_u32((&pdev->dev)->of_node,
		"qcom,custom-bridge-size", &custom_bridge_size);
	if (ret)
		default_bridge.size = DEFAULT_BRIDGE_SIZE;
	else
		default_bridge.size = custom_bridge_size * MIN_BRIDGE_SIZE;

	pr_debug("qtee shmbridge registered default bridge with size %x bytes\n",
		default_bridge.size);

	default_bridge.vaddr = (void *)__get_free_pages(GFP_KERNEL|__GFP_COMP,
				get_order(default_bridge.size));
	if (!default_bridge.vaddr)
@@ -432,7 +443,7 @@ static int qtee_shmbridge_init(struct platform_device *pdev)
	}

	pr_debug("qtee shmbridge registered default bridge with size %d bytes\n",
			DEFAULT_BRIDGE_SIZE);
			default_bridge.size);

	return 0;