From patchwork Sat Mar 25 13:44:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Van Assche X-Patchwork-Id: 667590 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2ABAFC6FD1C for ; Sat, 25 Mar 2023 13:44:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231719AbjCYNod (ORCPT ); Sat, 25 Mar 2023 09:44:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229805AbjCYNoc (ORCPT ); Sat, 25 Mar 2023 09:44:32 -0400 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [IPv6:2001:67c:2050:0:465::202]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E23AA113C4; Sat, 25 Mar 2023 06:44:30 -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-202.mailbox.org (Postfix) with ESMTPS id 4PkL0W40KBz9sZv; Sat, 25 Mar 2023 14:44:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dylanvanassche.be; s=MBO0001; t=1679751867; 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=egp86lPSAVRoHmUI43dTRCeOVXvgb3RGUlpfI0Vk4PA=; b=bRbRi8GmlCcub2pA68xfLa+vh5b+s+MRzOsU1UX0hkaBml3By0iR4T5sexKIdmrh9OtZ8+ enyQVMYOgMy9kHeX7N9v4qJO58Ms8wart++vVDf1O+0IP1A27dOmTq30zlnNesObAyio7a IepYHY+w4PR0UGnoLF6K0DvhUgfcce94GeErVd3Vz45EsWyiex+CL1QNarAD9LUl/4JdXG yJ0L9EmLngPJk3FGnz8EA0Q8UwdZ5XgohTszdS+ZbdSWU0mxziVikORsnJOFDUPwCO/vZI hC2Fk+mFVG8KV1jY8LNfOkbZmvAeTTvw+PaK3DtFzK4U/YZ/Rg23jxqyn236Xw== From: Dylan Van Assche To: Srinivas Kandagatla , Amol Maheshwari , Andy Gross , Bjorn Andersson , Rob Herring , Krzysztof Kozlowski Cc: Konrad Dybcio , Arnd Bergmann , Greg Kroah-Hartman , 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 Subject: [PATCH 1/2] dt-bindings: misc: qcom,fastrpc: add qcom,assign-all-memory property Date: Sat, 25 Mar 2023 14:44:09 +0100 Message-Id: <20230325134410.21092-2-me@dylanvanassche.be> In-Reply-To: <20230325134410.21092-1-me@dylanvanassche.be> References: <20230325134410.21092-1-me@dylanvanassche.be> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4PkL0W40KBz9sZv Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Document the added qcom,assign-all-memory in devicetree bindings. Signed-off-by: Dylan Van Assche --- Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml b/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml index 1ab9588cdd89..fa5b00534b30 100644 --- a/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml +++ b/Documentation/devicetree/bindings/misc/qcom,fastrpc.yaml @@ -57,6 +57,12 @@ properties: Virtual machine IDs for remote processor. $ref: "/schemas/types.yaml#/definitions/uint32-array" + qcom,assign-all-mem: + description: + Assign memory to all Virtual machines defined by qcom,vmids. + type: boolean + + "#address-cells": const: 1 From patchwork Sat Mar 25 13:44:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Van Assche X-Patchwork-Id: 666953 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B25E2C76196 for ; Sat, 25 Mar 2023 13:44:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229460AbjCYNog (ORCPT ); Sat, 25 Mar 2023 09:44:36 -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 ); 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 To: Srinivas Kandagatla , Amol Maheshwari , Andy Gross , Bjorn Andersson , Rob Herring , Krzysztof Kozlowski Cc: Konrad Dybcio , Arnd Bergmann , Greg Kroah-Hartman , 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 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 X-Rspamd-Queue-Id: 4PkL0Z1zpbz9sZ5 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 --- 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 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;