Skip to content

Commit c797ce5

Browse files
committed
Revert "FROMLIST: misc: fastrpc: Allocate entire reserved memory for Audio PD in probe"
This change corresponds to the v4 version shared with the upstream community. Revert it to apply the complete v6 revision, which includes additional fixes and updates not present in the earlier version. This reverts commit c9010fc. Signed-off-by: Vinayak Katoch <vkatoch@qti.qualcomm.com>
1 parent 768ed82 commit c797ce5

1 file changed

Lines changed: 52 additions & 51 deletions

File tree

drivers/misc/fastrpc.c

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,6 @@ struct fastrpc_channel_ctx {
294294
struct kref refcount;
295295
/* Flag if dsp attributes are cached */
296296
bool valid_attributes;
297-
/* Flag if audio PD init mem was allocated */
298-
bool audio_init_mem;
299297
u32 dsp_attributes[FASTRPC_MAX_DSP_ATTRIBUTES];
300298
struct fastrpc_device *secure_fdevice;
301299
struct fastrpc_device *fdevice;
@@ -1461,16 +1459,15 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
14611459
struct fastrpc_init_create_static init;
14621460
struct fastrpc_invoke_args *args;
14631461
struct fastrpc_phy_page pages[1];
1464-
struct fastrpc_channel_ctx *cctx = fl->cctx;
14651462
char *name;
14661463
int err;
1464+
bool scm_done = false;
14671465
struct {
14681466
int client_id;
14691467
u32 namelen;
14701468
u32 pageslen;
14711469
} inbuf;
14721470
u32 sc;
1473-
unsigned long flags;
14741471

14751472
args = kzalloc_objs(*args, FASTRPC_CREATE_STATIC_PROCESS_NARGS);
14761473
if (!args)
@@ -1494,6 +1491,31 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
14941491
inbuf.client_id = fl->client_id;
14951492
inbuf.namelen = init.namelen;
14961493
inbuf.pageslen = 0;
1494+
if (!fl->cctx->remote_heap) {
1495+
err = fastrpc_remote_heap_alloc(fl, fl->sctx->dev, init.memlen,
1496+
&fl->cctx->remote_heap);
1497+
if (err)
1498+
goto err_name;
1499+
1500+
/* Map if we have any heap VMIDs associated with this ADSP Static Process. */
1501+
if (fl->cctx->vmcount) {
1502+
u64 src_perms = BIT(QCOM_SCM_VMID_HLOS);
1503+
1504+
err = qcom_scm_assign_mem(fl->cctx->remote_heap->dma_addr,
1505+
(u64)fl->cctx->remote_heap->size,
1506+
&src_perms,
1507+
fl->cctx->vmperms, fl->cctx->vmcount);
1508+
if (err) {
1509+
dev_err(fl->sctx->dev,
1510+
"Failed to assign memory with dma_addr %pad size 0x%llx err %d\n",
1511+
&fl->cctx->remote_heap->dma_addr,
1512+
fl->cctx->remote_heap->size, err);
1513+
goto err_map;
1514+
}
1515+
scm_done = true;
1516+
inbuf.pageslen = 1;
1517+
}
1518+
}
14971519

14981520
fl->pd = USER_PD;
14991521

@@ -1505,25 +1527,8 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
15051527
args[1].length = inbuf.namelen;
15061528
args[1].fd = -1;
15071529

1508-
spin_lock_irqsave(&cctx->lock, flags);
1509-
if (!fl->cctx->audio_init_mem) {
1510-
if (!fl->cctx->remote_heap ||
1511-
!fl->cctx->remote_heap->dma_addr ||
1512-
!fl->cctx->remote_heap->size) {
1513-
spin_unlock_irqrestore(&cctx->lock, flags);
1514-
err = -ENOMEM;
1515-
goto err;
1516-
}
1517-
1518-
pages[0].addr = fl->cctx->remote_heap->dma_addr;
1519-
pages[0].size = fl->cctx->remote_heap->size;
1520-
fl->cctx->audio_init_mem = true;
1521-
inbuf.pageslen = 1;
1522-
} else {
1523-
pages[0].addr = 0;
1524-
pages[0].size = 0;
1525-
}
1526-
spin_unlock_irqrestore(&cctx->lock, flags);
1530+
pages[0].addr = fl->cctx->remote_heap->dma_addr;
1531+
pages[0].size = fl->cctx->remote_heap->size;
15271532

15281533
args[2].ptr = (u64)(uintptr_t) pages;
15291534
args[2].length = sizeof(*pages);
@@ -1541,7 +1546,27 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
15411546

15421547
return 0;
15431548
err_invoke:
1544-
fl->cctx->audio_init_mem = false;
1549+
if (fl->cctx->vmcount && scm_done) {
1550+
u64 src_perms = 0;
1551+
struct qcom_scm_vmperm dst_perms;
1552+
u32 i;
1553+
1554+
for (i = 0; i < fl->cctx->vmcount; i++)
1555+
src_perms |= BIT(fl->cctx->vmperms[i].vmid);
1556+
1557+
dst_perms.vmid = QCOM_SCM_VMID_HLOS;
1558+
dst_perms.perm = QCOM_SCM_PERM_RWX;
1559+
err = qcom_scm_assign_mem(fl->cctx->remote_heap->dma_addr,
1560+
(u64)fl->cctx->remote_heap->size,
1561+
&src_perms, &dst_perms, 1);
1562+
if (err)
1563+
dev_err(fl->sctx->dev, "Failed to assign memory dma_addr %pad size 0x%llx err %d\n",
1564+
&fl->cctx->remote_heap->dma_addr, fl->cctx->remote_heap->size, err);
1565+
}
1566+
err_map:
1567+
fastrpc_buf_free(fl->cctx->remote_heap);
1568+
fl->cctx->remote_heap = NULL;
1569+
err_name:
15451570
kfree(name);
15461571
err:
15471572
kfree(args);
@@ -2565,7 +2590,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
25652590
}
25662591
}
25672592

