Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9833da72 authored by Chris Lew's avatar Chris Lew Committed by Gerrit - the friendly Code Review server
Browse files

rpmsg: glink: Add option to affine resources to CPUs



On certain systems, all resources for a specific usecase may be pinned
to a specific cpu set to meet power and performance requirements. Add
support to define a cpu set for the irq and rx thread in device tree.
This change does not include any hotplug support.

Change-Id: I0e18e3cb1880886dddf20ce0e2744e7af3b8b553
Signed-off-by: default avatarChris Lew <clew@codeaurora.org>
parent 1e465bc9
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -32,6 +32,11 @@ a GLINK SPSS edge and a SPI based edge.
	Definition: reference to the "rpm_hlos" mailbox in APCS, as described
		    in mailbox/mailbox.txt

- cpu-affinity:
	Usage: optional
	Value type: <prop-encoded-array>
	Definition: cores to pin the irq to

= GLINK SPSS
The remote proc on a GLINK SPSS edge expects the descriptors and fifos to be
allocated by this processor. The following bindings are required to inform the
+33 −1
Original line number Diff line number Diff line
@@ -1799,15 +1799,35 @@ static int qcom_glink_create_chrdev(struct qcom_glink *glink)
	return rpmsg_chrdev_register_device(rpdev);
}

static void qcom_glink_set_affinity(struct qcom_glink *glink, u32 *arr,
				    size_t size)
{
	struct cpumask cpumask;
	int i;

	cpumask_clear(&cpumask);
	for (i = 0; i < size; i++) {
		if (arr[i] < num_possible_cpus())
			cpumask_set_cpu(arr[i], &cpumask);
	}
	if (irq_set_affinity(glink->irq, &cpumask))
		dev_err(glink->dev, "failed to set irq affinity\n");
	if (sched_setaffinity(glink->task->pid, &cpumask))
		dev_err(glink->dev, "failed to set task affinity\n");
}


struct qcom_glink *qcom_glink_native_probe(struct device *dev,
					   unsigned long features,
					   struct qcom_glink_pipe *rx,
					   struct qcom_glink_pipe *tx,
					   bool intentless)
{
	struct qcom_glink *glink;
	u32 *arr;
	int size;
	int irq;
	int ret;
	struct qcom_glink *glink;

	glink = devm_kzalloc(dev, sizeof(*glink), GFP_KERNEL);
	if (!glink)
@@ -1866,6 +1886,18 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev,

	glink->irq = irq;

	size = of_property_count_u32_elems(dev->of_node, "cpu-affinity");
	if (size > 0) {
		arr = kmalloc_array(size, sizeof(u32), GFP_KERNEL);
		if (!arr)
			return ERR_PTR(-ENOMEM);
		ret = of_property_read_u32_array(dev->of_node, "cpu-affinity",
						 arr, size);
		if (!ret)
			qcom_glink_set_affinity(glink, arr, size);
		kfree(arr);
	}

	ret = qcom_glink_send_version(glink);
	if (ret) {
		dev_err(dev, "failed to send version %d\n", ret);