Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5463759rwd; Mon, 12 Jun 2023 05:38:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5QyM6LTxratzoJM2bubtdC5TLPCU/nTrql7f0VzjYatRCj4lOhpd3hcpWGJy4qCIBPsnvq X-Received: by 2002:a17:907:a414:b0:965:b087:8002 with SMTP id sg20-20020a170907a41400b00965b0878002mr10505914ejc.0.1686573505971; Mon, 12 Jun 2023 05:38:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686573505; cv=none; d=google.com; s=arc-20160816; b=ASMCaj4uxMq5FCbBVsUP2siGg9VRZAhE3YXwGLt3uNqPul2g6bpiYtiwOt49Yunrss WgKdtemlp+89sLVmoOt8kTZXCm/eoIDQ5jN5QZoPQmLB/tYInHIK85VLeciCVOK6xoK0 iMU/Obf2FcpjgI+KgwKpic5w7T0SZdHSvBaqIUQZf51/U8ql+PrfUkBb2VQJoY8ILPP5 K39Dvyc7Wqw2Et21N8k7qX4AiEp0ULpUuss+whuE0m7zlPbDJPVEQW8jkFlj67bs6Td6 2lxbhfiT+qHX6kk+UeHyo06BKqcCrTTuNB6m+UdfpmPdlitkA6xgm/Z6wIWpuCeLULCx zNOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=8/WwQ7peSickvRK8UbVo3rJqxpw6vCZZCbW1F+Gubv0=; b=yUD/7NdOXgWnxmQmN0RQeX4NE7jQJPShxyTK/6gCut/NU3B81yrL2R6QaBB0K3KnmV zm/HZlrPQpRNbjaMW2ticKZTcgrgO3wo/8I5uEFZQjCPJwQDHmC5BB5WXJx3RGEwy2p+ UW3VwpNkKDPE6CLD9MlfhvhJvQvsBmW3VxiRrb0h6Bul2ixSd9wZeD5H7V2R65BmI+Mn 6SRgmMKm7myKjtkO8S9j9F8Rwh0Oir/nVzT9phDrTxzRuftfW3MhVbhRZuf6aWKLiSiJ XLDLwqz6Zed2PhED0knc3UAC7c3HplIg/3ujoR7DU4VclreRYngiyjGgthPq4DOdhLm/ f1dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cWEtlLtd; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb26-20020a170906edda00b009787e565055si5338360ejb.798.2023.06.12.05.38.01; Mon, 12 Jun 2023 05:38:25 -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=@linaro.org header.s=google header.b=cWEtlLtd; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229695AbjFLMEN (ORCPT + 99 others); Mon, 12 Jun 2023 08:04:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbjFLMEM (ORCPT ); Mon, 12 Jun 2023 08:04:12 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FE7F93 for ; Mon, 12 Jun 2023 05:04:10 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3f6e4554453so30842465e9.3 for ; Mon, 12 Jun 2023 05:04:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686571449; x=1689163449; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=8/WwQ7peSickvRK8UbVo3rJqxpw6vCZZCbW1F+Gubv0=; b=cWEtlLtdKG8iRdS9x/3Wm4yHpmckwY2Wed37J+iRl/mv8Pfcj/WzRbqwI9l9Ycxb3v yIQaNWHQMO/3pEuXQdwOOzwO/mSOfWHT71pBPFPkqXjljCyNyMCEXKokWtarEn4K6UrI eBNoThB0aUq+7+DKdBuzQciHcjOQdLBbGvUiYSJijONvD7l0jSs+Q9Xf6Bm2V439wG56 xjjCNZLneJ48Akn5SIMzS077UGsbegBrZT3xmCBYrwsbZW4L+IGZu362DtzJdY+QzA1q iaWRpcerrs3eOj3M7ZE8Ly2ztp7g3a4szWO/Umqv1aSxE8suPeqW52mbwfywnklhqOH4 WLaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686571449; x=1689163449; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8/WwQ7peSickvRK8UbVo3rJqxpw6vCZZCbW1F+Gubv0=; b=I2rZ4dWbY8P9GYH4wVjpp5cwNGGR0/kpfrJvXoUrx8nGmtfGRLpDb/EF7Ngza5U7aV wUxWMSABeQ6B2z3m9PxzrYW7FmndNSzxu+O3veiZM42LgTjKyolFK+bIgCbA4zmkaaqu 6RNlvzDGqeyzlh3vMhf7h4yIl+uwKusVDU5PbYOhWdrlTC4lt2I8vlES9I4oa1H0/UiX wJx4jdXDz3h/tP9cvW0l7cEnpxjW5jzKuOvIUoXNwhVOtqQApC66PkX4NdrEzEwzxY3L E94uFhg6mFSUGlYmeS+NdjFPX1XFZQgywVE8DSK3Fof4ajjvDpoMf+wd42GGmvasbPBz i2sw== X-Gm-Message-State: AC+VfDwTl3HhBgCHNtsRRFzrYQbvLooGFv5nab48c2c2BggxEaW49sMS dHNk6Rdye4uiejUrHs+O4/COhw== X-Received: by 2002:a7b:c410:0:b0:3f8:1d98:15af with SMTP id k16-20020a7bc410000000b003f81d9815afmr1257263wmi.22.1686571449056; Mon, 12 Jun 2023 05:04:09 -0700 (PDT) Received: from [192.168.1.195] ([5.133.47.210]) by smtp.googlemail.com with ESMTPSA id z20-20020a1c4c14000000b003f80946116dsm9618975wmf.45.2023.06.12.05.04.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jun 2023 05:04:08 -0700 (PDT) Message-ID: <81343778-6d5c-db85-29e3-8fcba0ec2e8a@linaro.org> Date: Mon, 12 Jun 2023 13:04:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v1] misc: fastrpc: Fix remote heap allocation request Content-Language: en-US To: Ekansh Gupta , linux-arm-msm@vger.kernel.org Cc: ekangupt@qti.qualcomm.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, bkumar@qti.qualcomm.com, fastrpc.upstream@qti.qualcomm.com, stable References: <1685974276-23435-1-git-send-email-quic_ekangupt@quicinc.com> From: Srinivas Kandagatla In-Reply-To: <1685974276-23435-1-git-send-email-quic_ekangupt@quicinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, 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 On 05/06/2023 15:11, Ekansh Gupta wrote: > 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 > --- > drivers/misc/fastrpc.c | 26 ++++++++++++++++++++------ > 1 file changed, 20 insertions(+), 6 deletions(-) > > diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c > index 30d4d04..f5fc2de 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,22 @@ 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); > + struct qcom_scm_vmperm *dst_perms; > + u32 i; > > - 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); > + 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; > + } > + Why not use fl->cctx->vmperms instead of allocating a new dst_perms? --srini > + err = qcom_scm_assign_mem(buf->phys,(u64)buf->size, > + &src_perms, dst_perms, fl->cctx->vmcount); > + kfree(dst_perms); > if (err) { > dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d", > buf->phys, buf->size, err);