Skip to contentSkip to conversation

GLINK intent preallocation support

PATCH Superseded Chris Lew 2 participants 6 messages Oct 19, 2017 – Oct 23, 2017

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chris Lew

author
#0 lore raw

cover GLINK intent preallocation support

Intents are used to specify when a channel can receive data from a remoteproc. Add support for channels to customize the size and amount of prequeued intents.

An audio channel might expect to receive 3 packets of size 4k in rapid succession. This change allows the channel to prepare for this data instead of allocating on demand.

Chris Lew (3):
dt-bindings: soc: qcom: Support GLINK intents
rpmsg: glink: Add support to preallocate intents
rpmsg: glink: Use best fit intent during tx

 .../devicetree/bindings/soc/qcom/qcom,glink.txt    | 10 +++++
 drivers/rpmsg/qcom_glink_native.c                  | 47 +++++++++++++++++-----
 2 files changed, 46 insertions(+), 11 deletions(-)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
author
#1 lore raw

PATCH 1/3 dt-bindings: soc: qcom: Support GLINK intents

Virtual GLINK channels may know what throughput to expect from a remoteproc. An intent advertises to the remoteproc this channel is ready to receive data. Allow a channel to define the size and amount of intents to be prequeued.

---
 Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt | 10 ++++++++++
 1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt +10 -0
index b277eca861f7..6c21f76822ca 100644
@@ -39,6 +39,14 @@ of these nodes are defined by the individual bindings for the specific function
 	Definition: a list of channels tied to this function, used for matching
 		    the function to a set of virtual channels
 
+- intents:
+	Usage: optional
+	Value type: <prop-encoded-array>
+	Definition: a list of size,amount pairs describing what intents should
+		    be preallocated for this virtual channel. If a GLINK node
+		    supports intents, an intent advertises this channel is ready
+		    to receive data.
+
 = EXAMPLE
 The following example represents the GLINK RPM node on a MSM8996 device, with
 the function for the "rpm_request" channel defined, which is used for
@@ -69,6 +77,8 @@ regualtors and root clocks.
 			compatible = "qcom,rpm-msm8996";
 			qcom,glink-channels = "rpm_requests";
 
+			intents = <0x400 5
+				   0x800 1>;
 			...
 		};
 	};
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
author
#4 lore raw

PATCH 2/3 rpmsg: glink: Add support to preallocate intents

In reply to Chris Lew

The base intents prequeued during channel creation may not satisfy a channel's throughput requirement. Add support for intents dt-binding to allow channels to specify the size and amount of intents to prequeue during endpoint announcement.

---
 drivers/rpmsg/qcom_glink_native.c | 36 ++++++++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 8 deletions(-)
