Loading drivers/soc/qcom/hab/hab_mem_linux.c +10 −44 Original line number Diff line number Diff line /* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. /* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -495,48 +495,18 @@ int habmem_hyp_grant(struct virtual_channel *vchan, int *export_id) { int ret = 0; void *kva = (void *)(uintptr_t)address; int is_vmalloc = is_vmalloc_addr(kva); struct page **pages; int i; struct dma_buf *dmabuf = NULL; struct pages_list *pglist = NULL; DEFINE_DMA_BUF_EXPORT_INFO(exp_info); pages = kmalloc_array(page_count, sizeof(struct page *), GFP_KERNEL); if (!pages) goto err; pglist = kzalloc(sizeof(*pglist), GFP_KERNEL); if (!pglist) goto err; pglist->pages = pages; pglist->npages = page_count; pglist->type = HAB_PAGE_LIST_EXPORT; pglist->pchan = vchan->pchan; pglist->vcid = vchan->id; kref_init(&pglist->refcount); for (i = 0; i < page_count; i++) { kva = (void *)(uintptr_t)(address + i*PAGE_SIZE); if (is_vmalloc) pages[i] = vmalloc_to_page(kva); else pages[i] = virt_to_page(kva); get_page(pages[i]); } if (HABMM_EXPIMP_FLAGS_DMABUF & flags) { dmabuf = (struct dma_buf *)address; if (dmabuf) get_dma_buf(dmabuf); } else if (HABMM_EXPIMP_FLAGS_FD & flags) dmabuf = dma_buf_get(address); exp_info.ops = &dma_buf_ops; exp_info.size = pglist->npages << PAGE_SHIFT; exp_info.flags = O_RDWR; exp_info.priv = pglist; dmabuf = dma_buf_export(&exp_info); if (IS_ERR(dmabuf)) { pr_err("export to dmabuf failed %d\n", PTR_ERR(dmabuf)); goto err; if (IS_ERR_OR_NULL(dmabuf)) { pr_err("failed, invalid input addr: %pK\n", address); return -EINVAL; } ret = habmem_add_export_compress(vchan, Loading @@ -548,10 +518,6 @@ int habmem_hyp_grant(struct virtual_channel *vchan, export_id); return ret; err: kfree(pages); kfree(pglist); return ret; } int habmem_exp_release(struct export_desc_super *exp_super) Loading drivers/soc/qcom/hab/khab.c +1 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ int32_t habmm_export(int32_t handle, void *buff_to_share, uint32_t size_bytes, param.vcid = handle; param.buffer = (uint64_t)(uintptr_t)buff_to_share; param.sizebytes = size_bytes; param.flags = flags; ret = hab_mem_export(hab_driver.kctx, ¶m, 1); Loading include/linux/habmm.h +3 −2 Original line number Diff line number Diff line /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -249,6 +249,7 @@ int32_t habmm_socket_recvfrom(int32_t handle, void *dst_buff, * this flag is used for export from dma_buf fd or import to dma_buf fd */ #define HABMM_EXPIMP_FLAGS_FD 0x00010000 #define HABMM_EXPIMP_FLAGS_DMABUF 0x00020000 #define HAB_MAX_EXPORT_SIZE 0x8000000 Loading Loading
drivers/soc/qcom/hab/hab_mem_linux.c +10 −44 Original line number Diff line number Diff line /* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. /* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -495,48 +495,18 @@ int habmem_hyp_grant(struct virtual_channel *vchan, int *export_id) { int ret = 0; void *kva = (void *)(uintptr_t)address; int is_vmalloc = is_vmalloc_addr(kva); struct page **pages; int i; struct dma_buf *dmabuf = NULL; struct pages_list *pglist = NULL; DEFINE_DMA_BUF_EXPORT_INFO(exp_info); pages = kmalloc_array(page_count, sizeof(struct page *), GFP_KERNEL); if (!pages) goto err; pglist = kzalloc(sizeof(*pglist), GFP_KERNEL); if (!pglist) goto err; pglist->pages = pages; pglist->npages = page_count; pglist->type = HAB_PAGE_LIST_EXPORT; pglist->pchan = vchan->pchan; pglist->vcid = vchan->id; kref_init(&pglist->refcount); for (i = 0; i < page_count; i++) { kva = (void *)(uintptr_t)(address + i*PAGE_SIZE); if (is_vmalloc) pages[i] = vmalloc_to_page(kva); else pages[i] = virt_to_page(kva); get_page(pages[i]); } if (HABMM_EXPIMP_FLAGS_DMABUF & flags) { dmabuf = (struct dma_buf *)address; if (dmabuf) get_dma_buf(dmabuf); } else if (HABMM_EXPIMP_FLAGS_FD & flags) dmabuf = dma_buf_get(address); exp_info.ops = &dma_buf_ops; exp_info.size = pglist->npages << PAGE_SHIFT; exp_info.flags = O_RDWR; exp_info.priv = pglist; dmabuf = dma_buf_export(&exp_info); if (IS_ERR(dmabuf)) { pr_err("export to dmabuf failed %d\n", PTR_ERR(dmabuf)); goto err; if (IS_ERR_OR_NULL(dmabuf)) { pr_err("failed, invalid input addr: %pK\n", address); return -EINVAL; } ret = habmem_add_export_compress(vchan, Loading @@ -548,10 +518,6 @@ int habmem_hyp_grant(struct virtual_channel *vchan, export_id); return ret; err: kfree(pages); kfree(pglist); return ret; } int habmem_exp_release(struct export_desc_super *exp_super) Loading
drivers/soc/qcom/hab/khab.c +1 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ int32_t habmm_export(int32_t handle, void *buff_to_share, uint32_t size_bytes, param.vcid = handle; param.buffer = (uint64_t)(uintptr_t)buff_to_share; param.sizebytes = size_bytes; param.flags = flags; ret = hab_mem_export(hab_driver.kctx, ¶m, 1); Loading
include/linux/habmm.h +3 −2 Original line number Diff line number Diff line /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -249,6 +249,7 @@ int32_t habmm_socket_recvfrom(int32_t handle, void *dst_buff, * this flag is used for export from dma_buf fd or import to dma_buf fd */ #define HABMM_EXPIMP_FLAGS_FD 0x00010000 #define HABMM_EXPIMP_FLAGS_DMABUF 0x00020000 #define HAB_MAX_EXPORT_SIZE 0x8000000 Loading