Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1974982rwn; Fri, 9 Sep 2022 06:56:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR7SFa0ROG8DMk6grgM1qFaYhOXKHFqwS9WArgD1z/Bd05f9juyPu0aIWzPvz6oBCwXkyPFF X-Received: by 2002:a63:5a01:0:b0:434:8bd7:284d with SMTP id o1-20020a635a01000000b004348bd7284dmr12503120pgb.538.1662731769221; Fri, 09 Sep 2022 06:56:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662731769; cv=none; d=google.com; s=arc-20160816; b=FP9a3tudzXG/kszGPAAg9i7pSXOG8raMgkn3Mrdi1KQKpg/w14xBgy/eKEggxWVnPi o9Hd4H62s/vKRl95jcEDHaiO3IkGwYBNbbW64XlUNRqpsWzNYlw7fVs/2TBp4zig++Bl eDHg3+1TaQHxetI9D4SXolVb9D9l1Jao105sMf6H3xlBWnDertvG0VR15K51wl1mb7yT IA7Xz0v2N0kk8c6zBPHiDdUL8cUN1xG0Su1hJQRTuqelMxvFnRkk8ZrEe3sFZ2aAFz52 JHP/zH3BzS7RILjCjjZroywck74nUuT8EdMn//YwvXwbpLOEwQfHmBi5qlY5jT2fGwIt tmNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RvvgLMHlA8hgiNoZmLZU2JRt2mlGnlAJryIJMd3OPZc=; b=g27Lk72iVwjMy8+csHxa2weXi9wRgsJsexlFd9X4GW5xA1BS+pSbSMAI2tFZabQtJo 1SoJzDenZtCuIqKW2VTfzdsOTTWKF7xBLS3rY1yLf30beM0RcGPLf/Soy9xjjtujbBqY Kqc7qbihjUXIqB1nAcZj7fFeqKOgWC/pTfzS0CWmrdldc67EnYk8+WrMgTIyZKGRleZC OvoQ4APJPJefLEN3b1Lr+EMPSOYqrXH4fVeXbJmrPnbjQJurgaUYUh5FTz9Omvb3fpRm 4C7Jk0K9w3GhOewWG0/9MYftxgP2iixPzILCnhYk49w3xMUjY/yRwhzbKzUIWHq/eQQT vz4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qphcdroe; 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 j73-20020a638b4c000000b0041c8dfb29f0si572185pge.705.2022.09.09.06.55.56; Fri, 09 Sep 2022 06:56: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=@linaro.org header.s=google header.b=qphcdroe; 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 S231700AbiIINmM (ORCPT + 99 others); Fri, 9 Sep 2022 09:42:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231445AbiIINlJ (ORCPT ); Fri, 9 Sep 2022 09:41:09 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 338BAC59FB for ; Fri, 9 Sep 2022 06:40:54 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id b5so2804609wrr.5 for ; Fri, 09 Sep 2022 06:40:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=RvvgLMHlA8hgiNoZmLZU2JRt2mlGnlAJryIJMd3OPZc=; b=qphcdroepFhcSrBD4twbvzWxiv2Wjf87RPRcw5l/qauKPkz4j6eJsVpGwRRlRfh8I3 QYTowvzAkWh6AfWkxKqkdcAZWiDxR4Azn00DojtT3tJHosp4khMGvCRnfqLgIgdiOtgD xG7sLWNKKTYQilkKiY03uJpOiApTri58PdS4OmqMIXD1OCk4nGyKf9DtKE18f26j0BNO hi/lJWrRDCrV5sB+FVU8ZLGXPFTUoGc5WPL5hMdt0c3W5BdeJ5VAManrsjLmqhPh5tYD ABWw0qNWw+LCBnUguLCCOG3cqrxq5Gfgp8gPt364xqaeAH4HlENMVTKfGuPOJ/4MD+6T j5Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=RvvgLMHlA8hgiNoZmLZU2JRt2mlGnlAJryIJMd3OPZc=; b=q94X51VVAFLdII4yZrcPkvkDxg/SGaFsoUx4ABZO50jWq7/a40qffKlrGQ4F4DlsDC rigYpfDIVl93zoWp6P/q/l4/I6jRkaHDqlqMWfxl3PoZIjJpSAWGRjL0ioap92mZK1ib 1tAAZHartx8IfjjQ15ot15EVvlg2yFSqvzOcQv1iJeQ06k8/ELOq+tfkhqXD3fvgEoAb doRvYWJrNI0JsGQ4UsdYh6gH/iehvFtt2QYWEuO2B2Hc+jSHfZJz/OIZN+vHMfTcwpQt 3JGffibuuRYlZmh3It/USwUVfjNf3t219NsFMZQiWgkXSvEA3yZPU0ZtO27LLGDNIa49 d0SA== X-Gm-Message-State: ACgBeo0S3bJPTF8hiwb92/y7dcDcfXiE+F8799gcHSIL5MqUI72LsG65 J6CKRrHRagwH2hHABexHCZnnvw== X-Received: by 2002:a5d:4285:0:b0:228:6321:c6e with SMTP id k5-20020a5d4285000000b0022863210c6emr8082546wrq.433.1662730852590; Fri, 09 Sep 2022 06:40:52 -0700 (PDT) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id q20-20020a1cf314000000b003a604a29a34sm660622wmq.35.2022.09.09.06.40.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 06:40:51 -0700 (PDT) From: Abel Vesa To: Srinivas Kandagatla , Amol Maheshwari , Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Ekansh Gupta , Bharath Kumar , Himateja Reddy , Anirudh Raghavendra Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Linux Kernel Mailing List , devicetree@vger.kernel.org Subject: [PATCH v3 09/10] misc: fastrpc: Add mmap request assigning for static PD pool Date: Fri, 9 Sep 2022 16:39:37 +0300 Message-Id: <20220909133938.3518520-10-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220909133938.3518520-1-abel.vesa@linaro.org> References: <20220909133938.3518520-1-abel.vesa@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 If the mmap request is to add pages and thre are VMIDs associated with that context, do a call to SCM to reassign that memory. Do not do this for remote heap allocation, that is done on init create static process only. Co-developed-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla Signed-off-by: Abel Vesa --- drivers/misc/fastrpc.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index bc1e8f003d7a..b9d9bfad93f6 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1842,8 +1842,9 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) if (copy_from_user(&req, argp, sizeof(req))) return -EFAULT; - if (req.flags != ADSP_MMAP_ADD_PAGES) { + if (req.flags != ADSP_MMAP_ADD_PAGES && req.flags != ADSP_MMAP_REMOTE_HEAP_ADDR) { dev_err(dev, "flag not supported 0x%x\n", req.flags); + return -EINVAL; } @@ -1889,6 +1890,22 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) /* let the client know the address to use */ req.vaddrout = rsp_msg.vaddr; + /* 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; + int err = 0; + + perm.vmid = QCOM_SCM_VMID_HLOS; + perm.perm = QCOM_SCM_PERM_RWX; + err = qcom_scm_assign_mem(buf->phys, buf->size, + &(fl->cctx->vmperms[0].vmid), &perm, 1); + if (err) { + dev_err(fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d", + buf->phys, buf->size, err); + goto err_assign; + } + } + spin_lock(&fl->lock); list_add_tail(&buf->node, &fl->mmaps); spin_unlock(&fl->lock); -- 2.34.1