Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp49106rdd; Mon, 8 Jan 2024 17:12:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IEgEidURwrtYgeh7++JhKuAnqeZnBRUFEUiS2VB8KJkuppcK1wpLpqrE7OQeVodvZt0onex X-Received: by 2002:a05:600c:458b:b0:40e:4f7a:bc29 with SMTP id r11-20020a05600c458b00b0040e4f7abc29mr46444wmo.159.1704762779500; Mon, 08 Jan 2024 17:12:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704762779; cv=none; d=google.com; s=arc-20160816; b=rzjuDHmSYliUzPLScmNPnFZgdLQKuRhGKO5dnd+stwzQdZbX5YfZkHuHYMkfGW+F4X FpjAr3OUPf6EUYPcw/iM3RvOn2680UugGBQFqGUodeaSGag06iUKGcCWUpHCMNGWz8Zq tDV267qxbEIHGy/mAhWORtbUuIPYsi/4aMIsBRTDe6IKNP+LYN5Jc6T/obJ6IAJ2PCQR NT7n4+PkGNDiRtVylJqVb8nmXV+YXRybquJX6r+/4+2xoFQilpSQcOM2+a6GYWXeNypR hePKijJXNka4+MGu+6OdVcCc8BRwdG+zfr5KOqFfHXfBz6ZYw4R63zcWFQWsxaKFMnNF J1mg== 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=qB7JK/rvHV/oMoLxNfOgyhrs98zc89tbNG9XG8X+Hi0=; fh=uOzslp+ecGcn8cmbRI7huoExA28h24LxdIBPCP8uKJI=; b=sDFGOcLWCRe3jjJyqrcb3fvmSOXVwczy+ovR2AX8jcd6HdLiOAIoMMO23PFaieqxTQ i70VKQz6aWUSegoMlcYy1oX8idXXSeW4zhZ4YDCROBA4Vtk/Iz5+aUefUJOklzAdMXmp S3p8X8ioaBNXrDv+brBwoKz8sPhXZxZUDVDR9GEFiUpAEkQH6c5+fnmtudz6aGfYK0kA BCNqwvX9zUzNv3AkF1xU1ef/vSFYAZ85CIJbhGSrMDkDDFCFuyAy1u/iktfc2qdPtecY 5ecQRAIZeD83wsqSwNPNYCDfWLlvt/HcmFvwbQlYqEMKHu1OmjOqHouzao98bUKQg94d U9fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=EpeXGelN; spf=pass (google.com: domain of linux-kernel+bounces-20248-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20248-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id lc16-20020a170906f91000b00a28aca767d6si368496ejb.815.2024.01.08.17.12.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 17:12:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20248-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=EpeXGelN; spf=pass (google.com: domain of linux-kernel+bounces-20248-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20248-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 43DE71F2427A for ; Tue, 9 Jan 2024 01:12:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 71BEA15AA; Tue, 9 Jan 2024 01:12:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="EpeXGelN" 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 46A34A49; Tue, 9 Jan 2024 01:12:37 +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 4090eVOA023723; Tue, 9 Jan 2024 01:12:34 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=qB7JK/rvHV/oMoLxNfOgyhrs98zc89tbNG9XG8X+Hi0=; b=Ep eXGelN/Uh5iU1xIZ90UmahpgUmni4+UPLqTLEaTmxEob6kTHCfJLF3rkua97MwRw 2iZSKkNwXdwuA+14YenL23iTlcKwnBW97Ij+6y1FPZayXZmKVkB9lZvzfdE2GWwl D9LOsqkE65l+hHnxAid4IgpTFp+vEOah6TfuSPhETdr7oTeHTctKmLMauIP8tNlt YNGgzeK26DL1WGZA8FCY4ySbyGetEBHTDaCUcSQC4JKAaY0/U5B+n0PO7oOP0m7M Vu1V5KkDt3s3PP4lyur+kg6Qfcq/fNSSgo+NUl2d1LufeMzvXfxMarCjEYOKH5oR ZMrIElIBNdk3nNJCDHJg== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vgkkh962x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Jan 2024 01:12:32 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 4091CWWP021026 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 9 Jan 2024 01:12:32 GMT Received: from [10.71.108.105] (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) 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 17:12:31 -0800 Message-ID: <79851641-8b56-4d25-b4c9-2d56a5bf41e9@quicinc.com> Date: Mon, 8 Jan 2024 17:12:30 -0800 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: Ekansh Gupta , , CC: , , stable References: <20240108100513.19993-1-quic_ekangupt@quicinc.com> From: Elliot Berman In-Reply-To: <20240108100513.19993-1-quic_ekangupt@quicinc.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: OK__ZbRzyjVHWeDIwxlQFIGchDtepcbW X-Proofpoint-ORIG-GUID: OK__ZbRzyjVHWeDIwxlQFIGchDtepcbW 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 phishscore=0 clxscore=1011 spamscore=0 suspectscore=0 priorityscore=1501 mlxlogscore=999 impostorscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401090005 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 > 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;