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

Commit 5e0925de authored by Olav Haugan's avatar Olav Haugan Committed by Satya Durga Srinivasu Prabhala
Browse files

drivers/base: cpu: Add node for cpu isolation



Add a new per-cpu node to control isolation of CPU.

Usage:
echo 1 > isolate - Isolate the core
echo 0 > isolate - Unisolate the core

Change-Id: I11385d8072f8fa6e69b58588bf6996a16ebf3d35
Signed-off-by: default avatarOlav Haugan <ohaugan@codeaurora.org>
[markivx: Adjust for lack of HMP]
Signed-off-by: default avatarVikram Mulukutla <markivx@codeaurora.org>
Signed-off-by: default avatarSatya Durga Srinivasu Prabhala <satyap@codeaurora.org>
parent f191c4a4
Loading
Loading
Loading
Loading
+58 −0
Original line number Diff line number Diff line
@@ -183,9 +183,64 @@ static struct attribute_group crash_note_cpu_attr_group = {
};
#endif

#ifdef CONFIG_HOTPLUG_CPU

static ssize_t show_cpu_isolated(struct device *dev,
				struct device_attribute *attr, char *buf)
{
	struct cpu *cpu = container_of(dev, struct cpu, dev);
	ssize_t rc;
	int cpuid = cpu->dev.id;
	unsigned int isolated = cpu_isolated(cpuid);

	rc = snprintf(buf, PAGE_SIZE-2, "%d\n", isolated);

	return rc;
}

static ssize_t __ref store_cpu_isolated(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t count)
{
	struct cpu *cpu = container_of(dev, struct cpu, dev);
	int err;
	int cpuid = cpu->dev.id;
	unsigned int isolated;

	err = kstrtouint(strstrip((char *)buf), 0, &isolated);
	if (err)
		return err;

	if (isolated > 1)
		return -EINVAL;

	if (isolated)
		sched_isolate_cpu(cpuid);
	else
		sched_unisolate_cpu(cpuid);

	return count;
}

static DEVICE_ATTR(isolate, 0644, show_cpu_isolated, store_cpu_isolated);

static struct attribute *cpu_isolated_attrs[] = {
	&dev_attr_isolate.attr,
	NULL
};

static struct attribute_group cpu_isolated_attr_group = {
	.attrs = cpu_isolated_attrs,
};

#endif

static const struct attribute_group *common_cpu_attr_groups[] = {
#ifdef CONFIG_KEXEC
	&crash_note_cpu_attr_group,
#endif
#ifdef CONFIG_HOTPLUG_CPU
	&cpu_isolated_attr_group,
#endif
	NULL
};
@@ -193,6 +248,9 @@ static const struct attribute_group *common_cpu_attr_groups[] = {
static const struct attribute_group *hotplugable_cpu_attr_groups[] = {
#ifdef CONFIG_KEXEC
	&crash_note_cpu_attr_group,
#endif
#ifdef CONFIG_HOTPLUG_CPU
	&cpu_isolated_attr_group,
#endif
	NULL
};