linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeya R <jeyr@codeaurora.org>
To: linux-arm-msm@vger.kernel.org, srinivas.kandagatla@linaro.org
Cc: Jeya R <jeyr@codeaurora.org>,
	gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	fastrpc.upstream@qti.qualcomm.com, bkumar@qti.qualcomm.com,
	ekangupt@qti.qualcomm.com, jeyr@qti.qualcomm.com
Subject: [PATCH 2/3] misc: fastrpc: Read virtual machine IDs during probe
Date: Tue, 30 Nov 2021 18:27:51 +0530	[thread overview]
Message-ID: <1638277072-6459-5-git-send-email-jeyr@codeaurora.org> (raw)
In-Reply-To: <1638277072-6459-1-git-send-email-jeyr@codeaurora.org>

Read virtual machine IDs DT property during rpmsg probe. This property is used
to set up memory protection for remote processor.

Signed-off-by: Jeya R <jeyr@codeaurora.org>
---
 drivers/misc/fastrpc.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 39aca77..a9adfa4d 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -17,6 +17,7 @@
 #include <linux/rpmsg.h>
 #include <linux/scatterlist.h>
 #include <linux/slab.h>
+#include <linux/qcom_scm.h>
 #include <uapi/misc/fastrpc.h>
 
 #define ADSP_DOMAIN_ID (0)
@@ -25,6 +26,7 @@
 #define CDSP_DOMAIN_ID (3)
 #define FASTRPC_DEV_MAX		4 /* adsp, mdsp, slpi, cdsp*/
 #define FASTRPC_MAX_SESSIONS	13 /*12 compute, 1 cpz*/
+#define FASTRPC_MAX_VMIDS	16
 #define FASTRPC_ALIGN		128
 #define FASTRPC_MAX_FDLIST	16
 #define FASTRPC_MAX_CRCLIST	64
@@ -207,6 +209,9 @@ struct fastrpc_session_ctx {
 struct fastrpc_channel_ctx {
 	int domain_id;
 	int sesscount;
+	int vmcount;
+	u32 perms;
+	struct qcom_scm_vmperm vmperms[FASTRPC_MAX_VMIDS];
 	struct rpmsg_device *rpdev;
 	struct fastrpc_session_ctx session[FASTRPC_MAX_SESSIONS];
 	spinlock_t lock;
@@ -1610,8 +1615,9 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
 {
 	struct device *rdev = &rpdev->dev;
 	struct fastrpc_channel_ctx *data;
-	int i, err, domain_id = -1;
+	int i, err, domain_id = -1, vmcount;
 	const char *domain;
+	unsigned int vmids[FASTRPC_MAX_VMIDS];
 
 	err = of_property_read_string(rdev->of_node, "label", &domain);
 	if (err) {
@@ -1631,9 +1637,24 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
 		return -EINVAL;
 	}
 
+	vmcount = of_property_read_variable_u32_array(rdev->of_node,
+				"qcom,vmids", &vmids[0], 0, FASTRPC_MAX_VMIDS);
+	if (vmcount < 0)
+		vmcount = 0;
+	else if (!qcom_scm_is_available())
+		return -EPROBE_DEFER;
+
 	data = kzalloc(sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
+	if (vmcount) {
+		data->vmcount = vmcount;
+		data->perms = BIT(QCOM_SCM_VMID_HLOS);
+		for (i = 0; i < data->vmcount; i++) {
+			data->vmperms[i].vmid = vmids[i];
+			data->vmperms[i].perm = QCOM_SCM_PERM_RWX;
+		}
+	}
 
 	data->miscdev.minor = MISC_DYNAMIC_MINOR;
 	data->miscdev.name = devm_kasprintf(rdev, GFP_KERNEL, "fastrpc-%s",
-- 
2.7.4


  parent reply	other threads:[~2021-11-30 12:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30 12:57 [PATCH 0/3] Add vmid property and mapping attribute Jeya R
2021-11-30 12:57 ` [PATCH 1/3] dt-bindings: misc: add fastrpc domain vmid property Jeya R
2021-11-30 13:17   ` Srinivas Kandagatla
2021-11-30 12:57 ` [PATCH 1/2] misc: fastrpc: Add fdlist implementation Jeya R
2021-11-30 20:20   ` kernel test robot
2021-11-30 23:52   ` kernel test robot
2021-11-30 12:57 ` [PATCH 2/2] misc: fastrpc: Add dma handle implementation Jeya R
2021-11-30 22:44   ` kernel test robot
2021-12-01  0:22   ` kernel test robot
2021-11-30 12:57 ` Jeya R [this message]
2021-11-30 12:57 ` [PATCH 3/3] misc: fastrpc: Handle mapping of invoke argument with attribute Jeya R
2021-11-30 18:18   ` 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=1638277072-6459-5-git-send-email-jeyr@codeaurora.org \
    --to=jeyr@codeaurora.org \
    --cc=bkumar@qti.qualcomm.com \
    --cc=ekangupt@qti.qualcomm.com \
    --cc=fastrpc.upstream@qti.qualcomm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jeyr@qti.qualcomm.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).