Message ID | 20240108100513.19993-1-quic_ekangupt@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-19316-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp925365dyq; Mon, 8 Jan 2024 02:06:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IH47vt0SR5yhDLKV3pVWwnM6j0KYpCjBhNFYwtWzi5L/2X0YeZ3EJkP4KJsb4b0QadUQMUv X-Received: by 2002:a05:6358:9387:b0:174:c540:dfd1 with SMTP id h7-20020a056358938700b00174c540dfd1mr4498759rwb.56.1704708362796; Mon, 08 Jan 2024 02:06:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704708362; cv=none; d=google.com; s=arc-20160816; b=BAknX9jZSbavaYJcBlxYJWpyTlTH0HVjUlTgxjDVIy54zfqHnVN0r+Wdp0IXn1vH34 Sb1xTPmojnCjkPqh/+5xTOqK2bM9S9KPHiF/+BCiNzF5vxU9xuTpMb+Tnyfoit1TqOj+ JXhwm/2vS535PdWKRzS5K9dzXajSoELMpt4W7H2+AV/zOk26JKjDt1PE2jQt44ErnHD3 V5Dia8XJ87Gi4wIqU7C5rn1x5ILzp6LPKcfmtMscjog7dhed3YDDtPxg/WathyaNr2gS NbH/vVQ2itiCdRhcqdtFlzwAqYGsiEjNZjLSCZhMxkOvcu40+nHn343JQj/twHSQ9PlN Vb4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from:dkim-signature; bh=eVg6xNPnAthWRp6dVUFjU+PI9OyT+fFbgWrhWYJmdiI=; fh=F5rbowGjvbqNBzTnmiL0S4FAgR2ymdfWoOSxHBDW0qI=; b=jHa1XjZwYjQFv9Yu4jwNQQyEs7fs2gNYVjYtmC9WgPT4dUBYRINI1DoYb7zYOSaOMP aVXiMk+zWBGZ/StapBj5xIHnTK38j4v1c+q709k1Q413nTLTddkbvA2jf1+5X03dxuHV qiF6imTaoylvkIjH3VKoda1B2UmAAhuEl0+4nA0dtfP1OfeFQVQupj1B3DgKTxHM/e32 ZBx8++hmUe25GmP0An2MsmXnYSWTVPXtIYa3nRfGXD+ITiD3Z6m/59LuvAh7NOalD8tX uUzdPhgKthWlyhcSITn0NAPkfoXhTAAS9IogXn8qYyR/c5i0KFzlkJsqj/1rjssrrR/Y kLMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=BXnEhf8H; spf=pass (google.com: domain of linux-kernel+bounces-19316-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19316-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id t70-20020a638149000000b005ce0a6eb0cesi5958358pgd.899.2024.01.08.02.06.02 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 02:06:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19316-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=BXnEhf8H; spf=pass (google.com: domain of linux-kernel+bounces-19316-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19316-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 22C87B216CE for <ouuuleilei@gmail.com>; Mon, 8 Jan 2024 10:05:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2157314005; Mon, 8 Jan 2024 10:05:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="BXnEhf8H" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51F71134C8; Mon, 8 Jan 2024 10:05:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 4088OuKU003159; Mon, 8 Jan 2024 10:05:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:mime-version:content-type; s= qcppdkim1; bh=eVg6xNPnAthWRp6dVUFjU+PI9OyT+fFbgWrhWYJmdiI=; b=BX nEhf8HVQY6vg5hCKldgGPzEwrw8z8UrQXR7AeOuS7zwRWgEjDDqsKkT7QZwZE7c6 vkf0wNWDN8tz+iPqTKBWqgT4FP7KUhQumvzcz0eHhnGxoIxsfxTelLwA2qnmfAIt zcS021ifFiy8xYI9XWVoK6sPaiszJFpYA5CgSDkdk+uuANdn2BkSNC5JPSVZamZd T/gnX5lAhktln0chS4duYpKMnItKPA4zGGDAKxjF8T+3VoFNDak9XV4GMLG0g0JV S/kZZz4XzRPH9WYLOZc6DH7YquNUqzyxJF87p3Dmz4xLdwkvhgpuIlwOXHdmnzuv hMJi4TzTsy7nwTJ+1RNg== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vfxrk1d19-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Jan 2024 10:05:24 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 408A5NgR003022 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 8 Jan 2024 10:05:23 GMT Received: from hu-ekangupt-hyd.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Mon, 8 Jan 2024 02:05:21 -0800 From: Ekansh Gupta <quic_ekangupt@quicinc.com> To: <srinivas.kandagatla@linaro.org>, <linux-arm-msm@vger.kernel.org> CC: <gregkh@linuxfoundation.org>, <linux-kernel@vger.kernel.org>, stable <stable@kernel.org> Subject: [PATCH v1] misc: fastrpc: Pass proper arguments to scm call Date: Mon, 8 Jan 2024 15:35:13 +0530 Message-ID: <20240108100513.19993-1-quic_ekangupt@quicinc.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: Aj6xEq-F1cEWqhAy-o7OlZ-c77Z_RFjK X-Proofpoint-ORIG-GUID: Aj6xEq-F1cEWqhAy-o7OlZ-c77Z_RFjK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_01,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=942 priorityscore=1501 impostorscore=0 suspectscore=0 mlxscore=0 clxscore=1011 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401080084 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787516276252356229 X-GMAIL-MSGID: 1787516276252356229 |
Series |
[v1] misc: fastrpc: Pass proper arguments to scm call
|
|
Commit Message
Ekansh Gupta
Jan. 8, 2024, 10:05 a.m. UTC
For CMA memory allocation, ownership is assigned to DSP to make it
accessible by the PD running on the DSP. With current implementation
HLOS VM is stored in the channel structure during rpmsg_probe and
this VM is passed to qcom_scm call as the source VM.
The qcom_scm call will overwrite the passed source VM with the next
VM which would cause a problem in case the scm call is again needed.
Adding a local copy of source VM whereever scm call is made to avoid
this problem.
Fixes: 0871561055e6 ("misc: fastrpc: Add support for audiopd")
Cc: stable <stable@kernel.org>
Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
---
drivers/misc/fastrpc.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
Comments
On 1/8/2024 2:05 AM, Ekansh Gupta wrote: > For CMA memory allocation, ownership is assigned to DSP to make it > accessible by the PD running on the DSP. With current implementation > HLOS VM is stored in the channel structure during rpmsg_probe and > this VM is passed to qcom_scm call as the source VM. > > The qcom_scm call will overwrite the passed source VM with the next > VM which would cause a problem in case the scm call is again needed. > Adding a local copy of source VM whereever scm call is made to avoid > this problem. > The perms in fastrpc_channel_ctx should always reflect the current permission bits, so I'm surprised you see problem. What is the scenario where that's not the case? > Fixes: 0871561055e6 ("misc: fastrpc: Add support for audiopd")> Cc: stable <stable@kernel.org> > Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com> > --- > drivers/misc/fastrpc.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c > index 1c6c62a7f7f5..c13efa7727e0 100644 > --- a/drivers/misc/fastrpc.c > +++ b/drivers/misc/fastrpc.c > @@ -263,7 +263,6 @@ struct fastrpc_channel_ctx { > int domain_id; > int sesscount; > int vmcount; > - u64 perms; > struct qcom_scm_vmperm vmperms[FASTRPC_MAX_VMIDS]; > struct rpmsg_device *rpdev; > struct fastrpc_session_ctx session[FASTRPC_MAX_SESSIONS]; > @@ -1279,9 +1278,11 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl, > > /* Map if we have any heap VMIDs associated with this ADSP Static Process. */ > if (fl->cctx->vmcount) { > + u64 src_perms = BIT(QCOM_SCM_VMID_HLOS); > + > err = qcom_scm_assign_mem(fl->cctx->remote_heap->phys, > (u64)fl->cctx->remote_heap->size, > - &fl->cctx->perms, > + &src_perms, > fl->cctx->vmperms, fl->cctx->vmcount); > if (err) { > dev_err(fl->sctx->dev, "Failed to assign memory with phys 0x%llx size 0x%llx err %d", > @@ -1915,8 +1916,10 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) > > /* Add memory to static PD pool, protection thru hypervisor */ > if (req.flags == ADSP_MMAP_REMOTE_HEAP_ADDR && fl->cctx->vmcount) { > + u64 src_perms = BIT(QCOM_SCM_VMID_HLOS); > + > err = qcom_scm_assign_mem(buf->phys, (u64)buf->size, > - &fl->cctx->perms, fl->cctx->vmperms, fl->cctx->vmcount); > + &src_perms, fl->cctx->vmperms, fl->cctx->vmcount); > if (err) { > dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d", > buf->phys, buf->size, err); > @@ -2290,7 +2293,6 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) > > if (vmcount) { > data->vmcount = vmcount; > - data->perms = BIT(QCOM_SCM_VMID_HLOS); > for (i = 0; i < data->vmcount; i++) { > data->vmperms[i].vmid = vmids[i]; > data->vmperms[i].perm = QCOM_SCM_PERM_RWX;
On 1/9/2024 6:42 AM, Elliot Berman wrote: > > On 1/8/2024 2:05 AM, Ekansh Gupta wrote: >> For CMA memory allocation, ownership is assigned to DSP to make it >> accessible by the PD running on the DSP. With current implementation >> HLOS VM is stored in the channel structure during rpmsg_probe and >> this VM is passed to qcom_scm call as the source VM. >> >> The qcom_scm call will overwrite the passed source VM with the next >> VM which would cause a problem in case the scm call is again needed. >> Adding a local copy of source VM whereever scm call is made to avoid >> this problem. >> > The perms in fastrpc_channel_ctx should always reflect the current > permission bits, so I'm surprised you see problem. > > What is the scenario where that's not the case? Thanks for reviewing the changes, Elliot. FastRPC driver is storing the bitfield of HLOS VMID in fastrpc_channel_ctx in perms(cctx->perms) and remoteproc specific VMID information from device tree in vmperms(cctx->vmperms). This information is intended to be passed to qcom_scm call when there is a requirement to move the ownership of memory to any remoteproc VM. As the srcvm is overwritten with the new VM, cctx->perms cannot be reused if the same request comes for any other memory allocation. The problem is seen with audioPD daemon. When the daemon is stated, it allocates some memory for audioPD and moves the ownership from HLOS to ADSP VM using qcom_scm call. After this, audioPD makes a request for some more memory which is again allocated in kernel and as per current implementation, qcom_scm call is again made with cctx->perms as srcVm which is no longer storing HLOS vmid. Hence using a local variable to make qcom_scm call where there is a need to move ownership from HLOS to remoteproc VM. Please let me know if you have any more queries. --ekansh > >> Fixes: 0871561055e6 ("misc: fastrpc: Add support for audiopd")> Cc: stable <stable@kernel.org> >> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com> >> --- >> drivers/misc/fastrpc.c | 10 ++++++---- >> 1 file changed, 6 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c >> index 1c6c62a7f7f5..c13efa7727e0 100644 >> --- a/drivers/misc/fastrpc.c >> +++ b/drivers/misc/fastrpc.c >> @@ -263,7 +263,6 @@ struct fastrpc_channel_ctx { >> int domain_id; >> int sesscount; >> int vmcount; >> - u64 perms; >> struct qcom_scm_vmperm vmperms[FASTRPC_MAX_VMIDS]; >> struct rpmsg_device *rpdev; >> struct fastrpc_session_ctx session[FASTRPC_MAX_SESSIONS]; >> @@ -1279,9 +1278,11 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl, >> >> /* Map if we have any heap VMIDs associated with this ADSP Static Process. */ >> if (fl->cctx->vmcount) { >> + u64 src_perms = BIT(QCOM_SCM_VMID_HLOS); >> + >> err = qcom_scm_assign_mem(fl->cctx->remote_heap->phys, >> (u64)fl->cctx->remote_heap->size, >> - &fl->cctx->perms, >> + &src_perms, >> fl->cctx->vmperms, fl->cctx->vmcount); >> if (err) { >> dev_err(fl->sctx->dev, "Failed to assign memory with phys 0x%llx size 0x%llx err %d", >> @@ -1915,8 +1916,10 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) >> >> /* Add memory to static PD pool, protection thru hypervisor */ >> if (req.flags == ADSP_MMAP_REMOTE_HEAP_ADDR && fl->cctx->vmcount) { >> + u64 src_perms = BIT(QCOM_SCM_VMID_HLOS); >> + >> err = qcom_scm_assign_mem(buf->phys, (u64)buf->size, >> - &fl->cctx->perms, fl->cctx->vmperms, fl->cctx->vmcount); >> + &src_perms, fl->cctx->vmperms, fl->cctx->vmcount); >> if (err) { >> dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d", >> buf->phys, buf->size, err); >> @@ -2290,7 +2293,6 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) >> >> if (vmcount) { >> data->vmcount = vmcount; >> - data->perms = BIT(QCOM_SCM_VMID_HLOS); >> for (i = 0; i < data->vmcount; i++) { >> data->vmperms[i].vmid = vmids[i]; >> data->vmperms[i].perm = QCOM_SCM_PERM_RWX;
On 1/8/2024 9:38 PM, Ekansh Gupta wrote: > > On 1/9/2024 6:42 AM, Elliot Berman wrote: >> >> On 1/8/2024 2:05 AM, Ekansh Gupta wrote: >>> For CMA memory allocation, ownership is assigned to DSP to make it >>> accessible by the PD running on the DSP. With current implementation >>> HLOS VM is stored in the channel structure during rpmsg_probe and >>> this VM is passed to qcom_scm call as the source VM. >>> >>> The qcom_scm call will overwrite the passed source VM with the next >>> VM which would cause a problem in case the scm call is again needed. >>> Adding a local copy of source VM whereever scm call is made to avoid >>> this problem. >>> >> The perms in fastrpc_channel_ctx should always reflect the current >> permission bits, so I'm surprised you see problem. >> >> What is the scenario where that's not the case? > > Thanks for reviewing the changes, Elliot. FastRPC driver is storing > the bitfield of HLOS VMID in fastrpc_channel_ctx in perms(cctx->perms) > and remoteproc specific VMID information from device tree in vmperms(cctx->vmperms). > This information is intended to be passed to qcom_scm call when there is > a requirement to move the ownership of memory to any remoteproc VM. As > the srcvm is overwritten with the new VM, cctx->perms cannot be reused if > the same request comes for any other memory allocation. > > The problem is seen with audioPD daemon. When the daemon is stated, it > allocates some memory for audioPD and moves the ownership from HLOS to > ADSP VM using qcom_scm call. After this, audioPD makes a request for some > more memory which is again allocated in kernel and as per current > implementation, qcom_scm call is again made with cctx->perms as srcVm > which is no longer storing HLOS vmid. Hence using a local variable to > make qcom_scm call where there is a need to move ownership from HLOS > to remoteproc VM. > > Please let me know if you have any more queries. > Ah, got it. There can be multiple allocations/assignments per fastrpc_channel_ctx. In that case: Reviewed-by: Elliot Berman <quic_eberman@quicinc.com> > --ekansh > >> >>> Fixes: 0871561055e6 ("misc: fastrpc: Add support for audiopd")> Cc: stable <stable@kernel.org> >>> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com> >>> --- >>> drivers/misc/fastrpc.c | 10 ++++++---- >>> 1 file changed, 6 insertions(+), 4 deletions(-) >>> >>> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c >>> index 1c6c62a7f7f5..c13efa7727e0 100644 >>> --- a/drivers/misc/fastrpc.c >>> +++ b/drivers/misc/fastrpc.c >>> @@ -263,7 +263,6 @@ struct fastrpc_channel_ctx { >>> int domain_id; >>> int sesscount; >>> int vmcount; >>> - u64 perms; >>> struct qcom_scm_vmperm vmperms[FASTRPC_MAX_VMIDS]; >>> struct rpmsg_device *rpdev; >>> struct fastrpc_session_ctx session[FASTRPC_MAX_SESSIONS]; >>> @@ -1279,9 +1278,11 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl, >>> /* Map if we have any heap VMIDs associated with this ADSP Static Process. */ >>> if (fl->cctx->vmcount) { >>> + u64 src_perms = BIT(QCOM_SCM_VMID_HLOS); >>> + >>> err = qcom_scm_assign_mem(fl->cctx->remote_heap->phys, >>> (u64)fl->cctx->remote_heap->size, >>> - &fl->cctx->perms, >>> + &src_perms, >>> fl->cctx->vmperms, fl->cctx->vmcount); >>> if (err) { >>> dev_err(fl->sctx->dev, "Failed to assign memory with phys 0x%llx size 0x%llx err %d", >>> @@ -1915,8 +1916,10 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) >>> /* Add memory to static PD pool, protection thru hypervisor */ >>> if (req.flags == ADSP_MMAP_REMOTE_HEAP_ADDR && fl->cctx->vmcount) { >>> + u64 src_perms = BIT(QCOM_SCM_VMID_HLOS); >>> + >>> err = qcom_scm_assign_mem(buf->phys, (u64)buf->size, >>> - &fl->cctx->perms, fl->cctx->vmperms, fl->cctx->vmcount); >>> + &src_perms, fl->cctx->vmperms, fl->cctx->vmcount); >>> if (err) { >>> dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d", >>> buf->phys, buf->size, err); >>> @@ -2290,7 +2293,6 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) >>> if (vmcount) { >>> data->vmcount = vmcount; >>> - data->perms = BIT(QCOM_SCM_VMID_HLOS); >>> for (i = 0; i < data->vmcount; i++) { >>> data->vmperms[i].vmid = vmids[i]; >>> data->vmperms[i].perm = QCOM_SCM_PERM_RWX;
On Mon, 08 Jan 2024 15:35:13 +0530, Ekansh Gupta wrote: > For CMA memory allocation, ownership is assigned to DSP to make it > accessible by the PD running on the DSP. With current implementation > HLOS VM is stored in the channel structure during rpmsg_probe and > this VM is passed to qcom_scm call as the source VM. > > The qcom_scm call will overwrite the passed source VM with the next > VM which would cause a problem in case the scm call is again needed. > Adding a local copy of source VM whereever scm call is made to avoid > this problem. > > [...] Applied, thanks! [1/1] misc: fastrpc: Pass proper arguments to scm call commit: 5169a077f22a23d27660d048d5f43a592fd2c62f Best regards,
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 1c6c62a7f7f5..c13efa7727e0 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -263,7 +263,6 @@ struct fastrpc_channel_ctx { int domain_id; int sesscount; int vmcount; - u64 perms; struct qcom_scm_vmperm vmperms[FASTRPC_MAX_VMIDS]; struct rpmsg_device *rpdev; struct fastrpc_session_ctx session[FASTRPC_MAX_SESSIONS]; @@ -1279,9 +1278,11 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl, /* Map if we have any heap VMIDs associated with this ADSP Static Process. */ if (fl->cctx->vmcount) { + u64 src_perms = BIT(QCOM_SCM_VMID_HLOS); + err = qcom_scm_assign_mem(fl->cctx->remote_heap->phys, (u64)fl->cctx->remote_heap->size, - &fl->cctx->perms, + &src_perms, fl->cctx->vmperms, fl->cctx->vmcount); if (err) { dev_err(fl->sctx->dev, "Failed to assign memory with phys 0x%llx size 0x%llx err %d", @@ -1915,8 +1916,10 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) /* Add memory to static PD pool, protection thru hypervisor */ if (req.flags == ADSP_MMAP_REMOTE_HEAP_ADDR && fl->cctx->vmcount) { + u64 src_perms = BIT(QCOM_SCM_VMID_HLOS); + err = qcom_scm_assign_mem(buf->phys, (u64)buf->size, - &fl->cctx->perms, fl->cctx->vmperms, fl->cctx->vmcount); + &src_perms, fl->cctx->vmperms, fl->cctx->vmcount); if (err) { dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d", buf->phys, buf->size, err); @@ -2290,7 +2293,6 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) if (vmcount) { data->vmcount = vmcount; - data->perms = BIT(QCOM_SCM_VMID_HLOS); for (i = 0; i < data->vmcount; i++) { data->vmperms[i].vmid = vmids[i]; data->vmperms[i].perm = QCOM_SCM_PERM_RWX;