Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1531341rdb; Mon, 8 Jan 2024 02:05:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHE8K1OXTsQi3Ak6R8t/6Rb+9CtlloYo2cOWZyJ6VbZ5uEtthZ3090GZzbFZw6huG3qoGTB X-Received: by 2002:a05:6358:42aa:b0:175:7201:5785 with SMTP id s42-20020a05635842aa00b0017572015785mr4729055rwc.7.1704708343780; Mon, 08 Jan 2024 02:05:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704708343; cv=none; d=google.com; s=arc-20160816; b=IxGGxevA4SGPll24dtlYFOjSGAAP7TfTBu411KL4viqa198ilT+rdQdApYdTSVsLhu 4/fh8r9VP2wL/f7Wt5ZkFh6kM/w9Hiklf5sD43TESZ/kW7qH0WrVv9Fep5Ty9vdV+b4w ZLkjlkKTZjvNCxeIUKx/PC6Shc/E56FybgXNmSktXRJC7Z/dnJxc6OcGK6qzBMmF65Sk m7A3PQ4yqEj7hkpBAn4xdmxrzxcxemKkHjsb5BLDdKSdosEK9W1N0L99eNpFjntMTnSt zb1h1yyiFXGGQb3hdXibriXJ1KbF8zgc+mDA1RzpMetc8DbDMo1qoWAhMc79kpfgyIDO GLlw== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19316-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b19-20020a63cf53000000b005c14fc66cc1si5721440pgj.22.2024.01.08.02.05.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 02:05:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19316-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19316-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 83EDDB214B4 for ; Mon, 8 Jan 2024 10:05:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5263413AE3; Mon, 8 Jan 2024 10:05:31 +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 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 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 --- 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; -- 2.17.1