drivers/rpmsg/qcom_glink_native.c +28 -8
index 5a5e927ea50f..05e04a8943e3 100644
@@ -1143,19 +1143,39 @@ static struct rpmsg_endpoint *qcom_glink_create_ept(struct rpmsg_device *rpdev,
 static int qcom_glink_announce_create(struct rpmsg_device *rpdev)
 {
 	struct glink_channel *channel = to_glink_channel(rpdev->ept);
-	struct glink_core_rx_intent *intent;
 	struct qcom_glink *glink = channel->glink;
-	int num_intents = glink->intentless ? 0 : 5;
+	struct glink_core_rx_intent *intent;
+	const struct property *prop = NULL;
+	int num_groups = 1;
+	int num_intents;
+	int size;
+	__be32 base[2];
+	int *val = base;
+
+	if (rpdev->dev.of_node)
+		prop = of_find_property(rpdev->dev.of_node, "intents", NULL);
+
+	if (prop && !glink->intentless) {
+		val = prop->value;
+		num_groups = prop->length / sizeof(u32) / 2;
+	} else {
+		base[0] = cpu_to_be32(SZ_1K);
+		base[1] = cpu_to_be32(glink->intentless ? 0 : 5);
+	}
 
 	/* Channel is now open, advertise base set of intents */
-	while (num_intents--) {
-		intent = qcom_glink_alloc_intent(glink, channel, SZ_1K, true);
-		if (!intent)
-			break;
+	while (num_groups--) {
+		size = be32_to_cpup(val++);
+		num_intents = be32_to_cpup(val++);
+		while (num_intents--) {
+			intent = qcom_glink_alloc_intent(glink, channel, size,
+							 true);
+			if (!intent)
+				break;
 
-		qcom_glink_advertise_intent(glink, channel, intent);
+			qcom_glink_advertise_intent(glink, channel, intent);
+		}
 	}
-
 	return 0;
 }
 
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
author
#5 lore raw

PATCH 3/3 rpmsg: glink: Use best fit intent during tx

In reply to Chris Lew

Intents can vary in size, try to find the best fitting remote intent instead of first fit when sending a message to the remote proc.

---
 drivers/rpmsg/qcom_glink_native.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/rpmsg/qcom_glink_native.c +8 -3
index 05e04a8943e3..650974f85a4c 100644
@@ -1251,11 +1251,16 @@ static int __qcom_glink_send(struct glink_channel *channel,
 			spin_lock_irqsave(&channel->intent_lock, flags);
 			idr_for_each_entry(&channel->riids, tmp, iid) {
 				if (tmp->size >= len && !tmp->in_use) {
-					tmp->in_use = true;
-					intent = tmp;
-					break;
+					if (!intent)
+						intent = tmp;
+					else if (intent->size > tmp->size)
+						intent = tmp;
+					if (intent->size == len)
+						break;
 				}
 			}
+			if (intent)
+				intent->in_use = true;
 			spin_unlock_irqrestore(&channel->intent_lock, flags);
 
 			/* We found an available intent */
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#2 lore raw

Re: [PATCH 1/3] dt-bindings: soc: qcom: Support GLINK intents

In reply to Chris Lew
Quoted 15 lines · Chris Lew

Virtual GLINK channels may know what throughput to expect from a remoteproc. An intent advertises to the remoteproc this channel is ready to receive data. Allow a channel to define the size and amount of intents to be prequeued.

---
 Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt | 10 ++++++++++
 1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt +0 -0
index b277eca861f7..6c21f76822ca 100644

Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt of these nodes are defined by the individual bindings for the specific function · line 42

Quoted 4 lines
Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt +1 -0
@@ -39,6 +39,14 @@ of these nodes are defined by the individual bindings for the specific function
  Definition: a list of channels tied to this function, used for matching
     the function to a set of virtual channels
 
+- intents:

qcom,intents or qcom,default-intents

Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt of these nodes are defined by the individual bindings for the specific function · line 48

Quoted 6 lines
Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt +6 -0
+ Usage: optional
+ Value type: <prop-encoded-array>
+ Definition: a list of size,amount pairs describing what intents should
+    be preallocated for this virtual channel. If a GLINK node
+    supports intents, an intent advertises this channel is ready
+    to receive data.

Rather than describing what a GLINK intent is I would suggest that you replace this second sentence with something like "This can be used to tweak the default intents available for the channel to meet expectations of the remote."

Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt regualtors and root clocks. · line 84

Quoted 13 lines
Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt +3 -0
+
 = EXAMPLE
 The following example represents the GLINK RPM node on a MSM8996 device, with
 the function for the "rpm_request" channel defined, which is used for
@@ -69,6 +77,8 @@ regualtors and root clocks.
  compatible = "qcom,rpm-msm8996";
  qcom,glink-channels = "rpm_requests";
 
+ intents = <0x400 5
+   0x800 1>;
...
  };
  };

Regards,
Bjorn

author
#3 lore raw

Re: [PATCH 1/3] dt-bindings: soc: qcom: Support GLINK intents

Quoted 20 lines · Bjorn Andersson
Quoted 18 lines · Chris Lew

Virtual GLINK channels may know what throughput to expect from a remoteproc. An intent advertises to the remoteproc this channel is ready to receive data. Allow a channel to define the size and amount of intents to be prequeued.

---
  Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt | 10 ++++++++++
  1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt +0 -0
index b277eca861f7..6c21f76822ca 100644
@@ -39,6 +39,14 @@ of these nodes are defined by the individual bindings for the specific function
   Definition: a list of channels tied to this function, used for matching
      the function to a set of virtual channels
 
Quoted 4 lines

Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt of these nodes are defined by the individual bindings for the specific function · line 42

Quoted 1 line
Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt +1 -0
+- intents:

qcom,intents or qcom,default-intents

Will use "qcom,intents".

Quoted 7 lines

Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt of these nodes are defined by the individual bindings for the specific function · line 48

Quoted 6 lines
Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt +6 -0
+ Usage: optional
+ Value type: <prop-encoded-array>
+ Definition: a list of size,amount pairs describing what intents should
+    be preallocated for this virtual channel. If a GLINK node
+    supports intents, an intent advertises this channel is ready
+    to receive data.
Quoted 5 lines

Rather than describing what a GLINK intent is I would suggest that you replace this second sentence with something like "This can be used to tweak the default intents available for the channel to meet expectations of the remote."

Sounds good, will change.

Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt +1 -0
+
  = EXAMPLE
  The following example represents the GLINK RPM node on a MSM8996 device, with
  the function for the "rpm_request" channel defined, which is used for
@@ -69,6 +77,8 @@ regualtors and root clocks.
   compatible = "qcom,rpm-msm8996";
   qcom,glink-channels = "rpm_requests";
 
Quoted 9 lines

Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt regualtors and root clocks. · line 84

Quoted 5 lines
Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt +2 -0
+ intents = <0x400 5
+   0x800 1>;
...
   };
   };

Regards,
Bjorn

Thanks,
Chris

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project