Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp129558rdd; Mon, 8 Jan 2024 21:39:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IHW6sm92v6VAwYHOyNm7Bp+JjU6ukrG1RmQMI34ccj2WZlP12pltGTKT2H6LqrUmICGVhYF X-Received: by 2002:a05:6214:194b:b0:67f:2eda:8eb6 with SMTP id q11-20020a056214194b00b0067f2eda8eb6mr6663393qvk.37.1704778748191; Mon, 08 Jan 2024 21:39:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704778748; cv=none; d=google.com; s=arc-20160816; b=h0QZruFUYuShklEEJG3KNWCHuhWuEy3Hgg0xPbqkWra+RGxpjyAHsz+47uDXQzF3OP FFgiB+uLIysAvSbqrBtu6XAPh6crVltkuBu+LZIR6HV9T+B73MI7tHpLkJb3s5GrqOgv UyxxKkju+oVIljn0iGEJRuLLSnyiBmk6FTYXdYDCPqyPQ533KrgF7IvMnYgblgKfrTLL ITzX7ER01i/3Ye2wM2fiL/Gowi8pKrwt28EapGA60A1GIfxSz5VRuM+P4tLyuu1HYp7R CyAEV00dEAF5yY296yo3A4cU7m/M508zaclvrv0MFjnqaWH+mRW6Ef405CzCgwnjV8V8 lsxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=U+lcuxDe7O11/MzKnHWkDOfp0ywpOp5eG391IDLVbfY=; fh=U4pxrJBOoN6nFKVfoEva/cyzRbe+bv8zsCCbdc7+fuo=; b=ifxl+ONDrgcS2FWTrL3ZkhTcmkA3f/KSIdomnYyXTRJ8cfL9220cFOpHDClZk1IRta PMBEODwMEC4EOUZntYksAmzywxpy011yoHpSzxlFAqFWP4BRMqZGBovLJJnsb8pr5Q3r 8U+PjE+GLteW1sYQDed3H4Qj4+swQ+u6uSOfLOLvTar2cBRSzim7sGJ0RG/Oe5A8m+yL /bpVC/zgYtUR2G0wB+8IEVl578xwp7hAjXOES5DfPAouz+FoOwki1laTOKrHNe7YM0hU +W1ltupxfq9mlNBfDp2lZkg1+UYj+OghJX2/c2bo1NG2DVTH61Df2x5u65iHW+Z9uYJh 0MAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=LaIDiLb2; spf=pass (google.com: domain of linux-kernel+bounces-20409-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20409-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x18-20020a0ce0d2000000b0067f7c4b9ac1si1231827qvk.313.2024.01.08.21.39.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 21:39:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20409-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=LaIDiLb2; spf=pass (google.com: domain of linux-kernel+bounces-20409-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20409-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E09711C235F9 for ; Tue, 9 Jan 2024 05:39:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 23C5D3FFF; Tue, 9 Jan 2024 05:38:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="LaIDiLb2" 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 E396B15A7; Tue, 9 Jan 2024 05:38:56 +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 (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 4093wwaL020733; Tue, 9 Jan 2024 05:38:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=U+lcuxDe7O11/MzKnHWkDOfp0ywpOp5eG391IDLVbfY=; b=La IDiLb2PLc4HXguJzU08uSzecECe+ucaYh2WJhrkZndntfL+QzNEXMHtaeLwdBXai /ombnrzMp8sYRi8bRe/YH1PnKCwXi/GEM0u6cpbFq1hwpfaofnQw3RLOA6jYKMpA p00JP2xTpx10kRe2NEr0BFEkaU9j0lLJC28KoHV6EVvuHdzz6TGNr0I+TJGcrOQR WzCih1SJvFFQR0OEsWXcGR5bHXDvB6zP8Dsqe9vax9tGJWuhelgoVXZycRNkMP+z iIH3XGRV5Sj3VDY/mDhEZDIEJZfoSMNYzt0J6qOs1Wsaju09sLkPVdoIALXMtolW EM4/bjlyewe7qxb/JWPw== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vgr1sgv15-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jan 2024 05:38:52 +0000 (GMT) Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 4095cp0E004093 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 9 Jan 2024 05:38:51 GMT Received: from [10.204.67.150] (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 21:38:49 -0800 Message-ID: <04500984-6bc0-4a07-9940-235e4b932172@quicinc.com> Date: Tue, 9 Jan 2024 11:08:45 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1] misc: fastrpc: Pass proper arguments to scm call Content-Language: en-US To: Elliot Berman , , CC: , , stable References: <20240108100513.19993-1-quic_ekangupt@quicinc.com> <79851641-8b56-4d25-b4c9-2d56a5bf41e9@quicinc.com> From: Ekansh Gupta In-Reply-To: <79851641-8b56-4d25-b4c9-2d56a5bf41e9@quicinc.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit 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-ORIG-GUID: ryAL2WnwQ3Yeqy1nUohN_soRBrPfsa7M X-Proofpoint-GUID: ryAL2WnwQ3Yeqy1nUohN_soRBrPfsa7M 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 clxscore=1015 malwarescore=0 lowpriorityscore=0 mlxscore=0 priorityscore=1501 suspectscore=0 bulkscore=0 impostorscore=0 adultscore=0 phishscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401090039 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 >> Signed-off-by: Ekansh Gupta >> --- >> 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;