All of lore.kernel.org
 help / color / mirror / Atom feed
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	[thread overview]
Message-ID: <20230325134410.21092-3-me@dylanvanassche.be> (raw)
In-Reply-To: <20230325134410.21092-1-me@dylanvanassche.be>

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(-)

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;
 
-- 
2.39.2


  parent reply	other threads:[~2023-03-25 13:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-25 13:44 [PATCH 0/2] FastRPC reserved memory assignment for SDM845 SLPI Dylan Van Assche
2023-03-25 13:44 ` [PATCH 1/2] dt-bindings: misc: qcom,fastrpc: add qcom,assign-all-memory property Dylan Van Assche
2023-03-26  8:55   ` Krzysztof Kozlowski
2023-03-27 11:37     ` Dylan Van Assche
2023-03-27 12:22       ` Krzysztof Kozlowski
2023-03-27 14:26         ` Dylan Van Assche
2023-03-27 14:32           ` Dmitry Baryshkov
2023-03-27 14:36           ` Krzysztof Kozlowski
2023-03-27 16:05             ` Dylan Van Assche
2023-03-25 13:44 ` Dylan Van Assche [this message]
2023-03-27  4:09   ` [PATCH 2/2] misc: fastrpc: support complete DMA pool access to the DSP Dan Carpenter
2023-03-26 23:59 kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230325134410.21092-3-me@dylanvanassche.be \
    --to=me@dylanvanassche.be \
    --cc=agross@kernel.org \
    --cc=amahesh@qti.qualcomm.com \
    --cc=andersson@kernel.org \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phone-devel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=~postmarketos/upstreaming@lists.sr.ht \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.