mirror of
https://github.com/commaai/agnos-kernel-sdm845.git
synced 2026-06-08 03:15:12 +08:00
msm: adsprpc: use same CPU address during DMA allocation and free
Ensure that the same CPU address returned from the DMA memory allocation API is passed to the DMA memory free API. Change-Id: I09d23fb9960bc3400f85aef84bb16d64b546b112 Acked-by: Thyagarajan Venkatanarayanan <venkatan@qti.qualcomm.com> Signed-off-by: Mohammed Nayeem Ur Rahman <mohara@codeaurora.org>
This commit is contained in:
committed by
Li.Zhengchun
parent
8eb455fed7
commit
2b84a57a6e
@@ -627,21 +627,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;
|
||||
@@ -780,6 +779,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;
|
||||
|
||||
@@ -802,12 +802,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;
|
||||
|
||||
@@ -2662,14 +2663,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)) {
|
||||
@@ -2677,13 +2679,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;
|
||||
|
||||
Reference in New Issue
Block a user