Commit 9dd333e7 authored by Tobias Huschle's avatar Tobias Huschle Committed by Vasily Gorbik
Browse files

s390/topology: Add sysctl handler for polarization



Provide an additional path to set the polarization of the system, such
that a user no longer relies on the sysfs interface only and is able
configure the polarization for every reboot via sysctl control files.

The new sysctl can be set as follows:
 - s390.polarization=0 for horizontal polarization
 - s390.polarization=1 for vertical polarization

Acked-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Tested-by: default avatarMete Durlu <meted@linux.ibm.com>
Signed-off-by: default avatarTobias Huschle <huschle@linux.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent 307b675c
Loading
Loading
Loading
Loading
+45 −13
Original line number Diff line number Diff line
@@ -376,6 +376,25 @@ void topology_expect_change(void)

static int cpu_management;

static int set_polarization(int polarization)
{
	int rc = 0;

	cpus_read_lock();
	mutex_lock(&smp_cpu_state_mutex);
	if (cpu_management == polarization)
		goto out;
	rc = topology_set_cpu_management(polarization);
	if (rc)
		goto out;
	cpu_management = polarization;
	topology_expect_change();
out:
	mutex_unlock(&smp_cpu_state_mutex);
	cpus_read_unlock();
	return rc;
}

static ssize_t dispatching_show(struct device *dev,
				struct device_attribute *attr,
				char *buf)
@@ -400,19 +419,7 @@ static ssize_t dispatching_store(struct device *dev,
		return -EINVAL;
	if (val != 0 && val != 1)
		return -EINVAL;
	rc = 0;
	cpus_read_lock();
	mutex_lock(&smp_cpu_state_mutex);
	if (cpu_management == val)
		goto out;
	rc = topology_set_cpu_management(val);
	if (rc)
		goto out;
	cpu_management = val;
	topology_expect_change();
out:
	mutex_unlock(&smp_cpu_state_mutex);
	cpus_read_unlock();
	rc = set_polarization(val);
	return rc ? rc : count;
}
static DEVICE_ATTR_RW(dispatching);
@@ -624,12 +631,37 @@ static int topology_ctl_handler(const struct ctl_table *ctl, int write,
	return rc;
}

static int polarization_ctl_handler(const struct ctl_table *ctl, int write,
				    void *buffer, size_t *lenp, loff_t *ppos)
{
	int polarization;
	int rc;
	struct ctl_table ctl_entry = {
		.procname	= ctl->procname,
		.data		= &polarization,
		.maxlen		= sizeof(int),
		.extra1		= SYSCTL_ZERO,
		.extra2		= SYSCTL_ONE,
	};

	polarization = cpu_management;
	rc = proc_douintvec_minmax(&ctl_entry, write, buffer, lenp, ppos);
	if (rc < 0 || !write)
		return rc;
	return set_polarization(polarization);
}

static struct ctl_table topology_ctl_table[] = {
	{
		.procname	= "topology",
		.mode		= 0644,
		.proc_handler	= topology_ctl_handler,
	},
	{
		.procname	= "polarization",
		.mode		= 0644,
		.proc_handler	= polarization_ctl_handler,
	},
};

static int __init topology_init(void)