Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

misc: fastrpc: Fix remote heap allocation request

Remote heap is used by DSP audioPD on need basis. This memory is
allocated from reserved CMA memory region and is then shared with
audioPD to use it for it's functionality.

Current implementation of remote heap is not allocating the memory
from CMA region, instead it is allocating the memory from SMMU
context bank. The arguments passed to scm call for the reassignment
of ownership is also not correct. Added changes to allocate CMA
memory and have a proper ownership reassignment.

Fixes: 532ad70c6d44 ("misc: fastrpc: Add mmap request assigning for static PD pool")
Cc: stable <stable@kernel.org>
Tested-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230811115643.38578-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ekansh Gupta and committed by
Greg Kroah-Hartman
ada6c2d9 48e32109

+7 -7
+7 -7
drivers/misc/fastrpc.c
··· 1867 1867 return -EINVAL; 1868 1868 } 1869 1869 1870 - err = fastrpc_buf_alloc(fl, fl->sctx->dev, req.size, &buf); 1870 + if (req.flags == ADSP_MMAP_REMOTE_HEAP_ADDR) 1871 + err = fastrpc_remote_heap_alloc(fl, dev, req.size, &buf); 1872 + else 1873 + err = fastrpc_buf_alloc(fl, dev, req.size, &buf); 1874 + 1871 1875 if (err) { 1872 1876 dev_err(dev, "failed to allocate buffer\n"); 1873 1877 return err; ··· 1910 1906 1911 1907 /* Add memory to static PD pool, protection thru hypervisor */ 1912 1908 if (req.flags == ADSP_MMAP_REMOTE_HEAP_ADDR && fl->cctx->vmcount) { 1913 - struct qcom_scm_vmperm perm; 1914 - 1915 - perm.vmid = QCOM_SCM_VMID_HLOS; 1916 - perm.perm = QCOM_SCM_PERM_RWX; 1917 - err = qcom_scm_assign_mem(buf->phys, buf->size, 1918 - &fl->cctx->perms, &perm, 1); 1909 + err = qcom_scm_assign_mem(buf->phys, (u64)buf->size, 1910 + &fl->cctx->perms, fl->cctx->vmperms, fl->cctx->vmcount); 1919 1911 if (err) { 1920 1912 dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d", 1921 1913 buf->phys, buf->size, err);