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: Anmolpreet Kaur <anmolpre@codeaurora.org>
This commit is contained in:
Anmolpreet Kaur 2021-04-09 21:28:03 +05:30
commit b5e7ea5c4b

View file

@ -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);
ret = -EINVAL;
goto exit;
}
if (IS_ERR_OR_NULL(shm)) {
pr_err("qtee_shm is NULL\n");
ret = -EINVAL;
goto exit;
}
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 */
default_bridge.size = DEFAULT_BRIDGE_SIZE;
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;