Message ID | 20230325134410.21092-3-me@dylanvanassche.be |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp420231vqo; Sat, 25 Mar 2023 06:52:27 -0700 (PDT) X-Google-Smtp-Source: AKy350bvu1dQeZemgqd3x33PvlMqf9afhflEHcIfXiJKWek94HEpNmgzZK/L4U3OlsWPB/grXqi4 X-Received: by 2002:aa7:c84a:0:b0:502:26b7:8311 with SMTP id g10-20020aa7c84a000000b0050226b78311mr3019280edt.17.1679752347252; Sat, 25 Mar 2023 06:52:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679752347; cv=none; d=google.com; s=arc-20160816; b=JyMkklfV942wXIsCduc8N3QiVvSw05SAnBxfX4g8T7TbXplb/c/vkEWDwFDgfZ6/Ks cI87DCJLRl51ZtvLPT2TsXBFP7f9tcwN+mP4iPwUT1KbrAqy9t899V2YoTVWHxu2TPmc qxfxdLHRk9hLUJkves/qD37VFYl39VE12G867yy+JvnE/6KAgfOl2t02Lgr0zfrOJc1x VCtaGKr+5R5mvGKhKK0gEe+Q4IbrwBRG+Pesoz+YhvtSKt8knp1iYlzjzsO+f6K5On6o tMGcb+jookL4ECwRQTyv5IVtNKsAB9HPfnh8Go08DzPOrDw+XKmd2pgVjBWUAYK8ibK0 0Q5Q== 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=1sIg4+FYFSnYc3mW7AmwNzvgOLT4u1cXGrJ6xp9wOhE=; b=VYMeyQ6WmXgCTdmOnE8kTldMRF7DERT0/BMhc8/uMT4qRavra4VCspUzzjLM//k/OK BWjgHC71bYArgrzBtl6PVHTqUxcyDTpY+EjCSjG1RqMrynHXQIFM4EdO0EwD3dZESZc/ DdjTy9OoPwPOsg4IUp/o6oaATWww8ZqS8i47b2P8G1lKuqj6PHzjpC4diQWvaD4zb4DF XndPBvKpcIzE0aPCCCwA9p/JPI83H3VWHAwMfuy8H9ghuPOpXRSjvgvdRyv9J2fmTwSD s0sdmWx+MsWTNOrrOiFnoX4tFdiyPwP1FewD1vQdwxS6NPApQTdIXJPZMOKxO3UBT3a3 XxkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dylanvanassche.be header.s=MBO0001 header.b=zmItbdzp; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dylanvanassche.be Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dy24-20020a05640231f800b004acb4f52ecesi17022367edb.156.2023.03.25.06.52.04; Sat, 25 Mar 2023 06:52:27 -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=@dylanvanassche.be header.s=MBO0001 header.b=zmItbdzp; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dylanvanassche.be Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231392AbjCYNoi (ORCPT <rfc822;makky5685@gmail.com> + 99 others); Sat, 25 Mar 2023 09:44:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229805AbjCYNof (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 25 Mar 2023 09:44:35 -0400 Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [IPv6:2001:67c:2050:0:465::201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6096812859; Sat, 25 Mar 2023 06:44:34 -0700 (PDT) Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4PkL0Z1zpbz9sZ5; Sat, 25 Mar 2023 14:44:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dylanvanassche.be; s=MBO0001; t=1679751870; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1sIg4+FYFSnYc3mW7AmwNzvgOLT4u1cXGrJ6xp9wOhE=; b=zmItbdzpCmB5D3oVIkJ0NewbyApwH9z0bpGgeV7q0rUsjfFCZ/xSAanvCcziJQ9Jbc/z5U dKJHJLA2MY+3dDJ4iROyviyqxtRS6q0btQNJq1wbWagz6Pveozyx8audQ6Iz62LQm/vbSc C36RtQrEqN57L3VgsO9byNTWbNIcsN2oQlH6PZswPVbE0WdFVxvj1PSO3SkQCpDAYdAmPf uAq0OML11fSwr/Yex6Yj5jnCeTAj1pXOV+LdYWlfYR5MN27avQLLZxyFz64XZ+oP9Bib8k yw7VbCbQDyYZHnq8F9Y2dUH2SCOtvsyU7dxiNavHjgzB3kJBJJF+Jv6jVmSYPw== From: Dylan Van Assche <me@dylanvanassche.be> To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>, Amol Maheshwari <amahesh@qti.qualcomm.com>, Andy Gross <agross@kernel.org>, Bjorn Andersson <andersson@kernel.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org> Cc: Konrad Dybcio <konrad.dybcio@linaro.org>, Arnd Bergmann <arnd@arndb.de>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Dylan Van Assche <me@dylanvanassche.be> Subject: [PATCH 2/2] misc: fastrpc: support complete DMA pool access to the DSP Date: Sat, 25 Mar 2023 14:44:10 +0100 Message-Id: <20230325134410.21092-3-me@dylanvanassche.be> In-Reply-To: <20230325134410.21092-1-me@dylanvanassche.be> References: <20230325134410.21092-1-me@dylanvanassche.be> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4PkL0Z1zpbz9sZ5 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761347997443513470?= X-GMAIL-MSGID: =?utf-8?q?1761347997443513470?= |
Series |
FastRPC reserved memory assignment for SDM845 SLPI
|
|
Commit Message
Dylan Van Assche
March 25, 2023, 1:44 p.m. UTC
To support FastRPC Context Banks which aren't mapped via the SMMU,
make the whole reserved memory region available to the DSP to allow
access to coherent buffers.
This is performed by assigning the memory to the DSP via a hypervisor
call to set the correct permissions for the Virtual Machines on the DSP.
Only perform this operation when at least one VM is enabled
and 'qcom,assign-all-mem' property is present in DTS.
Signed-off-by: Dylan Van Assche <me@dylanvanassche.be>
---
drivers/misc/fastrpc.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
Comments
Hi Dylan, https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Dylan-Van-Assche/dt-bindings-misc-qcom-fastrpc-add-qcom-assign-all-memory-property/20230325-214518 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next patch link: https://lore.kernel.org/r/20230325134410.21092-3-me%40dylanvanassche.be patch subject: [PATCH 2/2] misc: fastrpc: support complete DMA pool access to the DSP config: microblaze-randconfig-m041-20230326 (https://download.01.org/0day-ci/archive/20230327/202303270739.ODb2LA29-lkp@intel.com/config) compiler: microblaze-linux-gcc (GCC) 12.1.0 If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Reported-by: Dan Carpenter <error27@gmail.com> | Link: https://lore.kernel.org/r/202303270739.ODb2LA29-lkp@intel.com/ New smatch warnings: drivers/misc/fastrpc.c:2273 fastrpc_rpmsg_probe() warn: possible memory leak of 'data' vim +/data +2273 drivers/misc/fastrpc.c f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2227 static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2228 { f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2229 struct device *rdev = &rpdev->dev; f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2230 struct fastrpc_channel_ctx *data; e90d911906196b Vamsi Krishna Gattupalli 2022-02-14 2231 int i, err, domain_id = -1, vmcount; f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2232 const char *domain; 99edd50174e519 Dylan Van Assche 2023-03-25 2233 bool secure_dsp, assign_all_mem; 99edd50174e519 Dylan Van Assche 2023-03-25 2234 struct device_node *rmem_node; 99edd50174e519 Dylan Van Assche 2023-03-25 2235 struct reserved_mem *rmem; e90d911906196b Vamsi Krishna Gattupalli 2022-02-14 2236 unsigned int vmids[FASTRPC_MAX_VMIDS]; f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2237 f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2238 err = of_property_read_string(rdev->of_node, "label", &domain); f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2239 if (err) { f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2240 dev_info(rdev, "FastRPC Domain not specified in DT\n"); f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2241 return err; f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2242 } f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2243 f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2244 for (i = 0; i <= CDSP_DOMAIN_ID; i++) { f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2245 if (!strcmp(domains[i], domain)) { f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2246 domain_id = i; f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2247 break; f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2248 } f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2249 } f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2250 f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2251 if (domain_id < 0) { f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2252 dev_info(rdev, "FastRPC Invalid Domain ID %d\n", domain_id); f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2253 return -EINVAL; f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2254 } f6f9279f2bf0e3 Srinivas Kandagatla 2019-02-08 2255 1ce91d45ba77a4 Abel Vesa 2022-11-25 2256 if (of_reserved_mem_device_init_by_idx(rdev, rdev->of_node, 0)) 1ce91d45ba77a4 Abel Vesa 2022-11-25 2257 dev_info(rdev, "no reserved DMA memory for FASTRPC\n"); 1ce91d45ba77a4 Abel Vesa 2022-11-25 2258 e90d911906196b Vamsi Krishna Gattupalli 2022-02-14 2259 vmcount = of_property_read_variable_u32_array(rdev->of_node, e90d911906196b Vamsi Krishna Gattupalli 2022-02-14 2260 "qcom,vmids", &vmids[0], 0, FASTRPC_MAX_VMIDS); e90d911906196b Vamsi Krishna Gattupalli 2022-02-14 2261 if (vmcount < 0) e90d911906196b Vamsi Krishna Gattupalli 2022-02-14 2262 vmcount = 0; e90d911906196b Vamsi Krishna Gattupalli 2022-02-14 2263 else if (!qcom_scm_is_available()) e90d911906196b Vamsi Krishna Gattupalli 2022-02-14 2264 return -EPROBE_DEFER; e90d911906196b Vamsi Krishna Gattupalli 2022-02-14 2265 278d56f970ae6e Bjorn Andersson 2019-08-29 2266 data = kzalloc(sizeof(*data), GFP_KERNEL); 278d56f970ae6e Bjorn Andersson 2019-08-29 2267 if (!data) 278d56f970ae6e Bjorn Andersson 2019-08-29 2268 return -ENOMEM; 278d56f970ae6e Bjorn Andersson 2019-08-29 2269 99edd50174e519 Dylan Van Assche 2023-03-25 2270 assign_all_mem = of_property_read_bool(rdev->of_node, "qcom,assign-all-mem"); 99edd50174e519 Dylan Van Assche 2023-03-25 2271 99edd50174e519 Dylan Van Assche 2023-03-25 2272 if (assign_all_mem && !vmcount) 99edd50174e519 Dylan Van Assche 2023-03-25 @2273 return -EINVAL; Move this code before the data = kzalloc() allocation to avoid a memory leak. 99edd50174e519 Dylan Van Assche 2023-03-25 2274 e90d911906196b Vamsi Krishna Gattupalli 2022-02-14 2275 if (vmcount) { e90d911906196b Vamsi Krishna Gattupalli 2022-02-14 2276 data->vmcount = vmcount; e90d911906196b Vamsi Krishna Gattupalli 2022-02-14 2277 data->perms = BIT(QCOM_SCM_VMID_HLOS); e90d911906196b Vamsi Krishna Gattupalli 2022-02-14 2278 for (i = 0; i < data->vmcount; i++) { e90d911906196b Vamsi Krishna Gattupalli 2022-02-14 2279 data->vmperms[i].vmid = vmids[i]; e90d911906196b Vamsi Krishna Gattupalli 2022-02-14 2280 data->vmperms[i].perm = QCOM_SCM_PERM_RWX;
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index f48466960f1b..ecfd0a91113c 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -2230,7 +2230,9 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) struct fastrpc_channel_ctx *data; int i, err, domain_id = -1, vmcount; const char *domain; - bool secure_dsp; + bool secure_dsp, assign_all_mem; + struct device_node *rmem_node; + struct reserved_mem *rmem; unsigned int vmids[FASTRPC_MAX_VMIDS]; err = of_property_read_string(rdev->of_node, "label", &domain); @@ -2265,6 +2267,11 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) if (!data) return -ENOMEM; + assign_all_mem = of_property_read_bool(rdev->of_node, "qcom,assign-all-mem"); + + if (assign_all_mem && !vmcount) + return -EINVAL; + if (vmcount) { data->vmcount = vmcount; data->perms = BIT(QCOM_SCM_VMID_HLOS); @@ -2274,6 +2281,16 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev) } } + if (assign_all_mem) { + rmem_node = of_parse_phandle(rdev->of_node, "memory-region", 0); + if (rmem_node) { + rmem = of_reserved_mem_lookup(rmem_node); + if (rmem) + qcom_scm_assign_mem(rmem->base, rmem->size, &data->perms, + data->vmperms, data->vmcount); + } + } + secure_dsp = !(of_property_read_bool(rdev->of_node, "qcom,non-secure-domain")); data->secure = secure_dsp;