Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 19 additions & 24 deletions drivers/misc/fastrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,13 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
u32 sc;
unsigned long flags;

if (!fl->cctx->remote_heap ||
!fl->cctx->remote_heap->dma_addr ||
!fl->cctx->remote_heap->size) {
err = -ENOMEM;
dev_dbg(fl->sctx->dev, "remote heap memory region is not added\n");
return err;
}
args = kzalloc_objs(*args, FASTRPC_CREATE_STATIC_PROCESS_NARGS);
if (!args)
return -ENOMEM;
Expand Down Expand Up @@ -1506,14 +1513,6 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,

spin_lock_irqsave(&cctx->lock, flags);
if (!fl->cctx->audio_init_mem) {
if (!fl->cctx->remote_heap ||
!fl->cctx->remote_heap->dma_addr ||
!fl->cctx->remote_heap->size) {
spin_unlock_irqrestore(&cctx->lock, flags);
err = -ENOMEM;
goto err;
}

pages[0].addr = fl->cctx->remote_heap->dma_addr;
pages[0].size = fl->cctx->remote_heap->size;
fl->cctx->audio_init_mem = true;
Expand Down Expand Up @@ -2155,17 +2154,14 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp)

if (copy_to_user((void __user *)argp, &req, sizeof(req))) {
err = -EFAULT;
goto err_copy;
goto err_assign;
}

dev_dbg(dev, "mmap\t\tpt 0x%09lx OK [len 0x%08llx]\n",
buf->raddr, buf->size);

return 0;
err_copy:
spin_lock(&fl->lock);
list_del(&buf->node);
spin_unlock(&fl->lock);

err_assign:
fastrpc_req_munmap_impl(fl, buf);

Expand Down Expand Up @@ -2569,23 +2565,22 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)

err = of_reserved_mem_region_to_resource(rdev->of_node, 0, &res);
if (!err) {
if (domain_id == ADSP_DOMAIN_ID) {
data->remote_heap =
kzalloc_obj(*data->remote_heap, GFP_KERNEL);
if (!data->remote_heap)
return -ENOMEM;

data->remote_heap->dma_addr = res.start;
data->remote_heap->size = resource_size(&res);
}
src_perms = BIT(QCOM_SCM_VMID_HLOS);

err = qcom_scm_assign_mem(res.start, resource_size(&res), &src_perms,
data->vmperms, data->vmcount);
if (err)
goto err_free_data;
}

if (domain_id == ADSP_DOMAIN_ID) {
data->remote_heap =
kzalloc_obj(*data->remote_heap, GFP_KERNEL);
if (!data->remote_heap)
return -ENOMEM;

data->remote_heap->dma_addr = res.start;
data->remote_heap->size = resource_size(&res);
}
}

secure_dsp = !(of_property_read_bool(rdev->of_node, "qcom,non-secure-domain"));
Expand Down Expand Up @@ -2698,7 +2693,7 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev)
cctx->remote_heap->size, &src_perms,
&dst_perms, 1);
if (!err)
fastrpc_buf_free(cctx->remote_heap);
kfree(cctx->remote_heap);
}

of_platform_depopulate(&rpdev->dev);
Expand Down