From patchwork Mon Jun 5 13:48:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ekansh Gupta X-Patchwork-Id: 103272 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2708110vqr; Mon, 5 Jun 2023 07:04:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7lBGUFAhVN691vvqaX8M8tBn7nyNNc2fW+rjBocy1ox/BgcG39+A6SBAjAENVcVOGI7ExP X-Received: by 2002:a05:6a20:42a3:b0:111:52a4:7fab with SMTP id o35-20020a056a2042a300b0011152a47fabmr7009766pzj.26.1685973849407; Mon, 05 Jun 2023 07:04:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685973849; cv=none; d=google.com; s=arc-20160816; b=g/2JhmZAvzSov/NZXmzh1AUBvUtWJfoEpDuOcthGf95uUtli8tHjXQ4WgczAJ6wK/0 RZcY0N7thf/P6EwFEy3X9eXC+CLvrnMQI/M/BykrPadqcK7d6C92Ade3yClWuLDL853c gZZM9WCEkS3TgsBGI3n3erQaPXt5DDNe5w+VyPIQ7Jo9mIBarxI4MfxVfQBrPrPv4Dub Sw248vMU+uz8VcoClt/l6Auc/SCQ6h/nJRjXT98rgmLEm81LiBDj6KWMmlBfTcQiGODJ CvY66aV8fFdwkt7q6nk10r9djVlBPTgrln9RNb+6J632AsomZj9337cqpE7rcEilVxDr fnkg== 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=9z0PA9AKMhKUQkcp6ir2m1Wg6FOKEV1od3lPMM0PPU4=; b=jgSS5jmwPtaGPkX4RtL1my6BBRDnhmlXHgkdFD9NKva/+BB22HbHF0ku48KnpFRE4i JfmQ0lSWsUxIS64Ad5AdHoBvFwqQvQLq9EcQEHNbPRoEon1jmtKeWX53YzqoneJp+xuJ C/UI4oxvjHWNwu0pIepJDUAktoh2j8QAMiS3O8U7036YMoaPBYEdr62aJcCRLGX5R1Dc z4DjhUKhvjh2vsccVhSG6dItj/KYpkHw1N25pPJ7srECN/hZ5XV7wzL8qBUSQBV3YhtB UTBlnMIZ5RsRzzNnsyM1JnQeof5nXO2ueuGgVX8N4dmMzv/ATD9iguIBj/eO0YhzaxpY yMdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Bq7xd2uf; 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 q15-20020a638c4f000000b0050bf22172d3si5328796pgn.490.2023.06.05.07.03.56; Mon, 05 Jun 2023 07:04:09 -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=Bq7xd2uf; 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 S233382AbjFENs5 (ORCPT + 99 others); Mon, 5 Jun 2023 09:48:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231313AbjFENsz (ORCPT ); Mon, 5 Jun 2023 09:48:55 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBC799C; Mon, 5 Jun 2023 06:48:54 -0700 (PDT) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 355CPW1K030950; Mon, 5 Jun 2023 13:48:50 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=9z0PA9AKMhKUQkcp6ir2m1Wg6FOKEV1od3lPMM0PPU4=; b=Bq7xd2ufY9cppAx86CotK85mvdpegQo3DJdVdsRerO9HLyHQoDLL6p70ufGrk/PXNt7P h+0m7ztKMkrI+xESO+c7ak3NJC3TElBNhxJFnbqoDb9b5EspX7JYWiM9l3rLxAWK/mOq jJwLdDiV4luLgXwqHO1wXVeb/4yDw24l6mdMtcIXtMIi0FHDmZBWG4JTmCzT1yRqMxRP QK63XyN5vRqTFTRZRU4Mew3ijsSVkAi5PDZLQWCgI8b3eRXJjHoLBoNNEH9LTOaaiOpi ua6SY4AMXY8xdBK8sZ3s5BMNFH1merQETyZ2/X40HlsQZFMzX4RwbU9AHwZaY7uzIRXv WA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3r1ahp903h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Jun 2023 13:48:50 +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 355DmnJM024996 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 5 Jun 2023 13:48:49 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; Mon, 5 Jun 2023 06:48:46 -0700 From: Ekansh Gupta To: , CC: Ekansh Gupta , , , , , , stable Subject: [PATCH v1] misc: fastrpc: Pass proper scm arguments for static process init Date: Mon, 5 Jun 2023 19:18:38 +0530 Message-ID: <1685972918-30371-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: P19P0KUy9CZKD-Vk_8zPLktbAn2t2ACn X-Proofpoint-ORIG-GUID: P19P0KUy9CZKD-Vk_8zPLktbAn2t2ACn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-05_28,2023-06-02_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1011 phishscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306050120 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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?1767871715298912668?= X-GMAIL-MSGID: =?utf-8?q?1767871715298912668?= Memory is allocated for dynamic loading when audio daemon is trying to attach to audioPD on DSP side. This memory is allocated from reserved CMA memory region and needs ownership assignment to new VMID in order to use it from audioPD. In the current implementation, arguments are not correctly passed to the scm call which might result in failure of dynamic loading on audioPD. Added changes to pass correct arguments during daemon attach request. Fixes: 0871561055e6 ("misc: fastrpc: Add support for audiopd") Cc: stable Tested-by: Ekansh Gupta Signed-off-by: Ekansh Gupta --- drivers/misc/fastrpc.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 30d4d04..b7335dd 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1278,10 +1278,23 @@ 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); + struct qcom_scm_vmperm *dst_perms; + u32 i; + + dst_perms = kcalloc(fl->cctx->vmcount, + sizeof(struct qcom_scm_vmperm), GFP_KERNEL); + if (!dst_perms) + return -ENOMEM; + for (i = 0; i < fl->cctx->vmcount; i++) { + dst_perms[i].vmid = fl->cctx->vmperms[i].vmid; + dst_perms[i].perm = fl->cctx->vmperms[i].perm; + } + err = qcom_scm_assign_mem(fl->cctx->remote_heap->phys, (u64)fl->cctx->remote_heap->size, - &fl->cctx->perms, - fl->cctx->vmperms, fl->cctx->vmcount); + &src_perms, dst_perms, fl->cctx->vmcount); + kfree(dst_perms); if (err) { dev_err(fl->sctx->dev, "Failed to assign memory with phys 0x%llx size 0x%llx err %d", fl->cctx->remote_heap->phys, fl->cctx->remote_heap->size, err); @@ -1322,13 +1335,19 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl, return 0; err_invoke: if (fl->cctx->vmcount) { - struct qcom_scm_vmperm perm; + u64 src_perms = 0; + struct qcom_scm_vmperm dst_perms; + u32 i; - perm.vmid = QCOM_SCM_VMID_HLOS; - perm.perm = QCOM_SCM_PERM_RWX; + for (i = 0; i < fl->cctx->vmcount; i++) { + src_perms |= BIT(fl->cctx->vmperms[i].vmid); + } + + dst_perms.vmid = QCOM_SCM_VMID_HLOS; + dst_perms.perm = QCOM_SCM_PERM_RWX; err = qcom_scm_assign_mem(fl->cctx->remote_heap->phys, (u64)fl->cctx->remote_heap->size, - &fl->cctx->perms, &perm, 1); + &src_perms, &dst_perms, 1); if (err) dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d", fl->cctx->remote_heap->phys, fl->cctx->remote_heap->size, err);