Skip to content

Commit 532ad70

Browse files
abelvesagregkh
authored andcommitted
misc: fastrpc: Add mmap request assigning for static PD pool
If the mmap request is to add pages and thre are VMIDs associated with that context, do a call to SCM to reassign that memory. Do not do this for remote heap allocation, that is done on init create static process only. Co-developed-by: Srinivas Kandagatla <[email protected]> Signed-off-by: Abel Vesa <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 76e8e4a commit 532ad70

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

drivers/misc/fastrpc.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1839,8 +1839,9 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp)
18391839
if (copy_from_user(&req, argp, sizeof(req)))
18401840
return -EFAULT;
18411841

1842-
if (req.flags != ADSP_MMAP_ADD_PAGES) {
1842+
if (req.flags != ADSP_MMAP_ADD_PAGES && req.flags != ADSP_MMAP_REMOTE_HEAP_ADDR) {
18431843
dev_err(dev, "flag not supported 0x%x\n", req.flags);
1844+
18441845
return -EINVAL;
18451846
}
18461847

@@ -1886,6 +1887,22 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp)
18861887
/* let the client know the address to use */
18871888
req.vaddrout = rsp_msg.vaddr;
18881889

1890+
/* Add memory to static PD pool, protection thru hypervisor */
1891+
if (req.flags != ADSP_MMAP_REMOTE_HEAP_ADDR && fl->cctx->vmcount) {
1892+
struct qcom_scm_vmperm perm;
1893+
int err = 0;
1894+
1895+
perm.vmid = QCOM_SCM_VMID_HLOS;
1896+
perm.perm = QCOM_SCM_PERM_RWX;
1897+
err = qcom_scm_assign_mem(buf->phys, buf->size,
1898+
&(fl->cctx->vmperms[0].vmid), &perm, 1);
1899+
if (err) {
1900+
dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d",
1901+
buf->phys, buf->size, err);
1902+
goto err_assign;
1903+
}
1904+
}
1905+
18891906
spin_lock(&fl->lock);
18901907
list_add_tail(&buf->node, &fl->mmaps);
18911908
spin_unlock(&fl->lock);

0 commit comments

Comments
 (0)