diff options
author | Tharun Kumar Merugu <mtharu@codeaurora.org> | 2018-09-14 22:30:58 +0530 |
---|---|---|
committer | Mohit Sharma <smohit@codeaurora.org> | 2018-09-29 10:49:23 +0530 |
commit | d0e1ddc2fc5bbd6c58f316ee0c70e34e35b6f814 (patch) | |
tree | e35992c8fb65aca9ae870a358072bd5edf4fcb34 | |
parent | 4b4c3582cd0f94c23dd9aa89592a292aaf2b6075 (diff) |
msm: adsprpc: use same CPU address during DMA allocation and freeLA.UM.6.6.2.r1-05500-89xx.0
Ensure that the same CPU address returned from the DMA memory
allocation API is passed to the DMA memory free API.
Change-Id: I116358378465cd518e1e1ecb60aee465301a709f
Acked-by: Thyagarajan Venkatanarayanan <venkatan@qti.qualcomm.com>
Signed-off-by: Mohammed Nayeem Ur Rahman <mohara@codeaurora.org>
Signed-off-by: Mohit Sharma <smohit@codeaurora.org>
-rw-r--r-- | drivers/char/adsprpc.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/drivers/char/adsprpc.c b/drivers/char/adsprpc.c index eb4a41630086..a54e481f3c79 100644 --- a/drivers/char/adsprpc.c +++ b/drivers/char/adsprpc.c @@ -616,21 +616,20 @@ static int fastrpc_mmap_find(struct fastrpc_file *fl, int fd, return -ENOTTY; } -static int dma_alloc_memory(dma_addr_t *region_phys, size_t size, +static int dma_alloc_memory(dma_addr_t *region_phys, void **vaddr, size_t size, unsigned long dma_attrs) { struct fastrpc_apps *me = &gfa; - void *vaddr = NULL; if (me->dev == NULL) { pr_err("device adsprpc-mem is not initialized\n"); return -ENODEV; } - vaddr = dma_alloc_attrs(me->dev, size, region_phys, GFP_KERNEL, + *vaddr = dma_alloc_attrs(me->dev, size, region_phys, GFP_KERNEL, dma_attrs); - if (!vaddr) { - pr_err("ADSPRPC: Failed to allocate %x remote heap memory\n", - (unsigned int)size); + if (IS_ERR_OR_NULL(*vaddr)) { + pr_err("adsprpc: %s: %s: dma_alloc_attrs failed for size 0x%zx, returned %pK\n", + current->comm, __func__, size, (*vaddr)); return -ENOMEM; } return 0; @@ -769,6 +768,7 @@ static int fastrpc_mmap_create(struct fastrpc_file *fl, int fd, struct fastrpc_mmap *map = NULL; unsigned long attrs; dma_addr_t region_phys = 0; + void *region_vaddr = NULL; unsigned long flags; int err = 0, vmid; @@ -791,12 +791,13 @@ static int fastrpc_mmap_create(struct fastrpc_file *fl, int fd, map->apps = me; map->fl = NULL; - VERIFY(err, !dma_alloc_memory(®ion_phys, len, dma_attrs)); + VERIFY(err, !dma_alloc_memory(®ion_phys, ®ion_vaddr, + len, dma_attrs)); if (err) goto bail; map->phys = (uintptr_t)region_phys; map->size = len; - map->va = (uintptr_t)map->phys; + map->va = (uintptr_t)region_vaddr; } else if (mflags == FASTRPC_DMAHANDLE_NOMAP) { ion_phys_addr_t iphys; @@ -2625,14 +2626,15 @@ static int fastrpc_internal_mmap(struct fastrpc_file *fl, 1, &rbuf); if (err) goto bail; - rbuf->virt = NULL; - err = fastrpc_mmap_on_dsp(fl, ud->flags, - (uintptr_t)rbuf->virt, + err = fastrpc_mmap_on_dsp(fl, ud->flags, 0, rbuf->phys, rbuf->size, &raddr); if (err) goto bail; rbuf->raddr = raddr; } else { + + uintptr_t va_to_dsp; + mutex_lock(&fl->fl_map_mutex); if (!fastrpc_mmap_find(fl, ud->fd, (uintptr_t)ud->vaddrin, ud->size, ud->flags, 1, &map)) { @@ -2640,13 +2642,20 @@ static int fastrpc_internal_mmap(struct fastrpc_file *fl, mutex_unlock(&fl->map_mutex); return 0; } + VERIFY(err, !fastrpc_mmap_create(fl, ud->fd, 0, (uintptr_t)ud->vaddrin, ud->size, ud->flags, &map)); mutex_unlock(&fl->fl_map_mutex); if (err) goto bail; - VERIFY(err, 0 == fastrpc_mmap_on_dsp(fl, ud->flags, map->va, + + if (ud->flags == ADSP_MMAP_HEAP_ADDR || + ud->flags == ADSP_MMAP_REMOTE_HEAP_ADDR) + va_to_dsp = 0; + else + va_to_dsp = (uintptr_t)map->va; + VERIFY(err, 0 == fastrpc_mmap_on_dsp(fl, ud->flags, va_to_dsp, map->phys, map->size, &raddr)); if (err) goto bail; |