From patchwork Mon Jan 8 10:05:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ekansh Gupta X-Patchwork-Id: 185888 Return-Path: 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 (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 ; 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 To: , CC: , , stable 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: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 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 Signed-off-by: Ekansh Gupta Reviewed-by: Elliot Berman --- 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;