Loading drivers/firmware/qtee_shmbridge.c +19 −8 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "qtee_shmbridge_internal.h" #include "qtee_shmbridge_internal.h" #define DEFAULT_BRIDGE_SIZE SZ_4M /*4M*/ #define DEFAULT_BRIDGE_SIZE SZ_4M /*4M*/ #define MIN_BRIDGE_SIZE SZ_4K /*4K*/ #define MAXSHMVMS 4 #define MAXSHMVMS 4 #define PERM_BITS 3 #define PERM_BITS 3 Loading Loading @@ -280,18 +281,19 @@ int32_t qtee_shmbridge_allocate_shm(size_t size, struct qtee_shm *shm) int32_t ret = 0; int32_t ret = 0; unsigned long va; unsigned long va; if (size > DEFAULT_BRIDGE_SIZE) { if (IS_ERR_OR_NULL(shm)) { pr_err("requestd size %zu is larger than bridge size %d\n", pr_err("qtee_shm is NULL\n"); size, DEFAULT_BRIDGE_SIZE); ret = -EINVAL; ret = -EINVAL; goto exit; goto exit; } } if (IS_ERR_OR_NULL(shm)) { if (size > default_bridge.size) { pr_err("qtee_shm is NULL\n"); pr_err("requestd size %zu is larger than bridge size %d\n", size, default_bridge.size); ret = -EINVAL; ret = -EINVAL; goto exit; goto exit; } } size = roundup(size, 1 << default_bridge.min_alloc_order); size = roundup(size, 1 << default_bridge.min_alloc_order); va = gen_pool_alloc(default_bridge.genpool, size); va = gen_pool_alloc(default_bridge.genpool, size); Loading Loading @@ -350,6 +352,7 @@ EXPORT_SYMBOL(qtee_shmbridge_inv_shm_buf); static int qtee_shmbridge_init(struct platform_device *pdev) static int qtee_shmbridge_init(struct platform_device *pdev) { { int ret = 0; int ret = 0; uint32_t custom_bridge_size; uint32_t *ns_vm_ids; uint32_t *ns_vm_ids; uint32_t ns_vm_ids_hlos[] = {VMID_HLOS}; uint32_t ns_vm_ids_hlos[] = {VMID_HLOS}; uint32_t ns_vm_ids_hyp[] = {}; uint32_t ns_vm_ids_hyp[] = {}; Loading @@ -367,8 +370,16 @@ static int qtee_shmbridge_init(struct platform_device *pdev) return 0; 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; 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, default_bridge.vaddr = (void *)__get_free_pages(GFP_KERNEL|__GFP_COMP, get_order(default_bridge.size)); get_order(default_bridge.size)); if (!default_bridge.vaddr) if (!default_bridge.vaddr) Loading Loading @@ -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", pr_debug("qtee shmbridge registered default bridge with size %d bytes\n", DEFAULT_BRIDGE_SIZE); default_bridge.size); return 0; return 0; Loading Loading
drivers/firmware/qtee_shmbridge.c +19 −8 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "qtee_shmbridge_internal.h" #include "qtee_shmbridge_internal.h" #define DEFAULT_BRIDGE_SIZE SZ_4M /*4M*/ #define DEFAULT_BRIDGE_SIZE SZ_4M /*4M*/ #define MIN_BRIDGE_SIZE SZ_4K /*4K*/ #define MAXSHMVMS 4 #define MAXSHMVMS 4 #define PERM_BITS 3 #define PERM_BITS 3 Loading Loading @@ -280,18 +281,19 @@ int32_t qtee_shmbridge_allocate_shm(size_t size, struct qtee_shm *shm) int32_t ret = 0; int32_t ret = 0; unsigned long va; unsigned long va; if (size > DEFAULT_BRIDGE_SIZE) { if (IS_ERR_OR_NULL(shm)) { pr_err("requestd size %zu is larger than bridge size %d\n", pr_err("qtee_shm is NULL\n"); size, DEFAULT_BRIDGE_SIZE); ret = -EINVAL; ret = -EINVAL; goto exit; goto exit; } } if (IS_ERR_OR_NULL(shm)) { if (size > default_bridge.size) { pr_err("qtee_shm is NULL\n"); pr_err("requestd size %zu is larger than bridge size %d\n", size, default_bridge.size); ret = -EINVAL; ret = -EINVAL; goto exit; goto exit; } } size = roundup(size, 1 << default_bridge.min_alloc_order); size = roundup(size, 1 << default_bridge.min_alloc_order); va = gen_pool_alloc(default_bridge.genpool, size); va = gen_pool_alloc(default_bridge.genpool, size); Loading Loading @@ -350,6 +352,7 @@ EXPORT_SYMBOL(qtee_shmbridge_inv_shm_buf); static int qtee_shmbridge_init(struct platform_device *pdev) static int qtee_shmbridge_init(struct platform_device *pdev) { { int ret = 0; int ret = 0; uint32_t custom_bridge_size; uint32_t *ns_vm_ids; uint32_t *ns_vm_ids; uint32_t ns_vm_ids_hlos[] = {VMID_HLOS}; uint32_t ns_vm_ids_hlos[] = {VMID_HLOS}; uint32_t ns_vm_ids_hyp[] = {}; uint32_t ns_vm_ids_hyp[] = {}; Loading @@ -367,8 +370,16 @@ static int qtee_shmbridge_init(struct platform_device *pdev) return 0; 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; 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, default_bridge.vaddr = (void *)__get_free_pages(GFP_KERNEL|__GFP_COMP, get_order(default_bridge.size)); get_order(default_bridge.size)); if (!default_bridge.vaddr) if (!default_bridge.vaddr) Loading Loading @@ -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", pr_debug("qtee shmbridge registered default bridge with size %d bytes\n", DEFAULT_BRIDGE_SIZE); default_bridge.size); return 0; return 0; Loading