From patchwork Fri Jun 23 14:04:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ekansh Gupta X-Patchwork-Id: 112152 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5801369vqr; Fri, 23 Jun 2023 07:10:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5UgKgac5Bwe0FedqmZ2xZytO/onzdf4Vjljw/gcLX+sp9YQ6SDnNJPPamc0EmUlqDuDoRC X-Received: by 2002:a05:6a20:c185:b0:123:8852:1a1f with SMTP id bg5-20020a056a20c18500b0012388521a1fmr5577402pzb.45.1687529432584; Fri, 23 Jun 2023 07:10:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687529432; cv=none; d=google.com; s=arc-20160816; b=WQvPAMkCtJvXTaXu5Jy+bG87wTq64zR56YKlVnP48mZQbb4EHpA/d80GjUXeAZId1n QwLWRHAKlO6citX69dA9HFSgUqT/j2niFZC+x1uWqSYla/74QzUqbQ8sad9C6LaF5Era /epT66YslhfLnOMdz0SA4ksEDzeEpRnNLhlpXVpdy8C6VCKreBDxthB7yvH2wDo99Wy/ O0lgsPLWQlgAoTrpk1dMHwhcPvMVgKG0kOVIdHWb+F7Lpn2RHZjBd8B2Ayj/1FgP7jse /Is8/OiXBiEG1g8XKTFYcw4mw6yHg+kOmxL98viRQbYSDl4Xln+ZCgHE0r8FQ+CL4TE7 qJdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=wXAtRsjcIkvT30vMqvMcqecNTXMlzi9PASJwLOd4LVc=; b=UfA55RjgzL7hxjaFOaVrnnAnohjIKnSFzkfQ5gjZDKPODgKCIk2VJ+u9+WY1XcFzyB av3/e9suOlyq3hfl8bDR0fz+Ydv23tW6tQD0Iqv8KntkEdPHOcblZZ5MvPky3f2fi1oG xT0CzzJSki7YDOFRztCQTddCLPEDTNVYYyOrO5FWQNIcOizuWVeEtlqh1RUdA0tzECOn oPAPSoKBl8E9iLEX9m4dJ2iHC1VU3np7CHbceStgR/bIgm7xdQHT49VOcx3F1pCw/QgI 8c1RKNog9HNWB02VbyNIVyjCgwqHJU2TasAIXREMPYnzGtzOEQuavTnRa1UEH4RC/ORz dVLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="pFWmax/b"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x18-20020aa78f12000000b00666e9300909si8544449pfr.368.2023.06.23.07.10.18; Fri, 23 Jun 2023 07:10:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="pFWmax/b"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231356AbjFWOEh (ORCPT + 99 others); Fri, 23 Jun 2023 10:04:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229673AbjFWOEg (ORCPT ); Fri, 23 Jun 2023 10:04:36 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D0042695; Fri, 23 Jun 2023 07:04:34 -0700 (PDT) Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35NDpSKp013672; Fri, 23 Jun 2023 14:04:30 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=wXAtRsjcIkvT30vMqvMcqecNTXMlzi9PASJwLOd4LVc=; b=pFWmax/bxi+iXwsdnN3letf7Nd/gfVCkYSK97kwTRmIvs4Quk/cf6Kd8s5CIW0je8d5d nvYL4PK60lrVbeN0U+Ub1P00ozMgS7QdHPV8oCXDjg5rjCi3qY0iMWI6rJAzTnYoejw1 u7UQE2LZ2a5RGdX5upRKHLv6cilhdooGsCeSYVblrXCv1stqnin+ywHyJagTxpFrBj33 wqZTA3MWkoEPPgYqEFAX4PGnMERhpU6hX8g1TrkYFYTemEwW1CZmlhFlJR9aaC1Lbia2 rv3Kt6wh4Tz2vqM3zfSnS8pvEyA5Y4a5Mwrm+2ySagh9NXXANT39HHDCTQRFWfQ+APps bw== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rckn2ufh7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Jun 2023 14:04:29 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 35NE4TVZ005528 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Jun 2023 14:04:29 GMT Received: from ekangupt-linux.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.986.42; Fri, 23 Jun 2023 07:04:26 -0700 From: Ekansh Gupta To: , CC: Ekansh Gupta , , , , , stable Subject: [PATCH v2] misc: fastrpc: Fix remote heap allocation request Date: Fri, 23 Jun 2023 19:34:22 +0530 Message-ID: <1687529062-25988-1-git-send-email-quic_ekangupt@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] 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: JU6qxwFUHclaM26nPTR36ycRkZFomFVm X-Proofpoint-ORIG-GUID: JU6qxwFUHclaM26nPTR36ycRkZFomFVm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-23_07,2023-06-22_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 phishscore=0 impostorscore=0 mlxscore=0 spamscore=0 bulkscore=0 adultscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306230128 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767872473797996646?= X-GMAIL-MSGID: =?utf-8?q?1769502862195579549?= Remote heap is used by DSP audioPD on need basis. This memory is allocated from reserved CMA memory region and is then shared with audioPD to use it for it's functionality. Current implementation of remote heap is not allocating the memory from CMA region, instead it is allocating the memory from SMMU context bank. The arguments passed to scm call for the reassignment of ownership is also not correct. Added changes to allocate CMA memory and have a proper ownership reassignment. Fixes: 532ad70c6d44 ("misc: fastrpc: Add mmap request assigning for static PD pool") Cc: stable Tested-by: Ekansh Gupta Signed-off-by: Ekansh Gupta --- Changes in v2: - Removed redundant code drivers/misc/fastrpc.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 30d4d04..87a9096 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1866,7 +1866,11 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) return -EINVAL; } - err = fastrpc_buf_alloc(fl, fl->sctx->dev, req.size, &buf); + if (req.flags == ADSP_MMAP_REMOTE_HEAP_ADDR) + err = fastrpc_remote_heap_alloc(fl, dev, req.size, &buf); + else + err = fastrpc_buf_alloc(fl, dev, req.size, &buf); + if (err) { dev_err(dev, "failed to allocate buffer\n"); return err; @@ -1905,12 +1909,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) { - struct qcom_scm_vmperm perm; + u64 src_perms = BIT(QCOM_SCM_VMID_HLOS); - perm.vmid = QCOM_SCM_VMID_HLOS; - perm.perm = QCOM_SCM_PERM_RWX; - err = qcom_scm_assign_mem(buf->phys, buf->size, - &fl->cctx->perms, &perm, 1); + err = qcom_scm_assign_mem(buf->phys, (u64)buf->size, + &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);