2568-
if (domain_id == SDSP_DOMAIN_ID || domain_id == ADSP_DOMAIN_ID) {
2593+
if (domain_id == SDSP_DOMAIN_ID) {
25692594
struct resource res;
25702595
u64 src_perms;
25712596

@@ -2579,15 +2604,6 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
25792604
goto err_free_data;
25802605
}
25812606

2582-
if (domain_id == ADSP_DOMAIN_ID) {
2583-
data->remote_heap =
2584-
kzalloc_obj(*data->remote_heap, GFP_KERNEL);
2585-
if (!data->remote_heap)
2586-
return -ENOMEM;
2587-
2588-
data->remote_heap->dma_addr = res.start;
2589-
data->remote_heap->size = resource_size(&res);
2590-
}
25912607
}
25922608

25932609
secure_dsp = !(of_property_read_bool(rdev->of_node, "qcom,non-secure-domain"));
@@ -2668,7 +2684,6 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev)
26682684
struct fastrpc_buf *buf, *b;
26692685
struct fastrpc_user *user;
26702686
unsigned long flags;
2671-
int err;
26722687

26732688
/* No invocations past this point */
26742689
spin_lock_irqsave(&cctx->lock, flags);
@@ -2686,22 +2701,8 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev)
26862701
list_for_each_entry_safe(buf, b, &cctx->invoke_interrupted_mmaps, node)
26872702
list_del(&buf->node);
26882703

2689-
if (cctx->remote_heap && cctx->vmcount) {
2690-
u64 src_perms = 0;
2691-
struct qcom_scm_vmperm dst_perms;
2692-
2693-
for (u32 i = 0; i < cctx->vmcount; i++)
2694-
src_perms |= BIT(cctx->vmperms[i].vmid);
2695-
2696-
dst_perms.vmid = QCOM_SCM_VMID_HLOS;
2697-
dst_perms.perm = QCOM_SCM_PERM_RWX;
2698-
2699-
err = qcom_scm_assign_mem(cctx->remote_heap->dma_addr,
2700-
cctx->remote_heap->size, &src_perms,
2701-
&dst_perms, 1);
2702-
if (!err)
2703-
fastrpc_buf_free(cctx->remote_heap);
2704-
}
2704+
if (cctx->remote_heap)
2705+
fastrpc_buf_free(cctx->remote_heap);
27052706

27062707
of_platform_depopulate(&rpdev->dev);
27072708

0 commit comments

Comments
 (0)